| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 locs()); | 787 locs()); |
| 788 __ popl(result); | 788 __ popl(result); |
| 789 } | 789 } |
| 790 | 790 |
| 791 | 791 |
| 792 LocationSummary* LoadIndexedComp::MakeLocationSummary() const { | 792 LocationSummary* LoadIndexedComp::MakeLocationSummary() const { |
| 793 ASSERT((receiver_type() == kGrowableObjectArrayCid) || | 793 ASSERT((receiver_type() == kGrowableObjectArrayCid) || |
| 794 (receiver_type() == kArrayCid) || | 794 (receiver_type() == kArrayCid) || |
| 795 (receiver_type() == kImmutableArrayCid)); | 795 (receiver_type() == kImmutableArrayCid)); |
| 796 const intptr_t kNumInputs = 2; | 796 const intptr_t kNumInputs = 2; |
| 797 const intptr_t kNumTemps = 1; | 797 const intptr_t kNumTemps = receiver_type() == kGrowableObjectArrayCid ? 1 : 0; |
| 798 LocationSummary* locs = | 798 LocationSummary* locs = |
| 799 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 799 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 800 locs->set_in(0, Location::RequiresRegister()); | 800 locs->set_in(0, Location::RequiresRegister()); |
| 801 locs->set_in(1, Location::RequiresRegister()); | 801 locs->set_in(1, Location::RequiresRegister()); |
| 802 locs->set_temp(0, Location::RequiresRegister()); | 802 if (receiver_type() == kGrowableObjectArrayCid) { |
| 803 locs->set_temp(0, Location::RequiresRegister()); |
| 804 } |
| 803 locs->set_out(Location::RequiresRegister()); | 805 locs->set_out(Location::RequiresRegister()); |
| 804 return locs; | 806 return locs; |
| 805 } | 807 } |
| 806 | 808 |
| 807 | 809 |
| 808 void LoadIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 810 void LoadIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 809 Register receiver = locs()->in(0).reg(); | 811 Register receiver = locs()->in(0).reg(); |
| 810 Register index = locs()->in(1).reg(); | 812 Register index = locs()->in(1).reg(); |
| 811 Register result = locs()->out().reg(); | 813 Register result = locs()->out().reg(); |
| 812 Register temp = locs()->temp(0).reg(); | |
| 813 | 814 |
| 814 const DeoptReasonId deopt_reason = | 815 const DeoptReasonId deopt_reason = |
| 815 (receiver_type() == kGrowableObjectArrayCid) ? | 816 (receiver_type() == kGrowableObjectArrayCid) ? |
| 816 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; | 817 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; |
| 817 | 818 |
| 818 Label* deopt = compiler->AddDeoptStub(original()->deopt_id(), | 819 Label* deopt = compiler->AddDeoptStub(original()->deopt_id(), |
| 819 original()->try_index(), | 820 original()->try_index(), |
| 820 deopt_reason); | 821 deopt_reason); |
| 821 | 822 |
| 822 __ testl(receiver, Immediate(kSmiTagMask)); // Deoptimize if Smi. | |
| 823 __ j(ZERO, deopt); | |
| 824 __ CompareClassId(receiver, receiver_type(), temp); | |
| 825 __ j(NOT_EQUAL, deopt); | |
| 826 | |
| 827 __ testl(index, Immediate(kSmiTagMask)); | |
| 828 __ j(NOT_ZERO, deopt); | |
| 829 | |
| 830 switch (receiver_type()) { | 823 switch (receiver_type()) { |
| 831 case kArrayCid: | 824 case kArrayCid: |
| 832 case kImmutableArrayCid: | 825 case kImmutableArrayCid: |
| 833 __ cmpl(index, FieldAddress(receiver, Array::length_offset())); | 826 __ cmpl(index, FieldAddress(receiver, Array::length_offset())); |
| 834 __ j(ABOVE_EQUAL, deopt); | 827 __ j(ABOVE_EQUAL, deopt); |
| 835 // Note that index is Smi, i.e, times 2. | 828 // Note that index is Smi, i.e, times 2. |
| 836 ASSERT(kSmiTagShift == 1); | 829 ASSERT(kSmiTagShift == 1); |
| 837 __ movl(result, FieldAddress(receiver, index, TIMES_2, sizeof(RawArray))); | 830 __ movl(result, FieldAddress(receiver, index, TIMES_2, sizeof(RawArray))); |
| 838 break; | 831 break; |
| 839 | 832 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 854 UNREACHABLE(); | 847 UNREACHABLE(); |
| 855 break; | 848 break; |
| 856 } | 849 } |
| 857 } | 850 } |
| 858 | 851 |
| 859 | 852 |
| 860 LocationSummary* StoreIndexedComp::MakeLocationSummary() const { | 853 LocationSummary* StoreIndexedComp::MakeLocationSummary() const { |
| 861 ASSERT((receiver_type() == kGrowableObjectArrayCid) || | 854 ASSERT((receiver_type() == kGrowableObjectArrayCid) || |
| 862 (receiver_type() == kArrayCid)); | 855 (receiver_type() == kArrayCid)); |
| 863 const intptr_t kNumInputs = 3; | 856 const intptr_t kNumInputs = 3; |
| 864 const intptr_t kNumTemps = 1; | 857 const intptr_t kNumTemps = receiver_type() == kGrowableObjectArrayCid ? 1 : 0; |
| 865 LocationSummary* locs = | 858 LocationSummary* locs = |
| 866 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 859 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 867 locs->set_in(0, Location::RequiresRegister()); | 860 locs->set_in(0, Location::RequiresRegister()); |
| 868 locs->set_in(1, Location::RequiresRegister()); | 861 locs->set_in(1, Location::RequiresRegister()); |
| 869 locs->set_in(2, Location::RequiresRegister()); | 862 locs->set_in(2, Location::RequiresRegister()); |
| 870 locs->set_temp(0, Location::RequiresRegister()); | 863 if (receiver_type() == kGrowableObjectArrayCid) { |
| 864 locs->set_temp(0, Location::RequiresRegister()); |
| 865 } |
| 871 locs->set_out(Location::NoLocation()); | 866 locs->set_out(Location::NoLocation()); |
| 872 return locs; | 867 return locs; |
| 873 } | 868 } |
| 874 | 869 |
| 875 | 870 |
| 876 void StoreIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 871 void StoreIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 877 Register receiver = locs()->in(0).reg(); | 872 Register receiver = locs()->in(0).reg(); |
| 878 Register index = locs()->in(1).reg(); | 873 Register index = locs()->in(1).reg(); |
| 879 Register value = locs()->in(2).reg(); | 874 Register value = locs()->in(2).reg(); |
| 880 Register temp = locs()->temp(0).reg(); | |
| 881 | 875 |
| 882 Label* deopt = compiler->AddDeoptStub(original()->deopt_id(), | 876 Label* deopt = compiler->AddDeoptStub(original()->deopt_id(), |
| 883 original()->try_index(), | 877 original()->try_index(), |
| 884 kDeoptStoreIndexed); | 878 kDeoptStoreIndexed); |
| 885 | 879 |
| 886 __ testl(receiver, Immediate(kSmiTagMask)); // Deoptimize if Smi. | |
| 887 __ j(ZERO, deopt); | |
| 888 __ CompareClassId(receiver, receiver_type(), temp); | |
| 889 __ j(NOT_EQUAL, deopt); | |
| 890 | |
| 891 __ testl(index, Immediate(kSmiTagMask)); | |
| 892 __ j(NOT_ZERO, deopt); | |
| 893 | |
| 894 switch (receiver_type()) { | 880 switch (receiver_type()) { |
| 895 case kArrayCid: | 881 case kArrayCid: |
| 896 case kImmutableArrayCid: | 882 case kImmutableArrayCid: |
| 897 __ cmpl(index, FieldAddress(receiver, Array::length_offset())); | 883 __ cmpl(index, FieldAddress(receiver, Array::length_offset())); |
| 898 __ j(ABOVE_EQUAL, deopt); | 884 __ j(ABOVE_EQUAL, deopt); |
| 899 // Note that index is Smi, i.e, times 2. | 885 // Note that index is Smi, i.e, times 2. |
| 900 ASSERT(kSmiTagShift == 1); | 886 ASSERT(kSmiTagShift == 1); |
| 901 if (this->value()->NeedsStoreBuffer()) { | 887 if (this->value()->NeedsStoreBuffer()) { |
| 902 __ StoreIntoObject(receiver, | 888 __ StoreIntoObject(receiver, |
| 903 FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)), | 889 FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)), |
| 904 value); | 890 value); |
| 905 } else { | 891 } else { |
| 906 __ StoreIntoObjectNoBarrier(receiver, | 892 __ StoreIntoObjectNoBarrier(receiver, |
| 907 FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)), | 893 FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)), |
| 908 value); | 894 value); |
| 909 } | 895 } |
| 910 break; | 896 break; |
| 911 | 897 |
| 912 case kGrowableObjectArrayCid: { | 898 case kGrowableObjectArrayCid: { |
| 899 Register temp = locs()->temp(0).reg(); |
| 913 __ cmpl(index, | 900 __ cmpl(index, |
| 914 FieldAddress(receiver, GrowableObjectArray::length_offset())); | 901 FieldAddress(receiver, GrowableObjectArray::length_offset())); |
| 915 __ j(ABOVE_EQUAL, deopt); | 902 __ j(ABOVE_EQUAL, deopt); |
| 916 __ movl(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); | 903 __ movl(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); |
| 917 // Note that index is Smi, i.e, times 2. | 904 // Note that index is Smi, i.e, times 2. |
| 918 ASSERT(kSmiTagShift == 1); | 905 ASSERT(kSmiTagShift == 1); |
| 919 if (this->value()->NeedsStoreBuffer()) { | 906 if (this->value()->NeedsStoreBuffer()) { |
| 920 __ StoreIntoObject(temp, | 907 __ StoreIntoObject(temp, |
| 921 FieldAddress(temp, index, TIMES_2, sizeof(RawArray)), | 908 FieldAddress(temp, index, TIMES_2, sizeof(RawArray)), |
| 922 value); | 909 value); |
| (...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2431 __ testl(value, Immediate(kSmiTagMask)); | 2418 __ testl(value, Immediate(kSmiTagMask)); |
| 2432 __ j(NOT_ZERO, deopt); | 2419 __ j(NOT_ZERO, deopt); |
| 2433 } | 2420 } |
| 2434 | 2421 |
| 2435 | 2422 |
| 2436 } // namespace dart | 2423 } // namespace dart |
| 2437 | 2424 |
| 2438 #undef __ | 2425 #undef __ |
| 2439 | 2426 |
| 2440 #endif // defined TARGET_ARCH_X64 | 2427 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |