OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/field-index.h" | 8 #include "src/field-index.h" |
9 #include "src/hydrogen.h" | 9 #include "src/hydrogen.h" |
10 #include "src/lithium.h" | 10 #include "src/lithium.h" |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 BuildStoreNamedField(GetParameter(0), GetParameter(2), casted_stub()->index(), | 650 BuildStoreNamedField(GetParameter(0), GetParameter(2), casted_stub()->index(), |
651 casted_stub()->representation(), false); | 651 casted_stub()->representation(), false); |
652 return GetParameter(2); | 652 return GetParameter(2); |
653 } | 653 } |
654 | 654 |
655 | 655 |
656 Handle<Code> StoreFieldStub::GenerateCode() { return DoGenerateCode(this); } | 656 Handle<Code> StoreFieldStub::GenerateCode() { return DoGenerateCode(this); } |
657 | 657 |
658 | 658 |
659 template <> | 659 template <> |
660 HValue* CodeStubGraphBuilder<ExtendStorageStub>::BuildCodeStub() { | 660 HValue* CodeStubGraphBuilder<StoreTransitionStub>::BuildCodeStub() { |
661 HValue* object = GetParameter(ExtendStorageDescriptor::kReceiverIndex); | 661 HValue* object = GetParameter(StoreTransitionDescriptor::kReceiverIndex); |
662 HValue* properties = | |
663 Add<HLoadNamedField>(object, static_cast<HValue*>(NULL), | |
664 HObjectAccess::ForPropertiesPointer()); | |
665 HValue* length = AddLoadFixedArrayLength(properties); | |
666 HValue* delta = Add<HConstant>(static_cast<int32_t>(JSObject::kFieldsAdded)); | |
667 HValue* new_capacity = AddUncasted<HAdd>(length, delta); | |
668 | 662 |
669 // Grow properties array. | 663 switch (casted_stub()->store_mode()) { |
670 ElementsKind kind = FAST_ELEMENTS; | 664 case StoreTransitionStub::ExtendStorageAndStoreMapAndValue: { |
671 Add<HBoundsCheck>(new_capacity, | 665 HValue* properties = |
672 Add<HConstant>((Page::kMaxRegularHeapObjectSize - | 666 Add<HLoadNamedField>(object, static_cast<HValue*>(NULL), |
673 FixedArray::kHeaderSize) >> | 667 HObjectAccess::ForPropertiesPointer()); |
674 ElementsKindToShiftSize(kind))); | 668 HValue* length = AddLoadFixedArrayLength(properties); |
| 669 HValue* delta = |
| 670 Add<HConstant>(static_cast<int32_t>(JSObject::kFieldsAdded)); |
| 671 HValue* new_capacity = AddUncasted<HAdd>(length, delta); |
675 | 672 |
676 // Reuse this code for properties backing store allocation. | 673 // Grow properties array. |
677 HValue* new_properties = | 674 ElementsKind kind = FAST_ELEMENTS; |
678 BuildAllocateElementsAndInitializeElementsHeader(kind, new_capacity); | 675 Add<HBoundsCheck>(new_capacity, |
| 676 Add<HConstant>((Page::kMaxRegularHeapObjectSize - |
| 677 FixedArray::kHeaderSize) >> |
| 678 ElementsKindToShiftSize(kind))); |
679 | 679 |
680 BuildCopyProperties(properties, new_properties, length, new_capacity); | 680 // Reuse this code for properties backing store allocation. |
| 681 HValue* new_properties = |
| 682 BuildAllocateElementsAndInitializeElementsHeader(kind, new_capacity); |
681 | 683 |
682 // Store the new value into the "extended" object. | 684 BuildCopyProperties(properties, new_properties, length, new_capacity); |
683 Add<HStoreNamedField>(object, HObjectAccess::ForPropertiesPointer(), | |
684 new_properties); | |
685 | 685 |
686 BuildStoreNamedField(GetParameter(ExtendStorageDescriptor::kReceiverIndex), | 686 // Store the new value into the "extended" object. |
687 GetParameter(ExtendStorageDescriptor::kValueIndex), | 687 Add<HStoreNamedField>(object, HObjectAccess::ForPropertiesPointer(), |
688 casted_stub()->index(), casted_stub()->representation(), | 688 new_properties); |
689 true); | 689 } |
| 690 // Fall through. |
| 691 case StoreTransitionStub::StoreMapAndValue: |
| 692 BuildStoreNamedField( |
| 693 object, GetParameter(StoreTransitionDescriptor::kValueIndex), |
| 694 casted_stub()->index(), casted_stub()->representation(), true); |
| 695 // Fall through. |
690 | 696 |
691 // And finally update the map after the new field is added. | 697 case StoreTransitionStub::StoreMapOnly: |
692 Add<HStoreNamedField>(object, HObjectAccess::ForMap(), | 698 // And finally update the map. |
693 GetParameter(ExtendStorageDescriptor::kMapIndex)); | 699 Add<HStoreNamedField>(object, HObjectAccess::ForMap(), |
694 | 700 GetParameter(StoreTransitionDescriptor::kMapIndex)); |
695 return GetParameter(ExtendStorageDescriptor::kValueIndex); | 701 break; |
| 702 } |
| 703 return GetParameter(StoreTransitionDescriptor::kValueIndex); |
696 } | 704 } |
697 | 705 |
698 | 706 |
699 Handle<Code> ExtendStorageStub::GenerateCode() { return DoGenerateCode(this); } | 707 Handle<Code> StoreTransitionStub::GenerateCode() { |
| 708 return DoGenerateCode(this); |
| 709 } |
700 | 710 |
701 | 711 |
702 template <> | 712 template <> |
703 HValue* CodeStubGraphBuilder<StringLengthStub>::BuildCodeStub() { | 713 HValue* CodeStubGraphBuilder<StringLengthStub>::BuildCodeStub() { |
704 HValue* string = BuildLoadNamedField(GetParameter(0), | 714 HValue* string = BuildLoadNamedField(GetParameter(0), |
705 FieldIndex::ForInObjectOffset(JSValue::kValueOffset)); | 715 FieldIndex::ForInObjectOffset(JSValue::kValueOffset)); |
706 return BuildLoadNamedField(string, | 716 return BuildLoadNamedField(string, |
707 FieldIndex::ForInObjectOffset(String::kLengthOffset)); | 717 FieldIndex::ForInObjectOffset(String::kLengthOffset)); |
708 } | 718 } |
709 | 719 |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 | 1896 |
1887 // Probe the stub cache. | 1897 // Probe the stub cache. |
1888 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( | 1898 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( |
1889 Code::ComputeHandlerFlags(Code::LOAD_IC)); | 1899 Code::ComputeHandlerFlags(Code::LOAD_IC)); |
1890 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags); | 1900 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags); |
1891 | 1901 |
1892 // We never continue. | 1902 // We never continue. |
1893 return graph()->GetConstant0(); | 1903 return graph()->GetConstant0(); |
1894 } | 1904 } |
1895 } } // namespace v8::internal | 1905 } } // namespace v8::internal |
OLD | NEW |