Commit ab24897c authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[fni] Mark computed props as computed, not anonymous function

I thought about potentially adding the identifer ref to the error but
that would require allocating a new string or at the very least
increasing the size of the resulting cons string. Given that the
parser is pretty performance sensitive, I've decided to not display
the identifier.

Previously, the error was:
  _test.js:3: Error
  a[foo].c = () => { throw Error(); };
                     ^
  Error
    at a.(anonymous function).c (_test.js:3:26)
    at _test.js:5:1

With this patch, the error becomes:
  _test.js:3: Error
  a[foo].c = () => { throw Error(); };
                     ^
  Error
    at a.<computed>.c (_test.js:3:26)
    at _test.js:5:1

Bug: v8:8823
Change-Id: I557b3517e317652c447ca06c5a400e9625353d9b
Reviewed-on: https://chromium-review.googlesource.com/c/1495017
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: 's avatarMathias Bynens <mathias@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59985}
parent 368f55bb
......@@ -202,6 +202,7 @@ class AstBigInt {
F(await, "await") \
F(bigint, "bigint") \
F(boolean, "boolean") \
F(computed, "<computed>") \
F(constructor, "constructor") \
F(default, "default") \
F(done, "done") \
......
......@@ -114,6 +114,7 @@
V(_, buffer_string, "buffer") \
V(_, byte_length_string, "byteLength") \
V(_, byte_offset_string, "byteOffset") \
V(_, CompileError_string, "CompileError") \
V(_, call_string, "call") \
V(_, callee_string, "callee") \
V(_, caller_string, "caller") \
......@@ -121,11 +122,11 @@
V(_, closure_string, "(closure)") \
V(_, code_string, "code") \
V(_, column_string, "column") \
V(_, CompileError_string, "CompileError") \
V(_, computed_string, "<computed>") \
V(_, configurable_string, "configurable") \
V(_, conjunction_string, "conjunction") \
V(_, construct_string, "construct") \
V(_, constructor_string, "constructor") \
V(_, conjunction_string, "conjunction") \
V(_, create_string, "create") \
V(_, Date_string, "Date") \
V(_, date_to_string, "[object Date]") \
......
......@@ -643,7 +643,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
if (expression->IsPropertyName()) {
fni_.PushLiteralName(expression->AsLiteral()->AsRawPropertyName());
} else {
fni_.PushLiteralName(ast_value_factory()->anonymous_function_string());
fni_.PushLiteralName(ast_value_factory()->computed_string());
}
}
......
......@@ -453,8 +453,8 @@ TEST(FactoryHashmapVariable) {
" return obj;\n"
"}");
// Can't infer function names statically.
CheckFunctionName(script, "return 1", "obj.(anonymous function)");
CheckFunctionName(script, "return 2", "obj.(anonymous function)");
CheckFunctionName(script, "return 1", "obj.<computed>");
CheckFunctionName(script, "return 2", "obj.<computed>");
}
......@@ -470,7 +470,7 @@ TEST(FactoryHashmapConditional) {
" return obj;\n"
"}");
// Can't infer the function name statically.
CheckFunctionName(script, "return 1", "obj.(anonymous function)");
CheckFunctionName(script, "return 1", "obj.<computed>");
}
......
......@@ -3107,8 +3107,7 @@ TEST(FuncNameInferrerBasic) {
ExpectString("Ctor()", "Ctor.foo5");
ExpectString("%FunctionGetInferredName(obj1.foo6)", "obj1.foo6");
ExpectString("%FunctionGetInferredName(obj2.foo7)", "obj2.foo7");
ExpectString("%FunctionGetInferredName(obj3[1])",
"obj3.(anonymous function)");
ExpectString("%FunctionGetInferredName(obj3[1])", "obj3.<computed>");
ExpectString("%FunctionGetInferredName(obj4[1])", "");
ExpectString("%FunctionGetInferredName(obj5['foo9'])", "obj5.foo9");
ExpectString("%FunctionGetInferredName(obj6.obj7.foo10)", "obj6.obj7.foo10");
......
// Copyright 2019 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.
let a = { b: {} };
let foo = "b";
a[foo].c = () => { throw Error(); };
let fn = a.b.c;
fn();
*%(basename)s:7: Error
a[foo].c = () => { throw Error(); };
^
Error
at a.<computed>.c (*%(basename)s:7:26)
at *%(basename)s:9:1
......@@ -310,46 +310,46 @@ KNOWN_MAPS = {
("RO_SPACE", 0x02821): (175, "Tuple2Map"),
("RO_SPACE", 0x028c1): (177, "ArrayBoilerplateDescriptionMap"),
("RO_SPACE", 0x02c01): (164, "InterceptorInfoMap"),
("RO_SPACE", 0x05109): (153, "AccessCheckInfoMap"),
("RO_SPACE", 0x05159): (154, "AccessorInfoMap"),
("RO_SPACE", 0x051a9): (155, "AccessorPairMap"),
("RO_SPACE", 0x051f9): (156, "AliasedArgumentsEntryMap"),
("RO_SPACE", 0x05249): (157, "AllocationMementoMap"),
("RO_SPACE", 0x05299): (158, "AsmWasmDataMap"),
("RO_SPACE", 0x052e9): (159, "AsyncGeneratorRequestMap"),
("RO_SPACE", 0x05339): (160, "ClassPositionsMap"),
("RO_SPACE", 0x05389): (161, "DebugInfoMap"),
("RO_SPACE", 0x053d9): (162, "FunctionTemplateInfoMap"),
("RO_SPACE", 0x05429): (163, "FunctionTemplateRareDataMap"),
("RO_SPACE", 0x05479): (165, "InterpreterDataMap"),
("RO_SPACE", 0x054c9): (166, "ModuleInfoEntryMap"),
("RO_SPACE", 0x05519): (167, "ModuleMap"),
("RO_SPACE", 0x05569): (168, "ObjectTemplateInfoMap"),
("RO_SPACE", 0x055b9): (169, "PromiseCapabilityMap"),
("RO_SPACE", 0x05609): (170, "PromiseReactionMap"),
("RO_SPACE", 0x05659): (171, "PrototypeInfoMap"),
("RO_SPACE", 0x056a9): (172, "ScriptMap"),
("RO_SPACE", 0x056f9): (173, "StackFrameInfoMap"),
("RO_SPACE", 0x05749): (174, "StackTraceFrameMap"),
("RO_SPACE", 0x05799): (176, "Tuple3Map"),
("RO_SPACE", 0x057e9): (178, "WasmDebugInfoMap"),
("RO_SPACE", 0x05839): (179, "WasmExceptionTagMap"),
("RO_SPACE", 0x05889): (180, "WasmExportedFunctionDataMap"),
("RO_SPACE", 0x058d9): (181, "CallableTaskMap"),
("RO_SPACE", 0x05929): (182, "CallbackTaskMap"),
("RO_SPACE", 0x05979): (183, "PromiseFulfillReactionJobTaskMap"),
("RO_SPACE", 0x059c9): (184, "PromiseRejectReactionJobTaskMap"),
("RO_SPACE", 0x05a19): (185, "PromiseResolveThenableJobTaskMap"),
("RO_SPACE", 0x05a69): (186, "FinalizationGroupCleanupJobTaskMap"),
("RO_SPACE", 0x05ab9): (187, "AllocationSiteWithWeakNextMap"),
("RO_SPACE", 0x05b09): (187, "AllocationSiteWithoutWeakNextMap"),
("RO_SPACE", 0x05b59): (221, "LoadHandler1Map"),
("RO_SPACE", 0x05ba9): (221, "LoadHandler2Map"),
("RO_SPACE", 0x05bf9): (221, "LoadHandler3Map"),
("RO_SPACE", 0x05c49): (229, "StoreHandler0Map"),
("RO_SPACE", 0x05c99): (229, "StoreHandler1Map"),
("RO_SPACE", 0x05ce9): (229, "StoreHandler2Map"),
("RO_SPACE", 0x05d39): (229, "StoreHandler3Map"),
("RO_SPACE", 0x05129): (153, "AccessCheckInfoMap"),
("RO_SPACE", 0x05179): (154, "AccessorInfoMap"),
("RO_SPACE", 0x051c9): (155, "AccessorPairMap"),
("RO_SPACE", 0x05219): (156, "AliasedArgumentsEntryMap"),
("RO_SPACE", 0x05269): (157, "AllocationMementoMap"),
("RO_SPACE", 0x052b9): (158, "AsmWasmDataMap"),
("RO_SPACE", 0x05309): (159, "AsyncGeneratorRequestMap"),
("RO_SPACE", 0x05359): (160, "ClassPositionsMap"),
("RO_SPACE", 0x053a9): (161, "DebugInfoMap"),
("RO_SPACE", 0x053f9): (162, "FunctionTemplateInfoMap"),
("RO_SPACE", 0x05449): (163, "FunctionTemplateRareDataMap"),
("RO_SPACE", 0x05499): (165, "InterpreterDataMap"),
("RO_SPACE", 0x054e9): (166, "ModuleInfoEntryMap"),
("RO_SPACE", 0x05539): (167, "ModuleMap"),
("RO_SPACE", 0x05589): (168, "ObjectTemplateInfoMap"),
("RO_SPACE", 0x055d9): (169, "PromiseCapabilityMap"),
("RO_SPACE", 0x05629): (170, "PromiseReactionMap"),
("RO_SPACE", 0x05679): (171, "PrototypeInfoMap"),
("RO_SPACE", 0x056c9): (172, "ScriptMap"),
("RO_SPACE", 0x05719): (173, "StackFrameInfoMap"),
("RO_SPACE", 0x05769): (174, "StackTraceFrameMap"),
("RO_SPACE", 0x057b9): (176, "Tuple3Map"),
("RO_SPACE", 0x05809): (178, "WasmDebugInfoMap"),
("RO_SPACE", 0x05859): (179, "WasmExceptionTagMap"),
("RO_SPACE", 0x058a9): (180, "WasmExportedFunctionDataMap"),
("RO_SPACE", 0x058f9): (181, "CallableTaskMap"),
("RO_SPACE", 0x05949): (182, "CallbackTaskMap"),
("RO_SPACE", 0x05999): (183, "PromiseFulfillReactionJobTaskMap"),
("RO_SPACE", 0x059e9): (184, "PromiseRejectReactionJobTaskMap"),
("RO_SPACE", 0x05a39): (185, "PromiseResolveThenableJobTaskMap"),
("RO_SPACE", 0x05a89): (186, "FinalizationGroupCleanupJobTaskMap"),
("RO_SPACE", 0x05ad9): (187, "AllocationSiteWithWeakNextMap"),
("RO_SPACE", 0x05b29): (187, "AllocationSiteWithoutWeakNextMap"),
("RO_SPACE", 0x05b79): (221, "LoadHandler1Map"),
("RO_SPACE", 0x05bc9): (221, "LoadHandler2Map"),
("RO_SPACE", 0x05c19): (221, "LoadHandler3Map"),
("RO_SPACE", 0x05c69): (229, "StoreHandler0Map"),
("RO_SPACE", 0x05cb9): (229, "StoreHandler1Map"),
("RO_SPACE", 0x05d09): (229, "StoreHandler2Map"),
("RO_SPACE", 0x05d59): (229, "StoreHandler3Map"),
("MAP_SPACE", 0x00139): (1057, "ExternalMap"),
("MAP_SPACE", 0x00189): (1073, "JSMessageObjectMap"),
}
......
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