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


Ignore:
Timestamp:
Sep 10, 2008, 2:23:35 AM (17 years ago)
Author:
[email protected]
Message:

Add optimised access to known properties on the global object.

Reviewed by Maciej Stachowiak

Improve cross scope access to the global object by emitting
code to access it directly rather than by walking the scope chain.

This is a 0.8% win in SunSpider and a 1.7% win in the v8 benchmarks.

File:
1 edited

Legend:

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

    r36316 r36317  
    20872087        NEXT_OPCODE;
    20882088    }
     2089    BEGIN_OPCODE(op_get_global_var) {
     2090        /* get_global_var dst(r) index(n)
     2091
     2092           Gets the global var at global slot index and places it in register dst.
     2093         */
     2094        int dst = (++vPC)->u.operand;
     2095        JSGlobalObject* scope = static_cast<JSGlobalObject*>((++vPC)->u.jsCell);
     2096        ASSERT(scope->isGlobalObject());
     2097        int index = (++vPC)->u.operand;
     2098
     2099        r[dst] = scope->registerAt(index);
     2100        ++vPC;
     2101        NEXT_OPCODE;
     2102    }
     2103    BEGIN_OPCODE(op_put_global_var) {
     2104        /* put_global_var globalObject(c) index(n) value(r)
     2105         
     2106           Puts value into global slot index.
     2107         */
     2108        JSGlobalObject* scope = static_cast<JSGlobalObject*>((++vPC)->u.jsCell);
     2109        ASSERT(scope->isGlobalObject());
     2110        int index = (++vPC)->u.operand;
     2111        int value = (++vPC)->u.operand;
     2112       
     2113        scope->registerAt(index) = r[value].jsValue(exec);
     2114        ++vPC;
     2115        NEXT_OPCODE;
     2116    }           
    20892117    BEGIN_OPCODE(op_get_scoped_var) {
    20902118        /* get_scoped_var dst(r) index(n) skip(n)
Note: See TracChangeset for help on using the changeset viewer.