Skip to content

Commit 0ac21bc

Browse files
bnoordhuisofrobots
authored andcommitted
deps: cherry-pick 1f53e42 from v8 upstream
Original commit message: Handle symbols in FrameMirror#invocationText(). Fix a TypeError when putting together the invocationText for a symbol method's stack frame. See #7536. Review-Url: https://codereview.chromium.org/2122793003 Cr-Commit-Position: refs/heads/master@{#37597} Fixes: #7536 PR-URL: #7612 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent fc442e0 commit 0ac21bc

File tree

3 files changed

+63
-29
lines changed

3 files changed

+63
-29
lines changed

‎deps/v8/include/v8-version.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#defineV8_MAJOR_VERSION 5
1212
#defineV8_MINOR_VERSION 1
1313
#defineV8_BUILD_NUMBER 281
14-
#defineV8_PATCH_LEVEL75
14+
#defineV8_PATCH_LEVEL76
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

‎deps/v8/src/debug/mirrors.js‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,12 @@ PropertyMirror.prototype.name = function(){
14951495
};
14961496

14971497

1498+
PropertyMirror.prototype.toText=function(){
1499+
if(IS_SYMBOL(this.name_))return%SymbolDescriptiveString(this.name_);
1500+
returnthis.name_;
1501+
};
1502+
1503+
14981504
PropertyMirror.prototype.isIndexed=function(){
14991505
for(vari=0;i<this.name_.length;i++){
15001506
if(this.name_[i]<'0'||'9'<this.name_[i]){
@@ -2027,10 +2033,10 @@ FrameMirror.prototype.invocationText = function(){
20272033
if(display_receiver){
20282034
result+='.';
20292035
}
2030-
result+=property.name();
2036+
result+=property.toText();
20312037
}else{
20322038
result+='[';
2033-
result+=property.name();
2039+
result+=property.toText();
20342040
result+=']';
20352041
}
20362042
// Also known as - if the name in the function doesn't match the name

‎deps/v8/test/mjsunit/debug-backtrace-text.js‎

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ function Point(x, y){
3535

3636
Point.prototype.distanceTo=function(p){
3737
debugger;
38-
returnMath.sqrt(Math.pow(Math.abs(this.x-p.x),2)+Math.pow(Math.abs(this.y-p.y),2))
38+
returnMath.sqrt(Math.pow(Math.abs(this.x-p.x),2)+
39+
Math.pow(Math.abs(this.y-p.y),2))
3940
}
4041

4142
p1=newPoint(1,1);
@@ -58,7 +59,7 @@ a=[1,2,distance];
5859
// Get the Debug object exposed from the debug context global object.
5960
Debug=debug.Debug
6061

61-
testConstructor=false;// Flag to control which part of the test is run.
62+
what='constructor';// Flag to control which part of the test is run.
6263
listenerCalled=false;
6364
exception=false;
6465

@@ -72,30 +73,47 @@ function safeEval(code){
7273

7374
functionlistener(event,exec_state,event_data,data){
7475
try{
75-
if(event==Debug.DebugEvent.Break)
76-
{
77-
if(!testConstructor){
78-
// The expected backtrace is
79-
// 0: Call distance on Point where distance is a property on the prototype
80-
// 1: Call distance on Point where distance is a direct property
81-
// 2: Call on function an array element 2
82-
// 3: [anonymous]
83-
assertEquals("#<Point>.distanceTo(p=#<Point>)",exec_state.frame(0).invocationText());
84-
assertEquals("#<Point>.distanceTo(p=#<Point>)",exec_state.frame(1).invocationText());
85-
assertEquals("#<Array>[2](aka distance)(p=#<Point>, q=#<Point>)",exec_state.frame(2).invocationText());
86-
assertEquals("[anonymous]()",exec_state.frame(3).invocationText());
87-
listenerCalled=true;
88-
}else{
89-
// The expected backtrace is
90-
// 0: Call Point constructor
91-
// 1: Call on global function createPoint
92-
// 2: [anonymous]
93-
assertEquals("new Point(x=0, y=0)",exec_state.frame(0).invocationText());
94-
assertEquals("createPoint(x=0, y=0)",exec_state.frame(1).invocationText());
95-
assertEquals("[anonymous]()",exec_state.frame(2).invocationText());
96-
listenerCalled=true;
76+
if(event==Debug.DebugEvent.Break){
77+
if(what=='constructor'){
78+
// The expected backtrace is
79+
// 0: Call distance on Point where distance is a prototype property
80+
// 1: Call distance on Point where distance is a direct property
81+
// 2: Call on function an array element 2
82+
// 3: [anonymous]
83+
assertEquals("#<Point>.distanceTo(p=#<Point>)",
84+
exec_state.frame(0).invocationText());
85+
assertEquals("#<Point>.distanceTo(p=#<Point>)",
86+
exec_state.frame(1).invocationText());
87+
assertEquals("#<Array>[2](aka distance)(p=#<Point>, q=#<Point>)",
88+
exec_state.frame(2).invocationText());
89+
assertEquals("[anonymous]()",exec_state.frame(3).invocationText());
90+
listenerCalled=true;
91+
}elseif(what=='breakpoint'){
92+
// The expected backtrace is
93+
// 0: Call Point constructor
94+
// 1: Call on global function createPoint
95+
// 2: [anonymous]
96+
assertEquals("new Point(x=0, y=0)",
97+
exec_state.frame(0).invocationText());
98+
assertEquals("createPoint(x=0, y=0)",
99+
exec_state.frame(1).invocationText());
100+
assertEquals("[anonymous]()",exec_state.frame(2).invocationText());
101+
listenerCalled=true;
102+
}elseif(what=='symbol'){
103+
// The expected backtrace is
104+
// 0: Call Point constructor
105+
// 1: Call on symbol method
106+
// 2: [anonymous]
107+
assertEquals("new Point(x=0, y=0)",
108+
exec_state.frame(0).invocationText());
109+
assertEquals("#<Object>[Symbol(Das Symbol)](x=0, y=0)",
110+
exec_state.frame(1).invocationText());
111+
assertEquals("[anonymous]()",exec_state.frame(2).invocationText());
112+
listenerCalled=true;
113+
}else{
114+
assertUnreachable();
115+
}
97116
}
98-
}
99117
}catch(e){
100118
exception=e
101119
};
@@ -112,11 +130,21 @@ assertTrue(listenerCalled);
112130
assertFalse(exception,"exception in listener")
113131

114132
// Set a break point and call to invoke the debug event listener.
133+
what='breakpoint';
115134
listenerCalled=false;
116-
testConstructor=true;
117135
Debug.setBreakPoint(Point,0,0);
118136
createPoint(0,0);
119137

120138
// Make sure that the debug event listener vas invoked (again).
121139
assertTrue(listenerCalled);
122140
assertFalse(exception,"exception in listener")
141+
142+
what='symbol';
143+
listenerCalled=false;
144+
varS=Symbol('Das Symbol');
145+
varo={[S](x,y){returnnewPoint(x,y);}};
146+
Debug.setBreakPoint(Point,0,0);
147+
o[S](0,0);
148+
149+
assertTrue(listenerCalled);
150+
assertFalse(exception,"exception in listener")

0 commit comments

Comments
(0)