Skip to content

Commit 812226b

Browse files
nodejs-github-botXmader
authored andcommitted
deps: patch V8 to 14.6.202.34
Refs: v8/v8@14.6.202.33...14.6.202.34 PR-URL: nodejs#62964 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <richard.lau@ibm.com>
1 parent 78097f9 commit 812226b

3 files changed

Lines changed: 73 additions & 0 deletions

File tree

deps/v8/src/maglev/maglev-graph-builder.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4070,6 +4070,22 @@ ReduceResult MaglevGraphBuilder::BuildCheckSmi(ValueNode* object,
40704070
return EmitUnconditionalDeopt(DeoptimizeReason::kSmi);
40714071
}
40724072
if (EnsureType(object, NodeType::kSmi) && elidable) return object;
4073+
if constexpr (SmiValuesAre31Bits()) {
4074+
if (Phi* value_as_phi = object->TryCast<Phi>()) {
4075+
value_as_phi->SetUseRequires31BitValue();
4076+
}
4077+
}
4078+
// For non-tagged constants, we may be able to skip the runtime check: every
4079+
// non-tagged arm of the switch below emits a value-range check, which is
4080+
// exactly what `Smi::IsValid` proves. For tagged inputs the runtime check
4081+
// (CheckSmi) is a tag-bit check, and value-equivalence (e.g. via the
4082+
// checked_value alternative, which may hold a HeapNumber constant) does not
4083+
// imply Smi tagging.
4084+
if (object->value_representation() != ValueRepresentation::kTagged) {
4085+
if (std::optional<int32_t> constant_value = TryGetInt32Constant(object)) {
4086+
if (Smi::IsValid(constant_value.value())) return object;
4087+
}
4088+
}
40734089
switch (object->value_representation()) {
40744090
case ValueRepresentation::kInt32:
40754091
if (!SmiValuesAre32Bits()) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2026 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 --maglev --expose-gc
6+
7+
let f = new Float64Array(1); f[0] = 5;
8+
let HN5 = f[0];
9+
globalThis.G = HN5;
10+
11+
let obj = { smiField: 1 };
12+
obj.smiField = 2;
13+
obj.smiField = 3;
14+
15+
function sh(o, x, c) { if (c) o.smiField = x; }
16+
function corrupt(o, x, c) { G = x; sh(o, x, c); }
17+
18+
%PrepareFunctionForOptimization(sh);
19+
%PrepareFunctionForOptimization(corrupt);
20+
sh(obj, 5, true);
21+
corrupt(obj, HN5, false);
22+
corrupt(obj, HN5, false);
23+
%OptimizeMaglevOnNextCall(sh);
24+
%OptimizeMaglevOnNextCall(corrupt);
25+
26+
// Trigger: HeapNumber(5.0) ends up in a kSmi-typed field without a Smi check.
27+
corrupt(obj, HN5, true);
28+
29+
// Force a write-barrier verification path by allocating.
30+
gc();
31+
assertEquals(5, obj.smiField);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2026 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: --fuzzing --expose-gc --allow-natives-syntax --disable-abortjs
6+
// Flags: --disable-in-process-stack-traces
7+
8+
let f64 = new Float64Array(1);
9+
f64[0] = 1.0;
10+
let hn = f64[0];
11+
12+
let script_var_1 = hn;
13+
let script_var_2 = 1;
14+
script_var_2 = 2;
15+
16+
function foo(x) {
17+
script_var_1 = x;
18+
script_var_2 = x;
19+
}
20+
21+
%PrepareFunctionForOptimization(foo);
22+
%OptimizeMaglevOnNextCall(foo);
23+
24+
foo(hn);
25+
26+
assertEquals(1, script_var_2);

0 commit comments

Comments
 (0)