Skip to content

Commit 4369055

Browse files
bnoordhuisMylesBorins
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 8198dbc commit 4369055

File tree

3 files changed

+63
-29
lines changed

3 files changed

+63
-29
lines changed

deps/v8/include/v8-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 4
1212
#define V8_MINOR_VERSION 5
1313
#define V8_BUILD_NUMBER 103
14-
#define V8_PATCH_LEVEL 37
14+
#define V8_PATCH_LEVEL 38
1515

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

deps/v8/src/mirror-debugger.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,12 @@ PropertyMirror.prototype.name = function() {
15141514
};
15151515

15161516

1517+
PropertyMirror.prototype.toText = function() {
1518+
if (IS_SYMBOL(this.name_)) return %SymbolDescriptiveString(this.name_);
1519+
return this.name_;
1520+
};
1521+
1522+
15171523
PropertyMirror.prototype.isIndexed = function() {
15181524
for (var i = 0; i < this.name_.length; i++) {
15191525
if (this.name_[i] < '0' || '9' < this.name_[i]) {
@@ -2074,10 +2080,10 @@ FrameMirror.prototype.invocationText = function() {
20742080
if (display_receiver) {
20752081
result += '.';
20762082
}
2077-
result += property.name();
2083+
result += property.toText();
20782084
} else {
20792085
result += '[';
2080-
result += property.name();
2086+
result += property.toText();
20812087
result += ']';
20822088
}
20832089
// Also known as - if the name in the function doesn't match the name

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

+54-26
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-
return Math.sqrt(Math.pow(Math.abs(this.x - p.x), 2) + Math.pow(Math.abs(this.y - p.y), 2))
38+
return Math.sqrt(Math.pow(Math.abs(this.x - p.x), 2) +
39+
Math.pow(Math.abs(this.y - p.y), 2))
3940
}
4041

4142
p1 = new Point(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
function listener(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+
} else if (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+
} else if (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+
var S = Symbol('Das Symbol');
145+
var o = { [S](x, y) { return new Point(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)