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