Skip to content

Commit 853553f

Browse files
victorgomesV8 LUCI CQ
authored andcommitted
[trace] Don't add 'new' to Wasm call site
When constructors builtins are inlined in Maglev, but the constructor itself is not, we need to mark the call site flag kIsConstructor. This allows the stack trace builder to add the 'new' string. However, this should not be done if the target is Wasm. This creates the same stack trace string as Ignition. Fixed: 450308355 Change-Id: I5c21eba3b46f97ddca9c51c21a66aa8169c0293c Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7136920 Reviewed-by: Marja Hölttä <[email protected]> Auto-Submit: Victor Gomes <[email protected]> Commit-Queue: Victor Gomes <[email protected]> Cr-Commit-Position: refs/heads/main@{#103617}
1 parent 03eb882 commit 853553f

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

‎src/execution/isolate.cc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,9 @@ class CallSiteBuilder {
892892
DCHECK_GT(index_, 0);
893893
Tagged<CallSiteInfo> info =
894894
Tagged<CallSiteInfo>::cast(elements_->get(index_ - 1));
895+
#if V8_ENABLE_WEBASSEMBLY
896+
if (info->IsWasm()) return;
897+
#endif
895898
info->set_flags(info->flags() | CallSiteInfo::kIsConstructor);
896899
}
897900

‎test/mjsunit/regress-450308355.js‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2025 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --allow-natives-syntax
6+
7+
let captured;
8+
9+
function J_C() {
10+
let obj = {};
11+
Error.captureStackTrace(obj);
12+
captured = obj.stack;
13+
}
14+
15+
function AsmModule(stdlib, foreign, heap) {
16+
"use asm";
17+
var callback = foreign.callback;
18+
function W() {
19+
callback();
20+
}
21+
return { W: W };
22+
}
23+
24+
let exports = AsmModule(this, { callback: J_C }, new ArrayBuffer(65536));
25+
let W = exports.W;
26+
27+
function B() {
28+
new W();
29+
}
30+
31+
%PrepareFunctionForOptimization(B);
32+
B();
33+
// Stack minus last call.
34+
let from_ignition = captured.replace(/\n.*$/, '');
35+
%OptimizeMaglevOnNextCall(B);
36+
B();
37+
// Stack minus last call.
38+
let from_optimized = captured.replace(/\n.*$/, '');
39+
40+
// Ignition and optimized code agrees with the stack trace.
41+
assertEquals(from_ignition, from_optimized);

0 commit comments

Comments
 (0)