| 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 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 PretenureFlag pretenure) { | 1096 PretenureFlag pretenure) { |
| 1097 DCHECK_LE(1, capacity); | 1097 DCHECK_LE(1, capacity); |
| 1098 DCHECK_LE(capacity, JSArray::kInitialMaxFastElementArray); | 1098 DCHECK_LE(capacity, JSArray::kInitialMaxFastElementArray); |
| 1099 | 1099 |
| 1100 Handle<Map> elements_map = IsFastDoubleElementsKind(elements_kind) | 1100 Handle<Map> elements_map = IsFastDoubleElementsKind(elements_kind) |
| 1101 ? factory()->fixed_double_array_map() | 1101 ? factory()->fixed_double_array_map() |
| 1102 : factory()->fixed_array_map(); | 1102 : factory()->fixed_array_map(); |
| 1103 ElementAccess access = IsFastDoubleElementsKind(elements_kind) | 1103 ElementAccess access = IsFastDoubleElementsKind(elements_kind) |
| 1104 ? AccessBuilder::ForFixedDoubleArrayElement() | 1104 ? AccessBuilder::ForFixedDoubleArrayElement() |
| 1105 : AccessBuilder::ForFixedArrayElement(); | 1105 : AccessBuilder::ForFixedArrayElement(); |
| 1106 Node* value; | 1106 Node* value = jsgraph()->TheHoleConstant(); |
| 1107 if (IsFastDoubleElementsKind(elements_kind)) { | |
| 1108 // Load the hole NaN pattern from the canonical location. | |
| 1109 value = effect = graph()->NewNode( | |
| 1110 simplified()->LoadField(AccessBuilder::ForExternalDoubleValue()), | |
| 1111 jsgraph()->ExternalConstant( | |
| 1112 ExternalReference::address_of_the_hole_nan()), | |
| 1113 effect, control); | |
| 1114 } else { | |
| 1115 value = jsgraph()->TheHoleConstant(); | |
| 1116 } | |
| 1117 | 1107 |
| 1118 // Actually allocate the backing store. | 1108 // Actually allocate the backing store. |
| 1119 AllocationBuilder a(jsgraph(), effect, control); | 1109 AllocationBuilder a(jsgraph(), effect, control); |
| 1120 a.AllocateArray(capacity, elements_map, pretenure); | 1110 a.AllocateArray(capacity, elements_map, pretenure); |
| 1121 for (int i = 0; i < capacity; ++i) { | 1111 for (int i = 0; i < capacity; ++i) { |
| 1122 Node* index = jsgraph()->Constant(i); | 1112 Node* index = jsgraph()->Constant(i); |
| 1123 a.Store(access, index, value); | 1113 a.Store(access, index, value); |
| 1124 } | 1114 } |
| 1125 return a.Finish(); | 1115 return a.Finish(); |
| 1126 } | 1116 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1254 return jsgraph()->HeapConstant(boilerplate_elements); | 1244 return jsgraph()->HeapConstant(boilerplate_elements); |
| 1255 } | 1245 } |
| 1256 | 1246 |
| 1257 // Compute the elements to store first (might have effects). | 1247 // Compute the elements to store first (might have effects). |
| 1258 int const elements_length = boilerplate_elements->length(); | 1248 int const elements_length = boilerplate_elements->length(); |
| 1259 Handle<Map> elements_map(boilerplate_elements->map(), isolate()); | 1249 Handle<Map> elements_map(boilerplate_elements->map(), isolate()); |
| 1260 ZoneVector<Node*> elements_values(elements_length, zone()); | 1250 ZoneVector<Node*> elements_values(elements_length, zone()); |
| 1261 if (elements_map->instance_type() == FIXED_DOUBLE_ARRAY_TYPE) { | 1251 if (elements_map->instance_type() == FIXED_DOUBLE_ARRAY_TYPE) { |
| 1262 Handle<FixedDoubleArray> elements = | 1252 Handle<FixedDoubleArray> elements = |
| 1263 Handle<FixedDoubleArray>::cast(boilerplate_elements); | 1253 Handle<FixedDoubleArray>::cast(boilerplate_elements); |
| 1264 Node* the_hole_value = nullptr; | |
| 1265 for (int i = 0; i < elements_length; ++i) { | 1254 for (int i = 0; i < elements_length; ++i) { |
| 1266 if (elements->is_the_hole(i)) { | 1255 if (elements->is_the_hole(i)) { |
| 1267 if (the_hole_value == nullptr) { | 1256 elements_values[i] = jsgraph()->TheHoleConstant(); |
| 1268 // Load the hole NaN pattern from the canonical location. | |
| 1269 the_hole_value = effect = graph()->NewNode( | |
| 1270 simplified()->LoadField(AccessBuilder::ForExternalDoubleValue()), | |
| 1271 jsgraph()->ExternalConstant( | |
| 1272 ExternalReference::address_of_the_hole_nan()), | |
| 1273 effect, control); | |
| 1274 } | |
| 1275 elements_values[i] = the_hole_value; | |
| 1276 } else { | 1257 } else { |
| 1277 elements_values[i] = jsgraph()->Constant(elements->get_scalar(i)); | 1258 elements_values[i] = jsgraph()->Constant(elements->get_scalar(i)); |
| 1278 } | 1259 } |
| 1279 } | 1260 } |
| 1280 } else { | 1261 } else { |
| 1281 Handle<FixedArray> elements = | 1262 Handle<FixedArray> elements = |
| 1282 Handle<FixedArray>::cast(boilerplate_elements); | 1263 Handle<FixedArray>::cast(boilerplate_elements); |
| 1283 for (int i = 0; i < elements_length; ++i) { | 1264 for (int i = 0; i < elements_length; ++i) { |
| 1284 if (elements->is_the_hole(isolate(), i)) { | 1265 if (elements->is_the_hole(isolate(), i)) { |
| 1285 elements_values[i] = jsgraph()->TheHoleConstant(); | 1266 elements_values[i] = jsgraph()->TheHoleConstant(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 return jsgraph()->simplified(); | 1335 return jsgraph()->simplified(); |
| 1355 } | 1336 } |
| 1356 | 1337 |
| 1357 MachineOperatorBuilder* JSCreateLowering::machine() const { | 1338 MachineOperatorBuilder* JSCreateLowering::machine() const { |
| 1358 return jsgraph()->machine(); | 1339 return jsgraph()->machine(); |
| 1359 } | 1340 } |
| 1360 | 1341 |
| 1361 } // namespace compiler | 1342 } // namespace compiler |
| 1362 } // namespace internal | 1343 } // namespace internal |
| 1363 } // namespace v8 | 1344 } // namespace v8 |
| OLD | NEW |