Commit 80a7be5c authored by jarin's avatar jarin Committed by Commit bot

Restrict representation inference to avoid truncation of phi inputs.

BUG=chromium:446778
LOG=N

Review URL: https://codereview.chromium.org/837153002

Cr-Commit-Position: refs/heads/master@{#25967}
parent c71239dc
...@@ -307,8 +307,8 @@ class RepresentationSelector { ...@@ -307,8 +307,8 @@ class RepresentationSelector {
if ((use & kRepMask) == kRepTagged) { if ((use & kRepMask) == kRepTagged) {
// only tagged uses. // only tagged uses.
return kRepTagged; return kRepTagged;
} else if (IsSafeIntAdditiveOperand(node)) { } else if (upper->Is(Type::Integral32())) {
// Integer within [-2^52, 2^52] range. // Integer within [-2^31, 2^32[ range.
if ((use & kRepMask) == kRepFloat64) { if ((use & kRepMask) == kRepFloat64) {
// only float64 uses. // only float64 uses.
return kRepFloat64; return kRepFloat64;
...@@ -318,7 +318,7 @@ class RepresentationSelector { ...@@ -318,7 +318,7 @@ class RepresentationSelector {
} else if ((use & kRepMask) == kRepWord32 || } else if ((use & kRepMask) == kRepWord32 ||
(use & kTypeMask) == kTypeInt32 || (use & kTypeMask) == kTypeInt32 ||
(use & kTypeMask) == kTypeUint32) { (use & kTypeMask) == kTypeUint32) {
// The type is a safe integer, but we only use 32 bits. // We only use 32 bits or we use the result consistently.
return kRepWord32; return kRepWord32;
} else { } else {
return kRepFloat64; return kRepFloat64;
......
...@@ -2037,11 +2037,6 @@ TEST(PhiRepresentation) { ...@@ -2037,11 +2037,6 @@ TEST(PhiRepresentation) {
HandleAndZoneScope scope; HandleAndZoneScope scope;
Zone* z = scope.main_zone(); Zone* z = scope.main_zone();
Factory* f = z->isolate()->factory();
Handle<Object> range_min = f->NewNumber(-1e13);
Handle<Object> range_max = f->NewNumber(1e+15);
Type* range = Type::Range(range_min, range_max, z);
struct TestData { struct TestData {
Type* arg1; Type* arg1;
Type* arg2; Type* arg2;
...@@ -2052,7 +2047,8 @@ TEST(PhiRepresentation) { ...@@ -2052,7 +2047,8 @@ TEST(PhiRepresentation) {
TestData test_data[] = { TestData test_data[] = {
{Type::Signed32(), Type::Unsigned32(), kMachInt32, {Type::Signed32(), Type::Unsigned32(), kMachInt32,
kRepWord32 | kTypeNumber}, kRepWord32 | kTypeNumber},
{range, range, kMachUint32, kRepWord32 | kTypeNumber}, {Type::Signed32(), Type::Unsigned32(), kMachUint32,
kRepWord32 | kTypeNumber},
{Type::Signed32(), Type::Signed32(), kMachInt32, kMachInt32}, {Type::Signed32(), Type::Signed32(), kMachInt32, kMachInt32},
{Type::Unsigned32(), Type::Unsigned32(), kMachInt32, kMachUint32}, {Type::Unsigned32(), Type::Unsigned32(), kMachInt32, kMachUint32},
{Type::Number(), Type::Signed32(), kMachInt32, kMachFloat64}, {Type::Number(), Type::Signed32(), kMachInt32, kMachFloat64},
......
// Copyright 2015 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.
function Module() {
"use asm";
function f() {
var i = (140737463189505);
do {
i = i + i | 0;
x = undefined + i | 0;
} while (!i);
}
return { f: f };
}
Module().f();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment