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

Unified Diff: src/compiler/js-create-lowering.cc

Issue 2303643002: [turbofan] Don't treat the hole NaN as constant inside the compiler. (Closed)
Patch Set: Created 4 years, 4 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 | « src/compiler/access-builder.cc ('k') | test/mjsunit/regress/regress-5332.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-create-lowering.cc
diff --git a/src/compiler/js-create-lowering.cc b/src/compiler/js-create-lowering.cc
index f2c5edd630831aeb1c5e6dacd6baab9c29329f21..21997f7d5822fa84f082e9a02beb6e1776230a07 100644
--- a/src/compiler/js-create-lowering.cc
+++ b/src/compiler/js-create-lowering.cc
@@ -1013,10 +1013,17 @@ Node* JSCreateLowering::AllocateElements(Node* effect, Node* control,
ElementAccess access = IsFastDoubleElementsKind(elements_kind)
? AccessBuilder::ForFixedDoubleArrayElement()
: AccessBuilder::ForFixedArrayElement();
- Node* value =
- IsFastDoubleElementsKind(elements_kind)
- ? jsgraph()->Float64Constant(bit_cast<double>(kHoleNanInt64))
- : jsgraph()->TheHoleConstant();
+ Node* value;
+ if (IsFastDoubleElementsKind(elements_kind)) {
+ // Load the hole NaN pattern from the canonical location.
+ value = effect = graph()->NewNode(
+ simplified()->LoadField(AccessBuilder::ForExternalDoubleValue()),
+ jsgraph()->ExternalConstant(
+ ExternalReference::address_of_the_hole_nan()),
+ effect, control);
+ } else {
+ value = jsgraph()->TheHoleConstant();
+ }
// Actually allocate the backing store.
AllocationBuilder a(jsgraph(), effect, control);
@@ -1169,18 +1176,18 @@ Node* JSCreateLowering::AllocateFastLiteralElements(
if (elements_map->instance_type() == FIXED_DOUBLE_ARRAY_TYPE) {
Handle<FixedDoubleArray> elements =
Handle<FixedDoubleArray>::cast(boilerplate_elements);
+ Node* the_hole_value = nullptr;
for (int i = 0; i < elements_length; ++i) {
if (elements->is_the_hole(i)) {
- // TODO(turbofan): We cannot currently safely pass thru the (signaling)
- // hole NaN in C++ code, as the C++ compiler on Intel might use FPU
- // instructions/registers for doubles and therefore make the NaN quiet.
- // We should consider passing doubles in the compiler as raw int64
- // values to prevent this.
- elements_values[i] = effect =
- graph()->NewNode(simplified()->LoadElement(
- AccessBuilder::ForFixedDoubleArrayElement()),
- jsgraph()->HeapConstant(elements),
- jsgraph()->Constant(i), effect, control);
+ if (the_hole_value == nullptr) {
+ // Load the hole NaN pattern from the canonical location.
+ the_hole_value = effect = graph()->NewNode(
+ simplified()->LoadField(AccessBuilder::ForExternalDoubleValue()),
+ jsgraph()->ExternalConstant(
+ ExternalReference::address_of_the_hole_nan()),
+ effect, control);
+ }
+ elements_values[i] = the_hole_value;
} else {
elements_values[i] = jsgraph()->Constant(elements->get_scalar(i));
}
« no previous file with comments | « src/compiler/access-builder.cc ('k') | test/mjsunit/regress/regress-5332.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698