Skip to content

Commit d520ebb

Browse files
jaro-sevcikCommit Bot
authored andcommitted
[turbofan] Fix NumberFloor typing.
Bug: chromium:841117 Change-Id: I1e83dfc82f87d0b49d3cca96290ae1d738e37d20 Reviewed-on: https://chromium-review.googlesource.com/1051228 Reviewed-by: Benedikt Meurer <[email protected]> Commit-Queue: Jaroslav Sevcik <[email protected]> Cr-Commit-Position: refs/heads/master@{#53083}
1 parent 2b6fb35 commit d520ebb

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/compiler/typed-optimization.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,13 @@ Reduction TypedOptimization::ReduceNumberFloor(Node* node) {
242242
//
243243
// NumberToUint32(NumberDivide(lhs, rhs))
244244
//
245-
// and just smash the type of the {lhs} on the {node},
246-
// as the truncated result must be in the same range as
247-
// {lhs} since {rhs} cannot be less than 1 (due to the
245+
// and just smash the type [0...lhs.Max] on the {node},
246+
// as the truncated result must be loewr than {lhs}'s maximum
247+
// value (note that {rhs} cannot be less than 1 due to the
248248
// plain-number type constraint on the {node}).
249249
NodeProperties::ChangeOp(node, simplified()->NumberToUint32());
250-
NodeProperties::SetType(node, lhs_type);
250+
NodeProperties::SetType(node,
251+
Type::Range(0, lhs_type.Max(), graph()->zone()));
251252
return Changed(node);
252253
}
253254
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2018 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+
var v = 1e9;
8+
function f() { return Math.floor(v / 10); }
9+
assertEquals(1e8, f());
10+
%OptimizeFunctionOnNextCall(f);
11+
assertEquals(1e8, f());

0 commit comments

Comments
 (0)