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 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 // for FAST_ELEMENTS, since a transition to HOLEY elements won't change the | 1264 // for FAST_ELEMENTS, since a transition to HOLEY elements won't change the |
1265 // generated store code. | 1265 // generated store code. |
1266 if ((elements_kind == FAST_HOLEY_ELEMENTS) || | 1266 if ((elements_kind == FAST_HOLEY_ELEMENTS) || |
1267 (elements_kind == FAST_ELEMENTS && is_store)) { | 1267 (elements_kind == FAST_ELEMENTS && is_store)) { |
1268 if (mapcheck != NULL) { | 1268 if (mapcheck != NULL) { |
1269 mapcheck->ClearGVNFlag(kDependsOnElementsKind); | 1269 mapcheck->ClearGVNFlag(kDependsOnElementsKind); |
1270 } | 1270 } |
1271 } | 1271 } |
1272 bool fast_smi_only_elements = IsFastSmiElementsKind(elements_kind); | 1272 bool fast_smi_only_elements = IsFastSmiElementsKind(elements_kind); |
1273 bool fast_elements = IsFastObjectElementsKind(elements_kind); | 1273 bool fast_elements = IsFastObjectElementsKind(elements_kind); |
1274 HValue* elements = | 1274 HValue* elements = AddLoadElements(object, mapcheck); |
1275 AddInstruction(new(zone) HLoadElements(object, mapcheck)); | |
1276 if (is_store && (fast_elements || fast_smi_only_elements) && | 1275 if (is_store && (fast_elements || fast_smi_only_elements) && |
1277 store_mode != STORE_NO_TRANSITION_HANDLE_COW) { | 1276 store_mode != STORE_NO_TRANSITION_HANDLE_COW) { |
1278 HCheckMaps* check_cow_map = HCheckMaps::New( | 1277 HCheckMaps* check_cow_map = HCheckMaps::New( |
1279 elements, isolate()->factory()->fixed_array_map(), zone); | 1278 elements, isolate()->factory()->fixed_array_map(), zone); |
1280 check_cow_map->ClearGVNFlag(kDependsOnElementsKind); | 1279 check_cow_map->ClearGVNFlag(kDependsOnElementsKind); |
1281 AddInstruction(check_cow_map); | 1280 AddInstruction(check_cow_map); |
1282 } | 1281 } |
1283 HInstruction* length = NULL; | 1282 HInstruction* length = NULL; |
1284 if (is_js_array) { | 1283 if (is_js_array) { |
1285 length = AddInstruction( | 1284 length = AddInstruction( |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 | 1513 |
1515 HInstruction* HGraphBuilder::BuildStoreMap(HValue* object, | 1514 HInstruction* HGraphBuilder::BuildStoreMap(HValue* object, |
1516 Handle<Map> map) { | 1515 Handle<Map> map) { |
1517 Zone* zone = this->zone(); | 1516 Zone* zone = this->zone(); |
1518 HValue* map_constant = | 1517 HValue* map_constant = |
1519 AddInstruction(new(zone) HConstant(map, Representation::Tagged())); | 1518 AddInstruction(new(zone) HConstant(map, Representation::Tagged())); |
1520 return BuildStoreMap(object, map_constant); | 1519 return BuildStoreMap(object, map_constant); |
1521 } | 1520 } |
1522 | 1521 |
1523 | 1522 |
| 1523 HLoadNamedField* HGraphBuilder::AddLoadElements(HValue* object, |
| 1524 HValue* typecheck) { |
| 1525 HLoadNamedField* instr = new(zone()) HLoadNamedField(object, true, |
| 1526 Representation::Tagged(), JSObject::kElementsOffset, typecheck); |
| 1527 AddInstruction(instr); |
| 1528 instr->SetGVNFlag(kDependsOnElementsPointer); |
| 1529 instr->ClearGVNFlag(kDependsOnMaps); |
| 1530 instr->ClearGVNFlag(kDependsOnInobjectFields); |
| 1531 return instr; |
| 1532 } |
| 1533 |
| 1534 |
1524 HValue* HGraphBuilder::BuildNewElementsCapacity(HValue* context, | 1535 HValue* HGraphBuilder::BuildNewElementsCapacity(HValue* context, |
1525 HValue* old_capacity) { | 1536 HValue* old_capacity) { |
1526 Zone* zone = this->zone(); | 1537 Zone* zone = this->zone(); |
1527 HValue* half_old_capacity = | 1538 HValue* half_old_capacity = |
1528 AddInstruction(HShr::New(zone, context, old_capacity, | 1539 AddInstruction(HShr::New(zone, context, old_capacity, |
1529 graph_->GetConstant1())); | 1540 graph_->GetConstant1())); |
1530 half_old_capacity->ChangeRepresentation(Representation::Integer32()); | 1541 half_old_capacity->ChangeRepresentation(Representation::Integer32()); |
1531 half_old_capacity->ClearFlag(HValue::kCanOverflow); | 1542 half_old_capacity->ClearFlag(HValue::kCanOverflow); |
1532 | 1543 |
1533 HValue* new_capacity = AddInstruction( | 1544 HValue* new_capacity = AddInstruction( |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1737 } | 1748 } |
1738 | 1749 |
1739 // Create an allocation site info if requested. | 1750 // Create an allocation site info if requested. |
1740 if (mode == TRACK_ALLOCATION_SITE) { | 1751 if (mode == TRACK_ALLOCATION_SITE) { |
1741 BuildCreateAllocationSiteInfo(object, JSArray::kSize, boilerplate); | 1752 BuildCreateAllocationSiteInfo(object, JSArray::kSize, boilerplate); |
1742 } | 1753 } |
1743 | 1754 |
1744 if (length > 0) { | 1755 if (length > 0) { |
1745 // Get hold of the elements array of the boilerplate and setup the | 1756 // Get hold of the elements array of the boilerplate and setup the |
1746 // elements pointer in the resulting object. | 1757 // elements pointer in the resulting object. |
1747 HValue* boilerplate_elements = | 1758 HValue* boilerplate_elements = AddLoadElements(boilerplate); |
1748 AddInstruction(new(zone) HLoadElements(boilerplate, NULL)); | |
1749 HValue* object_elements = | 1759 HValue* object_elements = |
1750 AddInstruction(new(zone) HInnerAllocatedObject(object, elems_offset)); | 1760 AddInstruction(new(zone) HInnerAllocatedObject(object, elems_offset)); |
1751 AddInstruction(new(zone) HStoreNamedField(object, | 1761 AddInstruction(new(zone) HStoreNamedField(object, |
1752 factory->elements_field_string(), | 1762 factory->elements_field_string(), |
1753 object_elements, true, | 1763 object_elements, true, |
1754 Representation::Tagged(), | 1764 Representation::Tagged(), |
1755 JSObject::kElementsOffset)); | 1765 JSObject::kElementsOffset)); |
1756 | 1766 |
1757 // Copy the elements array header. | 1767 // Copy the elements array header. |
1758 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { | 1768 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { |
(...skipping 5064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6823 length, | 6833 length, |
6824 expr->literal_index(), | 6834 expr->literal_index(), |
6825 expr->depth(), | 6835 expr->depth(), |
6826 mode)); | 6836 mode)); |
6827 } | 6837 } |
6828 | 6838 |
6829 // The array is expected in the bailout environment during computation | 6839 // The array is expected in the bailout environment during computation |
6830 // of the property values and is the value of the entire expression. | 6840 // of the property values and is the value of the entire expression. |
6831 Push(literal); | 6841 Push(literal); |
6832 | 6842 |
6833 HLoadElements* elements = NULL; | 6843 HInstruction* elements = NULL; |
6834 | 6844 |
6835 for (int i = 0; i < length; i++) { | 6845 for (int i = 0; i < length; i++) { |
6836 Expression* subexpr = subexprs->at(i); | 6846 Expression* subexpr = subexprs->at(i); |
6837 // If the subexpression is a literal or a simple materialized literal it | 6847 // If the subexpression is a literal or a simple materialized literal it |
6838 // is already set in the cloned array. | 6848 // is already set in the cloned array. |
6839 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 6849 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
6840 | 6850 |
6841 CHECK_ALIVE(VisitForValue(subexpr)); | 6851 CHECK_ALIVE(VisitForValue(subexpr)); |
6842 HValue* value = Pop(); | 6852 HValue* value = Pop(); |
6843 if (!Smi::IsValid(i)) return Bailout("Non-smi key in array literal"); | 6853 if (!Smi::IsValid(i)) return Bailout("Non-smi key in array literal"); |
6844 | 6854 |
6845 // Pass in literal as dummy depedency, since the receiver always has | 6855 elements = AddLoadElements(literal); |
6846 // elements. | |
6847 elements = new(zone()) HLoadElements(literal, literal); | |
6848 AddInstruction(elements); | |
6849 | 6856 |
6850 HValue* key = AddInstruction( | 6857 HValue* key = AddInstruction( |
6851 new(zone()) HConstant(Handle<Object>(Smi::FromInt(i), isolate()), | 6858 new(zone()) HConstant(Handle<Object>(Smi::FromInt(i), isolate()), |
6852 Representation::Integer32())); | 6859 Representation::Integer32())); |
6853 | 6860 |
6854 switch (boilerplate_elements_kind) { | 6861 switch (boilerplate_elements_kind) { |
6855 case FAST_SMI_ELEMENTS: | 6862 case FAST_SMI_ELEMENTS: |
6856 case FAST_HOLEY_SMI_ELEMENTS: | 6863 case FAST_HOLEY_SMI_ELEMENTS: |
6857 // Smi-only arrays need a smi check. | 6864 // Smi-only arrays need a smi check. |
6858 AddInstruction(new(zone()) HCheckSmi(value)); | 6865 AddInstruction(new(zone()) HCheckSmi(value)); |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7953 if (position != RelocInfo::kNoPosition) instr->set_position(position); | 7960 if (position != RelocInfo::kNoPosition) instr->set_position(position); |
7954 return is_store ? NULL : instr; | 7961 return is_store ? NULL : instr; |
7955 } | 7962 } |
7956 | 7963 |
7957 HInstruction* checkspec = | 7964 HInstruction* checkspec = |
7958 AddInstruction(HCheckInstanceType::NewIsSpecObject(object, zone())); | 7965 AddInstruction(HCheckInstanceType::NewIsSpecObject(object, zone())); |
7959 HBasicBlock* join = graph()->CreateBasicBlock(); | 7966 HBasicBlock* join = graph()->CreateBasicBlock(); |
7960 | 7967 |
7961 HInstruction* elements_kind_instr = | 7968 HInstruction* elements_kind_instr = |
7962 AddInstruction(new(zone()) HElementsKind(object)); | 7969 AddInstruction(new(zone()) HElementsKind(object)); |
7963 HInstruction* elements = | 7970 HInstruction* elements = AddLoadElements(object, checkspec); |
7964 AddInstruction(new(zone()) HLoadElements(object, checkspec)); | |
7965 HLoadExternalArrayPointer* external_elements = NULL; | 7971 HLoadExternalArrayPointer* external_elements = NULL; |
7966 HInstruction* checked_key = NULL; | 7972 HInstruction* checked_key = NULL; |
7967 | 7973 |
7968 // Generated code assumes that FAST_* and DICTIONARY_ELEMENTS ElementsKinds | 7974 // Generated code assumes that FAST_* and DICTIONARY_ELEMENTS ElementsKinds |
7969 // are handled before external arrays. | 7975 // are handled before external arrays. |
7970 STATIC_ASSERT(FAST_SMI_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); | 7976 STATIC_ASSERT(FAST_SMI_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); |
7971 STATIC_ASSERT(FAST_HOLEY_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); | 7977 STATIC_ASSERT(FAST_HOLEY_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); |
7972 STATIC_ASSERT(FAST_DOUBLE_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); | 7978 STATIC_ASSERT(FAST_DOUBLE_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); |
7973 STATIC_ASSERT(DICTIONARY_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); | 7979 STATIC_ASSERT(DICTIONARY_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); |
7974 | 7980 |
(...skipping 4243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12218 } | 12224 } |
12219 } | 12225 } |
12220 | 12226 |
12221 #ifdef DEBUG | 12227 #ifdef DEBUG |
12222 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 12228 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
12223 if (allocator_ != NULL) allocator_->Verify(); | 12229 if (allocator_ != NULL) allocator_->Verify(); |
12224 #endif | 12230 #endif |
12225 } | 12231 } |
12226 | 12232 |
12227 } } // namespace v8::internal | 12233 } } // namespace v8::internal |
OLD | NEW |