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}
This commit is contained in:
adamk 2016-03-03 20:03:24 -08:00 committed by Commit bot
parent 53a393b5d1
commit edeaab7da0
6 changed files with 29 additions and 26 deletions

View File

@ -218,7 +218,6 @@ DEFINE_IMPLICATION(es_staging, harmony_tailcalls)
// Features that are complete (but still behind --harmony/es-staging flag).
#define HARMONY_STAGED(V) \
V(harmony_function_name, "harmony Function name inference") \
V(harmony_regexp_lookbehind, "harmony regexp lookbehind") \
V(harmony_instanceof, "harmony instanceof support") \
V(harmony_object_values_entries, "harmony Object.values / Object.entries") \
@ -230,6 +229,7 @@ DEFINE_IMPLICATION(es_staging, harmony_tailcalls)
V(harmony_default_parameters, "harmony default parameters") \
V(harmony_destructuring_assignment, "harmony destructuring assignment") \
V(harmony_destructuring_bind, "harmony destructuring bind") \
V(harmony_function_name, "harmony Function name inference") \
V(harmony_iterator_close, "harmony iterator finalization") \
V(harmony_tostring, "harmony toString") \
V(harmony_regexps, "harmony regular expression extensions") \

View File

@ -13521,7 +13521,7 @@ THREADED_TEST(ObjectGetConstructorName) {
"function Child() {};"
"Child.prototype = new Parent();"
"Child.prototype.constructor = Child;"
"var outer = { inner: function() { } };"
"var outer = { inner: (0, function() { }) };"
"var p = new Parent();"
"var c = new Child();"
"var x = new outer.inner();"
@ -18377,6 +18377,7 @@ THREADED_TEST(FunctionGetInferredName) {
THREADED_TEST(FunctionGetDebugName) {
i::FLAG_harmony_function_name = true;
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
const char* code =
@ -18420,7 +18421,8 @@ THREADED_TEST(FunctionGetDebugName) {
"Object.defineProperty(i, 'name', { value: 'function.name' });"
"var j = function() {};"
"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::Script::Compile(env.local(), v8_str(code), &origin)
.ToLocalChecked()
@ -18439,7 +18441,8 @@ THREADED_TEST(FunctionGetDebugName) {
"h", "displayName",
"i", "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) {
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
env->Global()

View File

@ -32,9 +32,9 @@ function f(x, y) {
a=1;
};
var m = function() {
var m = (0, function() {
new f(1);
};
});
function g() {
m();

View File

@ -96,21 +96,21 @@ var d = {
};
function testGetter1_1() {
expected_function_name = 'getter1';
expected_function_name = 'get getter1';
expected_source_line_text = ' return this.name; // getter 1';
debugger;
var x = c.getter1;
}
function testGetter1_2() {
expected_function_name = 'getter1';
expected_function_name = 'get getter1';
expected_source_line_text = ' return this.name; // getter 1';
debugger;
var x = c['getter1'];
}
function testGetter1_3() {
expected_function_name = 'getter1';
expected_function_name = 'get getter1';
expected_source_line_text = ' return this.name; // getter 1';
for (var i = 1; i < 2; i++) {
debugger;
@ -119,14 +119,14 @@ function testGetter1_3() {
}
function testGetter1_4() {
expected_function_name = 'getter1';
expected_function_name = 'get getter1';
expected_source_line_text = ' return this.name; // getter 1';
debugger;
var x = d.c.getter1;
}
function testGetter1_5() {
expected_function_name = 'getter1';
expected_function_name = 'get getter1';
expected_source_line_text = ' return this.name; // getter 1';
for (var i = 2; i != 1; i--);
debugger;
@ -134,7 +134,7 @@ function testGetter1_5() {
}
function testGetter2_1() {
expected_function_name = 'getter2';
expected_function_name = 'get getter2';
expected_source_line_text = ' return { // getter 2';
for (var i = 2; i != 1; i--);
debugger;
@ -172,21 +172,21 @@ function testIndexedSetter3_1() {
}
function testSetter1_1() {
expected_function_name = 'setter1';
expected_function_name = 'set setter1';
expected_source_line_text = ' this.name = n; // setter 1';
debugger;
d.c.setter1 = 'aa';
}
function testSetter1_2() {
expected_function_name = 'setter1';
expected_function_name = 'set setter1';
expected_source_line_text = ' this.name = n; // setter 1';
debugger;
d.c['setter1'] = 'bb';
}
function testSetter1_3() {
expected_function_name = 'setter1';
expected_function_name = 'set setter1';
expected_source_line_text = ' this.name = n; // setter 1';
for (var i = 2; i != 1; i--);
debugger;
@ -199,14 +199,14 @@ var e = {
e.__proto__ = c;
function testProtoGetter1_1() {
expected_function_name = 'getter1';
expected_function_name = 'get getter1';
expected_source_line_text = ' return this.name; // getter 1';
debugger;
var x = e.getter1;
}
function testProtoSetter1_1() {
expected_function_name = 'setter1';
expected_function_name = 'set setter1';
expected_source_line_text = ' this.name = n; // setter 1';
debugger;
e.setter1 = 'aa';
@ -227,7 +227,7 @@ function testProtoIndexedSetter3_1() {
}
function testProtoSetter1_2() {
expected_function_name = 'setter1';
expected_function_name = 'set setter1';
expected_source_line_text = ' this.name = n; // setter 1';
for (var i = 2; i != 1; i--);
debugger;
@ -240,7 +240,7 @@ for (var n in this) {
}
state = 1;
this[n]();
assertNull(exception);
if (exception) throw exception;
assertEquals(4, state);
}

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-sloppy --allow-natives-syntax
// Flags: --harmony-sloppy --harmony-function-name --allow-natives-syntax
(function TestBasics() {
var C = class C {}
@ -22,13 +22,11 @@
class D2 { constructor() {} }
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 {}
assertEquals('', E.name); // Should be 'E'.
assertEquals('E', E.name); // Should be 'E'.
var F = class { constructor() {} };
assertEquals('', F.name); // Should be 'F'.
assertEquals('F', F.name); // Should be 'F'.
})();

View File

@ -24,6 +24,8 @@
// 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-function-name
var obj = {
a: 7,
@ -218,7 +220,7 @@ function TestNumericNamesGetter(expectedKeys, object) {
assertEquals(expectedKeys, Object.keys(object));
expectedKeys.forEach(function(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'], {
@ -242,7 +244,7 @@ function TestNumericNamesSetter(expectedKeys, object) {
assertEquals(expectedKeys, Object.keys(object));
expectedKeys.forEach(function(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'], {