Index: src/v8natives.js |
diff --git a/src/v8natives.js b/src/v8natives.js |
index d9dc09651e65d7654ef1ee2e9193dc8a2d47f38b..5f870c8208f7c2add547a7d5ab378e11498958e8 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 |
@@ -395,7 +407,8 @@ function FromPropertyDescriptor(desc) { |
} |
// Must be an AccessorDescriptor then. We never return a generic descriptor. |
return { get: desc.getGet(), |
- set: desc.getSet(), |
+ set: desc.getSet() === ObjectSetProto ? ObjectPoisonProto |
+ : desc.getSet(), |
enumerable: desc.isEnumerable(), |
configurable: desc.isConfigurable() }; |
} |
@@ -1326,6 +1339,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(obj) { |
+ throw MakeTypeError("proto_poison_pill", []); |
+} |
+ |
+ |
%SetCode($Object, function(x) { |
if (%_IsConstructCall()) { |
if (x == null) return this; |
@@ -1336,14 +1367,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 +1391,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, |