Changeset 46598 in webkit for trunk/JavaScriptCore/interpreter
- Timestamp:
- Jul 30, 2009, 1:57:44 PM (16 years ago)
- Location:
- trunk/JavaScriptCore/interpreter
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/interpreter/CallFrame.h
r45609 r46598 106 106 Instruction* returnPC() const { return this[RegisterFile::ReturnPC].vPC(); } 107 107 108 void setCalleeArguments( Arguments*arguments) { this[RegisterFile::OptionalCalleeArguments] = arguments; }108 void setCalleeArguments(JSValue arguments) { this[RegisterFile::OptionalCalleeArguments] = arguments; } 109 109 void setCallerFrame(CallFrame* callerFrame) { this[RegisterFile::CallerFrame] = callerFrame; } 110 110 void setScopeChain(ScopeChainNode* scopeChain) { this[RegisterFile::ScopeChain] = scopeChain; } … … 119 119 setCallerFrame(callerFrame); 120 120 this[RegisterFile::ReturnPC] = vPC; // This is either an Instruction* or a pointer into JIT generated code stored as an Instruction*. 121 this[RegisterFile::ReturnValueRegister] = returnValueRegister;121 this[RegisterFile::ReturnValueRegister] = Register::withInt(returnValueRegister); 122 122 setArgumentCount(argc); // original argument count (for the sake of the "arguments" object) 123 123 setCallee(function); 124 setCalleeArguments( 0);124 setCalleeArguments(JSValue()); 125 125 } 126 126 … … 136 136 137 137 private: 138 void setArgumentCount(int count) { this[RegisterFile::ArgumentCount] = count; }138 void setArgumentCount(int count) { this[RegisterFile::ArgumentCount] = Register::withInt(count); } 139 139 void setCallee(JSFunction* callee) { this[RegisterFile::Callee] = callee; } 140 140 void setCodeBlock(CodeBlock* codeBlock) { this[RegisterFile::CodeBlock] = codeBlock; } -
trunk/JavaScriptCore/interpreter/CallFrameClosure.h
r44030 r46598 50 50 { 51 51 newCallFrame->setScopeChain(scopeChain); 52 newCallFrame->setCalleeArguments( 0);52 newCallFrame->setCalleeArguments(JSValue()); 53 53 for (int i = providedParams; i < expectedParams; ++i) 54 54 newCallFrame[i - RegisterFile::CallFrameHeaderSize - expectedParams] = jsUndefined(); -
trunk/JavaScriptCore/interpreter/Interpreter.cpp
r45903 r46598 381 381 { 382 382 printf("Register frame: \n\n"); 383 printf("---------------------------------------------------- \n");384 printf(" use | address | value\n");385 printf("---------------------------------------------------- \n");383 printf("-----------------------------------------------------------------------------\n"); 384 printf(" use | address | value \n"); 385 printf("-----------------------------------------------------------------------------\n"); 386 386 387 387 CodeBlock* codeBlock = callFrame->codeBlock(); … … 389 389 const Register* it; 390 390 const Register* end; 391 JSValue v; 391 392 392 393 if (codeBlock->codeType() == GlobalCode) { … … 394 395 end = it + registerFile->numGlobals(); 395 396 while (it != end) { 396 printf("[global var] | %10p | %10p \n", it, (*it).v()); 397 v = (*it).jsValue(); 398 #if USE(JSVALUE32_64) 399 printf("[global var] | %10p | %-16s 0x%llx \n", it, v.description(), JSValue::encode(v)); 400 #else 401 printf("[global var] | %10p | %-16s %p \n", it, v.description(), JSValue::encode(v)); 402 #endif 397 403 ++it; 398 404 } 399 printf("---------------------------------------------------- \n");405 printf("-----------------------------------------------------------------------------\n"); 400 406 } 401 407 402 408 it = callFrame->registers() - RegisterFile::CallFrameHeaderSize - codeBlock->m_numParameters; 403 printf("[this] | %10p | %10p \n", it, (*it).v()); ++it; 409 v = (*it).jsValue(); 410 #if USE(JSVALUE32_64) 411 printf("[this] | %10p | %-16s 0x%llx \n", it, v.description(), JSValue::encode(v)); ++it; 412 #else 413 printf("[this] | %10p | %-16s %p \n", it, v.description(), JSValue::encode(v)); ++it; 414 #endif 404 415 end = it + max(codeBlock->m_numParameters - 1, 0); // - 1 to skip "this" 405 416 if (it != end) { 406 417 do { 407 printf("[param] | %10p | %10p \n", it, (*it).v()); 418 v = (*it).jsValue(); 419 #if USE(JSVALUE32_64) 420 printf("[param] | %10p | %-16s 0x%llx \n", it, v.description(), JSValue::encode(v)); 421 #else 422 printf("[param] | %10p | %-16s %p \n", it, v.description(), JSValue::encode(v)); 423 #endif 408 424 ++it; 409 425 } while (it != end); 410 426 } 411 printf("----------------------------------------------------\n"); 412 413 printf("[CodeBlock] | %10p | %10p \n", it, (*it).v()); ++it; 414 printf("[ScopeChain] | %10p | %10p \n", it, (*it).v()); ++it; 415 printf("[CallerRegisters] | %10p | %10p \n", it, (*it).v()); ++it; 416 printf("[ReturnPC] | %10p | %10p \n", it, (*it).v()); ++it; 417 printf("[ReturnValueRegister] | %10p | %10p \n", it, (*it).v()); ++it; 418 printf("[ArgumentCount] | %10p | %10p \n", it, (*it).v()); ++it; 419 printf("[Callee] | %10p | %10p \n", it, (*it).v()); ++it; 420 printf("[OptionalCalleeArguments] | %10p | %10p \n", it, (*it).v()); ++it; 421 printf("----------------------------------------------------\n"); 427 printf("-----------------------------------------------------------------------------\n"); 428 printf("[CodeBlock] | %10p | %p \n", it, (*it).codeBlock()); ++it; 429 printf("[ScopeChain] | %10p | %p \n", it, (*it).scopeChain()); ++it; 430 printf("[CallerRegisters] | %10p | %d \n", it, (*it).i()); ++it; 431 printf("[ReturnPC] | %10p | %p \n", it, (*it).vPC()); ++it; 432 printf("[ReturnValueRegister] | %10p | %d \n", it, (*it).i()); ++it; 433 printf("[ArgumentCount] | %10p | %d \n", it, (*it).i()); ++it; 434 printf("[Callee] | %10p | %p \n", it, (*it).function()); ++it; 435 printf("[OptionalCalleeArguments] | %10p | %p \n", it, (*it).arguments()); ++it; 436 printf("-----------------------------------------------------------------------------\n"); 422 437 423 438 int registerCount = 0; … … 426 441 if (it != end) { 427 442 do { 428 printf("[r%2d] | %10p | %10p \n", registerCount, it, (*it).v()); 443 v = (*it).jsValue(); 444 #if USE(JSVALUE32_64) 445 printf("[r%2d] | %10p | %-16s 0x%llx \n", registerCount, it, v.description(), JSValue::encode(v)); 446 #else 447 printf("[r%2d] | %10p | %-16s %p \n", registerCount, it, v.description(), JSValue::encode(v)); 448 #endif 429 449 ++it; 430 450 ++registerCount; 431 451 } while (it != end); 432 452 } 433 printf("---------------------------------------------------- \n");453 printf("-----------------------------------------------------------------------------\n"); 434 454 435 455 end = it + codeBlock->m_numCalleeRegisters - codeBlock->m_numVars; 436 456 if (it != end) { 437 457 do { 438 printf("[r%2d] | %10p | %10p \n", registerCount, it, (*it).v()); 458 v = (*it).jsValue(); 459 #if USE(JSVALUE32_64) 460 printf("[r%2d] | %10p | %-16s 0x%llx \n", registerCount, it, v.description(), JSValue::encode(v)); 461 #else 462 printf("[r%2d] | %10p | %-16s %p \n", registerCount, it, v.description(), JSValue::encode(v)); 463 #endif 439 464 ++it; 440 465 ++registerCount; 441 466 } while (it != end); 442 467 } 443 printf("---------------------------------------------------- \n");468 printf("-----------------------------------------------------------------------------\n"); 444 469 } 445 470 … … 1112 1137 1113 1138 #if ENABLE(JIT) 1114 // Currently with CTI enabled we never interpret functions1139 // Mixing Interpreter + JIT is not supported. 1115 1140 ASSERT_NOT_REACHED(); 1116 1141 #endif … … 1242 1267 JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue(); 1243 1268 JSValue src2 = callFrame->r((++vPC)->u.operand).jsValue(); 1244 if ( JSFastMath::canDoFastBitwiseOperations(src1, src2))1245 callFrame->r(dst) = JSFastMath::equal(src1, src2);1269 if (src1.isInt32() && src2.isInt32()) 1270 callFrame->r(dst) = jsBoolean(src1.asInt32() == src2.asInt32()); 1246 1271 else { 1247 1272 JSValue result = jsBoolean(JSValue::equalSlowCase(callFrame, src1, src2)); … … 1282 1307 JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue(); 1283 1308 JSValue src2 = callFrame->r((++vPC)->u.operand).jsValue(); 1284 if ( JSFastMath::canDoFastBitwiseOperations(src1, src2))1285 callFrame->r(dst) = JSFastMath::notEqual(src1, src2);1309 if (src1.isInt32() && src2.isInt32()) 1310 callFrame->r(dst) = jsBoolean(src1.asInt32() != src2.asInt32()); 1286 1311 else { 1287 1312 JSValue result = jsBoolean(!JSValue::equalSlowCase(callFrame, src1, src2)); … … 1384 1409 int srcDst = (++vPC)->u.operand; 1385 1410 JSValue v = callFrame->r(srcDst).jsValue(); 1386 if ( JSFastMath::canDoFastAdditiveOperations(v))1387 callFrame->r(srcDst) = JSValue(JSFastMath::incImmediateNumber(v));1411 if (v.isInt32() && v.asInt32() < INT_MAX) 1412 callFrame->r(srcDst) = jsNumber(callFrame, v.asInt32() + 1); 1388 1413 else { 1389 1414 JSValue result = jsNumber(callFrame, v.toNumber(callFrame) + 1); … … 1403 1428 int srcDst = (++vPC)->u.operand; 1404 1429 JSValue v = callFrame->r(srcDst).jsValue(); 1405 if ( JSFastMath::canDoFastAdditiveOperations(v))1406 callFrame->r(srcDst) = JSValue(JSFastMath::decImmediateNumber(v));1430 if (v.isInt32() && v.asInt32() > INT_MIN) 1431 callFrame->r(srcDst) = jsNumber(callFrame, v.asInt32() - 1); 1407 1432 else { 1408 1433 JSValue result = jsNumber(callFrame, v.toNumber(callFrame) - 1); … … 1424 1449 int srcDst = (++vPC)->u.operand; 1425 1450 JSValue v = callFrame->r(srcDst).jsValue(); 1426 if (JSFastMath::canDoFastAdditiveOperations(v)) { 1451 if (v.isInt32() && v.asInt32() < INT_MAX) { 1452 callFrame->r(srcDst) = jsNumber(callFrame, v.asInt32() + 1); 1427 1453 callFrame->r(dst) = v; 1428 callFrame->r(srcDst) = JSValue(JSFastMath::incImmediateNumber(v));1429 1454 } else { 1430 1455 JSValue number = callFrame->r(srcDst).jsValue().toJSNumber(callFrame); 1431 1456 CHECK_FOR_EXCEPTION(); 1457 callFrame->r(srcDst) = jsNumber(callFrame, number.uncheckedGetNumber() + 1); 1432 1458 callFrame->r(dst) = number; 1433 callFrame->r(srcDst) = JSValue(jsNumber(callFrame, number.uncheckedGetNumber() + 1));1434 1459 } 1435 1460 … … 1447 1472 int srcDst = (++vPC)->u.operand; 1448 1473 JSValue v = callFrame->r(srcDst).jsValue(); 1449 if (JSFastMath::canDoFastAdditiveOperations(v)) { 1474 if (v.isInt32() && v.asInt32() > INT_MIN) { 1475 callFrame->r(srcDst) = jsNumber(callFrame, v.asInt32() - 1); 1450 1476 callFrame->r(dst) = v; 1451 callFrame->r(srcDst) = JSValue(JSFastMath::decImmediateNumber(v));1452 1477 } else { 1453 1478 JSValue number = callFrame->r(srcDst).jsValue().toJSNumber(callFrame); 1454 1479 CHECK_FOR_EXCEPTION(); 1480 callFrame->r(srcDst) = jsNumber(callFrame, number.uncheckedGetNumber() - 1); 1455 1481 callFrame->r(dst) = number; 1456 callFrame->r(srcDst) = JSValue(jsNumber(callFrame, number.uncheckedGetNumber() - 1));1457 1482 } 1458 1483 … … 1490 1515 int dst = (++vPC)->u.operand; 1491 1516 JSValue src = callFrame->r((++vPC)->u.operand).jsValue(); 1492 ++vPC; 1493 double v; 1494 if (src.getNumber(v)) 1495 callFrame->r(dst) = JSValue(jsNumber(callFrame, -v)); 1517 if (src.isInt32() && src.asInt32()) 1518 callFrame->r(dst) = jsNumber(callFrame, -src.asInt32()); 1496 1519 else { 1497 1520 JSValue result = jsNumber(callFrame, -src.toNumber(callFrame)); … … 1500 1523 } 1501 1524 1525 ++vPC; 1502 1526 NEXT_INSTRUCTION(); 1503 1527 } … … 1512 1536 JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue(); 1513 1537 JSValue src2 = callFrame->r((++vPC)->u.operand).jsValue(); 1514 if ( JSFastMath::canDoFastAdditiveOperations(src1, src2))1515 callFrame->r(dst) = JSValue(JSFastMath::addImmediateNumbers(src1, src2));1538 if (src1.isInt32() && src2.isInt32() && !(src1.asInt32() | src2.asInt32() & 0xc0000000)) // no overflow 1539 callFrame->r(dst) = jsNumber(callFrame, src1.asInt32() + src2.asInt32()); 1516 1540 else { 1517 1541 JSValue result = jsAdd(callFrame, src1, src2); … … 1531 1555 JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue(); 1532 1556 JSValue src2 = callFrame->r((++vPC)->u.operand).jsValue(); 1533 double left; 1534 double right; 1535 if (JSValue::areBothInt32Fast(src1, src2)) { 1536 int32_t left = src1.getInt32Fast(); 1537 int32_t right = src2.getInt32Fast(); 1538 if ((left | right) >> 15 == 0) 1539 callFrame->r(dst) = JSValue(jsNumber(callFrame, left * right)); 1540 else 1541 callFrame->r(dst) = JSValue(jsNumber(callFrame, static_cast<double>(left) * static_cast<double>(right))); 1542 } else if (src1.getNumber(left) && src2.getNumber(right)) 1543 callFrame->r(dst) = JSValue(jsNumber(callFrame, left * right)); 1557 if (src1.isInt32() && src2.isInt32() && !(src1.asInt32() | src2.asInt32() >> 15)) // no overflow 1558 callFrame->r(dst) = jsNumber(callFrame, src1.asInt32() * src2.asInt32()); 1544 1559 else { 1545 1560 JSValue result = jsNumber(callFrame, src1.toNumber(callFrame) * src2.toNumber(callFrame)); … … 1561 1576 JSValue dividend = callFrame->r((++vPC)->u.operand).jsValue(); 1562 1577 JSValue divisor = callFrame->r((++vPC)->u.operand).jsValue(); 1563 double left; 1564 double right; 1565 if (dividend.getNumber(left) && divisor.getNumber(right)) 1566 callFrame->r(dst) = JSValue(jsNumber(callFrame, left / right)); 1567 else { 1568 JSValue result = jsNumber(callFrame, dividend.toNumber(callFrame) / divisor.toNumber(callFrame)); 1569 CHECK_FOR_EXCEPTION(); 1570 callFrame->r(dst) = result; 1571 } 1572 ++vPC; 1578 1579 JSValue result = jsNumber(callFrame, dividend.toNumber(callFrame) / divisor.toNumber(callFrame)); 1580 CHECK_FOR_EXCEPTION(); 1581 callFrame->r(dst) = result; 1582 1583 vPC += 2; 1573 1584 NEXT_INSTRUCTION(); 1574 1585 } … … 1581 1592 */ 1582 1593 int dst = (++vPC)->u.operand; 1583 int dividend = (++vPC)->u.operand; 1584 int divisor = (++vPC)->u.operand; 1585 1586 JSValue dividendValue = callFrame->r(dividend).jsValue(); 1587 JSValue divisorValue = callFrame->r(divisor).jsValue(); 1588 1589 if (JSValue::areBothInt32Fast(dividendValue, divisorValue) && divisorValue != jsNumber(callFrame, 0)) { 1590 // We expect the result of the modulus of a number that was representable as an int32 to also be representable 1591 // as an int32. 1592 JSValue result = JSValue::makeInt32Fast(dividendValue.getInt32Fast() % divisorValue.getInt32Fast()); 1594 JSValue dividend = callFrame->r((++vPC)->u.operand).jsValue(); 1595 JSValue divisor = callFrame->r((++vPC)->u.operand).jsValue(); 1596 1597 if (dividend.isInt32() && divisor.isInt32() && divisor.asInt32() != 0) { 1598 JSValue result = jsNumber(callFrame, dividend.asInt32() % divisor.asInt32()); 1593 1599 ASSERT(result); 1594 1600 callFrame->r(dst) = result; … … 1597 1603 } 1598 1604 1599 double d = dividendValue.toNumber(callFrame); 1600 JSValue result = jsNumber(callFrame, fmod(d, divisorValue.toNumber(callFrame))); 1605 // Conversion to double must happen outside the call to fmod since the 1606 // order of argument evaluation is not guaranteed. 1607 double d1 = dividend.toNumber(callFrame); 1608 double d2 = divisor.toNumber(callFrame); 1609 JSValue result = jsNumber(callFrame, fmod(d1, d2)); 1601 1610 CHECK_FOR_EXCEPTION(); 1602 1611 callFrame->r(dst) = result; … … 1614 1623 JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue(); 1615 1624 JSValue src2 = callFrame->r((++vPC)->u.operand).jsValue(); 1616 double left; 1617 double right; 1618 if (JSFastMath::canDoFastAdditiveOperations(src1, src2)) 1619 callFrame->r(dst) = JSValue(JSFastMath::subImmediateNumbers(src1, src2)); 1620 else if (src1.getNumber(left) && src2.getNumber(right)) 1621 callFrame->r(dst) = JSValue(jsNumber(callFrame, left - right)); 1625 if (src1.isInt32() && src2.isInt32() && !(src1.asInt32() | src2.asInt32() & 0xc0000000)) // no overflow 1626 callFrame->r(dst) = jsNumber(callFrame, src1.asInt32() - src2.asInt32()); 1622 1627 else { 1623 1628 JSValue result = jsNumber(callFrame, src1.toNumber(callFrame) - src2.toNumber(callFrame)); … … 1638 1643 JSValue val = callFrame->r((++vPC)->u.operand).jsValue(); 1639 1644 JSValue shift = callFrame->r((++vPC)->u.operand).jsValue(); 1640 int32_t left; 1641 uint32_t right; 1642 if (JSValue::areBothInt32Fast(val, shift)) 1643 callFrame->r(dst) = JSValue(jsNumber(callFrame, val.getInt32Fast() << (shift.getInt32Fast() & 0x1f))); 1644 else if (val.numberToInt32(left) && shift.numberToUInt32(right)) 1645 callFrame->r(dst) = JSValue(jsNumber(callFrame, left << (right & 0x1f))); 1645 1646 if (val.isInt32() && shift.isInt32()) 1647 callFrame->r(dst) = jsNumber(callFrame, val.asInt32() << (shift.asInt32() & 0x1f)); 1646 1648 else { 1647 1649 JSValue result = jsNumber(callFrame, (val.toInt32(callFrame)) << (shift.toUInt32(callFrame) & 0x1f)); … … 1663 1665 JSValue val = callFrame->r((++vPC)->u.operand).jsValue(); 1664 1666 JSValue shift = callFrame->r((++vPC)->u.operand).jsValue(); 1665 int32_t left; 1666 uint32_t right; 1667 if (JSFastMath::canDoFastRshift(val, shift)) 1668 callFrame->r(dst) = JSValue(JSFastMath::rightShiftImmediateNumbers(val, shift)); 1669 else if (val.numberToInt32(left) && shift.numberToUInt32(right)) 1670 callFrame->r(dst) = JSValue(jsNumber(callFrame, left >> (right & 0x1f))); 1667 1668 if (val.isInt32() && shift.isInt32()) 1669 callFrame->r(dst) = jsNumber(callFrame, val.asInt32() >> (shift.asInt32() & 0x1f)); 1671 1670 else { 1672 1671 JSValue result = jsNumber(callFrame, (val.toInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f)); … … 1688 1687 JSValue val = callFrame->r((++vPC)->u.operand).jsValue(); 1689 1688 JSValue shift = callFrame->r((++vPC)->u.operand).jsValue(); 1690 if ( JSFastMath::canDoFastUrshift(val, shift))1691 callFrame->r(dst) = JSValue(JSFastMath::rightShiftImmediateNumbers(val, shift));1689 if (val.isUInt32() && shift.isInt32()) 1690 callFrame->r(dst) = jsNumber(callFrame, val.asInt32() >> (shift.asInt32() & 0x1f)); 1692 1691 else { 1693 1692 JSValue result = jsNumber(callFrame, (val.toUInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f)); … … 1709 1708 JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue(); 1710 1709 JSValue src2 = callFrame->r((++vPC)->u.operand).jsValue(); 1711 int32_t left; 1712 int32_t right; 1713 if (JSFastMath::canDoFastBitwiseOperations(src1, src2)) 1714 callFrame->r(dst) = JSValue(JSFastMath::andImmediateNumbers(src1, src2)); 1715 else if (src1.numberToInt32(left) && src2.numberToInt32(right)) 1716 callFrame->r(dst) = JSValue(jsNumber(callFrame, left & right)); 1710 if (src1.isInt32() && src2.isInt32()) 1711 callFrame->r(dst) = jsNumber(callFrame, src1.asInt32() & src2.asInt32()); 1717 1712 else { 1718 1713 JSValue result = jsNumber(callFrame, src1.toInt32(callFrame) & src2.toInt32(callFrame)); … … 1734 1729 JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue(); 1735 1730 JSValue src2 = callFrame->r((++vPC)->u.operand).jsValue(); 1736 int32_t left; 1737 int32_t right; 1738 if (JSFastMath::canDoFastBitwiseOperations(src1, src2)) 1739 callFrame->r(dst) = JSValue(JSFastMath::xorImmediateNumbers(src1, src2)); 1740 else if (src1.numberToInt32(left) && src2.numberToInt32(right)) 1741 callFrame->r(dst) = JSValue(jsNumber(callFrame, left ^ right)); 1731 if (src1.isInt32() && src2.isInt32()) 1732 callFrame->r(dst) = jsNumber(callFrame, src1.asInt32() ^ src2.asInt32()); 1742 1733 else { 1743 1734 JSValue result = jsNumber(callFrame, src1.toInt32(callFrame) ^ src2.toInt32(callFrame)); … … 1759 1750 JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue(); 1760 1751 JSValue src2 = callFrame->r((++vPC)->u.operand).jsValue(); 1761 int32_t left; 1762 int32_t right; 1763 if (JSFastMath::canDoFastBitwiseOperations(src1, src2)) 1764 callFrame->r(dst) = JSValue(JSFastMath::orImmediateNumbers(src1, src2)); 1765 else if (src1.numberToInt32(left) && src2.numberToInt32(right)) 1766 callFrame->r(dst) = JSValue(jsNumber(callFrame, left | right)); 1752 if (src1.isInt32() && src2.isInt32()) 1753 callFrame->r(dst) = jsNumber(callFrame, src1.asInt32() | src2.asInt32()); 1767 1754 else { 1768 1755 JSValue result = jsNumber(callFrame, src1.toInt32(callFrame) | src2.toInt32(callFrame)); … … 1782 1769 int dst = (++vPC)->u.operand; 1783 1770 JSValue src = callFrame->r((++vPC)->u.operand).jsValue(); 1784 int32_t value; 1785 if (src.numberToInt32(value)) 1786 callFrame->r(dst) = JSValue(jsNumber(callFrame, ~value)); 1771 if (src.isInt32()) 1772 callFrame->r(dst) = jsNumber(callFrame, ~src.asInt32()); 1787 1773 else { 1788 1774 JSValue result = jsNumber(callFrame, ~src.toInt32(callFrame)); … … 2118 2104 NEXT_INSTRUCTION(); 2119 2105 } 2120 DEFINE_OPCODE(op_resolve_func) {2121 /* resolve_func baseDst(r) funcDst(r) property(id)2122 2123 Searches the scope chain for an object containing2124 identifier property, and if one is found, writes the2125 appropriate object to use as "this" when calling its2126 properties to register baseDst; and the retrieved property2127 value to register propDst. If the property is not found,2128 raises an exception.2129 2130 This differs from resolve_with_base, because the2131 global this value will be substituted for activations or2132 the global object, which is the right behavior for function2133 calls but not for other property lookup.2134 */2135 if (UNLIKELY(!resolveBaseAndFunc(callFrame, vPC, exceptionValue)))2136 goto vm_throw;2137 2138 vPC += 4;2139 NEXT_INSTRUCTION();2140 }2141 2106 DEFINE_OPCODE(op_get_by_id) { 2142 2107 /* get_by_id dst(r) base(r) property(id) structure(sID) nop(n) nop(n) nop(n) … … 2319 2284 if (LIKELY(isJSArray(globalData, baseValue))) { 2320 2285 int dst = vPC[1].u.operand; 2321 callFrame->r(dst) = JSValue(jsNumber(callFrame, asArray(baseValue)->length()));2286 callFrame->r(dst) = jsNumber(callFrame, asArray(baseValue)->length()); 2322 2287 vPC += 8; 2323 2288 NEXT_INSTRUCTION(); … … 2339 2304 if (LIKELY(isJSString(globalData, baseValue))) { 2340 2305 int dst = vPC[1].u.operand; 2341 callFrame->r(dst) = JSValue(jsNumber(callFrame, asString(baseValue)->value().size()));2306 callFrame->r(dst) = jsNumber(callFrame, asString(baseValue)->value().size()); 2342 2307 vPC += 8; 2343 2308 NEXT_INSTRUCTION(); … … 2517 2482 JSValue result; 2518 2483 2519 if (LIKELY(subscript.isUInt32 Fast())) {2520 uint32_t i = subscript. getUInt32Fast();2484 if (LIKELY(subscript.isUInt32())) { 2485 uint32_t i = subscript.asUInt32(); 2521 2486 if (isJSArray(globalData, baseValue)) { 2522 2487 JSArray* jsArray = asArray(baseValue); … … 2559 2524 JSValue subscript = callFrame->r(property).jsValue(); 2560 2525 2561 if (LIKELY(subscript.isUInt32 Fast())) {2562 uint32_t i = subscript. getUInt32Fast();2526 if (LIKELY(subscript.isUInt32())) { 2527 uint32_t i = subscript.asUInt32(); 2563 2528 if (isJSArray(globalData, baseValue)) { 2564 2529 JSArray* jsArray = asArray(baseValue); … … 2571 2536 double dValue = 0; 2572 2537 JSValue jsValue = callFrame->r(value).jsValue(); 2573 if (jsValue.isInt32 Fast())2574 jsByteArray->setIndex(i, jsValue. getInt32Fast());2538 if (jsValue.isInt32()) 2539 jsByteArray->setIndex(i, jsValue.asInt32()); 2575 2540 else if (jsValue.getNumber(dValue)) 2576 2541 jsByteArray->setIndex(i, dValue); … … 2892 2857 int defaultOffset = (++vPC)->u.operand; 2893 2858 JSValue scrutinee = callFrame->r((++vPC)->u.operand).jsValue(); 2894 if (scrutinee.isInt32 Fast())2895 vPC += callFrame->codeBlock()->immediateSwitchJumpTable(tableIndex).offsetForValue(scrutinee. getInt32Fast(), defaultOffset);2859 if (scrutinee.isInt32()) 2860 vPC += callFrame->codeBlock()->immediateSwitchJumpTable(tableIndex).offsetForValue(scrutinee.asInt32(), defaultOffset); 2896 2861 else { 2897 2862 double value; … … 2956 2921 int func = (++vPC)->u.operand; 2957 2922 2958 callFrame->r(dst) = callFrame->codeBlock()->function(func)->makeFunction(callFrame, callFrame->scopeChain());2923 callFrame->r(dst) = JSValue(callFrame->codeBlock()->function(func)->makeFunction(callFrame, callFrame->scopeChain())); 2959 2924 2960 2925 ++vPC; … … 2972 2937 int func = (++vPC)->u.operand; 2973 2938 2974 callFrame->r(dst) = callFrame->codeBlock()->functionExpression(func)->makeFunction(callFrame, callFrame->scopeChain());2939 callFrame->r(dst) = JSValue(callFrame->codeBlock()->functionExpression(func)->makeFunction(callFrame, callFrame->scopeChain())); 2975 2940 2976 2941 ++vPC; … … 3080 3045 CHECK_FOR_EXCEPTION(); 3081 3046 3082 callFrame->r(dst) = JSValue(returnValue);3047 callFrame->r(dst) = returnValue; 3083 3048 3084 3049 vPC += 5; … … 3163 3128 } 3164 3129 CHECK_FOR_EXCEPTION(); 3165 callFrame->r(argCountDst) = argCount + 1;3130 callFrame->r(argCountDst) = Register::withInt(argCount + 1); 3166 3131 ++vPC; 3167 3132 NEXT_INSTRUCTION(); … … 3234 3199 CHECK_FOR_EXCEPTION(); 3235 3200 3236 callFrame->r(dst) = JSValue(returnValue);3201 callFrame->r(dst) = returnValue; 3237 3202 3238 3203 vPC += 5; … … 3280 3245 3281 3246 ASSERT(callFrame->codeBlock()->usesArguments() && !callFrame->codeBlock()->needsFullScopeChain()); 3247 3282 3248 if (callFrame->optionalCalleeArguments()) 3283 3249 callFrame->optionalCalleeArguments()->copyRegisters(); … … 3310 3276 return returnValue; 3311 3277 3312 callFrame->r(dst) = JSValue(returnValue);3278 callFrame->r(dst) = returnValue; 3313 3279 3314 3280 NEXT_INSTRUCTION(); … … 3355 3321 int dst = (++vPC)->u.operand; 3356 3322 JSActivation* activation = new (globalData) JSActivation(callFrame, static_cast<FunctionBodyNode*>(codeBlock->ownerNode())); 3357 callFrame->r(dst) = activation;3323 callFrame->r(dst) = JSValue(activation); 3358 3324 callFrame->setScopeChain(callFrame->scopeChain()->copy()->push(activation)); 3359 3325 … … 3406 3372 Arguments* arguments = new (globalData) Arguments(callFrame); 3407 3373 callFrame->setCalleeArguments(arguments); 3408 callFrame->r(RegisterFile::ArgumentsRegister) = arguments;3374 callFrame->r(RegisterFile::ArgumentsRegister) = JSValue(arguments); 3409 3375 } 3410 3376 ++vPC; … … 3868 3834 SymbolTable& symbolTable = codeBlock->symbolTable(); 3869 3835 int argumentsIndex = symbolTable.get(functionCallFrame->propertyNames().arguments.ustring().rep()).getIndex(); 3870 if (!functionCallFrame->r(argumentsIndex). arguments()) {3836 if (!functionCallFrame->r(argumentsIndex).jsValue()) { 3871 3837 Arguments* arguments = new (callFrame) Arguments(functionCallFrame); 3872 3838 functionCallFrame->setCalleeArguments(arguments); 3873 functionCallFrame->r(RegisterFile::ArgumentsRegister) = arguments;3839 functionCallFrame->r(RegisterFile::ArgumentsRegister) = JSValue(arguments); 3874 3840 } 3875 3841 return functionCallFrame->r(argumentsIndex).jsValue(); -
trunk/JavaScriptCore/interpreter/Register.h
r45128 r46598 53 53 Register(); 54 54 Register(JSValue); 55 Register(Arguments*);56 55 57 56 JSValue jsValue() const; … … 60 59 void mark(); 61 60 62 int32_t i() const;63 void* v() const;64 65 private:66 friend class ExecState;67 friend class Interpreter;68 69 // Only CallFrame, Interpreter, and JITStubs should use these functions.70 71 Register(intptr_t);72 73 61 Register(JSActivation*); 74 62 Register(CallFrame*); … … 79 67 Register(Instruction*); 80 68 69 int32_t i() const; 81 70 JSActivation* activation() const; 82 71 Arguments* arguments() const; … … 88 77 Instruction* vPC() const; 89 78 79 static Register withInt(int32_t i) 80 { 81 return Register(i); 82 } 83 84 private: 85 Register(int32_t); 86 90 87 union { 91 intptr_t i; 92 void* v; 88 int32_t i; 93 89 EncodedJSValue value; 94 90 95 91 JSActivation* activation; 96 Arguments* arguments;97 92 CallFrame* callFrame; 98 93 CodeBlock* codeBlock; … … 133 128 // Interpreter functions 134 129 135 ALWAYS_INLINE Register::Register(Arguments* arguments)136 {137 u.arguments = arguments;138 }139 140 130 ALWAYS_INLINE Register::Register(JSActivation* activation) 141 131 { … … 173 163 } 174 164 175 ALWAYS_INLINE Register::Register(intptr_t i) 176 { 177 // See comment on 'i()' below. 178 ASSERT(i == static_cast<int32_t>(i)); 165 ALWAYS_INLINE Register::Register(int32_t i) 166 { 179 167 u.i = i; 180 168 } 181 169 182 // Read 'i' as a 32-bit integer; we only use it to hold 32-bit values,183 // and we only write 32-bits when writing the arg count from JIT code.184 170 ALWAYS_INLINE int32_t Register::i() const 185 171 { 186 return static_cast<int32_t>(u.i); 187 } 188 189 ALWAYS_INLINE void* Register::v() const 190 { 191 return u.v; 192 } 193 172 return u.i; 173 } 174 194 175 ALWAYS_INLINE JSActivation* Register::activation() const 195 176 { … … 197 178 } 198 179 199 ALWAYS_INLINE Arguments* Register::arguments() const200 {201 return u.arguments;202 }203 204 180 ALWAYS_INLINE CallFrame* Register::callFrame() const 205 181 {
Note:
See TracChangeset
for help on using the changeset viewer.