Changeset 38286 in webkit for trunk/JavaScriptCore/VM/CTI.cpp
- Timestamp:
- Nov 10, 2008, 9:09:46 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/CTI.cpp
r38284 r38286 169 169 #endif 170 170 171 ALWAYS_INLINE JSValue* CTI::getConstant( CallFrame* callFrame,int src)172 { 173 return m_codeBlock->constantRegisters[src - m_codeBlock->numVars]. jsValue(callFrame);171 ALWAYS_INLINE JSValue* CTI::getConstant(int src) 172 { 173 return m_codeBlock->constantRegisters[src - m_codeBlock->numVars].getJSValue(); 174 174 } 175 175 … … 184 184 // TODO: we want to reuse values that are already in registers if we can - add a register allocator! 185 185 if (m_codeBlock->isConstant(src)) { 186 JSValue* js = getConstant( m_callFrame,src);186 JSValue* js = getConstant(src); 187 187 m_jit.movl_i32r(asInteger(js), dst); 188 188 } else … … 194 194 { 195 195 if (m_codeBlock->isConstant(src)) { 196 JSValue* js = getConstant( m_callFrame,src);196 JSValue* js = getConstant(src); 197 197 m_jit.movl_i32m(asInteger(js), offset + sizeof(void*), X86::esp); 198 198 } else { … … 216 216 { 217 217 if (m_codeBlock->isConstant(src)) { 218 JSValue* js = getConstant( m_callFrame,src);218 JSValue* js = getConstant(src); 219 219 return JSImmediate::isNumber(js) ? js : noValue(); 220 220 } … … 275 275 char which1 = '*'; 276 276 if (m_codeBlock->isConstant(src1)) { 277 JSValue* js = getConstant( m_callFrame,src1);277 JSValue* js = getConstant(src1); 278 278 which1 = 279 279 JSImmediate::isImmediate(js) ? … … 289 289 char which2 = '*'; 290 290 if (m_codeBlock->isConstant(src2)) { 291 JSValue* js = getConstant( m_callFrame,src2);291 JSValue* js = getConstant(src2); 292 292 which2 = 293 293 JSImmediate::isImmediate(js) ? … … 547 547 } 548 548 549 CTI::CTI( Machine* machine, CallFrame* callFrame, CodeBlock* codeBlock)550 : m_jit( machine->jitCodeBuffer())551 , m_machine( machine)552 , m_ callFrame(callFrame)549 CTI::CTI(JSGlobalData* globalData, CodeBlock* codeBlock) 550 : m_jit(globalData->machine->jitCodeBuffer()) 551 , m_machine(globalData->machine) 552 , m_globalData(globalData) 553 553 , m_codeBlock(codeBlock) 554 554 , m_labels(codeBlock ? codeBlock->instructions.size() : 0) … … 792 792 void CTI::compileBinaryArithOp(OpcodeID opcodeID, unsigned dst, unsigned src1, unsigned src2, OperandTypes types, unsigned i) 793 793 { 794 StructureID* numberStructureID = m_ callFrame->globalData().numberStructureID.get();794 StructureID* numberStructureID = m_globalData->numberStructureID.get(); 795 795 X86Assembler::JmpSrc wasJSNumberCell1; 796 796 X86Assembler::JmpSrc wasJSNumberCell1b; … … 1006 1006 unsigned src = instruction[i + 2].u.operand; 1007 1007 if (m_codeBlock->isConstant(src)) 1008 m_jit.movl_i32r(asInteger(getConstant( m_callFrame,src)), X86::eax);1008 m_jit.movl_i32r(asInteger(getConstant(src)), X86::eax); 1009 1009 else 1010 1010 emitGetArg(src, X86::eax); … … 1531 1531 if (!resultType.definitelyIsNumber()) { 1532 1532 emitJumpSlowCaseIfNotJSCell(X86::eax, i); 1533 StructureID* numberStructureID = m_ callFrame->globalData().numberStructureID.get();1533 StructureID* numberStructureID = m_globalData->numberStructureID.get(); 1534 1534 m_jit.cmpl_i32m(reinterpret_cast<unsigned>(numberStructureID), OBJECT_OFFSET(JSCell, m_structureID), X86::eax); 1535 1535 m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJne(), i)); … … 1541 1541 X86Assembler::JmpSrc wasCell; 1542 1542 if (!resultType.isReusableNumber()) 1543 emitAllocateNumber( &m_callFrame->globalData(), i);1543 emitAllocateNumber(m_globalData, i); 1544 1544 1545 1545 putDoubleResultToJSNumberCellOrJSImmediate(X86::xmm0, X86::eax, instruction[i + 1].u.operand, &wasCell, … … 3051 3051 } 3052 3052 3053 void CTI::privateCompileGetByIdProto(StructureID* structureID, StructureID* prototypeStructureID, size_t cachedOffset, void* returnAddress )3053 void CTI::privateCompileGetByIdProto(StructureID* structureID, StructureID* prototypeStructureID, size_t cachedOffset, void* returnAddress, CallFrame* callFrame) 3054 3054 { 3055 3055 #if USE(CTI_REPATCH_PIC) … … 3061 3061 // The prototype object definitely exists (if this stub exists the CodeBlock is referencing a StructureID that is 3062 3062 // referencing the prototype object - let's speculatively load it's table nice and early!) 3063 JSObject* protoObject = asObject(structureID->prototypeForLookup( m_callFrame));3063 JSObject* protoObject = asObject(structureID->prototypeForLookup(callFrame)); 3064 3064 PropertyStorage* protoPropertyStorage = &protoObject->m_propertyStorage; 3065 3065 m_jit.movl_mr(static_cast<void*>(protoPropertyStorage), X86::edx); … … 3104 3104 // The prototype object definitely exists (if this stub exists the CodeBlock is referencing a StructureID that is 3105 3105 // referencing the prototype object - let's speculatively load it's table nice and early!) 3106 JSObject* protoObject = asObject(structureID->prototypeForLookup( m_callFrame));3106 JSObject* protoObject = asObject(structureID->prototypeForLookup(callFrame)); 3107 3107 PropertyStorage* protoPropertyStorage = &protoObject->m_propertyStorage; 3108 3108 m_jit.movl_mr(static_cast<void*>(protoPropertyStorage), X86::edx); … … 3137 3137 } 3138 3138 3139 void CTI::privateCompileGetByIdChain(StructureID* structureID, StructureIDChain* chain, size_t count, size_t cachedOffset, void* returnAddress )3139 void CTI::privateCompileGetByIdChain(StructureID* structureID, StructureIDChain* chain, size_t count, size_t cachedOffset, void* returnAddress, CallFrame* callFrame) 3140 3140 { 3141 3141 ASSERT(count); … … 3153 3153 JSObject* protoObject = 0; 3154 3154 for (unsigned i = 0; i<count; ++i) { 3155 protoObject = asObject(currStructureID->prototypeForLookup( m_callFrame));3155 protoObject = asObject(currStructureID->prototypeForLookup(callFrame)); 3156 3156 currStructureID = chainEntries[i].get(); 3157 3157 … … 3329 3329 } 3330 3330 3331 void* CTI::privateCompileArrayLengthTrampoline() 3332 { 3331 void CTI::privateCompileCTIMachineTrampolines() 3332 { 3333 // (1) The first function provides fast property access for array length 3334 3333 3335 // Check eax is an array 3334 3336 m_jit.testl_i32r(JSImmediate::TagMask, X86::eax); 3335 X86Assembler::JmpSrc failureCases1 = m_jit.emitUnlinkedJne();3337 X86Assembler::JmpSrc array_failureCases1 = m_jit.emitUnlinkedJne(); 3336 3338 m_jit.cmpl_i32m(reinterpret_cast<unsigned>(m_machine->m_jsArrayVptr), X86::eax); 3337 X86Assembler::JmpSrc failureCases2 = m_jit.emitUnlinkedJne();3339 X86Assembler::JmpSrc array_failureCases2 = m_jit.emitUnlinkedJne(); 3338 3340 3339 3341 // Checks out okay! - get the length from the storage … … 3342 3344 3343 3345 m_jit.addl_rr(X86::eax, X86::eax); 3344 X86Assembler::JmpSrc failureCases3 = m_jit.emitUnlinkedJo();3346 X86Assembler::JmpSrc array_failureCases3 = m_jit.emitUnlinkedJo(); 3345 3347 m_jit.addl_i8r(1, X86::eax); 3346 3348 3347 3349 m_jit.ret(); 3348 3350 3349 void* code = m_jit.copy(); 3350 ASSERT(code); 3351 3352 X86Assembler::link(code, failureCases1, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail)); 3353 X86Assembler::link(code, failureCases2, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail)); 3354 X86Assembler::link(code, failureCases3, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail)); 3351 // (2) The second function provides fast property access for string length 3355 3352 3356 return code; 3357 } 3358 3359 void* CTI::privateCompileStringLengthTrampoline() 3360 { 3353 X86Assembler::JmpDst stringLengthBegin = m_jit.align(16); 3354 3361 3355 // Check eax is a string 3362 3356 m_jit.testl_i32r(JSImmediate::TagMask, X86::eax); 3363 X86Assembler::JmpSrc failureCases1 = m_jit.emitUnlinkedJne();3357 X86Assembler::JmpSrc string_failureCases1 = m_jit.emitUnlinkedJne(); 3364 3358 m_jit.cmpl_i32m(reinterpret_cast<unsigned>(m_machine->m_jsStringVptr), X86::eax); 3365 X86Assembler::JmpSrc failureCases2 = m_jit.emitUnlinkedJne();3359 X86Assembler::JmpSrc string_failureCases2 = m_jit.emitUnlinkedJne(); 3366 3360 3367 3361 // Checks out okay! - get the length from the Ustring. … … 3370 3364 3371 3365 m_jit.addl_rr(X86::eax, X86::eax); 3372 X86Assembler::JmpSrc failureCases3 = m_jit.emitUnlinkedJo();3366 X86Assembler::JmpSrc string_failureCases3 = m_jit.emitUnlinkedJo(); 3373 3367 m_jit.addl_i8r(1, X86::eax); 3374 3368 3375 3369 m_jit.ret(); 3376 3370 3371 // All trampolines constructed! copy the code, link up calls, and set the pointers on the Machine object. 3372 3377 3373 void* code = m_jit.copy(); 3378 3374 ASSERT(code); 3379 3375 3380 X86Assembler::link(code, failureCases1, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail)); 3381 X86Assembler::link(code, failureCases2, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail)); 3382 X86Assembler::link(code, failureCases3, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail)); 3383 3384 return code; 3376 X86Assembler::link(code, array_failureCases1, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail)); 3377 X86Assembler::link(code, array_failureCases2, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail)); 3378 X86Assembler::link(code, array_failureCases3, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail)); 3379 X86Assembler::link(code, string_failureCases1, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail)); 3380 X86Assembler::link(code, string_failureCases2, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail)); 3381 X86Assembler::link(code, string_failureCases3, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail)); 3382 3383 m_machine->m_ctiArrayLengthTrampoline = code; 3384 m_machine->m_ctiStringLengthTrampoline = X86Assembler::getRelocatedAddress(code, stringLengthBegin); 3385 } 3386 3387 void CTI::freeCTIMachineTrampolines(Machine* machine) 3388 { 3389 WTF::fastFreeExecutable(machine->m_ctiArrayLengthTrampoline); 3385 3390 } 3386 3391
Note:
See TracChangeset
for help on using the changeset viewer.