Ignore:
Timestamp:
Aug 14, 2009, 1:18:09 PM (16 years ago)
Author:
[email protected]
Message:

[ES5] Arguments object should inherit from Array
https://bugs.webkit.org/show_bug.cgi?id=28298

Reviewed by Gavin Barraclough

Make the Arguments object conform to the behaviour specified in ES5.
The simple portion of this is to make Arguments use Array.prototype
as its prototype rather than Object.prototype.

The spec then requires us to set instance.constructor to the pristine
Object constructor, and instance.toString and instance.toLocaleString
to the pristine versions from Object.prototype. To do this we now
make the ObjectPrototype constructor return its toString and
toLocaleString functions (similar to the call and apply functions
from FunctionPrototype).

Oddly enough this reports itself as a slight win, but given the code
isn't hit in the tests that claim to have improved I put this down to
code motion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSGlobalObject.h

    r47022 r47292  
    4141    class GlobalEvalFunction;
    4242    class NativeErrorConstructor;
     43    class ObjectConstructor;
    4344    class ProgramCodeBlock;
    4445    class PrototypeFunction;
     
    6162                , registerArraySize(0)
    6263                , globalScopeChain(NoScopeChain())
     64                , objectConstructor(0)
    6365                , regExpConstructor(0)
    6466                , errorConstructor(0)
     
    7274                , callFunction(0)
    7375                , applyFunction(0)
     76                , objectToStringFunction(0)
     77                , objectToLocaleStringFunction(0)
    7478                , objectPrototype(0)
    7579                , functionPrototype(0)
     
    100104            int recursion;
    101105
     106            ObjectConstructor* objectConstructor;
    102107            RegExpConstructor* regExpConstructor;
    103108            ErrorConstructor* errorConstructor;
     
    112117            NativeFunctionWrapper* callFunction;
    113118            NativeFunctionWrapper* applyFunction;
     119            NativeFunctionWrapper* objectToStringFunction;
     120            NativeFunctionWrapper* objectToLocaleStringFunction;
    114121
    115122            ObjectPrototype* objectPrototype;
     
    184191        // replaces the global object's associated property.
    185192
     193        ObjectConstructor* objectConstructor() const { return d()->objectConstructor; }
    186194        RegExpConstructor* regExpConstructor() const { return d()->regExpConstructor; }
    187195
     
    204212        DatePrototype* datePrototype() const { return d()->datePrototype; }
    205213        RegExpPrototype* regExpPrototype() const { return d()->regExpPrototype; }
     214
     215        NativeFunctionWrapper* objectToStringFunction() const { return d()->objectToStringFunction; }
     216        NativeFunctionWrapper* objectToLocaleStringFunction() const { return d()->objectToLocaleStringFunction; }
    206217
    207218        JSObject* methodCallDummy() const { return d()->methodCallDummy; }
Note: See TracChangeset for help on using the changeset viewer.