Reviewers: adamk,

Message:
PTAL

Description:
[es6] Function.prototype.name should be the empty string

ES6 specifies the function name property (it was not part of ES5) and
it specifies the name of Function.prototype to the empty string ("" and
not "Empty"). This makes us match Firefox, Safari and IE developer
preview.

BUG=v8:4033
LOG=N
[email protected]
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_chromium_rel_ng;tryserver.blink:linux_blink_rel


Please review this at https://codereview.chromium.org/1080393004/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+17, -9 lines):
  M src/bootstrapper.cc
  M test/mjsunit/es6/function-name-configurable.js
  A test/mjsunit/es6/function-prototype-name.js


Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index cb9bdfaf4ef26689ea17361175c719043d9be659..62b455f3dad80ed31b9f439a1d3cb76ebf8ead0a 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -501,13 +501,10 @@ Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
         .Assert();
   }

-  // Allocate the empty function as the prototype for function ECMAScript
-  // 262 15.3.4.
-  Handle<String> empty_string =
-      factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty"));
+  // Allocate the empty function as the prototype for function - ES6 19.2.3
Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction));
-  Handle<JSFunction> empty_function = factory->NewFunctionWithoutPrototype(
-      empty_string, code);
+  Handle<JSFunction> empty_function =
+      factory->NewFunctionWithoutPrototype(factory->empty_string(), code);

   // Allocate the function map first and then patch the prototype later
   Handle<Map> empty_function_map =
Index: test/mjsunit/es6/function-name-configurable.js
diff --git a/test/mjsunit/es6/function-name-configurable.js b/test/mjsunit/es6/function-name-configurable.js index f0ff406da86d0f0c39648ba4785eeede43c47cf0..68ba82d705d25e50dd98170e7c476977f79d6422 100644
--- a/test/mjsunit/es6/function-name-configurable.js
+++ b/test/mjsunit/es6/function-name-configurable.js
@@ -90,10 +90,10 @@ test(testFunctionToString);

   function f() {}
   delete f.name;
-  assertEquals('Empty', f.name);
+  assertEquals('', f.name);

   f.name = 42;
-  assertEquals('Empty', f.name);  // non writable prototype property.
+  assertEquals('', f.name);  // non writable prototype property.
   assertFalse(f.hasOwnProperty('name'));

   Object.defineProperty(Function.prototype, 'name', {writable: true});
@@ -108,7 +108,7 @@ test(testFunctionToString);
   function f() {}
   assertTrue(delete f.name);
   assertFalse(f.hasOwnProperty('name'));
-  assertEquals('Empty', f.name);
+  assertEquals('', f.name);

   assertTrue(delete Function.prototype.name);
   assertEquals(undefined, f.name);
Index: test/mjsunit/es6/function-prototype-name.js
diff --git a/test/mjsunit/es6/function-prototype-name.js b/test/mjsunit/es6/function-prototype-name.js
new file mode 100644
index 0000000000000000000000000000000000000000..4766bd42eb1809e17d16791c732b7ab617a29bae
--- /dev/null
+++ b/test/mjsunit/es6/function-prototype-name.js
@@ -0,0 +1,11 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+assertSame('', Function.prototype.name);
+
+var descr = Object.getOwnPropertyDescriptor(Function.prototype, 'name');
+assertFalse(descr.enumerable);
+assertTrue(descr.configurable);
+assertFalse(descr.writable);
+assertSame('', descr.value);


--
--
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/d/optout.

Reply via email to