Changeset 107498

02/11/12 18:47:50 (3 years ago)

Move special proto property to Object.prototype

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.


  • parser/Parser.cpp:


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


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


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


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


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


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


  • Remove the special handling for proto.


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


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


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


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


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


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


  • bindings/js/JSDOMWindowBase.cpp:


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


  • expose allowsAccessFrom check to JSC.


  • 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.
29 edited

Note: See TracChangeset for help on using the changeset viewer.