Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Unified Diff: src/crankshaft/hydrogen-instructions.cc

Issue 2115413002: [crankshaft] Use canonical nan_value or minus_zero_value objects instead of constant heap numbers w… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-625547.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/hydrogen-instructions.cc
diff --git a/src/crankshaft/hydrogen-instructions.cc b/src/crankshaft/hydrogen-instructions.cc
index 9947dee6d4b4a172c0c1abf5b317e53d1f5d5d6a..b8020c727064914dae35b8478b9be95be8bbee8b 100644
--- a/src/crankshaft/hydrogen-instructions.cc
+++ b/src/crankshaft/hydrogen-instructions.cc
@@ -2172,6 +2172,32 @@ HConstant::HConstant(Handle<Object> object, Representation r)
BooleanValueField::encode(object->BooleanValue()) |
IsUndetectableField::encode(false) | IsCallableField::encode(false) |
InstanceTypeField::encode(kUnknownInstanceType)) {
+ if (object->IsNumber()) {
+ double n = object->Number();
+ bool has_int32_value = IsInteger32(n);
+ bit_field_ = HasInt32ValueField::update(bit_field_, has_int32_value);
+ int32_value_ = DoubleToInt32(n);
+ bit_field_ = HasSmiValueField::update(
+ bit_field_, has_int32_value && Smi::IsValid(int32_value_));
+ if (std::isnan(n)) {
+ double_value_ = std::numeric_limits<double>::quiet_NaN();
+ // Canonicalize object with NaN value.
+ DCHECK(object->IsHeapObject()); // NaN can't be a Smi.
+ Isolate* isolate = HeapObject::cast(*object)->GetIsolate();
+ object = isolate->factory()->nan_value();
+ object_ = Unique<Object>::CreateUninitialized(object);
+ } else {
+ double_value_ = n;
+ // Canonicalize object with -0.0 value.
+ if (bit_cast<int64_t>(n) == bit_cast<int64_t>(-0.0)) {
+ DCHECK(object->IsHeapObject()); // -0.0 can't be a Smi.
+ Isolate* isolate = HeapObject::cast(*object)->GetIsolate();
+ object = isolate->factory()->minus_zero_value();
+ object_ = Unique<Object>::CreateUninitialized(object);
+ }
+ }
+ bit_field_ = HasDoubleValueField::update(bit_field_, true);
+ }
if (object->IsHeapObject()) {
Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object);
Isolate* isolate = heap_object->GetIsolate();
@@ -2187,20 +2213,6 @@ HConstant::HConstant(Handle<Object> object, Representation r)
bit_field_,
HasMapValue() && Handle<Map>::cast(heap_object)->is_stable());
}
- if (object->IsNumber()) {
- double n = object->Number();
- bool has_int32_value = IsInteger32(n);
- bit_field_ = HasInt32ValueField::update(bit_field_, has_int32_value);
- int32_value_ = DoubleToInt32(n);
- bit_field_ = HasSmiValueField::update(
- bit_field_, has_int32_value && Smi::IsValid(int32_value_));
- if (std::isnan(n)) {
- double_value_ = std::numeric_limits<double>::quiet_NaN();
- } else {
- double_value_ = n;
- }
- bit_field_ = HasDoubleValueField::update(bit_field_, true);
- }
Initialize(r);
}
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-625547.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698