Skip to content

Commit

Permalink
[maglev] Throw exception if inlined result is not tagged
Browse files Browse the repository at this point in the history
... when inlining a derived constructor.

Fixed: chromium:1466928
Bug: v8:7700
Change-Id: I593a5e620d4ab006342c9144798f3b2ed71441e9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4711506
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/main@{#89152}
  • Loading branch information
victorgomes authored and V8 LUCI CQ committed Jul 24, 2023
1 parent f43a566 commit 5c1c91f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/maglev/maglev-graph-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7415,6 +7415,10 @@ ReduceResult MaglevGraphBuilder::ReduceConstruct(
compiler::HeapObjectRef constant = maybe_constant.value();
if (constant.IsJSReceiver()) return constant_node;
}
if (!call_result->properties().is_tagged()) {
return BuildCallRuntime(Runtime::kThrowConstructorReturnedNonObject,
{});
}
return AddNewNode<CheckDerivedConstructResult>({call_result});
}

Expand Down
17 changes: 17 additions & 0 deletions test/mjsunit/maglev/regress-1466928.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2023 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --allow-natives-syntax --maglev --single-threaded

for (let v1 = 0; v1 < 1000; v1++) {
v1++;
function f3() {
}
class C4 extends f3 {
constructor(a6) {
return a6;
}
}
try { new C4(v1); } catch (e) {}
}

0 comments on commit 5c1c91f

Please sign in to comment.