Skip to content

Commit dc3a90b

Browse files
psmarshallCommit Bot
authored andcommitted
[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}
1 parent c870489 commit dc3a90b

5 files changed

Lines changed: 12 additions & 26 deletions

File tree

src/builtins/builtins-function.cc

Lines changed: 0 additions & 11 deletions
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

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

Lines changed: 5 additions & 5 deletions
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
}

test/debugger/debugger.status

Lines changed: 0 additions & 3 deletions
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],

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

Lines changed: 3 additions & 3 deletions
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

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

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)