Changeset 185022 in webkit
- Timestamp:
- May 29, 2015, 5:19:01 PM (10 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r185002 r185022 1 2015-05-29 Mark Lam <mark.lam@apple.com> 2 3 Refactoring HandlerInfo and UnlinkedHandlerInfo. 4 https://bugs.webkit.org/show_bug.cgi?id=145480 5 6 Reviewed by Benjamin Poulain. 7 8 HandlerInfo and UnlinkedHandlerInfo have common parts, but are not currently 9 expressed as 2 unrelated structs that happen to have near identical fields. 10 We can refactor them to better express their relationship. We can also add 11 some convenience functions to make the code that uses them a little more 12 readable. 13 14 * bytecode/CodeBlock.cpp: 15 (JSC::CodeBlock::dumpBytecode): 16 (JSC::CodeBlock::CodeBlock): 17 (JSC::CodeBlock::handlerForBytecodeOffset): 18 * bytecode/HandlerInfo.h: 19 (JSC::UnlinkedHandlerInfo::UnlinkedHandlerInfo): 20 (JSC::HandlerInfo::initialize): 21 - I chose to include CodeLocationLabel arg even though it is unused by 22 by non-JIT builds. This makes the call site cleaner to read. 23 24 * bytecode/UnlinkedCodeBlock.h: 25 (JSC::UnlinkedSimpleJumpTable::add): 26 (JSC::UnlinkedInstruction::UnlinkedInstruction): 27 (JSC::UnlinkedCodeBlock::numberOfExceptionHandlers): 28 (JSC::UnlinkedCodeBlock::addExceptionHandler): 29 (JSC::UnlinkedCodeBlock::exceptionHandler): 30 (JSC::UnlinkedCodeBlock::symbolTable): 31 * bytecompiler/BytecodeGenerator.cpp: 32 (JSC::BytecodeGenerator::generate): 33 1 34 2015-05-28 Filip Pizlo <fpizlo@apple.com> 2 35 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r184828 r185022 655 655 unsigned i = 0; 656 656 do { 657 out.printf("\t %d: { start: [%4d] end: [%4d] target: [%4d] depth: [%4d] }\n", i + 1, m_rareData->m_exceptionHandlers[i].start, m_rareData->m_exceptionHandlers[i].end, m_rareData->m_exceptionHandlers[i].target, m_rareData->m_exceptionHandlers[i].scopeDepth); 657 HandlerInfo& handler = m_rareData->m_exceptionHandlers[i]; 658 out.printf("\t %d: { start: [%4d] end: [%4d] target: [%4d] depth: [%4d] }\n", 659 i + 1, handler.start, handler.end, handler.target, handler.scopeDepth); 658 660 ++i; 659 661 } while (i < m_rareData->m_exceptionHandlers.size()); … … 1820 1822 size_t nonLocalScopeDepth = scope->depth(); 1821 1823 for (size_t i = 0; i < count; i++) { 1822 const UnlinkedHandlerInfo& handler = unlinkedCodeBlock->exceptionHandler(i); 1823 m_rareData->m_exceptionHandlers[i].start = handler.start; 1824 m_rareData->m_exceptionHandlers[i].end = handler.end; 1825 m_rareData->m_exceptionHandlers[i].target = handler.target; 1826 m_rareData->m_exceptionHandlers[i].scopeDepth = nonLocalScopeDepth + handler.scopeDepth; 1827 #if ENABLE(JIT) 1828 m_rareData->m_exceptionHandlers[i].nativeCode = CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(LLInt::getCodePtr(op_catch))); 1829 #endif 1824 const UnlinkedHandlerInfo& unlinkedHandler = unlinkedCodeBlock->exceptionHandler(i); 1825 HandlerInfo& handler = m_rareData->m_exceptionHandlers[i]; 1826 handler.initialize(unlinkedHandler, nonLocalScopeDepth, 1827 CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(LLInt::getCodePtr(op_catch)))); 1830 1828 } 1831 1829 } … … 2886 2884 Vector<HandlerInfo>& exceptionHandlers = m_rareData->m_exceptionHandlers; 2887 2885 for (size_t i = 0; i < exceptionHandlers.size(); ++i) { 2886 HandlerInfo& handler = exceptionHandlers[i]; 2888 2887 // Handlers are ordered innermost first, so the first handler we encounter 2889 2888 // that contains the source address is the correct handler to use. 2890 if ( exceptionHandlers[i].start <= bytecodeOffset && exceptionHandlers[i].end > bytecodeOffset)2891 return & exceptionHandlers[i];2889 if (handler.start <= bytecodeOffset && handler.end > bytecodeOffset) 2890 return &handler; 2892 2891 } 2893 2892 -
trunk/Source/JavaScriptCore/bytecode/HandlerInfo.h
r164424 r185022 31 31 namespace JSC { 32 32 33 struct HandlerInfo {33 struct HandlerInfoBase { 34 34 uint32_t start; 35 35 uint32_t end; 36 36 uint32_t target; 37 37 uint32_t scopeDepth; 38 }; 39 40 struct UnlinkedHandlerInfo : public HandlerInfoBase { 41 UnlinkedHandlerInfo(uint32_t start, uint32_t end, uint32_t target, uint32_t scopeDepth) 42 { 43 this->start = start; 44 this->end = end; 45 this->target = target; 46 this->scopeDepth = scopeDepth; 47 } 48 }; 49 50 struct HandlerInfo : public HandlerInfoBase { 51 void initialize(const UnlinkedHandlerInfo& unlinkedInfo, size_t nonLocalScopeDepth, CodeLocationLabel label) 52 { 53 start = unlinkedInfo.start; 54 end = unlinkedInfo.end; 55 target = unlinkedInfo.target; 56 scopeDepth = unlinkedInfo.scopeDepth + nonLocalScopeDepth; 57 #if ENABLE(JIT) 58 nativeCode = label; 59 #else 60 UNUSED_PARAM(label); 61 #endif 62 } 63 38 64 #if ENABLE(JIT) 39 65 CodeLocationLabel nativeCode; -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
r183972 r185022 31 31 #include "CodeType.h" 32 32 #include "ExpressionRangeInfo.h" 33 #include "HandlerInfo.h" 33 34 #include "Identifier.h" 34 35 #include "JSCell.h" … … 247 248 }; 248 249 249 struct UnlinkedHandlerInfo {250 uint32_t start;251 uint32_t end;252 uint32_t target;253 uint32_t scopeDepth;254 };255 256 250 struct UnlinkedInstruction { 257 251 UnlinkedInstruction() { u.operand = 0; } … … 428 422 // Exception handling support 429 423 size_t numberOfExceptionHandlers() const { return m_rareData ? m_rareData->m_exceptionHandlers.size() : 0; } 430 void addExceptionHandler(const UnlinkedHandlerInfo& han ler) { createRareDataIfNecessary(); return m_rareData->m_exceptionHandlers.append(hanler); }424 void addExceptionHandler(const UnlinkedHandlerInfo& handler) { createRareDataIfNecessary(); return m_rareData->m_exceptionHandlers.append(handler); } 431 425 UnlinkedHandlerInfo& exceptionHandler(int index) { ASSERT(m_rareData); return m_rareData->m_exceptionHandlers[index]; } 432 426 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r184868 r185022 130 130 131 131 ASSERT(range.tryData->targetScopeDepth != UINT_MAX); 132 UnlinkedHandlerInfo info = { 133 static_cast<uint32_t>(start), static_cast<uint32_t>(end), 134 static_cast<uint32_t>(range.tryData->target->bind()), 135 range.tryData->targetScopeDepth 136 }; 132 UnlinkedHandlerInfo info(static_cast<uint32_t>(start), static_cast<uint32_t>(end), 133 static_cast<uint32_t>(range.tryData->target->bind()), range.tryData->targetScopeDepth); 137 134 m_codeBlock->addExceptionHandler(info); 138 135 }
Note:
See TracChangeset
for help on using the changeset viewer.