Ignore:
Timestamp:
Feb 20, 2012, 1:14:48 PM (13 years ago)
Author:
[email protected]
Message:

Move special proto property to Object.prototype
https://bugs.webkit.org/show_bug.cgi?id=78409

Reviewed by Oliver Hunt.

Re-implement this as a regular accessor property. This has three key benefits:
1) It makes it possible for objects to be given properties named proto.
2) Object.prototype.proto can be deleted, preventing object prototypes from being changed.
3) This largely removes the magic used the implement proto, it can just be made a regular accessor property.

Source/JavaScriptCore:

  • parser/Parser.cpp:

(JSC::::parseFunctionInfo):

  • No need to prohibit functions named proto.
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::reset):

  • Add proto accessor to Object.prototype.
  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncProtoGetter):
(JSC::globalFuncProtoSetter):

  • Definition of the proto accessor functions.
  • runtime/JSGlobalObjectFunctions.h:
    • Declaration of the proto accessor functions.
  • runtime/JSObject.cpp:

(JSC::JSObject::put):

  • Remove the special handling for proto, there is still a check to allow for a fast guard for accessors excluding proto.

(JSC::JSObject::putDirectAccessor):

  • Track on the structure whether an object contains accessors other than one for proto.

(JSC::JSObject::defineOwnProperty):

  • No need to prohibit definition of own properties named proto.
  • runtime/JSObject.h:

(JSC::JSObject::inlineGetOwnPropertySlot):

  • Remove the special handling for proto.

(JSC::JSValue::get):

  • Remove the special handling for proto.
  • runtime/JSString.cpp:

(JSC::JSString::getOwnPropertySlot):

  • Remove the special handling for proto.
  • runtime/JSValue.h:

(JSValue):

  • Made synthesizePrototype public (this may be needed by the proto getter).
  • runtime/ObjectConstructor.cpp:

(JSC::objectConstructorGetPrototypeOf):

  • Perform the security check & call prototype() directly.
  • runtime/Structure.cpp:

(JSC::Structure::Structure):

  • Added 'ExcludingProto' variant of the 'hasGetterSetterProperties' state.
  • runtime/Structure.h:

(JSC::Structure::hasGetterSetterPropertiesExcludingProto):
(JSC::Structure::setHasGetterSetterProperties):
(Structure):

  • Added 'ExcludingProto' variant of the 'hasGetterSetterProperties' state.

Source/WebCore:

  • bindings/js/JSDOMWindowBase.cpp:

(WebCore::JSDOMWindowBase::allowsAccessFrom):
(WebCore):

  • expose allowsAccessFrom check to JSC.
  • bindings/js/JSDOMWindowBase.h:

(JSDOMWindowBase):

  • expose allowsAccessFrom check to JSC.

LayoutTests:

  • fast/js/Object-getOwnPropertyNames-expected.txt:
  • fast/js/cyclic-prototypes-expected.txt:
  • fast/js/parser-syntax-check-expected.txt:
  • fast/js/preventExtensions-expected.txt:
  • fast/js/prototypes-expected.txt:
    • Update results
  • fast/js/script-tests/Object-getOwnPropertyNames.js:
    • proto is now a property of Object Prototype.
  • fast/js/script-tests/cyclic-prototypes.js:
    • setting an object's prototype to null removes proto setter, future usage won't set prototype.
  • fast/js/script-tests/parser-syntax-check.js:
    • Allow functions named proto
  • fast/js/script-tests/preventExtensions.js:
    • Setting proto should not throw.
  • fast/js/script-tests/prototypes.js:
    • Objects may contained own properties named proto, add new test cases.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.cpp

    r107860 r108259  
    141141    // machineCaller -> The caller according to the machine, which may be zero or
    142142    //    more frames above the true caller due to inlining.
    143    
     143
    144144    // Am I an inline call frame? If so, we're done.
    145     if (isInlineCallFrame())
    146         return callerFrame();
     145    if (isInlineCallFrame() || !hasReturnPC())
     146        return callerFrame()->removeHostCallFrameFlag();
    147147   
    148148    // I am a machine call frame, so the question is: is my caller a machine call frame
     
    155155    // Figure out how we want to get the current code location.
    156156    if (hasHostCallFrameFlag() || returnAddressIsInCtiTrampoline(returnPC()))
    157         return machineCaller->trueCallFrameFromVMCode();
     157        return machineCaller->trueCallFrameFromVMCode()->removeHostCallFrameFlag();
    158158   
    159     return machineCaller->trueCallFrame(returnPC());
     159    return machineCaller->trueCallFrame(returnPC())->removeHostCallFrameFlag();
    160160}
    161161#endif
Note: See TracChangeset for help on using the changeset viewer.