Commit c17b44bd authored by verwaest's avatar verwaest Committed by Commit bot

Fix double canonicalization

This turns the blacklist back into a white-list adding all binary operations as allowed operations. The one known fix is that it forces canonicalization of the double-hole as double constant.

BUG=chromium:621147

Review-Url: https://codereview.chromium.org/2106393002
Cr-Commit-Position: refs/heads/master@{#37452}
parent 5a8cfaf0
...@@ -2194,7 +2194,11 @@ HConstant::HConstant(Handle<Object> object, Representation r) ...@@ -2194,7 +2194,11 @@ HConstant::HConstant(Handle<Object> object, Representation r)
int32_value_ = DoubleToInt32(n); int32_value_ = DoubleToInt32(n);
bit_field_ = HasSmiValueField::update( bit_field_ = HasSmiValueField::update(
bit_field_, has_int32_value && Smi::IsValid(int32_value_)); bit_field_, has_int32_value && Smi::IsValid(int32_value_));
double_value_ = n; if (std::isnan(n)) {
double_value_ = std::numeric_limits<double>::quiet_NaN();
} else {
double_value_ = n;
}
bit_field_ = HasDoubleValueField::update(bit_field_, true); bit_field_ = HasDoubleValueField::update(bit_field_, true);
} }
...@@ -2247,7 +2251,6 @@ HConstant::HConstant(int32_t integer_value, Representation r, ...@@ -2247,7 +2251,6 @@ HConstant::HConstant(int32_t integer_value, Representation r,
Initialize(r); Initialize(r);
} }
HConstant::HConstant(double double_value, Representation r, HConstant::HConstant(double double_value, Representation r,
bool is_not_in_new_space, Unique<Object> object) bool is_not_in_new_space, Unique<Object> object)
: object_(object), : object_(object),
...@@ -2261,8 +2264,7 @@ HConstant::HConstant(double double_value, Representation r, ...@@ -2261,8 +2264,7 @@ HConstant::HConstant(double double_value, Representation r,
!std::isnan(double_value)) | !std::isnan(double_value)) |
IsUndetectableField::encode(false) | IsUndetectableField::encode(false) |
InstanceTypeField::encode(kUnknownInstanceType)), InstanceTypeField::encode(kUnknownInstanceType)),
int32_value_(DoubleToInt32(double_value)), int32_value_(DoubleToInt32(double_value)) {
double_value_(double_value) {
bit_field_ = HasSmiValueField::update( bit_field_ = HasSmiValueField::update(
bit_field_, HasInteger32Value() && Smi::IsValid(int32_value_)); bit_field_, HasInteger32Value() && Smi::IsValid(int32_value_));
// It's possible to create a constant with a value in Smi-range but stored // It's possible to create a constant with a value in Smi-range but stored
...@@ -2270,6 +2272,11 @@ HConstant::HConstant(double double_value, Representation r, ...@@ -2270,6 +2272,11 @@ HConstant::HConstant(double double_value, Representation r,
bool could_be_heapobject = r.IsTagged() && !object.handle().is_null(); bool could_be_heapobject = r.IsTagged() && !object.handle().is_null();
bool is_smi = HasSmiValue() && !could_be_heapobject; bool is_smi = HasSmiValue() && !could_be_heapobject;
set_type(is_smi ? HType::Smi() : HType::TaggedNumber()); set_type(is_smi ? HType::Smi() : HType::TaggedNumber());
if (std::isnan(double_value)) {
double_value_ = std::numeric_limits<double>::quiet_NaN();
} else {
double_value_ = double_value;
}
Initialize(r); Initialize(r);
} }
...@@ -3288,13 +3295,11 @@ bool HStoreKeyed::NeedsCanonicalization() { ...@@ -3288,13 +3295,11 @@ bool HStoreKeyed::NeedsCanonicalization() {
Representation from = HChange::cast(value())->from(); Representation from = HChange::cast(value())->from();
return from.IsTagged() || from.IsHeapObject(); return from.IsTagged() || from.IsHeapObject();
} }
case kLoadNamedField: case kConstant:
case kPhi: { // Double constants are canonicalized upon construction.
// Better safe than sorry...
return true;
}
default:
return false; return false;
default:
return !value()->IsBinaryOperation();
} }
} }
......
// Copyright 2016 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
var ab = new ArrayBuffer(8);
var i_view = new Int32Array(ab);
i_view[0] = %GetHoleNaNUpper()
i_view[1] = %GetHoleNaNLower();
var hole_nan = (new Float64Array(ab))[0];
var array = [];
function write() {
array[0] = hole_nan;
}
write();
%OptimizeFunctionOnNextCall(write);
write();
array[1] = undefined;
assertTrue(isNaN(array[0]));
assertEquals("number", typeof array[0]);
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