Chromium Code Reviews| Index: src/v8natives.js |
| diff --git a/src/v8natives.js b/src/v8natives.js |
| index d9dc09651e65d7654ef1ee2e9193dc8a2d47f38b..adabbc24f8130a77e272ac4527729d387677945c 100644 |
| --- a/src/v8natives.js |
| +++ b/src/v8natives.js |
| @@ -61,7 +61,7 @@ function InstallFunctions(object, attributes, functions) { |
| } |
| -// Helper function to install a getter only property. |
| +// Helper function to install a getter-only accessor property. |
| function InstallGetter(object, name, getter) { |
| %FunctionSetName(getter, name); |
| %FunctionRemovePrototype(getter); |
| @@ -70,6 +70,18 @@ function InstallGetter(object, name, getter) { |
| } |
| +// Helper function to install a getter/setter accessor property. |
| +function InstallGetterSetter(object, name, getter, setter) { |
| + %FunctionSetName(getter, name); |
| + %FunctionSetName(setter, name); |
| + %FunctionRemovePrototype(getter); |
| + %FunctionRemovePrototype(setter); |
| + %DefineOrRedefineAccessorProperty(object, name, getter, setter, DONT_ENUM); |
| + %SetNativeFlag(getter); |
| + %SetNativeFlag(setter); |
| +} |
| + |
| + |
| // Prevents changes to the prototype of a built-in function. |
| // The "prototype" property of the function object is made non-configurable, |
| // and the prototype object is made non-extensible. The latter prevents |
| @@ -394,8 +406,10 @@ function FromPropertyDescriptor(desc) { |
| configurable: desc.isConfigurable() }; |
| } |
| // Must be an AccessorDescriptor then. We never return a generic descriptor. |
| - return { get: desc.getGet(), |
| - set: desc.getSet(), |
| + return { get: desc.getGet() === ObjectGetProto ? ObjectPoisonProto |
|
rossberg
2013/04/04 09:58:43
I don't think there is a need (or the intention) t
Michael Starzinger
2013/04/04 11:52:19
Done.
|
| + : desc.getGet(), |
| + set: desc.getSet() === ObjectSetProto ? ObjectPoisonProto |
| + : desc.getSet(), |
| enumerable: desc.isEnumerable(), |
| configurable: desc.isConfigurable() }; |
| } |
| @@ -1326,6 +1340,24 @@ function ObjectIs(obj1, obj2) { |
| } |
| +// Harmony __proto__ getter. |
| +function ObjectGetProto() { |
| + return %GetPrototype(this); |
| +} |
| + |
| + |
| +// Harmony __proto__ setter. |
| +function ObjectSetProto(obj) { |
| + return %SetPrototype(this, obj); |
| +} |
| + |
| + |
| +// Harmony __proto__ poison pill. |
| +function ObjectPoisonProto() { |
| + throw MakeTypeError("proto_poison_pill", []); |
| +} |
| + |
| + |
| %SetCode($Object, function(x) { |
| if (%_IsConstructCall()) { |
| if (x == null) return this; |
| @@ -1336,14 +1368,18 @@ function ObjectIs(obj1, obj2) { |
| } |
| }); |
| -%SetExpectedNumberOfProperties($Object, 4); |
| // ---------------------------------------------------------------------------- |
| // Object |
| function SetUpObject() { |
| %CheckIsBootstrapping(); |
| - // Set Up non-enumerable functions on the Object.prototype object. |
| + |
| + %FunctionSetName(ObjectPoisonProto, "__proto__"); |
| + %FunctionRemovePrototype(ObjectPoisonProto); |
| + %SetExpectedNumberOfProperties($Object, 4); |
| + |
| + // Set up non-enumerable functions on the Object.prototype object. |
| InstallFunctions($Object.prototype, DONT_ENUM, $Array( |
| "toString", ObjectToString, |
| "toLocaleString", ObjectToLocaleString, |
| @@ -1356,6 +1392,10 @@ function SetUpObject() { |
| "__defineSetter__", ObjectDefineSetter, |
| "__lookupSetter__", ObjectLookupSetter |
| )); |
| + InstallGetterSetter($Object.prototype, "__proto__", |
| + ObjectGetProto, ObjectSetProto); |
| + |
| + // Set up non-enumerable functions in the Object object. |
| InstallFunctions($Object, DONT_ENUM, $Array( |
| "keys", ObjectKeys, |
| "create", ObjectCreate, |