OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/js-create-lowering.h" | 5 #include "src/compiler/js-create-lowering.h" |
6 | 6 |
7 #include "src/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 PretenureFlag pretenure) { | 1006 PretenureFlag pretenure) { |
1007 DCHECK_LE(1, capacity); | 1007 DCHECK_LE(1, capacity); |
1008 DCHECK_LE(capacity, JSArray::kInitialMaxFastElementArray); | 1008 DCHECK_LE(capacity, JSArray::kInitialMaxFastElementArray); |
1009 | 1009 |
1010 Handle<Map> elements_map = IsFastDoubleElementsKind(elements_kind) | 1010 Handle<Map> elements_map = IsFastDoubleElementsKind(elements_kind) |
1011 ? factory()->fixed_double_array_map() | 1011 ? factory()->fixed_double_array_map() |
1012 : factory()->fixed_array_map(); | 1012 : factory()->fixed_array_map(); |
1013 ElementAccess access = IsFastDoubleElementsKind(elements_kind) | 1013 ElementAccess access = IsFastDoubleElementsKind(elements_kind) |
1014 ? AccessBuilder::ForFixedDoubleArrayElement() | 1014 ? AccessBuilder::ForFixedDoubleArrayElement() |
1015 : AccessBuilder::ForFixedArrayElement(); | 1015 : AccessBuilder::ForFixedArrayElement(); |
1016 Node* value = | 1016 Node* value; |
1017 IsFastDoubleElementsKind(elements_kind) | 1017 if (IsFastDoubleElementsKind(elements_kind)) { |
1018 ? jsgraph()->Float64Constant(bit_cast<double>(kHoleNanInt64)) | 1018 // Load the hole NaN pattern from the canonical location. |
1019 : jsgraph()->TheHoleConstant(); | 1019 value = effect = graph()->NewNode( |
| 1020 simplified()->LoadField(AccessBuilder::ForExternalDoubleValue()), |
| 1021 jsgraph()->ExternalConstant( |
| 1022 ExternalReference::address_of_the_hole_nan()), |
| 1023 effect, control); |
| 1024 } else { |
| 1025 value = jsgraph()->TheHoleConstant(); |
| 1026 } |
1020 | 1027 |
1021 // Actually allocate the backing store. | 1028 // Actually allocate the backing store. |
1022 AllocationBuilder a(jsgraph(), effect, control); | 1029 AllocationBuilder a(jsgraph(), effect, control); |
1023 a.AllocateArray(capacity, elements_map, pretenure); | 1030 a.AllocateArray(capacity, elements_map, pretenure); |
1024 for (int i = 0; i < capacity; ++i) { | 1031 for (int i = 0; i < capacity; ++i) { |
1025 Node* index = jsgraph()->Constant(i); | 1032 Node* index = jsgraph()->Constant(i); |
1026 a.Store(access, index, value); | 1033 a.Store(access, index, value); |
1027 } | 1034 } |
1028 return a.Finish(); | 1035 return a.Finish(); |
1029 } | 1036 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 return jsgraph()->HeapConstant(boilerplate_elements); | 1169 return jsgraph()->HeapConstant(boilerplate_elements); |
1163 } | 1170 } |
1164 | 1171 |
1165 // Compute the elements to store first (might have effects). | 1172 // Compute the elements to store first (might have effects). |
1166 int const elements_length = boilerplate_elements->length(); | 1173 int const elements_length = boilerplate_elements->length(); |
1167 Handle<Map> elements_map(boilerplate_elements->map(), isolate()); | 1174 Handle<Map> elements_map(boilerplate_elements->map(), isolate()); |
1168 ZoneVector<Node*> elements_values(elements_length, zone()); | 1175 ZoneVector<Node*> elements_values(elements_length, zone()); |
1169 if (elements_map->instance_type() == FIXED_DOUBLE_ARRAY_TYPE) { | 1176 if (elements_map->instance_type() == FIXED_DOUBLE_ARRAY_TYPE) { |
1170 Handle<FixedDoubleArray> elements = | 1177 Handle<FixedDoubleArray> elements = |
1171 Handle<FixedDoubleArray>::cast(boilerplate_elements); | 1178 Handle<FixedDoubleArray>::cast(boilerplate_elements); |
| 1179 Node* the_hole_value = nullptr; |
1172 for (int i = 0; i < elements_length; ++i) { | 1180 for (int i = 0; i < elements_length; ++i) { |
1173 if (elements->is_the_hole(i)) { | 1181 if (elements->is_the_hole(i)) { |
1174 // TODO(turbofan): We cannot currently safely pass thru the (signaling) | 1182 if (the_hole_value == nullptr) { |
1175 // hole NaN in C++ code, as the C++ compiler on Intel might use FPU | 1183 // Load the hole NaN pattern from the canonical location. |
1176 // instructions/registers for doubles and therefore make the NaN quiet. | 1184 the_hole_value = effect = graph()->NewNode( |
1177 // We should consider passing doubles in the compiler as raw int64 | 1185 simplified()->LoadField(AccessBuilder::ForExternalDoubleValue()), |
1178 // values to prevent this. | 1186 jsgraph()->ExternalConstant( |
1179 elements_values[i] = effect = | 1187 ExternalReference::address_of_the_hole_nan()), |
1180 graph()->NewNode(simplified()->LoadElement( | 1188 effect, control); |
1181 AccessBuilder::ForFixedDoubleArrayElement()), | 1189 } |
1182 jsgraph()->HeapConstant(elements), | 1190 elements_values[i] = the_hole_value; |
1183 jsgraph()->Constant(i), effect, control); | |
1184 } else { | 1191 } else { |
1185 elements_values[i] = jsgraph()->Constant(elements->get_scalar(i)); | 1192 elements_values[i] = jsgraph()->Constant(elements->get_scalar(i)); |
1186 } | 1193 } |
1187 } | 1194 } |
1188 } else { | 1195 } else { |
1189 Handle<FixedArray> elements = | 1196 Handle<FixedArray> elements = |
1190 Handle<FixedArray>::cast(boilerplate_elements); | 1197 Handle<FixedArray>::cast(boilerplate_elements); |
1191 for (int i = 0; i < elements_length; ++i) { | 1198 for (int i = 0; i < elements_length; ++i) { |
1192 if (elements->is_the_hole(i)) { | 1199 if (elements->is_the_hole(i)) { |
1193 elements_values[i] = jsgraph()->TheHoleConstant(); | 1200 elements_values[i] = jsgraph()->TheHoleConstant(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 return jsgraph()->simplified(); | 1269 return jsgraph()->simplified(); |
1263 } | 1270 } |
1264 | 1271 |
1265 MachineOperatorBuilder* JSCreateLowering::machine() const { | 1272 MachineOperatorBuilder* JSCreateLowering::machine() const { |
1266 return jsgraph()->machine(); | 1273 return jsgraph()->machine(); |
1267 } | 1274 } |
1268 | 1275 |
1269 } // namespace compiler | 1276 } // namespace compiler |
1270 } // namespace internal | 1277 } // namespace internal |
1271 } // namespace v8 | 1278 } // namespace v8 |
OLD | NEW |