| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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-native-context-specialization.h" | 5 #include "src/compiler/js-native-context-specialization.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.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 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 index = effect = graph()->NewNode(simplified()->CheckBounds(), index, | 1151 index = effect = graph()->NewNode(simplified()->CheckBounds(), index, |
| 1152 jsgraph()->Constant(Smi::kMaxValue), | 1152 jsgraph()->Constant(Smi::kMaxValue), |
| 1153 effect, control); | 1153 effect, control); |
| 1154 } else { | 1154 } else { |
| 1155 // Check that the {index} is in the valid range for the {receiver}. | 1155 // Check that the {index} is in the valid range for the {receiver}. |
| 1156 index = effect = graph()->NewNode(simplified()->CheckBounds(), index, | 1156 index = effect = graph()->NewNode(simplified()->CheckBounds(), index, |
| 1157 length, effect, control); | 1157 length, effect, control); |
| 1158 } | 1158 } |
| 1159 | 1159 |
| 1160 // Compute the element access. | 1160 // Compute the element access. |
| 1161 Type* element_type = Type::Any(); | 1161 Type* element_type = Type::NonInternal(); |
| 1162 MachineType element_machine_type = MachineType::AnyTagged(); | 1162 MachineType element_machine_type = MachineType::AnyTagged(); |
| 1163 if (IsFastDoubleElementsKind(elements_kind)) { | 1163 if (IsFastDoubleElementsKind(elements_kind)) { |
| 1164 element_type = Type::Number(); | 1164 element_type = Type::Number(); |
| 1165 element_machine_type = MachineType::Float64(); | 1165 element_machine_type = MachineType::Float64(); |
| 1166 } else if (IsFastSmiElementsKind(elements_kind)) { | 1166 } else if (IsFastSmiElementsKind(elements_kind)) { |
| 1167 element_type = type_cache_.kSmi; | 1167 element_type = type_cache_.kSmi; |
| 1168 } | 1168 } |
| 1169 ElementAccess element_access = {kTaggedBase, FixedArray::kHeaderSize, | 1169 ElementAccess element_access = {kTaggedBase, FixedArray::kHeaderSize, |
| 1170 element_type, element_machine_type, | 1170 element_type, element_machine_type, |
| 1171 kFullWriteBarrier}; | 1171 kFullWriteBarrier}; |
| 1172 | 1172 |
| 1173 // Access the actual element. | 1173 // Access the actual element. |
| 1174 if (access_mode == AccessMode::kLoad) { | 1174 if (access_mode == AccessMode::kLoad) { |
| 1175 // Compute the real element access type, which includes the hole in case | 1175 // Compute the real element access type, which includes the hole in case |
| 1176 // of holey backing stores. | 1176 // of holey backing stores. |
| 1177 if (elements_kind == FAST_HOLEY_ELEMENTS || | 1177 if (elements_kind == FAST_HOLEY_ELEMENTS || |
| 1178 elements_kind == FAST_HOLEY_SMI_ELEMENTS) { | 1178 elements_kind == FAST_HOLEY_SMI_ELEMENTS) { |
| 1179 element_access.type = Type::Union( | 1179 element_access.type = |
| 1180 element_type, | 1180 Type::Union(element_type, Type::Hole(), graph()->zone()); |
| 1181 Type::Constant(factory()->the_hole_value(), graph()->zone()), | |
| 1182 graph()->zone()); | |
| 1183 } | 1181 } |
| 1184 // Perform the actual backing store access. | 1182 // Perform the actual backing store access. |
| 1185 value = effect = | 1183 value = effect = |
| 1186 graph()->NewNode(simplified()->LoadElement(element_access), elements, | 1184 graph()->NewNode(simplified()->LoadElement(element_access), elements, |
| 1187 index, effect, control); | 1185 index, effect, control); |
| 1188 // Handle loading from holey backing stores correctly, by either mapping | 1186 // Handle loading from holey backing stores correctly, by either mapping |
| 1189 // the hole to undefined if possible, or deoptimizing otherwise. | 1187 // the hole to undefined if possible, or deoptimizing otherwise. |
| 1190 if (elements_kind == FAST_HOLEY_ELEMENTS || | 1188 if (elements_kind == FAST_HOLEY_ELEMENTS || |
| 1191 elements_kind == FAST_HOLEY_SMI_ELEMENTS) { | 1189 elements_kind == FAST_HOLEY_SMI_ELEMENTS) { |
| 1192 // Perform the hole check on the result. | |
| 1193 CheckTaggedHoleMode mode = CheckTaggedHoleMode::kNeverReturnHole; | |
| 1194 // Check if we are allowed to turn the hole into undefined. | 1190 // Check if we are allowed to turn the hole into undefined. |
| 1195 if (CanTreatHoleAsUndefined(receiver_maps, native_context)) { | 1191 if (CanTreatHoleAsUndefined(receiver_maps, native_context)) { |
| 1196 // Turn the hole into undefined. | 1192 // Turn the hole into undefined. |
| 1197 mode = CheckTaggedHoleMode::kConvertHoleToUndefined; | 1193 value = graph()->NewNode(simplified()->ConvertTaggedHoleToUndefined(), |
| 1194 value); |
| 1195 } else { |
| 1196 // Bailout if we see the hole. |
| 1197 value = effect = graph()->NewNode(simplified()->CheckTaggedHole(), |
| 1198 value, effect, control); |
| 1198 } | 1199 } |
| 1199 value = effect = graph()->NewNode(simplified()->CheckTaggedHole(mode), | |
| 1200 value, effect, control); | |
| 1201 } else if (elements_kind == FAST_HOLEY_DOUBLE_ELEMENTS) { | 1200 } else if (elements_kind == FAST_HOLEY_DOUBLE_ELEMENTS) { |
| 1202 // Perform the hole check on the result. | 1201 // Perform the hole check on the result. |
| 1203 CheckFloat64HoleMode mode = CheckFloat64HoleMode::kNeverReturnHole; | 1202 CheckFloat64HoleMode mode = CheckFloat64HoleMode::kNeverReturnHole; |
| 1204 // Check if we are allowed to return the hole directly. | 1203 // Check if we are allowed to return the hole directly. |
| 1205 if (CanTreatHoleAsUndefined(receiver_maps, native_context)) { | 1204 if (CanTreatHoleAsUndefined(receiver_maps, native_context)) { |
| 1206 // Return the signaling NaN hole directly if all uses are truncating. | 1205 // Return the signaling NaN hole directly if all uses are truncating. |
| 1207 mode = CheckFloat64HoleMode::kAllowReturnHole; | 1206 mode = CheckFloat64HoleMode::kAllowReturnHole; |
| 1208 } | 1207 } |
| 1209 value = effect = graph()->NewNode(simplified()->CheckFloat64Hole(mode), | 1208 value = effect = graph()->NewNode(simplified()->CheckFloat64Hole(mode), |
| 1210 value, effect, control); | 1209 value, effect, control); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 } | 1483 } |
| 1485 | 1484 |
| 1486 | 1485 |
| 1487 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { | 1486 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { |
| 1488 return jsgraph()->simplified(); | 1487 return jsgraph()->simplified(); |
| 1489 } | 1488 } |
| 1490 | 1489 |
| 1491 } // namespace compiler | 1490 } // namespace compiler |
| 1492 } // namespace internal | 1491 } // namespace internal |
| 1493 } // namespace v8 | 1492 } // namespace v8 |
| OLD | NEW |