Changeset 37681 in webkit for trunk/JavaScriptCore/VM/CTI.cpp
- Timestamp:
- Oct 18, 2008, 4:08:12 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/CTI.cpp
r37678 r37681 178 178 } 179 179 180 inline uintptr_t CTI::asInteger(JSValue* value) 181 { 182 return reinterpret_cast<uintptr_t>(value); 183 } 184 180 185 // get arg puts an arg from the SF register array into a h/w register 181 186 ALWAYS_INLINE void CTI::emitGetArg(int src, X86Assembler::RegisterID dst) … … 184 189 if (isConstant(src)) { 185 190 JSValue* js = getConstant(m_callFrame, src); 186 m_jit.movl_i32r( reinterpret_cast<unsigned>(js), dst);191 m_jit.movl_i32r(asInteger(js), dst); 187 192 } else 188 193 m_jit.movl_mr(src * sizeof(Register), X86::edi, dst); … … 194 199 if (isConstant(src)) { 195 200 JSValue* js = getConstant(m_callFrame, src); 196 m_jit.movl_i32m( reinterpret_cast<unsigned>(js), offset + sizeof(void*), X86::esp);201 m_jit.movl_i32m(asInteger(js), offset + sizeof(void*), X86::esp); 197 202 } else { 198 203 m_jit.movl_mr(src * sizeof(Register), X86::edi, scratch); … … 216 221 if (isConstant(src)) { 217 222 JSValue* js = getConstant(m_callFrame, src); 218 return JSImmediate::isNumber(js) ? js : 0;223 return JSImmediate::isNumber(js) ? js : noValue(); 219 224 } 220 return 0;225 return noValue(); 221 226 } 222 227 … … 254 259 ALWAYS_INLINE void CTI::emitInitRegister(unsigned dst) 255 260 { 256 m_jit.movl_i32m( reinterpret_cast<unsigned>(jsUndefined()), dst * sizeof(Register), X86::edi);261 m_jit.movl_i32m(asInteger(jsUndefined()), dst * sizeof(Register), X86::edi); 257 262 // FIXME: #ifndef NDEBUG, Write the correct m_type to the register. 258 263 } … … 443 448 { 444 449 ASSERT(JSImmediate::isNumber(imm)); 445 return reinterpret_cast<unsigned>(imm) & ~JSImmediate::TagBitTypeInteger;450 return asInteger(imm) & ~JSImmediate::TagBitTypeInteger; 446 451 } 447 452 … … 534 539 emitGetArg(callee, X86::ecx); // Load callee JSFunction into ecx 535 540 m_jit.movl_rm(X86::eax, RegisterFile::CodeBlock * static_cast<int>(sizeof(Register)), X86::edx); // callee CodeBlock was returned in eax 536 m_jit.movl_i32m( reinterpret_cast<unsigned>(nullJSValue), RegisterFile::OptionalCalleeArguments * static_cast<int>(sizeof(Register)), X86::edx);541 m_jit.movl_i32m(asInteger(noValue()), RegisterFile::OptionalCalleeArguments * static_cast<int>(sizeof(Register)), X86::edx); 537 542 m_jit.movl_rm(X86::ecx, RegisterFile::Callee * static_cast<int>(sizeof(Register)), X86::edx); 538 543 … … 573 578 if (thisVal == missingThisObjectMarker()) { 574 579 // FIXME: should this be loaded dynamically off m_callFrame? 575 m_jit.movl_i32m( reinterpret_cast<unsigned>(m_callFrame->globalThisValue()), firstArg * sizeof(Register), X86::edi);580 m_jit.movl_i32m(asInteger(m_callFrame->globalThisValue()), firstArg * sizeof(Register), X86::edi); 576 581 } else { 577 582 emitGetArg(thisVal, X86::eax); … … 587 592 588 593 emitCTICall(i, Machine::cti_op_call_eval); 589 m_jit.cmpl_i32r( reinterpret_cast<unsigned>(JSImmediate::impossibleValue()), X86::eax);594 m_jit.cmpl_i32r(asInteger(JSImmediate::impossibleValue()), X86::eax); 590 595 wasEval = m_jit.emitUnlinkedJne(); 591 596 } … … 594 599 // This deliberately leaves the callee in ecx, used when setting up the stack frame below 595 600 emitGetArg(callee, X86::ecx); 596 m_jit.cmpl_i32r( reinterpret_cast<unsigned>(JSImmediate::impossibleValue()), X86::ecx);601 m_jit.cmpl_i32r(asInteger(JSImmediate::impossibleValue()), X86::ecx); 597 602 X86Assembler::JmpDst addressOfLinkedFunctionCheck = m_jit.label(); 598 603 m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJne(), i)); … … 621 626 // Fast version of stack frame initialization, directly relative to edi. 622 627 // Note that this omits to set up RegisterFile::CodeBlock, which is set in the callee 623 m_jit.movl_i32m( reinterpret_cast<unsigned>(nullJSValue), (registerOffset + RegisterFile::OptionalCalleeArguments) * static_cast<int>(sizeof(Register)), X86::edi);628 m_jit.movl_i32m(asInteger(noValue()), (registerOffset + RegisterFile::OptionalCalleeArguments) * static_cast<int>(sizeof(Register)), X86::edi); 624 629 m_jit.movl_rm(X86::ecx, (registerOffset + RegisterFile::Callee) * static_cast<int>(sizeof(Register)), X86::edi); 625 630 m_jit.movl_mr(OBJECT_OFFSET(JSFunction, m_scopeChain) + OBJECT_OFFSET(ScopeChain, m_node), X86::ecx, X86::edx); // newScopeChain … … 671 676 m_jit.setz_r(X86::ecx); 672 677 m_jit.movzbl_rr(X86::ecx, X86::ecx); // ecx is now 1 if edx was nonimmediate 673 m_jit.cmpl_i32r( reinterpret_cast<uint32_t>(JSImmediate::zeroImmediate()), X86::edx);678 m_jit.cmpl_i32r(asInteger(JSImmediate::zeroImmediate()), X86::edx); 674 679 m_jit.sete_r(X86::edx); 675 680 m_jit.movzbl_rr(X86::edx, X86::edx); // edx is now 1 if edx was the 0 immediate … … 678 683 m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJnz(), i)); 679 684 680 m_jit.movl_i32r( reinterpret_cast<uint32_t>(jsBoolean(negated)), X86::eax);685 m_jit.movl_i32r(asInteger(jsBoolean(negated)), X86::eax); 681 686 682 687 X86Assembler::JmpSrc firstWasNotImmediate = m_jit.emitUnlinkedJmp(); … … 684 689 m_jit.link(secondNotImmediate, m_jit.label()); 685 690 // check that eax is not the zero immediate (we know it must be immediate) 686 m_jit.cmpl_i32r( reinterpret_cast<uint32_t>(JSImmediate::zeroImmediate()), X86::eax);691 m_jit.cmpl_i32r(asInteger(JSImmediate::zeroImmediate()), X86::eax); 687 692 m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJe(), i)); 688 693 689 m_jit.movl_i32r( reinterpret_cast<uint32_t>(jsBoolean(negated)), X86::eax);694 m_jit.movl_i32r(asInteger(jsBoolean(negated)), X86::eax); 690 695 691 696 m_jit.link(bothWereImmediates, m_jit.label()); … … 955 960 unsigned src = instruction[i + 2].u.operand; 956 961 if (isConstant(src)) 957 m_jit.movl_i32r( reinterpret_cast<unsigned>(getConstant(m_callFrame, src)), X86::edx);962 m_jit.movl_i32r(asInteger(getConstant(m_callFrame, src)), X86::edx); 958 963 else 959 964 emitGetArg(src, X86::edx); … … 1038 1043 emitGetArg(instruction[i + 1].u.operand, X86::edx); 1039 1044 emitJumpSlowCaseIfNotImmNum(X86::edx, i); 1040 m_jit.cmpl_i32r( reinterpret_cast<unsigned>(src2imm), X86::edx);1045 m_jit.cmpl_i32r(asInteger(src2imm), X86::edx); 1041 1046 m_jmpTable.append(JmpTable(m_jit.emitUnlinkedJl(), i + 3 + target)); 1042 1047 } else { … … 1059 1064 emitGetArg(instruction[i + 1].u.operand, X86::edx); 1060 1065 emitJumpSlowCaseIfNotImmNum(X86::edx, i); 1061 m_jit.cmpl_i32r( reinterpret_cast<unsigned>(src2imm), X86::edx);1066 m_jit.cmpl_i32r(asInteger(src2imm), X86::edx); 1062 1067 m_jmpTable.append(JmpTable(m_jit.emitUnlinkedJle(), i + 3 + target)); 1063 1068 } else { … … 1171 1176 1172 1177 // optimistically load true result 1173 m_jit.movl_i32r( reinterpret_cast<int32_t>(jsBoolean(true)), X86::eax);1178 m_jit.movl_i32r(asInteger(jsBoolean(true)), X86::eax); 1174 1179 1175 1180 X86Assembler::JmpDst loop = m_jit.label(); … … 1182 1187 X86Assembler::JmpSrc exit = m_jit.emitUnlinkedJe(); 1183 1188 1184 m_jit.cmpl_i32r( reinterpret_cast<int32_t>(jsNull()), X86::ecx);1189 m_jit.cmpl_i32r(asInteger(jsNull()), X86::ecx); 1185 1190 X86Assembler::JmpSrc goToLoop = m_jit.emitUnlinkedJne(); 1186 1191 m_jit.link(goToLoop, loop); 1187 1192 1188 m_jit.movl_i32r( reinterpret_cast<int32_t>(jsBoolean(false)), X86::eax);1193 m_jit.movl_i32r(asInteger(jsBoolean(false)), X86::eax); 1189 1194 1190 1195 m_jit.link(exit, m_jit.label()); … … 1250 1255 case op_get_global_var: { 1251 1256 JSVariableObject* globalObject = static_cast<JSVariableObject*>(instruction[i + 2].u.jsCell); 1252 m_jit.movl_i32r( reinterpret_cast<unsigned>(globalObject), X86::eax);1257 m_jit.movl_i32r(asInteger(globalObject), X86::eax); 1253 1258 emitGetVariableObjectRegister(X86::eax, instruction[i + 3].u.operand, X86::eax); 1254 1259 emitPutResult(instruction[i + 1].u.operand, X86::eax); … … 1258 1263 case op_put_global_var: { 1259 1264 JSVariableObject* globalObject = static_cast<JSVariableObject*>(instruction[i + 1].u.jsCell); 1260 m_jit.movl_i32r( reinterpret_cast<unsigned>(globalObject), X86::eax);1265 m_jit.movl_i32r(asInteger(globalObject), X86::eax); 1261 1266 emitGetArg(instruction[i + 3].u.operand, X86::edx); 1262 1267 emitPutVariableObjectRegister(X86::edx, X86::eax, instruction[i + 2].u.operand); … … 1444 1449 emitGetArg(instruction[i + 1].u.operand, X86::eax); 1445 1450 1446 m_jit.cmpl_i32r( reinterpret_cast<uint32_t>(JSImmediate::zeroImmediate()), X86::eax);1451 m_jit.cmpl_i32r(asInteger(JSImmediate::zeroImmediate()), X86::eax); 1447 1452 X86Assembler::JmpSrc isZero = m_jit.emitUnlinkedJe(); 1448 1453 m_jit.testl_i32r(JSImmediate::TagBitTypeInteger, X86::eax); 1449 1454 m_jmpTable.append(JmpTable(m_jit.emitUnlinkedJne(), i + 2 + target)); 1450 1455 1451 m_jit.cmpl_i32r( reinterpret_cast<uint32_t>(JSImmediate::trueImmediate()), X86::eax);1456 m_jit.cmpl_i32r(asInteger(JSImmediate::trueImmediate()), X86::eax); 1452 1457 m_jmpTable.append(JmpTable(m_jit.emitUnlinkedJe(), i + 2 + target)); 1453 m_jit.cmpl_i32r( reinterpret_cast<uint32_t>(JSImmediate::falseImmediate()), X86::eax);1458 m_jit.cmpl_i32r(asInteger(JSImmediate::falseImmediate()), X86::eax); 1454 1459 m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJne(), i)); 1455 1460 … … 1484 1489 case op_resolve_global: { 1485 1490 // Fast case 1486 unsigned globalObject = reinterpret_cast<unsigned>(instruction[i + 2].u.jsCell);1491 unsigned globalObject = asInteger(instruction[i + 2].u.jsCell); 1487 1492 Identifier* ident = &(m_codeBlock->identifiers[instruction[i + 3].u.operand]); 1488 1493 void* structureIDAddr = reinterpret_cast<void*>(instruction + i + 4); … … 1532 1537 emitGetArg(instruction[i + 1].u.operand, X86::edx); 1533 1538 emitJumpSlowCaseIfNotImmNum(X86::edx, i); 1534 m_jit.cmpl_i32r( reinterpret_cast<unsigned>(src2imm), X86::edx);1539 m_jit.cmpl_i32r(asInteger(src2imm), X86::edx); 1535 1540 m_jmpTable.append(JmpTable(m_jit.emitUnlinkedJge(), i + 3 + target)); 1536 1541 } else { … … 1559 1564 emitGetArg(instruction[i + 1].u.operand, X86::eax); 1560 1565 1561 m_jit.cmpl_i32r( reinterpret_cast<uint32_t>(JSImmediate::zeroImmediate()), X86::eax);1566 m_jit.cmpl_i32r(asInteger(JSImmediate::zeroImmediate()), X86::eax); 1562 1567 m_jmpTable.append(JmpTable(m_jit.emitUnlinkedJe(), i + 2 + target)); 1563 1568 m_jit.testl_i32r(JSImmediate::TagBitTypeInteger, X86::eax); 1564 1569 X86Assembler::JmpSrc isNonZero = m_jit.emitUnlinkedJne(); 1565 1570 1566 m_jit.cmpl_i32r( reinterpret_cast<uint32_t>(JSImmediate::falseImmediate()), X86::eax);1571 m_jit.cmpl_i32r(asInteger(JSImmediate::falseImmediate()), X86::eax); 1567 1572 m_jmpTable.append(JmpTable(m_jit.emitUnlinkedJe(), i + 2 + target)); 1568 m_jit.cmpl_i32r( reinterpret_cast<uint32_t>(JSImmediate::trueImmediate()), X86::eax);1573 m_jit.cmpl_i32r(asInteger(JSImmediate::trueImmediate()), X86::eax); 1569 1574 m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJne(), i)); 1570 1575 … … 1587 1592 case op_unexpected_load: { 1588 1593 JSValue* v = m_codeBlock->unexpectedConstants[instruction[i + 2].u.operand]; 1589 m_jit.movl_i32r( reinterpret_cast<unsigned>(v), X86::eax);1594 m_jit.movl_i32r(asInteger(v), X86::eax); 1590 1595 emitPutResult(instruction[i + 1].u.operand); 1591 1596 i += 3; … … 1640 1645 emitGetArg(src2, X86::eax); 1641 1646 emitJumpSlowCaseIfNotImmNum(X86::eax, i); 1642 m_jit.andl_i32r( reinterpret_cast<unsigned>(value), X86::eax); // FIXME: make it more obvious this is relying on the format of JSImmediate1647 m_jit.andl_i32r(asInteger(value), X86::eax); // FIXME: make it more obvious this is relying on the format of JSImmediate 1643 1648 emitPutResult(dst); 1644 1649 } else if (JSValue* value = getConstantImmediateNumericArg(src2)) { 1645 1650 emitGetArg(src1, X86::eax); 1646 1651 emitJumpSlowCaseIfNotImmNum(X86::eax, i); 1647 m_jit.andl_i32r( reinterpret_cast<unsigned>(value), X86::eax);1652 m_jit.andl_i32r(asInteger(value), X86::eax); 1648 1653 emitPutResult(dst); 1649 1654 } else { … … 1713 1718 emitGetArg(instruction[i + 1].u.operand, X86::eax); 1714 1719 1715 m_jit.cmpl_i32r( reinterpret_cast<uint32_t>(JSImmediate::zeroImmediate()), X86::eax);1720 m_jit.cmpl_i32r(asInteger(JSImmediate::zeroImmediate()), X86::eax); 1716 1721 X86Assembler::JmpSrc isZero = m_jit.emitUnlinkedJe(); 1717 1722 m_jit.testl_i32r(JSImmediate::TagBitTypeInteger, X86::eax); 1718 1723 m_jmpTable.append(JmpTable(m_jit.emitUnlinkedJne(), i + 2 + target)); 1719 1724 1720 m_jit.cmpl_i32r( reinterpret_cast<uint32_t>(JSImmediate::trueImmediate()), X86::eax);1725 m_jit.cmpl_i32r(asInteger(JSImmediate::trueImmediate()), X86::eax); 1721 1726 m_jmpTable.append(JmpTable(m_jit.emitUnlinkedJe(), i + 2 + target)); 1722 m_jit.cmpl_i32r( reinterpret_cast<uint32_t>(JSImmediate::falseImmediate()), X86::eax);1727 m_jit.cmpl_i32r(asInteger(JSImmediate::falseImmediate()), X86::eax); 1723 1728 m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJne(), i)); 1724 1729 … … 1984 1989 JSValue* message = m_codeBlock->unexpectedConstants[instruction[i + 3].u.operand]; 1985 1990 emitPutArgConstant(instruction[i + 2].u.operand, 0); 1986 emitPutArgConstant( reinterpret_cast<unsigned>(message), 4);1991 emitPutArgConstant(asInteger(message), 4); 1987 1992 emitPutArgConstant(m_codeBlock->lineNumberForVPC(&instruction[i]), 8); 1988 1993 emitCTICall(i, Machine::cti_op_new_error); … … 2846 2851 // The prototype object definitely exists (if this stub exists the CodeBlock is referencing a StructureID that is 2847 2852 // referencing the prototype object - let's speculatively load it's table nice and early!) 2848 JSObject* protoObject = static_cast<JSObject*>(structureID->prototypeForLookup(m_callFrame));2853 JSObject* protoObject = asObject(structureID->prototypeForLookup(m_callFrame)); 2849 2854 PropertyStorage* protoPropertyStorage = &protoObject->m_propertyStorage; 2850 2855 m_jit.movl_mr(static_cast<void*>(protoPropertyStorage), X86::edx); … … 2889 2894 // The prototype object definitely exists (if this stub exists the CodeBlock is referencing a StructureID that is 2890 2895 // referencing the prototype object - let's speculatively load it's table nice and early!) 2891 JSObject* protoObject = static_cast<JSObject*>(structureID->prototypeForLookup(m_callFrame));2896 JSObject* protoObject = asObject(structureID->prototypeForLookup(m_callFrame)); 2892 2897 PropertyStorage* protoPropertyStorage = &protoObject->m_propertyStorage; 2893 2898 m_jit.movl_mr(static_cast<void*>(protoPropertyStorage), X86::edx); … … 2938 2943 JSObject* protoObject = 0; 2939 2944 for (unsigned i = 0; i<count; ++i) { 2940 protoObject = static_cast<JSObject*>(currStructureID->prototypeForLookup(m_callFrame));2945 protoObject = asObject(currStructureID->prototypeForLookup(m_callFrame)); 2941 2946 currStructureID = chainEntries[i].get(); 2942 2947 … … 3025 3030 for (RefPtr<StructureID>* it = sIDC->head(); *it; ++it) { 3026 3031 // null check the prototype 3027 m_jit.cmpl_i32r( reinterpret_cast<intptr_t>(jsNull()), X86::ecx);3032 m_jit.cmpl_i32r(asInteger(jsNull()), X86::ecx); 3028 3033 successCases.append(m_jit.emitUnlinkedJe()); 3029 3034
Note:
See TracChangeset
for help on using the changeset viewer.