Revision: 18687
Author:   [email protected]
Date:     Mon Jan 20 10:59:07 2014 UTC
Log:      Revert "ES6: Implement Object.setPrototypeOf"

This reverts commit r18685 for breaking WebKit tests.

[email protected]
http://code.google.com/p/v8/source/detail?r=18687

Deleted:
 /branches/bleeding_edge/test/mjsunit/set-prototype-of.js
Modified:
 /branches/bleeding_edge/src/macros.py
 /branches/bleeding_edge/src/messages.js
 /branches/bleeding_edge/src/string.js
 /branches/bleeding_edge/src/v8natives.js

=======================================
--- /branches/bleeding_edge/test/mjsunit/set-prototype-of.js Mon Jan 20 10:38:01 2014 UTC
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-//       notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-//       copyright notice, this list of conditions and the following
-//       disclaimer in the documentation and/or other materials provided
-//       with the distribution.
-//     * Neither the name of Google Inc. nor the names of its
-//       contributors may be used to endorse or promote products derived
-//       from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Flags: --harmony-symbols
-
-
-function getObjects() {
-  function func() {}
-  return [
-    func,
-    new func(),
-    {x: 5},
-    /regexp/,
-    ['array'],
-    // new Error(),
-    new Date(),
-    new Number(1),
-    new Boolean(true),
-    new String('str'),
-    Object(Symbol())
-  ];
-}
-
-
-var coercibleValues = [
-  1,
-  true,
-  'string',
-  Symbol()
-];
-
-
-var nonCoercibleValues = [
-  undefined,
-  null
-];
-
-
-var valuesWithoutNull = coercibleValues.concat(undefined);
-
-
-function TestSetPrototypeOfCoercibleValues() {
-  for (var i = 0; i < coercibleValues.length; i++) {
-    var value = coercibleValues[i];
-    assertThrows(function() {
-      Object.getPrototypeOf(value);
-    }, TypeError);
-
-    assertEquals(Object.setPrototypeOf(value, {}), value);
-
-    assertThrows(function() {
-      Object.getPrototypeOf(value);
-    }, TypeError);
-  }
-}
-TestSetPrototypeOfCoercibleValues();
-
-
-function TestSetPrototypeOfNonCoercibleValues() {
-  for (var i = 0; i < nonCoercibleValues.length; i++) {
-    var value = nonCoercibleValues[i];
-    assertThrows(function() {
-      Object.setPrototypeOf(value, {});
-    }, TypeError);
-  }
-}
-TestSetPrototypeOfNonCoercibleValues();
-
-
-function TestSetPrototypeToNonObject(proto) {
-  var objects = getObjects();
-  for (var i = 0; i < objects.length; i++) {
-    var object = objects[i];
-    for (var j = 0; j < valuesWithoutNull.length; j++) {
-      var proto = valuesWithoutNull[j];
-      assertThrows(function() {
-        Object.setPrototypeOf(object, proto);
-      }, TypeError);
-    }
-  }
-}
-TestSetPrototypeToNonObject();
-
-
-function TestSetPrototypeOf(object, proto) {
-  assertEquals(Object.setPrototypeOf(object, proto), object);
-  assertEquals(Object.getPrototypeOf(object), proto);
-}
-
-
-function TestSetPrototypeOfForObjects() {
-  var objects1 = getObjects();
-  var objects2 = getObjects();
-  for (var i = 0; i < objects1.length; i++) {
-    for (var j = 0; j < objects2.length; j++) {
-      TestSetPrototypeOf(objects1[i], objects2[j]);
-    }
-  }
-}
-TestSetPrototypeOfForObjects();
-
-
-function TestSetPrototypeToNull() {
-  var objects = getObjects();
-  for (var i = 0; i < objects.length; i++) {
-    TestSetPrototypeOf(objects[i], null);
-  }
-}
-TestSetPrototypeToNull();
-
-
-function TestSetPrototypeOfNonExtensibleObject() {
-  var objects = getObjects();
-  var proto = {};
-  for (var i = 0; i < objects.length; i++) {
-    var object = objects[i];
-    Object.preventExtensions(object);
-    assertThrows(function() {
-      Object.setPrototypeOf(object, proto);
-    }, TypeError);
-  }
-}
-TestSetPrototypeOfNonExtensibleObject();
-
-
-function TestLookup() {
-  var object = {};
-  assertFalse('x' in object);
-  assertFalse('y' in object);
-
-  var oldProto = {
-    x: 'old x',
-    y: 'old y'
-  };
-  Object.setPrototypeOf(object, oldProto);
-  assertEquals(object.x, 'old x');
-  assertEquals(object.y, 'old y');
-
-  var newProto = {
-    x: 'new x'
-  };
-  Object.setPrototypeOf(object, newProto);
-  assertEquals(object.x, 'new x');
-  assertFalse('y' in object);
-}
-TestLookup();
=======================================
--- /branches/bleeding_edge/src/macros.py       Mon Jan 20 10:38:01 2014 UTC
+++ /branches/bleeding_edge/src/macros.py       Mon Jan 20 10:59:07 2014 UTC
@@ -139,10 +139,6 @@
 # we cannot handle those anyway.
 macro IS_SPEC_FUNCTION(arg) = (%_ClassOf(arg) === 'Function');

-# Macro for ES6 CheckObjectCoercible
-# Will throw a TypeError of the form "[functionName] called on null or undefined". -macro CHECK_OBJECT_COERCIBLE(arg, functionName) = if (IS_NULL_OR_UNDEFINED(arg) && !IS_UNDETECTABLE(arg)) throw MakeTypeError('called_on_null_or_undefined', [functionName]);
-
# Indices in bound function info retrieved by %BoundFunctionGetBindings(...).
 const kBoundFunctionIndex = 0;
 const kBoundThisIndex = 1;
=======================================
--- /branches/bleeding_edge/src/messages.js     Mon Jan 20 10:38:01 2014 UTC
+++ /branches/bleeding_edge/src/messages.js     Mon Jan 20 10:59:07 2014 UTC
@@ -78,7 +78,7 @@
   getter_must_be_callable:       ["Getter must be a function: ", "%0"],
   setter_must_be_callable:       ["Setter must be a function: ", "%0"],
value_and_accessor: ["Invalid property. A property cannot both have accessors and be writable or have a value, ", "%0"], - proto_object_or_null: ["Object prototype may only be an Object or null: ", "%0"], + proto_object_or_null: ["Object prototype may only be an Object or null"], property_desc_object: ["Property description must be an object: ", "%0"],
   redefine_disallowed:           ["Cannot redefine property: ", "%0"],
define_disallowed: ["Cannot define property:", "%0", ", object is not extensible."],
=======================================
--- /branches/bleeding_edge/src/string.js       Mon Jan 20 10:38:01 2014 UTC
+++ /branches/bleeding_edge/src/string.js       Mon Jan 20 10:59:07 2014 UTC
@@ -61,8 +61,10 @@

 // ECMA-262, section 15.5.4.4
 function StringCharAt(pos) {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.charAt");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.charAt"]);
+  }
   var result = %_StringCharAt(this, pos);
   if (%_IsSmi(result)) {
     result = %_StringCharAt(TO_STRING_INLINE(this), TO_INTEGER(pos));
@@ -73,8 +75,10 @@

 // ECMA-262 section 15.5.4.5
 function StringCharCodeAt(pos) {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.charCodeAt");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.charCodeAt"]);
+  }
   var result = %_StringCharCodeAt(this, pos);
   if (!%_IsSmi(result)) {
     result = %_StringCharCodeAt(TO_STRING_INLINE(this), TO_INTEGER(pos));
@@ -85,8 +89,10 @@

 // ECMA-262, section 15.5.4.6
 function StringConcat() {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.concat");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.concat"]);
+  }
   var len = %_ArgumentsLength();
   var this_as_string = TO_STRING_INLINE(this);
   if (len === 1) {
@@ -107,8 +113,10 @@

 // ECMA-262 section 15.5.4.7
 function StringIndexOf(pattern /* position */) {  // length == 1
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.indexOf");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.indexOf"]);
+  }
   var subject = TO_STRING_INLINE(this);
   pattern = TO_STRING_INLINE(pattern);
   var index = 0;
@@ -124,8 +132,10 @@

 // ECMA-262 section 15.5.4.8
 function StringLastIndexOf(pat /* position */) {  // length == 1
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.lastIndexOf");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.lastIndexOf"]);
+  }
   var sub = TO_STRING_INLINE(this);
   var subLength = sub.length;
   var pat = TO_STRING_INLINE(pat);
@@ -155,8 +165,10 @@
 // This function is implementation specific.  For now, we do not
 // do anything locale specific.
 function StringLocaleCompare(other) {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.localeCompare");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.localeCompare"]);
+  }
   return %StringLocaleCompare(TO_STRING_INLINE(this),
                               TO_STRING_INLINE(other));
 }
@@ -164,8 +176,10 @@

 // ECMA-262 section 15.5.4.10
 function StringMatch(regexp) {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.match");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.match"]);
+  }
   var subject = TO_STRING_INLINE(this);
   if (IS_REGEXP(regexp)) {
     // Emulate RegExp.prototype.exec's side effect in step 5, even though
@@ -196,8 +210,10 @@

 // ECMA-262, section 15.5.4.11
 function StringReplace(search, replace) {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.replace");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.replace"]);
+  }
   var subject = TO_STRING_INLINE(this);

   // Decision tree for dispatch
@@ -527,8 +543,10 @@

 // ECMA-262 section 15.5.4.12
 function StringSearch(re) {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.search");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.search"]);
+  }
   var regexp;
   if (IS_STRING(re)) {
     regexp = %_GetFromCache(STRING_TO_REGEXP_CACHE_ID, re);
@@ -547,8 +565,10 @@

 // ECMA-262 section 15.5.4.13
 function StringSlice(start, end) {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.slice");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.slice"]);
+  }
   var s = TO_STRING_INLINE(this);
   var s_len = s.length;
   var start_i = TO_INTEGER(start);
@@ -589,8 +609,10 @@

 // ECMA-262 section 15.5.4.14
 function StringSplit(separator, limit) {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.split");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.split"]);
+  }
   var subject = TO_STRING_INLINE(this);
   limit = (IS_UNDEFINED(limit)) ? 0xffffffff : TO_UINT32(limit);

@@ -687,8 +709,10 @@

 // ECMA-262 section 15.5.4.15
 function StringSubstring(start, end) {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.subString");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.subString"]);
+  }
   var s = TO_STRING_INLINE(this);
   var s_len = s.length;

@@ -720,8 +744,10 @@

 // This is not a part of ECMA-262.
 function StringSubstr(start, n) {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.substr");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.substr"]);
+  }
   var s = TO_STRING_INLINE(this);
   var len;

@@ -760,51 +786,65 @@

 // ECMA-262, 15.5.4.16
 function StringToLowerCase() {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.toLowerCase"]);
+  }
   return %StringToLowerCase(TO_STRING_INLINE(this));
 }


 // ECMA-262, 15.5.4.17
 function StringToLocaleLowerCase() {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleLowerCase");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.toLocaleLowerCase"]);
+  }
   return %StringToLowerCase(TO_STRING_INLINE(this));
 }


 // ECMA-262, 15.5.4.18
 function StringToUpperCase() {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.toUpperCase");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.toUpperCase"]);
+  }
   return %StringToUpperCase(TO_STRING_INLINE(this));
 }


 // ECMA-262, 15.5.4.19
 function StringToLocaleUpperCase() {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleUpperCase");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.toLocaleUpperCase"]);
+  }
   return %StringToUpperCase(TO_STRING_INLINE(this));
 }

 // ES5, 15.5.4.20
 function StringTrim() {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.trim");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.trim"]);
+  }
   return %StringTrim(TO_STRING_INLINE(this), true, true);
 }

 function StringTrimLeft() {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.trimLeft");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.trimLeft"]);
+  }
   return %StringTrim(TO_STRING_INLINE(this), true, false);
 }

 function StringTrimRight() {
-  CHECK_OBJECT_COERCIBLE(this, "String.prototype.trimRight");
-
+  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
+    throw MakeTypeError("called_on_null_or_undefined",
+                        ["String.prototype.trimRight"]);
+  }
   return %StringTrim(TO_STRING_INLINE(this), false, true);
 }

=======================================
--- /branches/bleeding_edge/src/v8natives.js    Mon Jan 20 10:38:01 2014 UTC
+++ /branches/bleeding_edge/src/v8natives.js    Mon Jan 20 10:59:07 2014 UTC
@@ -1015,21 +1015,6 @@
   return %GetPrototype(obj);
 }

-// ES6 section 19.1.2.19.
-function ObjectSetPrototypeOf(obj, proto) {
-  CHECK_OBJECT_COERCIBLE(obj, "Object.setPrototypeOf");
-
-  if (proto !== null && !IS_SPEC_OBJECT(proto)) {
-    throw MakeTypeError("proto_object_or_null", [proto]);
-  }
-
-  if (IS_SPEC_OBJECT(obj)) {
-    %SetPrototype(obj, proto);
-  }
-
-  return obj;
-}
-

 // ES5 section 15.2.3.3
 function ObjectGetOwnPropertyDescriptor(obj, p) {
@@ -1458,7 +1443,6 @@
     "defineProperties", ObjectDefineProperties,
     "freeze", ObjectFreeze,
     "getPrototypeOf", ObjectGetPrototypeOf,
-    "setPrototypeOf", ObjectSetPrototypeOf,
     "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor,
     "getOwnPropertyNames", ObjectGetOwnPropertyNames,
     // getOwnPropertySymbols is added in symbol.js.

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to