From d0db1c39cab264339ed32ea63912b7e814a24993 Mon Sep 17 00:00:00 2001 From: arv Date: Wed, 22 Apr 2015 17:29:40 -0700 Subject: [PATCH] [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 R=adamk@chromium.org CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_chromium_rel_ng;tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1080393004 Cr-Commit-Position: refs/heads/master@{#28021} --- src/bootstrapper.cc | 9 +++------ test/mjsunit/es6/function-name-configurable.js | 6 +++--- test/mjsunit/es6/function-prototype-name.js | 11 +++++++++++ 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 test/mjsunit/es6/function-prototype-name.js diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 1a5bfcf..1fbbcb9 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -501,13 +501,10 @@ Handle Genesis::CreateEmptyFunction(Isolate* isolate) { .Assert(); } - // Allocate the empty function as the prototype for function ECMAScript - // 262 15.3.4. - Handle empty_string = - factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty")); + // Allocate the empty function as the prototype for function - ES6 19.2.3 Handle code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); - Handle empty_function = factory->NewFunctionWithoutPrototype( - empty_string, code); + Handle empty_function = + factory->NewFunctionWithoutPrototype(factory->empty_string(), code); // Allocate the function map first and then patch the prototype later Handle empty_function_map = diff --git a/test/mjsunit/es6/function-name-configurable.js b/test/mjsunit/es6/function-name-configurable.js index f0ff406..68ba82d 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); diff --git a/test/mjsunit/es6/function-prototype-name.js b/test/mjsunit/es6/function-prototype-name.js new file mode 100644 index 0000000..4766bd4 --- /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); -- 2.7.4