[turbofan] representation selection: do not convert from Boolean to Number without truncation
Bug: chromium:937649 Change-Id: I13c64a7cab7a6f1668c546114610006d0d6b91ee Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1501052 Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#60027}
This commit is contained in:
parent
5e71633333
commit
676a020322
@ -643,7 +643,17 @@ Node* RepresentationChanger::GetFloat64RepresentationFor(
|
||||
op = machine()->ChangeUint32ToFloat64();
|
||||
}
|
||||
} else if (output_rep == MachineRepresentation::kBit) {
|
||||
op = machine()->ChangeUint32ToFloat64();
|
||||
CHECK(output_type.Is(Type::Boolean()));
|
||||
if (use_info.truncation().IsUsedAsFloat64()) {
|
||||
op = machine()->ChangeUint32ToFloat64();
|
||||
} else {
|
||||
CHECK_NE(use_info.type_check(), TypeCheckKind::kNone);
|
||||
Node* unreachable =
|
||||
InsertUnconditionalDeopt(use_node, DeoptimizeReason::kNotAHeapNumber);
|
||||
return jsgraph()->graph()->NewNode(
|
||||
jsgraph()->common()->DeadValue(MachineRepresentation::kFloat64),
|
||||
unreachable);
|
||||
}
|
||||
} else if (output_rep == MachineRepresentation::kTagged ||
|
||||
output_rep == MachineRepresentation::kTaggedSigned ||
|
||||
output_rep == MachineRepresentation::kTaggedPointer) {
|
||||
@ -984,7 +994,13 @@ Node* RepresentationChanger::GetWord64RepresentationFor(
|
||||
return jsgraph()->graph()->NewNode(
|
||||
jsgraph()->common()->DeadValue(MachineRepresentation::kWord64), node);
|
||||
} else if (output_rep == MachineRepresentation::kBit) {
|
||||
return node; // Sloppy comparison -> word64
|
||||
CHECK(output_type.Is(Type::Boolean()));
|
||||
CHECK_NE(use_info.type_check(), TypeCheckKind::kNone);
|
||||
Node* unreachable =
|
||||
InsertUnconditionalDeopt(use_node, DeoptimizeReason::kNotASmi);
|
||||
return jsgraph()->graph()->NewNode(
|
||||
jsgraph()->common()->DeadValue(MachineRepresentation::kWord64),
|
||||
unreachable);
|
||||
} else if (IsWord(output_rep)) {
|
||||
if (output_type.Is(Type::Unsigned32())) {
|
||||
op = machine()->ChangeUint32ToUint64();
|
||||
|
@ -692,8 +692,6 @@ TEST(Nops) {
|
||||
MachineRepresentation::kWord16);
|
||||
r.CheckNop(MachineRepresentation::kBit, Type::Boolean(),
|
||||
MachineRepresentation::kWord32);
|
||||
r.CheckNop(MachineRepresentation::kBit, Type::Boolean(),
|
||||
MachineRepresentation::kWord64);
|
||||
}
|
||||
|
||||
|
||||
|
17
test/mjsunit/regress/regress-crbug-937649.js
Normal file
17
test/mjsunit/regress/regress-crbug-937649.js
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2019 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
|
||||
|
||||
(function() {
|
||||
function foo(x) {
|
||||
const i = x > 0;
|
||||
const dv = new DataView(ab);
|
||||
return dv.getUint16(i);
|
||||
}
|
||||
const ab = new ArrayBuffer(2);
|
||||
foo(0);
|
||||
foo(0);
|
||||
%OptimizeFunctionOnNextCall(foo);
|
||||
foo(0);
|
||||
})();
|
Loading…
Reference in New Issue
Block a user