| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 void HGraphBuilder::AddSimulate(BailoutId id, | 971 void HGraphBuilder::AddSimulate(BailoutId id, |
| 972 RemovableSimulate removable) { | 972 RemovableSimulate removable) { |
| 973 ASSERT(current_block() != NULL); | 973 ASSERT(current_block() != NULL); |
| 974 ASSERT(no_side_effects_scope_count_ == 0); | 974 ASSERT(no_side_effects_scope_count_ == 0); |
| 975 current_block()->AddSimulate(id, removable); | 975 current_block()->AddSimulate(id, removable); |
| 976 } | 976 } |
| 977 | 977 |
| 978 | 978 |
| 979 HBoundsCheck* HGraphBuilder::AddBoundsCheck(HValue* index, | 979 HBoundsCheck* HGraphBuilder::AddBoundsCheck(HValue* index, |
| 980 HValue* length, | 980 HValue* length, |
| 981 BoundsCheckKeyMode key_mode, | 981 BoundsCheckKeyMode key_mode) { |
| 982 Representation r) { | |
| 983 HBoundsCheck* result = new(graph()->zone()) HBoundsCheck( | 982 HBoundsCheck* result = new(graph()->zone()) HBoundsCheck( |
| 984 index, length, key_mode, r); | 983 index, length, key_mode); |
| 985 AddInstruction(result); | 984 AddInstruction(result); |
| 986 return result; | 985 return result; |
| 987 } | 986 } |
| 988 | 987 |
| 989 | 988 |
| 990 HReturn* HGraphBuilder::AddReturn(HValue* value) { | 989 HReturn* HGraphBuilder::AddReturn(HValue* value) { |
| 991 HValue* context = environment()->LookupContext(); | 990 HValue* context = environment()->LookupContext(); |
| 992 int num_parameters = graph()->info()->num_parameters(); | 991 int num_parameters = graph()->info()->num_parameters(); |
| 993 HValue* params = AddInstruction(new(graph()->zone()) | 992 HValue* params = AddInstruction(new(graph()->zone()) |
| 994 HConstant(num_parameters, Representation::Integer32())); | 993 HConstant(num_parameters, Representation::Integer32())); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 | 1213 |
| 1215 HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess( | 1214 HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess( |
| 1216 HValue* object, | 1215 HValue* object, |
| 1217 HValue* key, | 1216 HValue* key, |
| 1218 HValue* val, | 1217 HValue* val, |
| 1219 HCheckMaps* mapcheck, | 1218 HCheckMaps* mapcheck, |
| 1220 bool is_js_array, | 1219 bool is_js_array, |
| 1221 ElementsKind elements_kind, | 1220 ElementsKind elements_kind, |
| 1222 bool is_store, | 1221 bool is_store, |
| 1223 LoadKeyedHoleMode load_mode, | 1222 LoadKeyedHoleMode load_mode, |
| 1224 KeyedAccessStoreMode store_mode, | 1223 KeyedAccessStoreMode store_mode) { |
| 1225 Representation checked_index_representation) { | |
| 1226 ASSERT(!IsExternalArrayElementsKind(elements_kind) || !is_js_array); | 1224 ASSERT(!IsExternalArrayElementsKind(elements_kind) || !is_js_array); |
| 1227 Zone* zone = this->zone(); | 1225 Zone* zone = this->zone(); |
| 1228 // No GVNFlag is necessary for ElementsKind if there is an explicit dependency | 1226 // No GVNFlag is necessary for ElementsKind if there is an explicit dependency |
| 1229 // on a HElementsTransition instruction. The flag can also be removed if the | 1227 // on a HElementsTransition instruction. The flag can also be removed if the |
| 1230 // map to check has FAST_HOLEY_ELEMENTS, since there can be no further | 1228 // map to check has FAST_HOLEY_ELEMENTS, since there can be no further |
| 1231 // ElementsKind transitions. Finally, the dependency can be removed for stores | 1229 // ElementsKind transitions. Finally, the dependency can be removed for stores |
| 1232 // for FAST_ELEMENTS, since a transition to HOLEY elements won't change the | 1230 // for FAST_ELEMENTS, since a transition to HOLEY elements won't change the |
| 1233 // generated store code. | 1231 // generated store code. |
| 1234 if ((elements_kind == FAST_HOLEY_ELEMENTS) || | 1232 if ((elements_kind == FAST_HOLEY_ELEMENTS) || |
| 1235 (elements_kind == FAST_ELEMENTS && is_store)) { | 1233 (elements_kind == FAST_ELEMENTS && is_store)) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 negative_checker.Then(); | 1269 negative_checker.Then(); |
| 1272 HInstruction* result = BuildExternalArrayElementAccess( | 1270 HInstruction* result = BuildExternalArrayElementAccess( |
| 1273 external_elements, key, val, bounds_check, | 1271 external_elements, key, val, bounds_check, |
| 1274 elements_kind, is_store); | 1272 elements_kind, is_store); |
| 1275 AddInstruction(result); | 1273 AddInstruction(result); |
| 1276 negative_checker.ElseDeopt(); | 1274 negative_checker.ElseDeopt(); |
| 1277 length_checker.End(); | 1275 length_checker.End(); |
| 1278 return result; | 1276 return result; |
| 1279 } else { | 1277 } else { |
| 1280 ASSERT(store_mode == STANDARD_STORE); | 1278 ASSERT(store_mode == STANDARD_STORE); |
| 1281 checked_key = AddBoundsCheck( | 1279 checked_key = AddBoundsCheck(key, length, ALLOW_SMI_KEY); |
| 1282 key, length, ALLOW_SMI_KEY, checked_index_representation); | |
| 1283 HLoadExternalArrayPointer* external_elements = | 1280 HLoadExternalArrayPointer* external_elements = |
| 1284 new(zone) HLoadExternalArrayPointer(elements); | 1281 new(zone) HLoadExternalArrayPointer(elements); |
| 1285 AddInstruction(external_elements); | 1282 AddInstruction(external_elements); |
| 1286 return AddInstruction(BuildExternalArrayElementAccess( | 1283 return AddInstruction(BuildExternalArrayElementAccess( |
| 1287 external_elements, checked_key, val, mapcheck, | 1284 external_elements, checked_key, val, mapcheck, |
| 1288 elements_kind, is_store)); | 1285 elements_kind, is_store)); |
| 1289 } | 1286 } |
| 1290 } | 1287 } |
| 1291 ASSERT(fast_smi_only_elements || | 1288 ASSERT(fast_smi_only_elements || |
| 1292 fast_elements || | 1289 fast_elements || |
| 1293 IsFastDoubleElementsKind(elements_kind)); | 1290 IsFastDoubleElementsKind(elements_kind)); |
| 1294 | 1291 |
| 1295 if (is_store && IsFastSmiElementsKind(elements_kind) && | 1292 if (is_store && IsFastSmiElementsKind(elements_kind) && |
| 1296 !val->type().IsSmi()) { | 1293 !val->type().IsSmi()) { |
| 1297 AddInstruction(new(zone) HCheckSmi(val)); | 1294 AddInstruction(new(zone) HCheckSmi(val)); |
| 1298 } | 1295 } |
| 1299 | 1296 |
| 1300 if (IsGrowStoreMode(store_mode)) { | 1297 if (IsGrowStoreMode(store_mode)) { |
| 1301 NoObservableSideEffectsScope no_effects(this); | 1298 NoObservableSideEffectsScope no_effects(this); |
| 1302 | 1299 |
| 1303 elements = BuildCheckForCapacityGrow(object, elements, elements_kind, | 1300 elements = BuildCheckForCapacityGrow(object, elements, elements_kind, |
| 1304 length, key, is_js_array); | 1301 length, key, is_js_array); |
| 1305 checked_key = key; | 1302 checked_key = key; |
| 1306 } else { | 1303 } else { |
| 1307 checked_key = AddBoundsCheck( | 1304 checked_key = AddBoundsCheck(key, length, ALLOW_SMI_KEY); |
| 1308 key, length, ALLOW_SMI_KEY, checked_index_representation); | |
| 1309 | 1305 |
| 1310 if (is_store && (fast_elements || fast_smi_only_elements)) { | 1306 if (is_store && (fast_elements || fast_smi_only_elements)) { |
| 1311 if (store_mode == STORE_NO_TRANSITION_HANDLE_COW) { | 1307 if (store_mode == STORE_NO_TRANSITION_HANDLE_COW) { |
| 1312 NoObservableSideEffectsScope no_effects(this); | 1308 NoObservableSideEffectsScope no_effects(this); |
| 1313 | 1309 |
| 1314 elements = BuildCopyElementsOnWrite(object, elements, elements_kind, | 1310 elements = BuildCopyElementsOnWrite(object, elements, elements_kind, |
| 1315 length); | 1311 length); |
| 1316 } else { | 1312 } else { |
| 1317 HCheckMaps* check_cow_map = HCheckMaps::New( | 1313 HCheckMaps* check_cow_map = HCheckMaps::New( |
| 1318 elements, isolate()->factory()->fixed_array_map(), zone); | 1314 elements, isolate()->factory()->fixed_array_map(), zone); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 Heap* heap = isolate()->heap(); | 1466 Heap* heap = isolate()->heap(); |
| 1471 int element_size = IsFastDoubleElementsKind(kind) ? kDoubleSize | 1467 int element_size = IsFastDoubleElementsKind(kind) ? kDoubleSize |
| 1472 : kPointerSize; | 1468 : kPointerSize; |
| 1473 int max_size = heap->MaxNewSpaceAllocationSize() / element_size; | 1469 int max_size = heap->MaxNewSpaceAllocationSize() / element_size; |
| 1474 max_size -= JSArray::kSize / element_size; | 1470 max_size -= JSArray::kSize / element_size; |
| 1475 HConstant* max_size_constant = | 1471 HConstant* max_size_constant = |
| 1476 new(zone) HConstant(max_size, Representation::Integer32()); | 1472 new(zone) HConstant(max_size, Representation::Integer32()); |
| 1477 AddInstruction(max_size_constant); | 1473 AddInstruction(max_size_constant); |
| 1478 // Since we're forcing Integer32 representation for this HBoundsCheck, | 1474 // Since we're forcing Integer32 representation for this HBoundsCheck, |
| 1479 // there's no need to Smi-check the index. | 1475 // there's no need to Smi-check the index. |
| 1480 AddInstruction(new(zone) | 1476 AddInstruction(new(zone) HBoundsCheck( |
| 1481 HBoundsCheck(length, max_size_constant, | 1477 length, max_size_constant, DONT_ALLOW_SMI_KEY)); |
| 1482 DONT_ALLOW_SMI_KEY, Representation::Integer32())); | |
| 1483 } | 1478 } |
| 1484 | 1479 |
| 1485 | 1480 |
| 1486 HValue* HGraphBuilder::BuildGrowElementsCapacity(HValue* object, | 1481 HValue* HGraphBuilder::BuildGrowElementsCapacity(HValue* object, |
| 1487 HValue* elements, | 1482 HValue* elements, |
| 1488 ElementsKind kind, | 1483 ElementsKind kind, |
| 1489 HValue* length, | 1484 HValue* length, |
| 1490 HValue* new_capacity) { | 1485 HValue* new_capacity) { |
| 1491 HValue* context = environment()->LookupContext(); | 1486 HValue* context = environment()->LookupContext(); |
| 1492 | 1487 |
| (...skipping 10850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12343 } | 12338 } |
| 12344 } | 12339 } |
| 12345 | 12340 |
| 12346 #ifdef DEBUG | 12341 #ifdef DEBUG |
| 12347 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 12342 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 12348 if (allocator_ != NULL) allocator_->Verify(); | 12343 if (allocator_ != NULL) allocator_->Verify(); |
| 12349 #endif | 12344 #endif |
| 12350 } | 12345 } |
| 12351 | 12346 |
| 12352 } } // namespace v8::internal | 12347 } } // namespace v8::internal |
| OLD | NEW |