f2fd4923f3
At the moment when the static private method is unused in source code (either explicitly or through eval) but is accessed at runtime through the debugger, and there are no other potential references to the class variable in the source code otherwise, the reference to the class variable is lost here since the class variable would not be context-allocated, then we could not rebuild a proper brand check for it. For now, a ReferenceError would be thrown and the method is considered "optimized away", similar to how unused ordinary methods in closures work. Before this patch it would DCHECK when generating bytecode for the debugger instead of throwing errors. Bug: v8:9839, v8:8330 Change-Id: I5d63131a7bdba141d01a3e6459bc27d0f5953c1a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2095637 Commit-Queue: Joyee Cheung <joyee@igalia.com> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Reviewed-by: Shu-yu Guo <syg@chromium.org> Cr-Commit-Position: refs/heads/master@{#66734}
84 lines
2.7 KiB
Plaintext
84 lines
2.7 KiB
Plaintext
Test accessing unused private methods at runtime
|
|
|
|
Running test: testScopesPaused
|
|
Get privateProperties of A in testStatic()
|
|
[
|
|
[0] : {
|
|
name : #staticMethod
|
|
value : {
|
|
className : Function
|
|
description : #staticMethod() { return 1; }
|
|
objectId : {"injectedScriptId":1,"id":34}
|
|
type : function
|
|
}
|
|
}
|
|
]
|
|
Access A.#staticMethod() in testStatic()
|
|
{
|
|
exceptionDetails : {
|
|
columnNumber : 0
|
|
exception : {
|
|
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
|
|
objectId : {"injectedScriptId":1,"id":36}
|
|
subtype : error
|
|
type : object
|
|
}
|
|
exceptionId : 1
|
|
lineNumber : 0
|
|
scriptId : 5
|
|
text : Uncaught
|
|
}
|
|
result : {
|
|
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
|
|
objectId : {"injectedScriptId":1,"id":35}
|
|
subtype : error
|
|
type : object
|
|
}
|
|
}
|
|
Access this.#staticMethod() in testStatic()
|
|
{
|
|
exceptionDetails : {
|
|
columnNumber : 0
|
|
exception : {
|
|
className : Error
|
|
description : Error: Unused static private method '#staticMethod' cannot be accessed at debug time 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
|
|
objectId : {"injectedScriptId":1,"id":38}
|
|
subtype : error
|
|
type : object
|
|
}
|
|
exceptionId : 2
|
|
lineNumber : 0
|
|
scriptId : 6
|
|
text : Uncaught
|
|
}
|
|
result : {
|
|
className : Error
|
|
description : Error: Unused static private method '#staticMethod' cannot be accessed at debug time 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
|
|
objectId : {"injectedScriptId":1,"id":37}
|
|
subtype : error
|
|
type : object
|
|
}
|
|
}
|
|
get privateProperties of a in testInstance()
|
|
[
|
|
[0] : {
|
|
name : #instanceMethod
|
|
value : {
|
|
className : Function
|
|
description : #instanceMethod() { return 2; }
|
|
objectId : {"injectedScriptId":1,"id":61}
|
|
type : function
|
|
}
|
|
}
|
|
]
|
|
Evaluating this.#instanceMethod() in testInstance()
|
|
{
|
|
result : {
|
|
description : 2
|
|
type : number
|
|
value : 2
|
|
}
|
|
}
|