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/Arguments.h

    r47022 r47292  
    2929#include "JSGlobalObject.h"
    3030#include "Interpreter.h"
     31#include "ObjectConstructor.h"
    3132
    3233namespace JSC {
     
    99100
    100101        void init(CallFrame*);
     102        void initializeStandardProperties(CallFrame*);
    101103
    102104        OwnPtr<ArgumentsData> d;
     
    132134        , d(new ArgumentsData)
    133135    {
     136        initializeStandardProperties(callFrame);
    134137        JSFunction* callee;
    135138        ptrdiff_t firstParameterIndex;
     
    170173    {
    171174        ASSERT(!callFrame->callee()->body()->parameterCount());
    172 
     175       
     176        initializeStandardProperties(callFrame);
    173177        unsigned numArguments = callFrame->argumentCount() - 1;
    174178
     
    238242    }
    239243   
     244   
     245    inline void Arguments::initializeStandardProperties(CallFrame* callFrame)
     246    {
     247        putDirectFunction(callFrame->propertyNames().constructor, callFrame->lexicalGlobalObject()->objectConstructor(), DontEnum);
     248        putDirectFunction(callFrame->propertyNames().toString, callFrame->lexicalGlobalObject()->objectToStringFunction(), DontEnum);
     249        putDirectFunction(callFrame->propertyNames().toLocaleString, callFrame->lexicalGlobalObject()->objectToLocaleStringFunction(), DontEnum);
     250    }
    240251
    241252} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.