Changeset 36036 in webkit for trunk/JavaScriptCore/VM/Machine.cpp


Ignore:
Timestamp:
Sep 2, 2008, 7:58:14 PM (17 years ago)
Author:
[email protected]
Message:

2008-09-02 Geoffrey Garen <[email protected]>

Reviewed by Anders Carlsson.


Added optimized paths for comparing to null.


SunSpider says 0.5% faster.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/Machine.cpp

    r36032 r36036  
    14181418        NEXT_OPCODE;
    14191419    }
     1420    BEGIN_OPCODE(op_eq_null) {
     1421        /* neq dst(r) src(r)
     1422
     1423           Checks whether register src is null, as with the ECMAScript '!='
     1424           operator, and puts the result as a boolean in register dst.
     1425        */
     1426        int dst = (++vPC)->u.operand;
     1427        JSValue* src = r[(++vPC)->u.operand].jsValue(exec);
     1428
     1429        if (src->isNull()) {
     1430            r[dst] = jsBoolean(true);
     1431            ++vPC;
     1432            NEXT_OPCODE;
     1433        }
     1434       
     1435        if (src->isUndefined()) {
     1436            r[dst] = jsBoolean(true);
     1437            ++vPC;
     1438            NEXT_OPCODE;
     1439        }
     1440       
     1441        r[dst] = jsBoolean(!JSImmediate::isImmediate(src) && static_cast<JSCell*>(src)->masqueradeAsUndefined());
     1442        ++vPC;
     1443        NEXT_OPCODE;
     1444    }
    14201445    BEGIN_OPCODE(op_neq) {
    14211446        /* neq dst(r) src1(r) src2(r)
     
    14361461        }
    14371462
     1463        ++vPC;
     1464        NEXT_OPCODE;
     1465    }
     1466    BEGIN_OPCODE(op_neq_null) {
     1467        /* neq dst(r) src(r)
     1468
     1469           Checks whether register src is not null, as with the ECMAScript '!='
     1470           operator, and puts the result as a boolean in register dst.
     1471        */
     1472        int dst = (++vPC)->u.operand;
     1473        JSValue* src = r[(++vPC)->u.operand].jsValue(exec);
     1474
     1475        if (src->isNull()) {
     1476            r[dst] = jsBoolean(false);
     1477            ++vPC;
     1478            NEXT_OPCODE;
     1479        }
     1480       
     1481        if (src->isUndefined()) {
     1482            r[dst] = jsBoolean(false);
     1483            ++vPC;
     1484            NEXT_OPCODE;
     1485        }
     1486       
     1487        r[dst] = jsBoolean(JSImmediate::isImmediate(src) || !static_cast<JSCell*>(src)->masqueradeAsUndefined());
    14381488        ++vPC;
    14391489        NEXT_OPCODE;
Note: See TracChangeset for help on using the changeset viewer.