Changeset 46598 in webkit for trunk/JavaScriptCore/interpreter


Ignore:
Timestamp:
Jul 30, 2009, 1:57:44 PM (16 years ago)
Author:
[email protected]
Message:

Merged nitro-extreme branch into trunk.

Location:
trunk/JavaScriptCore/interpreter
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/CallFrame.h

    r45609 r46598  
    106106        Instruction* returnPC() const { return this[RegisterFile::ReturnPC].vPC(); }
    107107
    108         void setCalleeArguments(Arguments* arguments) { this[RegisterFile::OptionalCalleeArguments] = arguments; }
     108        void setCalleeArguments(JSValue arguments) { this[RegisterFile::OptionalCalleeArguments] = arguments; }
    109109        void setCallerFrame(CallFrame* callerFrame) { this[RegisterFile::CallerFrame] = callerFrame; }
    110110        void setScopeChain(ScopeChainNode* scopeChain) { this[RegisterFile::ScopeChain] = scopeChain; }
     
    119119            setCallerFrame(callerFrame);
    120120            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);
    122122            setArgumentCount(argc); // original argument count (for the sake of the "arguments" object)
    123123            setCallee(function);
    124             setCalleeArguments(0);
     124            setCalleeArguments(JSValue());
    125125        }
    126126
     
    136136
    137137    private:
    138         void setArgumentCount(int count) { this[RegisterFile::ArgumentCount] = count; }
     138        void setArgumentCount(int count) { this[RegisterFile::ArgumentCount] = Register::withInt(count); }
    139139        void setCallee(JSFunction* callee) { this[RegisterFile::Callee] = callee; }
    140140        void setCodeBlock(CodeBlock* codeBlock) { this[RegisterFile::CodeBlock] = codeBlock; }
  • trunk/JavaScriptCore/interpreter/CallFrameClosure.h

    r44030 r46598  
    5050    {
    5151        newCallFrame->setScopeChain(scopeChain);
    52         newCallFrame->setCalleeArguments(0);
     52        newCallFrame->setCalleeArguments(JSValue());
    5353        for (int i = providedParams; i < expectedParams; ++i)
    5454            newCallFrame[i - RegisterFile::CallFrameHeaderSize - expectedParams] = jsUndefined();
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r45903 r46598  
    381381{
    382382    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");
    386386
    387387    CodeBlock* codeBlock = callFrame->codeBlock();
     
    389389    const Register* it;
    390390    const Register* end;
     391    JSValue v;
    391392
    392393    if (codeBlock->codeType() == GlobalCode) {
     
    394395        end = it + registerFile->numGlobals();
    395396        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
    397403            ++it;
    398404        }
    399         printf("----------------------------------------------------\n");
     405        printf("-----------------------------------------------------------------------------\n");
    400406    }
    401407   
    402408    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
    404415    end = it + max(codeBlock->m_numParameters - 1, 0); // - 1 to skip "this"
    405416    if (it != end) {
    406417        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
    408424            ++it;
    409425        } while (it != end);
    410426    }
    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");
    422437
    423438    int registerCount = 0;
     
    426441    if (it != end) {
    427442        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
    429449            ++it;
    430450            ++registerCount;
    431451        } while (it != end);
    432452    }
    433     printf("----------------------------------------------------\n");
     453    printf("-----------------------------------------------------------------------------\n");
    434454
    435455    end = it + codeBlock->m_numCalleeRegisters - codeBlock->m_numVars;
    436456    if (it != end) {
    437457        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
    439464            ++it;
    440465            ++registerCount;
    441466        } while (it != end);
    442467    }
    443     printf("----------------------------------------------------\n");
     468    printf("-----------------------------------------------------------------------------\n");
    444469}
    445470
     
    11121137
    11131138#if ENABLE(JIT)
    1114     // Currently with CTI enabled we never interpret functions
     1139    // Mixing Interpreter + JIT is not supported.
    11151140    ASSERT_NOT_REACHED();
    11161141#endif
     
    12421267        JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue();
    12431268        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());
    12461271        else {
    12471272            JSValue result = jsBoolean(JSValue::equalSlowCase(callFrame, src1, src2));
     
    12821307        JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue();
    12831308        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());
    12861311        else {
    12871312            JSValue result = jsBoolean(!JSValue::equalSlowCase(callFrame, src1, src2));
     
    13841409        int srcDst = (++vPC)->u.operand;
    13851410        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);
    13881413        else {
    13891414            JSValue result = jsNumber(callFrame, v.toNumber(callFrame) + 1);
     
    14031428        int srcDst = (++vPC)->u.operand;
    14041429        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);
    14071432        else {
    14081433            JSValue result = jsNumber(callFrame, v.toNumber(callFrame) - 1);
     
    14241449        int srcDst = (++vPC)->u.operand;
    14251450        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);
    14271453            callFrame->r(dst) = v;
    1428             callFrame->r(srcDst) = JSValue(JSFastMath::incImmediateNumber(v));
    14291454        } else {
    14301455            JSValue number = callFrame->r(srcDst).jsValue().toJSNumber(callFrame);
    14311456            CHECK_FOR_EXCEPTION();
     1457            callFrame->r(srcDst) = jsNumber(callFrame, number.uncheckedGetNumber() + 1);
    14321458            callFrame->r(dst) = number;
    1433             callFrame->r(srcDst) = JSValue(jsNumber(callFrame, number.uncheckedGetNumber() + 1));
    14341459        }
    14351460
     
    14471472        int srcDst = (++vPC)->u.operand;
    14481473        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);
    14501476            callFrame->r(dst) = v;
    1451             callFrame->r(srcDst) = JSValue(JSFastMath::decImmediateNumber(v));
    14521477        } else {
    14531478            JSValue number = callFrame->r(srcDst).jsValue().toJSNumber(callFrame);
    14541479            CHECK_FOR_EXCEPTION();
     1480            callFrame->r(srcDst) = jsNumber(callFrame, number.uncheckedGetNumber() - 1);
    14551481            callFrame->r(dst) = number;
    1456             callFrame->r(srcDst) = JSValue(jsNumber(callFrame, number.uncheckedGetNumber() - 1));
    14571482        }
    14581483
     
    14901515        int dst = (++vPC)->u.operand;
    14911516        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());
    14961519        else {
    14971520            JSValue result = jsNumber(callFrame, -src.toNumber(callFrame));
     
    15001523        }
    15011524
     1525        ++vPC;
    15021526        NEXT_INSTRUCTION();
    15031527    }
     
    15121536        JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue();
    15131537        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());
    15161540        else {
    15171541            JSValue result = jsAdd(callFrame, src1, src2);
     
    15311555        JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue();
    15321556        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());
    15441559        else {
    15451560            JSValue result = jsNumber(callFrame, src1.toNumber(callFrame) * src2.toNumber(callFrame));
     
    15611576        JSValue dividend = callFrame->r((++vPC)->u.operand).jsValue();
    15621577        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;
    15731584        NEXT_INSTRUCTION();
    15741585    }
     
    15811592        */
    15821593        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());
    15931599            ASSERT(result);
    15941600            callFrame->r(dst) = result;
     
    15971603        }
    15981604
    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));
    16011610        CHECK_FOR_EXCEPTION();
    16021611        callFrame->r(dst) = result;
     
    16141623        JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue();
    16151624        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());
    16221627        else {
    16231628            JSValue result = jsNumber(callFrame, src1.toNumber(callFrame) - src2.toNumber(callFrame));
     
    16381643        JSValue val = callFrame->r((++vPC)->u.operand).jsValue();
    16391644        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));
    16461648        else {
    16471649            JSValue result = jsNumber(callFrame, (val.toInt32(callFrame)) << (shift.toUInt32(callFrame) & 0x1f));
     
    16631665        JSValue val = callFrame->r((++vPC)->u.operand).jsValue();
    16641666        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));
    16711670        else {
    16721671            JSValue result = jsNumber(callFrame, (val.toInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f));
     
    16881687        JSValue val = callFrame->r((++vPC)->u.operand).jsValue();
    16891688        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));
    16921691        else {
    16931692            JSValue result = jsNumber(callFrame, (val.toUInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f));
     
    17091708        JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue();
    17101709        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());
    17171712        else {
    17181713            JSValue result = jsNumber(callFrame, src1.toInt32(callFrame) & src2.toInt32(callFrame));
     
    17341729        JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue();
    17351730        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());
    17421733        else {
    17431734            JSValue result = jsNumber(callFrame, src1.toInt32(callFrame) ^ src2.toInt32(callFrame));
     
    17591750        JSValue src1 = callFrame->r((++vPC)->u.operand).jsValue();
    17601751        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());
    17671754        else {
    17681755            JSValue result = jsNumber(callFrame, src1.toInt32(callFrame) | src2.toInt32(callFrame));
     
    17821769        int dst = (++vPC)->u.operand;
    17831770        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());
    17871773        else {
    17881774            JSValue result = jsNumber(callFrame, ~src.toInt32(callFrame));
     
    21182104        NEXT_INSTRUCTION();
    21192105    }
    2120     DEFINE_OPCODE(op_resolve_func) {
    2121         /* resolve_func baseDst(r) funcDst(r) property(id)
    2122 
    2123            Searches the scope chain for an object containing
    2124            identifier property, and if one is found, writes the
    2125            appropriate object to use as "this" when calling its
    2126            properties to register baseDst; and the retrieved property
    2127            value to register propDst. If the property is not found,
    2128            raises an exception.
    2129 
    2130            This differs from resolve_with_base, because the
    2131            global this value will be substituted for activations or
    2132            the global object, which is the right behavior for function
    2133            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     }
    21412106    DEFINE_OPCODE(op_get_by_id) {
    21422107        /* get_by_id dst(r) base(r) property(id) structure(sID) nop(n) nop(n) nop(n)
     
    23192284        if (LIKELY(isJSArray(globalData, baseValue))) {
    23202285            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());
    23222287            vPC += 8;
    23232288            NEXT_INSTRUCTION();
     
    23392304        if (LIKELY(isJSString(globalData, baseValue))) {
    23402305            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());
    23422307            vPC += 8;
    23432308            NEXT_INSTRUCTION();
     
    25172482        JSValue result;
    25182483
    2519         if (LIKELY(subscript.isUInt32Fast())) {
    2520             uint32_t i = subscript.getUInt32Fast();
     2484        if (LIKELY(subscript.isUInt32())) {
     2485            uint32_t i = subscript.asUInt32();
    25212486            if (isJSArray(globalData, baseValue)) {
    25222487                JSArray* jsArray = asArray(baseValue);
     
    25592524        JSValue subscript = callFrame->r(property).jsValue();
    25602525
    2561         if (LIKELY(subscript.isUInt32Fast())) {
    2562             uint32_t i = subscript.getUInt32Fast();
     2526        if (LIKELY(subscript.isUInt32())) {
     2527            uint32_t i = subscript.asUInt32();
    25632528            if (isJSArray(globalData, baseValue)) {
    25642529                JSArray* jsArray = asArray(baseValue);
     
    25712536                double dValue = 0;
    25722537                JSValue jsValue = callFrame->r(value).jsValue();
    2573                 if (jsValue.isInt32Fast())
    2574                     jsByteArray->setIndex(i, jsValue.getInt32Fast());
     2538                if (jsValue.isInt32())
     2539                    jsByteArray->setIndex(i, jsValue.asInt32());
    25752540                else if (jsValue.getNumber(dValue))
    25762541                    jsByteArray->setIndex(i, dValue);
     
    28922857        int defaultOffset = (++vPC)->u.operand;
    28932858        JSValue scrutinee = callFrame->r((++vPC)->u.operand).jsValue();
    2894         if (scrutinee.isInt32Fast())
    2895             vPC += callFrame->codeBlock()->immediateSwitchJumpTable(tableIndex).offsetForValue(scrutinee.getInt32Fast(), defaultOffset);
     2859        if (scrutinee.isInt32())
     2860            vPC += callFrame->codeBlock()->immediateSwitchJumpTable(tableIndex).offsetForValue(scrutinee.asInt32(), defaultOffset);
    28962861        else {
    28972862            double value;
     
    29562921        int func = (++vPC)->u.operand;
    29572922
    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()));
    29592924
    29602925        ++vPC;
     
    29722937        int func = (++vPC)->u.operand;
    29732938
    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()));
    29752940
    29762941        ++vPC;
     
    30803045            CHECK_FOR_EXCEPTION();
    30813046
    3082             callFrame->r(dst) = JSValue(returnValue);
     3047            callFrame->r(dst) = returnValue;
    30833048
    30843049            vPC += 5;
     
    31633128        }
    31643129        CHECK_FOR_EXCEPTION();
    3165         callFrame->r(argCountDst) = argCount + 1;
     3130        callFrame->r(argCountDst) = Register::withInt(argCount + 1);
    31663131        ++vPC;
    31673132        NEXT_INSTRUCTION();
     
    32343199            CHECK_FOR_EXCEPTION();
    32353200           
    3236             callFrame->r(dst) = JSValue(returnValue);
     3201            callFrame->r(dst) = returnValue;
    32373202           
    32383203            vPC += 5;
     
    32803245
    32813246        ASSERT(callFrame->codeBlock()->usesArguments() && !callFrame->codeBlock()->needsFullScopeChain());
     3247
    32823248        if (callFrame->optionalCalleeArguments())
    32833249            callFrame->optionalCalleeArguments()->copyRegisters();
     
    33103276            return returnValue;
    33113277
    3312         callFrame->r(dst) = JSValue(returnValue);
     3278        callFrame->r(dst) = returnValue;
    33133279
    33143280        NEXT_INSTRUCTION();
     
    33553321        int dst = (++vPC)->u.operand;
    33563322        JSActivation* activation = new (globalData) JSActivation(callFrame, static_cast<FunctionBodyNode*>(codeBlock->ownerNode()));
    3357         callFrame->r(dst) = activation;
     3323        callFrame->r(dst) = JSValue(activation);
    33583324        callFrame->setScopeChain(callFrame->scopeChain()->copy()->push(activation));
    33593325
     
    34063372             Arguments* arguments = new (globalData) Arguments(callFrame);
    34073373             callFrame->setCalleeArguments(arguments);
    3408              callFrame->r(RegisterFile::ArgumentsRegister) = arguments;
     3374             callFrame->r(RegisterFile::ArgumentsRegister) = JSValue(arguments);
    34093375         }
    34103376        ++vPC;
     
    38683834        SymbolTable& symbolTable = codeBlock->symbolTable();
    38693835        int argumentsIndex = symbolTable.get(functionCallFrame->propertyNames().arguments.ustring().rep()).getIndex();
    3870         if (!functionCallFrame->r(argumentsIndex).arguments()) {
     3836        if (!functionCallFrame->r(argumentsIndex).jsValue()) {
    38713837            Arguments* arguments = new (callFrame) Arguments(functionCallFrame);
    38723838            functionCallFrame->setCalleeArguments(arguments);
    3873             functionCallFrame->r(RegisterFile::ArgumentsRegister) = arguments;
     3839            functionCallFrame->r(RegisterFile::ArgumentsRegister) = JSValue(arguments);
    38743840        }
    38753841        return functionCallFrame->r(argumentsIndex).jsValue();
  • trunk/JavaScriptCore/interpreter/Register.h

    r45128 r46598  
    5353        Register();
    5454        Register(JSValue);
    55         Register(Arguments*);
    5655
    5756        JSValue jsValue() const;
     
    6059        void mark();
    6160       
    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 
    7361        Register(JSActivation*);
    7462        Register(CallFrame*);
     
    7967        Register(Instruction*);
    8068
     69        int32_t i() const;
    8170        JSActivation* activation() const;
    8271        Arguments* arguments() const;
     
    8877        Instruction* vPC() const;
    8978
     79        static Register withInt(int32_t i)
     80        {
     81            return Register(i);
     82        }
     83
     84    private:
     85        Register(int32_t);
     86
    9087        union {
    91             intptr_t i;
    92             void* v;
     88            int32_t i;
    9389            EncodedJSValue value;
    9490
    9591            JSActivation* activation;
    96             Arguments* arguments;
    9792            CallFrame* callFrame;
    9893            CodeBlock* codeBlock;
     
    133128    // Interpreter functions
    134129
    135     ALWAYS_INLINE Register::Register(Arguments* arguments)
    136     {
    137         u.arguments = arguments;
    138     }
    139 
    140130    ALWAYS_INLINE Register::Register(JSActivation* activation)
    141131    {
     
    173163    }
    174164
    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    {
    179167        u.i = i;
    180168    }
    181169
    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.
    184170    ALWAYS_INLINE int32_t Register::i() const
    185171    {
    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   
    194175    ALWAYS_INLINE JSActivation* Register::activation() const
    195176    {
     
    197178    }
    198179   
    199     ALWAYS_INLINE Arguments* Register::arguments() const
    200     {
    201         return u.arguments;
    202     }
    203    
    204180    ALWAYS_INLINE CallFrame* Register::callFrame() const
    205181    {
Note: See TracChangeset for help on using the changeset viewer.