Ignore:
Timestamp:
Oct 28, 2009, 6:25:02 PM (16 years ago)
Author:
[email protected]
Message:

Improve for..in enumeration performance
https://bugs.webkit.org/show_bug.cgi?id=30887

Reviewed by Geoff Garen.

Improve indexing of an object with a for..in iterator by
identifying cases where get_by_val is being used with a iterator
as the subscript and replace it with a new get_by_pname
bytecode. get_by_pname then optimizes lookups that directly access
the base object.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r49734 r50254  
    24162416        callFrame->r(dst) = result;
    24172417        vPC += OPCODE_LENGTH(op_del_by_id);
     2418        NEXT_INSTRUCTION();
     2419    }
     2420    DEFINE_OPCODE(op_get_by_pname) {
     2421        int dst = vPC[1].u.operand;
     2422        int base = vPC[2].u.operand;
     2423        int property = vPC[3].u.operand;
     2424        int expected = vPC[4].u.operand;
     2425        int iter = vPC[5].u.operand;
     2426        int i = vPC[6].u.operand;
     2427
     2428        JSValue baseValue = callFrame->r(base).jsValue();
     2429        JSPropertyNameIterator* it = callFrame->r(iter).propertyNameIterator();
     2430        JSValue subscript = callFrame->r(property).jsValue();
     2431        JSValue expectedSubscript = callFrame->r(expected).jsValue();
     2432        int index = callFrame->r(i).i() - 1;
     2433        JSValue result;
     2434        int offset = 0;
     2435        if (subscript == expectedSubscript && baseValue.isCell() && (baseValue.asCell()->structure() == it->cachedStructure()) && it->getOffset(index, offset)) {
     2436            callFrame->r(dst) = asObject(baseValue)->getDirectOffset(offset);
     2437            vPC += OPCODE_LENGTH(op_get_by_pname);
     2438            NEXT_INSTRUCTION();
     2439        }
     2440        Identifier propertyName(callFrame, subscript.toString(callFrame));
     2441        result = baseValue.get(callFrame, propertyName);
     2442        CHECK_FOR_EXCEPTION();
     2443        callFrame->r(dst) = result;
     2444        vPC += OPCODE_LENGTH(op_get_by_pname);
    24182445        NEXT_INSTRUCTION();
    24192446    }
Note: See TracChangeset for help on using the changeset viewer.