Skip to content

Commit ea85768

Browse files
committed
deps: V8: cherry-pick dc3a90be6ca7
Original commit message: [debug] Revert to old line number behavior for new Function() Reverting https://chromium-review.googlesource.com/c/v8/v8/+/1741660 This fixed one bug but caused a lot of others and on balance I think reverting it is the lesser evil. This also fixed generator-relocation.js because (function*(){}).constructor is the function constructor and we try to set a breakpoint on line 3. Bug: chromium:109362, chromium:1028689 Fixes: v8:9721 Change-Id: I1bfe6ec57ce77ea7292df91266311f5c0194947e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1940259 Commit-Queue: Peter Marshall <[email protected]> Reviewed-by: Yang Guo <[email protected]> Cr-Commit-Position: refs/heads/master@{#65232} Refs: v8/v8@dc3a90b Revert "assert: fix line number calculation after V8 upgrade" This reverts commit 5981fb7. Fixes: #32688 PR-URL: #32795 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 947ddec commit ea85768

File tree

7 files changed

+14
-31
lines changed

7 files changed

+14
-31
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
# Reset this number to 0 on major V8 upgrades.
3737
# Increment by one for each non-official patch applied to deps/v8.
38-
'v8_embedder_string': '-node.30',
38+
'v8_embedder_string': '-node.31',
3939

4040
##### V8 defaults for Node.js #####
4141

deps/v8/src/builtins/builtins-function.cc

-11
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,6 @@ MaybeHandle<Object> CreateDynamicFunction(Isolate* isolate,
9393
function->shared().set_name_should_print_as_anonymous(true);
9494
}
9595

96-
// The spec says that we have to wrap code created via the function
97-
// constructor in e.g. 'function anonymous(' as above, including with extra
98-
// line breaks. Ths is confusing when reporting stack traces from the eval'd
99-
// code as the line number of the error is always reported with 2 extra line
100-
// breaks e.g. line 1 is reported as line 3. We fix this up here by setting
101-
// line_offset which is read by stack trace code.
102-
Handle<Script> script(Script::cast(function->shared().script()), isolate);
103-
if (script->line_offset() == 0) {
104-
script->set_line_offset(-2);
105-
}
106-
10796
// If new.target is equal to target then the function created
10897
// is already correctly setup and nothing else should be done
10998
// here. But if new.target is not equal to target then we are

deps/v8/test/cctest/test-api-stack-traces.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -250,31 +250,31 @@ static void AnalyzeStackInNativeCode(
250250
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
251251
args.GetIsolate(), 5, v8::StackTrace::kOverview);
252252
CHECK_EQ(3, stackTrace->GetFrameCount());
253-
checkStackFrame(nullptr, "function.name", 1, 1, true, false,
253+
checkStackFrame(nullptr, "function.name", 3, 1, true, false,
254254
stackTrace->GetFrame(isolate, 0));
255255
} else if (testGroup == kDisplayName) {
256256
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
257257
args.GetIsolate(), 5, v8::StackTrace::kOverview);
258258
CHECK_EQ(3, stackTrace->GetFrameCount());
259-
checkStackFrame(nullptr, "function.displayName", 1, 1, true, false,
259+
checkStackFrame(nullptr, "function.displayName", 3, 1, true, false,
260260
stackTrace->GetFrame(isolate, 0));
261261
} else if (testGroup == kFunctionNameAndDisplayName) {
262262
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
263263
args.GetIsolate(), 5, v8::StackTrace::kOverview);
264264
CHECK_EQ(3, stackTrace->GetFrameCount());
265-
checkStackFrame(nullptr, "function.displayName", 1, 1, true, false,
265+
checkStackFrame(nullptr, "function.displayName", 3, 1, true, false,
266266
stackTrace->GetFrame(isolate, 0));
267267
} else if (testGroup == kDisplayNameIsNotString) {
268268
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
269269
args.GetIsolate(), 5, v8::StackTrace::kOverview);
270270
CHECK_EQ(3, stackTrace->GetFrameCount());
271-
checkStackFrame(nullptr, "function.name", 1, 1, true, false,
271+
checkStackFrame(nullptr, "function.name", 3, 1, true, false,
272272
stackTrace->GetFrame(isolate, 0));
273273
} else if (testGroup == kFunctionNameIsNotString) {
274274
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
275275
args.GetIsolate(), 5, v8::StackTrace::kOverview);
276276
CHECK_EQ(3, stackTrace->GetFrameCount());
277-
checkStackFrame(nullptr, "", 1, 1, true, false,
277+
checkStackFrame(nullptr, "", 3, 1, true, false,
278278
stackTrace->GetFrame(isolate, 0));
279279
}
280280
}

deps/v8/test/debugger/debugger.status

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
# not work, but we expect it to not crash.
1212
'debug/debug-step-turbofan': [PASS, FAIL],
1313

14-
# BUG (v8:9721)
15-
'debug/es6/generators-relocation': [FAIL],
16-
1714
# Issue 3641: The new 'then' semantics suppress some exceptions.
1815
# These tests may be changed or removed when 'chain' is deprecated.
1916
'debug/es6/debug-promises/reject-with-throw-in-reject': [FAIL],

deps/v8/test/inspector/runtime/evaluate-new-function-error-expected.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ Tests that Runtime.evaluate has the correct error line number for 'new Function(
66
columnNumber : 3
77
exception : {
88
className : TypeError
9-
description : TypeError: 0 is not a function at eval (eval at <anonymous> (:1:1), <anonymous>:1:4) at <anonymous>:1:22
9+
description : TypeError: 0 is not a function at eval (eval at <anonymous> (:1:1), <anonymous>:3:4) at <anonymous>:1:22
1010
objectId : <objectId>
1111
subtype : error
1212
type : object
1313
}
1414
exceptionId : <exceptionId>
15-
lineNumber : 0
15+
lineNumber : 2
1616
scriptId : <scriptId>
1717
text : Uncaught
1818
}
1919
result : {
2020
className : TypeError
21-
description : TypeError: 0 is not a function at eval (eval at <anonymous> (:1:1), <anonymous>:1:4) at <anonymous>:1:22
21+
description : TypeError: 0 is not a function at eval (eval at <anonymous> (:1:1), <anonymous>:3:4) at <anonymous>:1:22
2222
objectId : <objectId>
2323
subtype : error
2424
type : object

deps/v8/test/mjsunit/regress/regress-crbug-109362.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/assert.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function getErrMessage(message, fn) {
277277
const call = err.stack[0];
278278

279279
const filename = call.getFileName();
280-
let line = call.getLineNumber() - 1;
280+
const line = call.getLineNumber() - 1;
281281
let column = call.getColumnNumber() - 1;
282282
let identifier;
283283
let code;
@@ -297,9 +297,6 @@ function getErrMessage(message, fn) {
297297
return message;
298298
}
299299
code = String(fn);
300-
// For functions created with the Function constructor, V8 does not count
301-
// the lines containing the function header.
302-
line += 2;
303300
identifier = `${code}${line}${column}`;
304301
}
305302

0 commit comments

Comments
 (0)