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/bailout-reason.h" | 7 #include "src/bailout-reason.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/field-index.h" | 9 #include "src/field-index.h" |
10 #include "src/hydrogen.h" | 10 #include "src/hydrogen.h" |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 BuildStoreNamedField(GetParameter(0), GetParameter(2), casted_stub()->index(), | 769 BuildStoreNamedField(GetParameter(0), GetParameter(2), casted_stub()->index(), |
770 casted_stub()->representation(), false); | 770 casted_stub()->representation(), false); |
771 return GetParameter(2); | 771 return GetParameter(2); |
772 } | 772 } |
773 | 773 |
774 | 774 |
775 Handle<Code> StoreFieldStub::GenerateCode() { return DoGenerateCode(this); } | 775 Handle<Code> StoreFieldStub::GenerateCode() { return DoGenerateCode(this); } |
776 | 776 |
777 | 777 |
778 template <> | 778 template <> |
779 HValue* CodeStubGraphBuilder<ExtendStorageStub>::BuildCodeStub() { | 779 HValue* CodeStubGraphBuilder<StoreTransitionStub>::BuildCodeStub() { |
780 HValue* object = GetParameter(ExtendStorageDescriptor::kReceiverIndex); | 780 HValue* object = GetParameter(StoreTransitionDescriptor::kReceiverIndex); |
781 HValue* properties = | |
782 Add<HLoadNamedField>(object, static_cast<HValue*>(NULL), | |
783 HObjectAccess::ForPropertiesPointer()); | |
784 HValue* length = AddLoadFixedArrayLength(properties); | |
785 HValue* delta = Add<HConstant>(static_cast<int32_t>(JSObject::kFieldsAdded)); | |
786 HValue* new_capacity = AddUncasted<HAdd>(length, delta); | |
787 | 781 |
788 // Grow properties array. | 782 switch (casted_stub()->store_mode()) { |
789 ElementsKind kind = FAST_ELEMENTS; | 783 case StoreTransitionStub::ExtendStorageAndStoreMapAndValue: { |
790 Add<HBoundsCheck>(new_capacity, | 784 HValue* properties = |
791 Add<HConstant>((Page::kMaxRegularHeapObjectSize - | 785 Add<HLoadNamedField>(object, static_cast<HValue*>(NULL), |
792 FixedArray::kHeaderSize) >> | 786 HObjectAccess::ForPropertiesPointer()); |
793 ElementsKindToShiftSize(kind))); | 787 HValue* length = AddLoadFixedArrayLength(properties); |
| 788 HValue* delta = |
| 789 Add<HConstant>(static_cast<int32_t>(JSObject::kFieldsAdded)); |
| 790 HValue* new_capacity = AddUncasted<HAdd>(length, delta); |
794 | 791 |
795 // Reuse this code for properties backing store allocation. | 792 // Grow properties array. |
796 HValue* new_properties = BuildAllocateAndInitializeArray(kind, new_capacity); | 793 ElementsKind kind = FAST_ELEMENTS; |
| 794 Add<HBoundsCheck>(new_capacity, |
| 795 Add<HConstant>((Page::kMaxRegularHeapObjectSize - |
| 796 FixedArray::kHeaderSize) >> |
| 797 ElementsKindToShiftSize(kind))); |
797 | 798 |
798 BuildCopyProperties(properties, new_properties, length, new_capacity); | 799 // Reuse this code for properties backing store allocation. |
| 800 HValue* new_properties = |
| 801 BuildAllocateAndInitializeArray(kind, new_capacity); |
799 | 802 |
800 // Store the new value into the "extended" object. | 803 BuildCopyProperties(properties, new_properties, length, new_capacity); |
801 Add<HStoreNamedField>(object, HObjectAccess::ForPropertiesPointer(), | |
802 new_properties); | |
803 | 804 |
804 BuildStoreNamedField( | 805 // Store the new value into the "extended" object. |
805 object, GetParameter(ExtendStorageDescriptor::kValueIndex), | 806 Add<HStoreNamedField>(object, HObjectAccess::ForPropertiesPointer(), |
806 casted_stub()->index(), casted_stub()->representation(), true); | 807 new_properties); |
| 808 } |
| 809 // Fall through. |
| 810 case StoreTransitionStub::StoreMapAndValue: |
| 811 BuildStoreNamedField( |
| 812 object, GetParameter(StoreTransitionDescriptor::kValueIndex), |
| 813 casted_stub()->index(), casted_stub()->representation(), true); |
| 814 // Fall through. |
807 | 815 |
808 // And finally update the map after the new field is added. | 816 case StoreTransitionStub::StoreMapOnly: |
809 Add<HStoreNamedField>(object, HObjectAccess::ForMap(), | 817 // And finally update the map. |
810 GetParameter(ExtendStorageDescriptor::kMapIndex)); | 818 Add<HStoreNamedField>(object, HObjectAccess::ForMap(), |
811 | 819 GetParameter(StoreTransitionDescriptor::kMapIndex)); |
812 return GetParameter(ExtendStorageDescriptor::kValueIndex); | 820 break; |
| 821 } |
| 822 return GetParameter(StoreTransitionDescriptor::kValueIndex); |
813 } | 823 } |
814 | 824 |
815 | 825 |
816 Handle<Code> ExtendStorageStub::GenerateCode() { return DoGenerateCode(this); } | 826 Handle<Code> StoreTransitionStub::GenerateCode() { |
| 827 return DoGenerateCode(this); |
| 828 } |
817 | 829 |
818 | 830 |
819 template <> | 831 template <> |
820 HValue* CodeStubGraphBuilder<StringLengthStub>::BuildCodeStub() { | 832 HValue* CodeStubGraphBuilder<StringLengthStub>::BuildCodeStub() { |
821 HValue* string = BuildLoadNamedField(GetParameter(0), | 833 HValue* string = BuildLoadNamedField(GetParameter(0), |
822 FieldIndex::ForInObjectOffset(JSValue::kValueOffset)); | 834 FieldIndex::ForInObjectOffset(JSValue::kValueOffset)); |
823 return BuildLoadNamedField(string, | 835 return BuildLoadNamedField(string, |
824 FieldIndex::ForInObjectOffset(String::kLengthOffset)); | 836 FieldIndex::ForInObjectOffset(String::kLengthOffset)); |
825 } | 837 } |
826 | 838 |
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2002 | 2014 |
2003 // Probe the stub cache. | 2015 // Probe the stub cache. |
2004 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( | 2016 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( |
2005 Code::ComputeHandlerFlags(Code::LOAD_IC)); | 2017 Code::ComputeHandlerFlags(Code::LOAD_IC)); |
2006 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags); | 2018 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags); |
2007 | 2019 |
2008 // We never continue. | 2020 // We never continue. |
2009 return graph()->GetConstant0(); | 2021 return graph()->GetConstant0(); |
2010 } | 2022 } |
2011 } } // namespace v8::internal | 2023 } } // namespace v8::internal |
OLD | NEW |