Commit edeaab7d authored by adamk's avatar adamk Committed by Commit bot

Ship ES2015 Function.name reform

BUG=v8:3699, chromium:588803
LOG=y
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_chromium_rel_ng;tryserver.blink:linux_blink_rel

Review URL: https://codereview.chromium.org/1749353004

Cr-Commit-Position: refs/heads/master@{#34474}
parent 53a393b5
...@@ -218,7 +218,6 @@ DEFINE_IMPLICATION(es_staging, harmony_tailcalls) ...@@ -218,7 +218,6 @@ DEFINE_IMPLICATION(es_staging, harmony_tailcalls)
// Features that are complete (but still behind --harmony/es-staging flag). // Features that are complete (but still behind --harmony/es-staging flag).
#define HARMONY_STAGED(V) \ #define HARMONY_STAGED(V) \
V(harmony_function_name, "harmony Function name inference") \
V(harmony_regexp_lookbehind, "harmony regexp lookbehind") \ V(harmony_regexp_lookbehind, "harmony regexp lookbehind") \
V(harmony_instanceof, "harmony instanceof support") \ V(harmony_instanceof, "harmony instanceof support") \
V(harmony_object_values_entries, "harmony Object.values / Object.entries") \ V(harmony_object_values_entries, "harmony Object.values / Object.entries") \
...@@ -230,6 +229,7 @@ DEFINE_IMPLICATION(es_staging, harmony_tailcalls) ...@@ -230,6 +229,7 @@ DEFINE_IMPLICATION(es_staging, harmony_tailcalls)
V(harmony_default_parameters, "harmony default parameters") \ V(harmony_default_parameters, "harmony default parameters") \
V(harmony_destructuring_assignment, "harmony destructuring assignment") \ V(harmony_destructuring_assignment, "harmony destructuring assignment") \
V(harmony_destructuring_bind, "harmony destructuring bind") \ V(harmony_destructuring_bind, "harmony destructuring bind") \
V(harmony_function_name, "harmony Function name inference") \
V(harmony_iterator_close, "harmony iterator finalization") \ V(harmony_iterator_close, "harmony iterator finalization") \
V(harmony_tostring, "harmony toString") \ V(harmony_tostring, "harmony toString") \
V(harmony_regexps, "harmony regular expression extensions") \ V(harmony_regexps, "harmony regular expression extensions") \
......
...@@ -13521,7 +13521,7 @@ THREADED_TEST(ObjectGetConstructorName) { ...@@ -13521,7 +13521,7 @@ THREADED_TEST(ObjectGetConstructorName) {
"function Child() {};" "function Child() {};"
"Child.prototype = new Parent();" "Child.prototype = new Parent();"
"Child.prototype.constructor = Child;" "Child.prototype.constructor = Child;"
"var outer = { inner: function() { } };" "var outer = { inner: (0, function() { }) };"
"var p = new Parent();" "var p = new Parent();"
"var c = new Child();" "var c = new Child();"
"var x = new outer.inner();" "var x = new outer.inner();"
...@@ -18377,6 +18377,7 @@ THREADED_TEST(FunctionGetInferredName) { ...@@ -18377,6 +18377,7 @@ THREADED_TEST(FunctionGetInferredName) {
THREADED_TEST(FunctionGetDebugName) { THREADED_TEST(FunctionGetDebugName) {
i::FLAG_harmony_function_name = true;
LocalContext env; LocalContext env;
v8::HandleScope scope(env->GetIsolate()); v8::HandleScope scope(env->GetIsolate());
const char* code = const char* code =
...@@ -18420,7 +18421,8 @@ THREADED_TEST(FunctionGetDebugName) { ...@@ -18420,7 +18421,8 @@ THREADED_TEST(FunctionGetDebugName) {
"Object.defineProperty(i, 'name', { value: 'function.name' });" "Object.defineProperty(i, 'name', { value: 'function.name' });"
"var j = function() {};" "var j = function() {};"
"Object.defineProperty(j, 'name', { value: 'function.name' });" "Object.defineProperty(j, 'name', { value: 'function.name' });"
"var foo = { bar : { baz : function() {}}}; var k = foo.bar.baz;"; "var foo = { bar : { baz : (0, function() {})}}; var k = foo.bar.baz;"
"var foo = { bar : { baz : function() {} }}; var l = foo.bar.baz;";
v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str("test")); v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str("test"));
v8::Script::Compile(env.local(), v8_str(code), &origin) v8::Script::Compile(env.local(), v8_str(code), &origin)
.ToLocalChecked() .ToLocalChecked()
...@@ -18439,7 +18441,8 @@ THREADED_TEST(FunctionGetDebugName) { ...@@ -18439,7 +18441,8 @@ THREADED_TEST(FunctionGetDebugName) {
"h", "displayName", "h", "displayName",
"i", "function.name", "i", "function.name",
"j", "function.name", "j", "function.name",
"k", "foo.bar.baz"}; "k", "foo.bar.baz",
"l", "baz"};
for (size_t i = 0; i < sizeof(functions) / sizeof(functions[0]) / 2; ++i) { for (size_t i = 0; i < sizeof(functions) / sizeof(functions[0]) / 2; ++i) {
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
env->Global() env->Global()
......
...@@ -32,9 +32,9 @@ function f(x, y) { ...@@ -32,9 +32,9 @@ function f(x, y) {
a=1; a=1;
}; };
var m = function() { var m = (0, function() {
new f(1); new f(1);
}; });
function g() { function g() {
m(); m();
......
...@@ -96,21 +96,21 @@ var d = { ...@@ -96,21 +96,21 @@ var d = {
}; };
function testGetter1_1() { function testGetter1_1() {
expected_function_name = 'getter1'; expected_function_name = 'get getter1';
expected_source_line_text = ' return this.name; // getter 1'; expected_source_line_text = ' return this.name; // getter 1';
debugger; debugger;
var x = c.getter1; var x = c.getter1;
} }
function testGetter1_2() { function testGetter1_2() {
expected_function_name = 'getter1'; expected_function_name = 'get getter1';
expected_source_line_text = ' return this.name; // getter 1'; expected_source_line_text = ' return this.name; // getter 1';
debugger; debugger;
var x = c['getter1']; var x = c['getter1'];
} }
function testGetter1_3() { function testGetter1_3() {
expected_function_name = 'getter1'; expected_function_name = 'get getter1';
expected_source_line_text = ' return this.name; // getter 1'; expected_source_line_text = ' return this.name; // getter 1';
for (var i = 1; i < 2; i++) { for (var i = 1; i < 2; i++) {
debugger; debugger;
...@@ -119,14 +119,14 @@ function testGetter1_3() { ...@@ -119,14 +119,14 @@ function testGetter1_3() {
} }
function testGetter1_4() { function testGetter1_4() {
expected_function_name = 'getter1'; expected_function_name = 'get getter1';
expected_source_line_text = ' return this.name; // getter 1'; expected_source_line_text = ' return this.name; // getter 1';
debugger; debugger;
var x = d.c.getter1; var x = d.c.getter1;
} }
function testGetter1_5() { function testGetter1_5() {
expected_function_name = 'getter1'; expected_function_name = 'get getter1';
expected_source_line_text = ' return this.name; // getter 1'; expected_source_line_text = ' return this.name; // getter 1';
for (var i = 2; i != 1; i--); for (var i = 2; i != 1; i--);
debugger; debugger;
...@@ -134,7 +134,7 @@ function testGetter1_5() { ...@@ -134,7 +134,7 @@ function testGetter1_5() {
} }
function testGetter2_1() { function testGetter2_1() {
expected_function_name = 'getter2'; expected_function_name = 'get getter2';
expected_source_line_text = ' return { // getter 2'; expected_source_line_text = ' return { // getter 2';
for (var i = 2; i != 1; i--); for (var i = 2; i != 1; i--);
debugger; debugger;
...@@ -172,21 +172,21 @@ function testIndexedSetter3_1() { ...@@ -172,21 +172,21 @@ function testIndexedSetter3_1() {
} }
function testSetter1_1() { function testSetter1_1() {
expected_function_name = 'setter1'; expected_function_name = 'set setter1';
expected_source_line_text = ' this.name = n; // setter 1'; expected_source_line_text = ' this.name = n; // setter 1';
debugger; debugger;
d.c.setter1 = 'aa'; d.c.setter1 = 'aa';
} }
function testSetter1_2() { function testSetter1_2() {
expected_function_name = 'setter1'; expected_function_name = 'set setter1';
expected_source_line_text = ' this.name = n; // setter 1'; expected_source_line_text = ' this.name = n; // setter 1';
debugger; debugger;
d.c['setter1'] = 'bb'; d.c['setter1'] = 'bb';
} }
function testSetter1_3() { function testSetter1_3() {
expected_function_name = 'setter1'; expected_function_name = 'set setter1';
expected_source_line_text = ' this.name = n; // setter 1'; expected_source_line_text = ' this.name = n; // setter 1';
for (var i = 2; i != 1; i--); for (var i = 2; i != 1; i--);
debugger; debugger;
...@@ -199,14 +199,14 @@ var e = { ...@@ -199,14 +199,14 @@ var e = {
e.__proto__ = c; e.__proto__ = c;
function testProtoGetter1_1() { function testProtoGetter1_1() {
expected_function_name = 'getter1'; expected_function_name = 'get getter1';
expected_source_line_text = ' return this.name; // getter 1'; expected_source_line_text = ' return this.name; // getter 1';
debugger; debugger;
var x = e.getter1; var x = e.getter1;
} }
function testProtoSetter1_1() { function testProtoSetter1_1() {
expected_function_name = 'setter1'; expected_function_name = 'set setter1';
expected_source_line_text = ' this.name = n; // setter 1'; expected_source_line_text = ' this.name = n; // setter 1';
debugger; debugger;
e.setter1 = 'aa'; e.setter1 = 'aa';
...@@ -227,7 +227,7 @@ function testProtoIndexedSetter3_1() { ...@@ -227,7 +227,7 @@ function testProtoIndexedSetter3_1() {
} }
function testProtoSetter1_2() { function testProtoSetter1_2() {
expected_function_name = 'setter1'; expected_function_name = 'set setter1';
expected_source_line_text = ' this.name = n; // setter 1'; expected_source_line_text = ' this.name = n; // setter 1';
for (var i = 2; i != 1; i--); for (var i = 2; i != 1; i--);
debugger; debugger;
...@@ -240,7 +240,7 @@ for (var n in this) { ...@@ -240,7 +240,7 @@ for (var n in this) {
} }
state = 1; state = 1;
this[n](); this[n]();
assertNull(exception); if (exception) throw exception;
assertEquals(4, state); assertEquals(4, state);
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --harmony-sloppy --allow-natives-syntax // Flags: --harmony-sloppy --harmony-function-name --allow-natives-syntax
(function TestBasics() { (function TestBasics() {
var C = class C {} var C = class C {}
...@@ -22,13 +22,11 @@ ...@@ -22,13 +22,11 @@
class D2 { constructor() {} } class D2 { constructor() {} }
assertEquals('D2', D2.name); assertEquals('D2', D2.name);
// TODO(arv): The logic for the name of anonymous functions in ES6 requires
// the below to be 'E';
var E = class {} var E = class {}
assertEquals('', E.name); // Should be 'E'. assertEquals('E', E.name); // Should be 'E'.
var F = class { constructor() {} }; var F = class { constructor() {} };
assertEquals('', F.name); // Should be 'F'. assertEquals('F', F.name); // Should be 'F'.
})(); })();
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Flags: --harmony-function-name
var obj = { var obj = {
a: 7, a: 7,
...@@ -218,7 +220,7 @@ function TestNumericNamesGetter(expectedKeys, object) { ...@@ -218,7 +220,7 @@ function TestNumericNamesGetter(expectedKeys, object) {
assertEquals(expectedKeys, Object.keys(object)); assertEquals(expectedKeys, Object.keys(object));
expectedKeys.forEach(function(key) { expectedKeys.forEach(function(key) {
var descr = Object.getOwnPropertyDescriptor(object, key); var descr = Object.getOwnPropertyDescriptor(object, key);
assertEquals(key, descr.get.name); assertEquals('get ' + key, descr.get.name);
}); });
} }
TestNumericNamesGetter(['1', '2', '3', '4', '5', '6', '7', '8', '9'], { TestNumericNamesGetter(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
...@@ -242,7 +244,7 @@ function TestNumericNamesSetter(expectedKeys, object) { ...@@ -242,7 +244,7 @@ function TestNumericNamesSetter(expectedKeys, object) {
assertEquals(expectedKeys, Object.keys(object)); assertEquals(expectedKeys, Object.keys(object));
expectedKeys.forEach(function(key) { expectedKeys.forEach(function(key) {
var descr = Object.getOwnPropertyDescriptor(object, key); var descr = Object.getOwnPropertyDescriptor(object, key);
assertEquals(key, descr.set.name); assertEquals('set ' + key, descr.set.name);
}); });
} }
TestNumericNamesSetter(['1', '2', '3', '4', '5', '6', '7', '8', '9'], { TestNumericNamesSetter(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment