Changeset 37428 in webkit for trunk/JavaScriptCore/VM/CTI.cpp
- Timestamp:
- Oct 8, 2008, 10:50:42 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/CTI.cpp
r37427 r37428 35 35 #include "wrec/WREC.h" 36 36 #include "ResultType.h" 37 38 37 #if PLATFORM(MAC) 39 38 #include <sys/sysctl.h> … … 45 44 46 45 #if PLATFORM(MAC) 47 48 static inline bool isSSE2Present() 46 bool isSSE2Present() 49 47 { 50 48 return true; // All X86 Macs are guaranteed to support at least SSE2 51 49 } 52 53 #else 54 55 static bool isSSE2Present() 50 #else COMPILER(MSVC) 51 bool isSSE2Present() 56 52 { 57 53 static const int SSE2FeatureBit = 1 << 26; … … 77 73 return check.present; 78 74 } 79 80 75 #endif 81 82 COMPILE_ASSERT(CTI_ARGS_code == 0xC, CTI_ARGS_code_is_C);83 COMPILE_ASSERT(CTI_ARGS_callFrame == 0xE, CTI_ARGS_callFrame_is_E);84 76 85 77 #if COMPILER(GCC) && PLATFORM(X86) … … 92 84 "subl $0x24, %esp" "\n" 93 85 "movl $512, %esi" "\n" 94 "movl 0x38(%esp), %edi" "\n" // Ox38 = 0x0E * 4, 0x0E = CTI_ARGS_ callFrame (see assertion above)95 "call *0x30(%esp)" "\n" // Ox30 = 0x0C * 4, 0x0C = CTI_ARGS_code (see assertion above)86 "movl 0x38(%esp), %edi" "\n" // Ox38 = 0x0E * 4, 0x0E = CTI_ARGS_r 87 "call *0x30(%esp)" "\n" // Ox30 = 0x0C * 4, 0x0C = CTI_ARGS_code 96 88 "addl $0x24, %esp" "\n" 97 89 "popl %edi" "\n" … … 123 115 mov ecx, esp; 124 116 mov edi, [esp + 0x38]; 125 call [esp + 0x30]; // Ox30 = 0x0C * 4, 0x0C = CTI_ARGS_code (see assertion above)117 call [esp + 0x30]; 126 118 add esp, 0x24; 127 119 pop edi; … … 147 139 #endif 148 140 141 149 142 ALWAYS_INLINE bool CTI::isConstant(int src) 150 143 { … … 152 145 } 153 146 154 ALWAYS_INLINE JSValue* CTI::getConstant( CallFrame* callFrame, int src)155 { 156 return m_codeBlock->constantRegisters[src - m_codeBlock->numVars].jsValue( callFrame);147 ALWAYS_INLINE JSValue* CTI::getConstant(ExecState* exec, int src) 148 { 149 return m_codeBlock->constantRegisters[src - m_codeBlock->numVars].jsValue(exec); 157 150 } 158 151 … … 162 155 // TODO: we want to reuse values that are already in registers if we can - add a register allocator! 163 156 if (isConstant(src)) { 164 JSValue* js = getConstant(m_ callFrame, src);157 JSValue* js = getConstant(m_exec, src); 165 158 m_jit.movl_i32r(reinterpret_cast<unsigned>(js), dst); 166 159 } else … … 172 165 { 173 166 if (isConstant(src)) { 174 JSValue* js = getConstant(m_ callFrame, src);167 JSValue* js = getConstant(m_exec, src); 175 168 m_jit.movl_i32m(reinterpret_cast<unsigned>(js), offset + sizeof(void*), X86::esp); 176 169 } else { … … 194 187 { 195 188 if (isConstant(src)) { 196 JSValue* js = getConstant(m_ callFrame, src);189 JSValue* js = getConstant(m_exec, src); 197 190 return JSImmediate::isNumber(js) ? js : 0; 198 191 } … … 257 250 char which1 = '*'; 258 251 if (isConstant(src1)) { 259 JSValue* js = getConstant(m_ callFrame, src1);252 JSValue* js = getConstant(m_exec, src1); 260 253 which1 = 261 254 JSImmediate::isImmediate(js) ? … … 271 264 char which2 = '*'; 272 265 if (isConstant(src2)) { 273 JSValue* js = getConstant(m_ callFrame, src2);266 JSValue* js = getConstant(m_exec, src2); 274 267 which2 = 275 268 JSImmediate::isImmediate(js) ? … … 453 446 } 454 447 455 CTI::CTI(Machine* machine, CallFrame* callFrame, CodeBlock* codeBlock)448 CTI::CTI(Machine* machine, ExecState* exec, CodeBlock* codeBlock) 456 449 : m_jit(machine->jitCodeBuffer()) 457 450 , m_machine(machine) 458 , m_ callFrame(callFrame)451 , m_exec(exec) 459 452 , m_codeBlock(codeBlock) 460 453 , m_labels(codeBlock ? codeBlock->instructions.size() : 0) … … 495 488 m_jit.movl_mr(OBJECT_OFFSET(JSFunction, m_scopeChain) + OBJECT_OFFSET(ScopeChain, m_node), X86::ecx, X86::ecx); // newScopeChain 496 489 m_jit.movl_i32m(argCount, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register)), X86::edx); 497 m_jit.movl_rm(X86::edi, RegisterFile::Caller Frame* static_cast<int>(sizeof(Register)), X86::edx);490 m_jit.movl_rm(X86::edi, RegisterFile::CallerRegisters * static_cast<int>(sizeof(Register)), X86::edx); 498 491 m_jit.movl_rm(X86::ecx, RegisterFile::ScopeChain * static_cast<int>(sizeof(Register)), X86::edx); 499 492 } … … 523 516 int thisVal = instruction[i + 3].u.operand; 524 517 if (thisVal == missingThisObjectMarker()) { 525 // FIXME: should this be loaded dynamically off m_ callFrame?526 m_jit.movl_i32m(reinterpret_cast<unsigned>(m_ callFrame->globalThisValue()), firstArg * sizeof(Register), X86::edi);518 // FIXME: should this be loaded dynamically off m_exec? 519 m_jit.movl_i32m(reinterpret_cast<unsigned>(m_exec->globalThisValue()), firstArg * sizeof(Register), X86::edi); 527 520 } else { 528 521 emitGetArg(thisVal, X86::ecx); … … 567 560 m_jit.movl_mr(OBJECT_OFFSET(CodeBlock, ctiCode), X86::eax, X86::eax); 568 561 569 // Put the new value of 'callFrame' into edi and ontothe stack, too.570 emitPutCTIParam(X86::edx, CTI_ARGS_ callFrame);562 // Setup the new value of 'r' in edi, and on the stack, too. 563 emitPutCTIParam(X86::edx, CTI_ARGS_r); 571 564 m_jit.movl_rr(X86::edx, X86::edi); 572 565 … … 693 686 void CTI::compileBinaryArithOp(OpcodeID opcodeID, unsigned dst, unsigned src1, unsigned src2, OperandTypes types, unsigned i) 694 687 { 695 StructureID* numberStructureID = m_ callFrame->globalData().numberStructureID.get();688 StructureID* numberStructureID = m_exec->globalData().numberStructureID.get(); 696 689 X86Assembler::JmpSrc wasJSNumberCell1, wasJSNumberCell1b, wasJSNumberCell2, wasJSNumberCell2b; 697 690 … … 886 879 unsigned src = instruction[i + 2].u.operand; 887 880 if (isConstant(src)) 888 m_jit.movl_i32r(reinterpret_cast<unsigned>(getConstant(m_ callFrame, src)), X86::edx);881 m_jit.movl_i32r(reinterpret_cast<unsigned>(getConstant(m_exec, src)), X86::edx); 889 882 else 890 883 emitGetArg(src, X86::edx); … … 1246 1239 1247 1240 // Restore our caller's "r". 1248 emitGetArg(RegisterFile::Caller Frame, X86::edi);1249 emitPutCTIParam(X86::edi, CTI_ARGS_ callFrame);1241 emitGetArg(RegisterFile::CallerRegisters, X86::edi); 1242 emitPutCTIParam(X86::edi, CTI_ARGS_r); 1250 1243 1251 1244 // Return. … … 1811 1804 } 1812 1805 case op_catch: { 1813 emitGetCTIParam(CTI_ARGS_ callFrame, X86::edi); // edi := r1806 emitGetCTIParam(CTI_ARGS_r, X86::edi); // edi := r 1814 1807 emitPutResult(instruction[i + 1].u.operand); 1815 1808 i += 2; … … 2660 2653 // The prototype object definitely exists (if this stub exists the CodeBlock is referencing a StructureID that is 2661 2654 // referencing the prototype object - let's speculatively load it's table nice and early!) 2662 JSObject* protoObject = static_cast<JSObject*>(structureID->prototypeForLookup(m_ callFrame));2655 JSObject* protoObject = static_cast<JSObject*>(structureID->prototypeForLookup(m_exec)); 2663 2656 PropertyStorage* protoPropertyStorage = &protoObject->m_propertyStorage; 2664 2657 m_jit.movl_mr(static_cast<void*>(protoPropertyStorage), X86::edx); … … 2703 2696 // The prototype object definitely exists (if this stub exists the CodeBlock is referencing a StructureID that is 2704 2697 // referencing the prototype object - let's speculatively load it's table nice and early!) 2705 JSObject* protoObject = static_cast<JSObject*>(structureID->prototypeForLookup(m_ callFrame));2698 JSObject* protoObject = static_cast<JSObject*>(structureID->prototypeForLookup(m_exec)); 2706 2699 PropertyStorage* protoPropertyStorage = &protoObject->m_propertyStorage; 2707 2700 m_jit.movl_mr(static_cast<void*>(protoPropertyStorage), X86::edx); … … 2752 2745 JSObject* protoObject = 0; 2753 2746 for (unsigned i = 0; i<count; ++i) { 2754 protoObject = static_cast<JSObject*>(currStructureID->prototypeForLookup(m_ callFrame));2747 protoObject = static_cast<JSObject*>(currStructureID->prototypeForLookup(m_exec)); 2755 2748 currStructureID = chainEntries[i].get(); 2756 2749 … … 3052 3045 #if ENABLE(WREC) 3053 3046 3054 void* CTI::compileRegExp( Machine* machine, const UString& pattern, unsigned* numSubpatterns_ptr, const char** error_ptr, bool ignoreCase, bool multiline)3047 void* CTI::compileRegExp(ExecState* exec, const UString& pattern, unsigned* numSubpatterns_ptr, const char** error_ptr, bool ignoreCase, bool multiline) 3055 3048 { 3056 3049 // TODO: better error messages … … 3060 3053 } 3061 3054 3062 X86Assembler jit( machine->jitCodeBuffer());3055 X86Assembler jit(exec->machine()->jitCodeBuffer()); 3063 3056 WRECParser parser(pattern, ignoreCase, multiline, jit); 3064 3057
Note:
See TracChangeset
for help on using the changeset viewer.