Changeset 47404 in webkit


Ignore:
Timestamp:
Aug 17, 2009 6:00:12 PM (15 years ago)
Author:
oliver@apple.com
Message:

REGRESSION (r47292): Prototype.js is broken by ES5 Arguments changes
https://bugs.webkit.org/show_bug.cgi?id=28341
<rdar://problem/7145615>

RS=Mark Rowe

Reverting r47292. Alas Prototype.js breaks with Arguments inheriting
from Array as ES5 attempted. Prototype.js defines $A in terms of a
function it places on (among other global objects) the Array prototype,
thus breaking $A for arrays.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r47392 r47404  
     12009-08-17  Oliver Hunt  <oliver@apple.com>
     2
     3        RS=Mark Rowe.
     4
     5        REGRESSION (r47292): Prototype.js is broken by ES5 Arguments changes
     6        https://bugs.webkit.org/show_bug.cgi?id=28341
     7        <rdar://problem/7145615>
     8
     9        Reverting r47292.  Alas Prototype.js breaks with Arguments inheriting
     10        from Array as ES5 attempted.  Prototype.js defines $A in terms of a
     11        function it places on (among other global objects) the Array prototype,
     12        thus breaking $A for arrays.
     13
     14        * runtime/Arguments.h:
     15        (JSC::Arguments::Arguments):
     16        * runtime/JSGlobalObject.cpp:
     17        (JSC::JSGlobalObject::reset):
     18        (JSC::JSGlobalObject::markChildren):
     19        * runtime/JSGlobalObject.h:
     20        (JSC::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData):
     21        * runtime/ObjectPrototype.cpp:
     22        (JSC::ObjectPrototype::ObjectPrototype):
     23        * runtime/ObjectPrototype.h:
     24        * tests/mozilla/ecma_3/Function/arguments-001.js:
     25
    1262009-08-17  Peter Kasting  <pkasting@google.com>
    227
  • trunk/JavaScriptCore/runtime/Arguments.h

    r47330 r47404  
    101101
    102102        void init(CallFrame*);
    103         void initializeStandardProperties(CallFrame*);
    104103
    105104        OwnPtr<ArgumentsData> d;
     
    135134        , d(new ArgumentsData)
    136135    {
    137         initializeStandardProperties(callFrame);
    138136        JSFunction* callee;
    139137        ptrdiff_t firstParameterIndex;
     
    174172    {
    175173        ASSERT(!callFrame->callee()->body()->parameterCount());
    176        
    177         initializeStandardProperties(callFrame);
     174
    178175        unsigned numArguments = callFrame->argumentCount() - 1;
    179176
     
    243240    }
    244241   
    245    
    246     inline void Arguments::initializeStandardProperties(CallFrame* callFrame)
    247     {
    248         putDirectFunction(callFrame->propertyNames().constructor, callFrame->lexicalGlobalObject()->objectConstructor(), DontEnum);
    249         putDirectFunction(callFrame->propertyNames().toString, callFrame->lexicalGlobalObject()->objectToStringFunction(), DontEnum);
    250         putDirectFunction(callFrame->propertyNames().toLocaleString, callFrame->lexicalGlobalObject()->objectToLocaleStringFunction(), DontEnum);
    251     }
    252242
    253243} // namespace JSC
  • trunk/JavaScriptCore/runtime/JSGlobalObject.cpp

    r47304 r47404  
    211211    d()->callFunction = callFunction;
    212212    d()->applyFunction = applyFunction;
    213     NativeFunctionWrapper* objectToStringFunction = 0;
    214     NativeFunctionWrapper* objectToLocaleStringFunction = 0;
    215     d()->objectPrototype = new (exec) ObjectPrototype(exec, ObjectPrototype::createStructure(jsNull()), d()->prototypeFunctionStructure.get(), &objectToStringFunction, &objectToLocaleStringFunction);
    216     d()->objectToStringFunction = objectToStringFunction;
    217     d()->objectToLocaleStringFunction = objectToLocaleStringFunction;
     213    d()->objectPrototype = new (exec) ObjectPrototype(exec, ObjectPrototype::createStructure(jsNull()), d()->prototypeFunctionStructure.get());
    218214    d()->functionPrototype->structure()->setPrototypeWithoutTransition(d()->objectPrototype);
    219215
     
    222218    d()->functionStructure = JSFunction::createStructure(d()->functionPrototype);
    223219    d()->callbackFunctionStructure = JSCallbackFunction::createStructure(d()->functionPrototype);
     220    d()->argumentsStructure = Arguments::createStructure(d()->objectPrototype);
    224221    d()->callbackConstructorStructure = JSCallbackConstructor::createStructure(d()->objectPrototype);
    225222    d()->callbackObjectStructure = JSCallbackObject<JSObject>::createStructure(d()->objectPrototype);
    226223
    227224    d()->arrayPrototype = new (exec) ArrayPrototype(ArrayPrototype::createStructure(d()->objectPrototype));
    228     d()->argumentsStructure = Arguments::createStructure(d()->arrayPrototype);
    229225    d()->arrayStructure = JSArray::createStructure(d()->arrayPrototype);
    230226    d()->regExpMatchesArrayStructure = RegExpMatchesArray::createStructure(d()->arrayPrototype);
     
    261257    // Constructors
    262258
    263     ObjectConstructor* objectConstructor = new (exec) ObjectConstructor(exec, ObjectConstructor::createStructure(d()->functionPrototype), d()->objectPrototype, d()->prototypeFunctionStructure.get());
     259    JSCell* objectConstructor = new (exec) ObjectConstructor(exec, ObjectConstructor::createStructure(d()->functionPrototype), d()->objectPrototype, d()->prototypeFunctionStructure.get());
    264260    JSCell* functionConstructor = new (exec) FunctionConstructor(exec, FunctionConstructor::createStructure(d()->functionPrototype), d()->functionPrototype);
    265261    JSCell* arrayConstructor = new (exec) ArrayConstructor(exec, ArrayConstructor::createStructure(d()->functionPrototype), d()->arrayPrototype, d()->prototypeFunctionStructure.get());
     
    275271    RefPtr<Structure> nativeErrorStructure = NativeErrorConstructor::createStructure(d()->functionPrototype);
    276272
    277     d()->objectConstructor = objectConstructor;
    278273    d()->evalErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, evalErrorPrototype);
    279274    d()->rangeErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, rangeErrorPrototype);
     
    374369    if (registerFile.globalObject() == this)
    375370        registerFile.markGlobals(markStack, &globalData()->heap);
    376    
    377     markIfNeeded(markStack, d()->objectConstructor);
     371
    378372    markIfNeeded(markStack, d()->regExpConstructor);
    379373    markIfNeeded(markStack, d()->errorConstructor);
     
    388382    markIfNeeded(markStack, d()->callFunction);
    389383    markIfNeeded(markStack, d()->applyFunction);
    390     markIfNeeded(markStack, d()->objectToStringFunction);
    391     markIfNeeded(markStack, d()->objectToLocaleStringFunction);
    392384
    393385    markIfNeeded(markStack, d()->objectPrototype);
  • trunk/JavaScriptCore/runtime/JSGlobalObject.h

    r47304 r47404  
    3939    class ErrorConstructor;
    4040    class FunctionPrototype;
     41    class GlobalCodeBlock;
    4142    class GlobalEvalFunction;
    4243    class NativeErrorConstructor;
    43     class GlobalCodeBlock;
    44     class ObjectConstructor;
     44    class ProgramCodeBlock;
    4545    class PrototypeFunction;
    4646    class RegExpConstructor;
     
    6262                , registerArraySize(0)
    6363                , globalScopeChain(NoScopeChain())
    64                 , objectConstructor(0)
    6564                , regExpConstructor(0)
    6665                , errorConstructor(0)
     
    7473                , callFunction(0)
    7574                , applyFunction(0)
    76                 , objectToStringFunction(0)
    77                 , objectToLocaleStringFunction(0)
    7875                , objectPrototype(0)
    7976                , functionPrototype(0)
     
    104101            int recursion;
    105102
    106             ObjectConstructor* objectConstructor;
    107103            RegExpConstructor* regExpConstructor;
    108104            ErrorConstructor* errorConstructor;
     
    117113            NativeFunctionWrapper* callFunction;
    118114            NativeFunctionWrapper* applyFunction;
    119             NativeFunctionWrapper* objectToStringFunction;
    120             NativeFunctionWrapper* objectToLocaleStringFunction;
    121115
    122116            ObjectPrototype* objectPrototype;
     
    191185        // replaces the global object's associated property.
    192186
    193         ObjectConstructor* objectConstructor() const { return d()->objectConstructor; }
    194187        RegExpConstructor* regExpConstructor() const { return d()->regExpConstructor; }
    195188
     
    212205        DatePrototype* datePrototype() const { return d()->datePrototype; }
    213206        RegExpPrototype* regExpPrototype() const { return d()->regExpPrototype; }
    214 
    215         NativeFunctionWrapper* objectToStringFunction() const { return d()->objectToStringFunction; }
    216         NativeFunctionWrapper* objectToLocaleStringFunction() const { return d()->objectToLocaleStringFunction; }
    217207
    218208        JSObject* methodCallDummy() const { return d()->methodCallDummy; }
  • trunk/JavaScriptCore/runtime/ObjectPrototype.cpp

    r47292 r47404  
    4141static JSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState*, JSObject*, JSValue, const ArgList&);
    4242
    43 ObjectPrototype::ObjectPrototype(ExecState* exec, PassRefPtr<Structure> stucture, Structure* prototypeFunctionStructure, NativeFunctionWrapper** toStringFunction, NativeFunctionWrapper** toLocaleStringFunction)
     43ObjectPrototype::ObjectPrototype(ExecState* exec, PassRefPtr<Structure> stucture, Structure* prototypeFunctionStructure)
    4444    : JSObject(stucture)
    4545{
    46     NativeFunctionWrapper* toString = new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, objectProtoFuncToString);
    47     NativeFunctionWrapper* toLocaleString = new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString);
    48     *toStringFunction = toString;
    49     *toLocaleStringFunction = toLocaleString;
    50     putDirectFunctionWithoutTransition(exec, toString, DontEnum);
    51     putDirectFunctionWithoutTransition(exec, toLocaleString, DontEnum);
     46    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
     47    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
    5248    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
    5349    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
  • trunk/JavaScriptCore/runtime/ObjectPrototype.h

    r47292 r47404  
    2828    class ObjectPrototype : public JSObject {
    2929    public:
    30         ObjectPrototype(ExecState*, PassRefPtr<Structure>, Structure* prototypeFunctionStructure, NativeFunctionWrapper** toStringFunction, NativeFunctionWrapper** toLocaleStringFunction);
     30        ObjectPrototype(ExecState*, PassRefPtr<Structure>, Structure* prototypeFunctionStructure);
    3131    };
    3232
  • trunk/JavaScriptCore/tests/mozilla/ecma_3/Function/arguments-001.js

    r47292 r47404  
    5050
    5151actual = a instanceof Array;
    52 expect = true;
     52expect = false;
    5353addThis();
    5454
    5555actual = a.length;
    56 expect = 0;
     56expect = undefined;
    5757addThis();
    5858
     
    6666
    6767actual = a instanceof Array;
    68 expect = true;
     68expect = false;
    6969addThis();
    7070
    7171actual = a.length;
    72 expect = 0;
     72expect = undefined;
    7373addThis();
    7474
  • trunk/LayoutTests/ChangeLog

    r47401 r47404  
     12009-08-17  Oliver Hunt  <oliver@apple.com>
     2
     3        RS=Mark Rowe.
     4
     5        REGRESSION (r47291-r47308): MobileMe applications do not load data
     6        https://bugs.webkit.org/show_bug.cgi?id=28341
     7
     8        Reverting r47292
     9
     10        * fast/js/arguments-expected.txt:
     11        * fast/js/resources/arguments.js:
     12
    1132009-08-17  Brian Weinstein  <bweinstein@apple.com>
    214
  • trunk/LayoutTests/fast/js/arguments-expected.txt

    r47292 r47404  
    130130FAIL argumentsConstUndefined() should be undefined. Was [object Arguments]
    131131PASS argumentCalleeInException() is argumentCalleeInException
    132 PASS getArguments() instanceof Object is true
    133 PASS getArguments() instanceof Array is true
    134 PASS getArguments().constructor is Object
    135 PASS Object.getPrototypeOf(getArguments()) is Array.prototype
    136 PASS getArguments().toString is Object.prototype.toString
    137 PASS getArguments().toLocaleString is Object.prototype.toLocaleString
    138 PASS getArguments() instanceof originalObject is true
    139 PASS getArguments() instanceof originalArray is true
    140 PASS getArguments().constructor is originalObject
    141 PASS originalObject.getPrototypeOf(getArguments()) is originalArray.prototype
    142 PASS getArguments().toString is originalObject.prototype.toString
    143 PASS getArguments().toLocaleString is originalObject.prototype.toLocaleString
    144 PASS originalObject.getPrototypeOf(getArguments()) is originalArrayPrototype
    145 PASS getArguments().toString is originalObjectToString
    146 PASS getArguments().toLocaleString is originalObjectToLocaleString
    147132PASS successfullyParsed is true
    148133
  • trunk/LayoutTests/fast/js/resources/arguments.js

    r47292 r47404  
    535535shouldBe("argumentCalleeInException()", "argumentCalleeInException")
    536536
    537 function getArguments() {
    538     return arguments;
    539 }
    540 
    541 shouldBeTrue("getArguments() instanceof Object");
    542 shouldBeTrue("getArguments() instanceof Array");
    543 shouldBe("getArguments().constructor", "Object");
    544 shouldBe("Object.getPrototypeOf(getArguments())", "Array.prototype");
    545 shouldBe("getArguments().toString", "Object.prototype.toString");
    546 shouldBe("getArguments().toLocaleString", "Object.prototype.toLocaleString");
    547 
    548 var originalObject = Object;
    549 Object = function NewObject() {};
    550 var originalArray = Array;
    551 Array = function NewArray() {};
    552 shouldBeTrue("getArguments() instanceof originalObject");
    553 shouldBeTrue("getArguments() instanceof originalArray");
    554 shouldBe("getArguments().constructor", "originalObject");
    555 shouldBe("originalObject.getPrototypeOf(getArguments())", "originalArray.prototype");
    556 shouldBe("getArguments().toString", "originalObject.prototype.toString");
    557 shouldBe("getArguments().toLocaleString", "originalObject.prototype.toLocaleString");
    558 
    559 var originalObjectToString = originalObject.prototype.toString;
    560 originalObject.prototype.toString = function NewObjectPrototypeToString() {};
    561 var originalObjectToLocaleString = originalObject.prototype.toLocaleString;
    562 originalObject.prototype.toLocaleString = function NewObjectPrototypeToLocaleString() {};
    563 var originalArrayPrototype = originalArray.prototype;
    564 Array.prototype = function NewArrayPrototype() {};
    565 shouldBe("originalObject.getPrototypeOf(getArguments())", "originalArrayPrototype");
    566 shouldBe("getArguments().toString", "originalObjectToString");
    567 shouldBe("getArguments().toLocaleString", "originalObjectToLocaleString");
    568 
    569537var successfullyParsed = true;
Note: See TracChangeset for help on using the changeset viewer.