Commit 14718889 authored by jameslahm's avatar jameslahm Committed by V8 LUCI CQ

[error] Improve error message for static methods

This CL changes frame message from `Function.${staticMethodName}`
to `${className}.${staticMethodName}` for stack trace in class
static methods.

Bug: v8:12778
Change-Id: Ie2b9471066a6ba38265412f4af471789bd375c98
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3575759Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: 王澳 <wangao.james@bytedance.com>
Cr-Commit-Position: refs/heads/main@{#79898}
parent 6078cb52
...@@ -673,6 +673,14 @@ void AppendMethodCall(Isolate* isolate, Handle<CallSiteInfo> frame, ...@@ -673,6 +673,14 @@ void AppendMethodCall(Isolate* isolate, Handle<CallSiteInfo> frame,
Handle<Object> method_name = CallSiteInfo::GetMethodName(frame); Handle<Object> method_name = CallSiteInfo::GetMethodName(frame);
Handle<Object> function_name = CallSiteInfo::GetFunctionName(frame); Handle<Object> function_name = CallSiteInfo::GetFunctionName(frame);
Handle<Object> receiver(frame->receiver_or_instance(), isolate);
if (receiver->IsJSClassConstructor()) {
Handle<JSFunction> function = Handle<JSFunction>::cast(receiver);
Handle<String> class_name = JSFunction::GetDebugName(function);
if (class_name->length() != 0) {
type_name = class_name;
}
}
if (IsNonEmptyString(function_name)) { if (IsNonEmptyString(function_name)) {
Handle<String> function_string = Handle<String>::cast(function_name); Handle<String> function_string = Handle<String>::cast(function_name);
if (IsNonEmptyString(type_name)) { if (IsNonEmptyString(type_name)) {
......
...@@ -121,7 +121,7 @@ Evaluating this.#inc(); from the base class ...@@ -121,7 +121,7 @@ Evaluating this.#inc(); from the base class
columnNumber : 4 columnNumber : 4
exception : { exception : {
className : SyntaxError className : SyntaxError
description : SyntaxError: Private field '#inc' must be declared in an enclosing class at Function.test (<anonymous>:24:7) at run (<anonymous>:28:5) at <anonymous>:1:1 description : SyntaxError: Private field '#inc' must be declared in an enclosing class at B.test (<anonymous>:24:7) at run (<anonymous>:28:5) at <anonymous>:1:1
objectId : <objectId> objectId : <objectId>
subtype : error subtype : error
type : object type : object
...@@ -133,7 +133,7 @@ Evaluating this.#inc(); from the base class ...@@ -133,7 +133,7 @@ Evaluating this.#inc(); from the base class
} }
result : { result : {
className : SyntaxError className : SyntaxError
description : SyntaxError: Private field '#inc' must be declared in an enclosing class at Function.test (<anonymous>:24:7) at run (<anonymous>:28:5) at <anonymous>:1:1 description : SyntaxError: Private field '#inc' must be declared in an enclosing class at B.test (<anonymous>:24:7) at run (<anonymous>:28:5) at <anonymous>:1:1
objectId : <objectId> objectId : <objectId>
subtype : error subtype : error
type : object type : object
......
...@@ -19,7 +19,7 @@ Access A.#staticMethod() in testStatic() ...@@ -19,7 +19,7 @@ Access A.#staticMethod() in testStatic()
columnNumber : 0 columnNumber : 0
exception : { exception : {
className : ReferenceError className : ReferenceError
description : ReferenceError: A is not defined at eval (eval at testStatic (:1:1), <anonymous>:1:1) at Function.testStatic (<anonymous>:6:29) at run (<anonymous>:9:7) at <anonymous>:1:1 description : ReferenceError: A is not defined at eval (eval at testStatic (:1:1), <anonymous>:1:1) at A.testStatic (<anonymous>:6:29) at run (<anonymous>:9:7) at <anonymous>:1:1
objectId : <objectId> objectId : <objectId>
subtype : error subtype : error
type : object type : object
...@@ -31,7 +31,7 @@ Access A.#staticMethod() in testStatic() ...@@ -31,7 +31,7 @@ Access A.#staticMethod() in testStatic()
} }
result : { result : {
className : ReferenceError className : ReferenceError
description : ReferenceError: A is not defined at eval (eval at testStatic (:1:1), <anonymous>:1:1) at Function.testStatic (<anonymous>:6:29) at run (<anonymous>:9:7) at <anonymous>:1:1 description : ReferenceError: A is not defined at eval (eval at testStatic (:1:1), <anonymous>:1:1) at A.testStatic (<anonymous>:6:29) at run (<anonymous>:9:7) at <anonymous>:1:1
objectId : <objectId> objectId : <objectId>
subtype : error subtype : error
type : object type : object
...@@ -43,7 +43,7 @@ Access this.#staticMethod() in testStatic() ...@@ -43,7 +43,7 @@ Access this.#staticMethod() in testStatic()
columnNumber : 5 columnNumber : 5
exception : { exception : {
className : Error className : Error
description : Error: Unused static private method '#staticMethod' cannot be accessed at debug time at eval (eval at testStatic (:1:1), <anonymous>:1:6) at Function.testStatic (<anonymous>:6:29) at run (<anonymous>:9:7) at <anonymous>:1:1 description : Error: Unused static private method '#staticMethod' cannot be accessed at debug time at eval (eval at testStatic (:1:1), <anonymous>:1:6) at A.testStatic (<anonymous>:6:29) at run (<anonymous>:9:7) at <anonymous>:1:1
objectId : <objectId> objectId : <objectId>
subtype : error subtype : error
type : object type : object
...@@ -55,7 +55,7 @@ Access this.#staticMethod() in testStatic() ...@@ -55,7 +55,7 @@ Access this.#staticMethod() in testStatic()
} }
result : { result : {
className : Error className : Error
description : Error: Unused static private method '#staticMethod' cannot be accessed at debug time at eval (eval at testStatic (:1:1), <anonymous>:1:6) at Function.testStatic (<anonymous>:6:29) at run (<anonymous>:9:7) at <anonymous>:1:1 description : Error: Unused static private method '#staticMethod' cannot be accessed at debug time at eval (eval at testStatic (:1:1), <anonymous>:1:6) at A.testStatic (<anonymous>:6:29) at run (<anonymous>:9:7) at <anonymous>:1:1
objectId : <objectId> objectId : <objectId>
subtype : error subtype : error
type : object type : object
......
...@@ -183,13 +183,13 @@ function testStaticClassFieldCall() { ...@@ -183,13 +183,13 @@ function testStaticClassFieldCall() {
} }
// ReferenceError: FAIL is not defined // ReferenceError: FAIL is not defined
// at Function.thrower [as x] // at X.thrower [as x]
// at testStaticClassFieldCall // at testStaticClassFieldCall
// at testTrace // at testTrace
testTrace( testTrace(
"during static class field call", "during static class field call",
testStaticClassFieldCall, testStaticClassFieldCall,
["Function.thrower"], ["X.thrower"],
["anonymous"] ["anonymous"]
); );
...@@ -226,12 +226,12 @@ function testStaticClassFieldCallWithFNI() { ...@@ -226,12 +226,12 @@ function testStaticClassFieldCallWithFNI() {
} }
// ReferenceError: FAIL is not defined // ReferenceError: FAIL is not defined
// at Function.x // at X.x
// at testStaticClassFieldCallWithFNI // at testStaticClassFieldCallWithFNI
// at testTrace // at testTrace
testTrace( testTrace(
"during static class field call with FNI", "during static class field call with FNI",
testStaticClassFieldCallWithFNI, testStaticClassFieldCallWithFNI,
["Function.x"], ["X.x"],
["anonymous"] ["anonymous"]
); );
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