| 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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 locs->set_out(Location::RequiresRegister()); | 805 locs->set_out(Location::RequiresRegister()); |
| 806 return locs; | 806 return locs; |
| 807 } | 807 } |
| 808 | 808 |
| 809 | 809 |
| 810 void LoadIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 810 void LoadIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 811 Register receiver = locs()->in(0).reg(); | 811 Register receiver = locs()->in(0).reg(); |
| 812 Register index = locs()->in(1).reg(); | 812 Register index = locs()->in(1).reg(); |
| 813 Register result = locs()->out().reg(); | 813 Register result = locs()->out().reg(); |
| 814 | 814 |
| 815 const DeoptReasonId deopt_reason = | |
| 816 (receiver_type() == kGrowableObjectArrayCid) ? | |
| 817 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; | |
| 818 | |
| 819 Label* deopt = compiler->AddDeoptStub(original()->deopt_id(), | |
| 820 original()->try_index(), | |
| 821 deopt_reason); | |
| 822 | |
| 823 switch (receiver_type()) { | 815 switch (receiver_type()) { |
| 824 case kArrayCid: | 816 case kArrayCid: |
| 825 case kImmutableArrayCid: | 817 case kImmutableArrayCid: |
| 826 __ cmpl(index, FieldAddress(receiver, Array::length_offset())); | |
| 827 __ j(ABOVE_EQUAL, deopt); | |
| 828 // Note that index is Smi, i.e, times 2. | 818 // Note that index is Smi, i.e, times 2. |
| 829 ASSERT(kSmiTagShift == 1); | 819 ASSERT(kSmiTagShift == 1); |
| 830 __ movl(result, FieldAddress(receiver, index, TIMES_2, sizeof(RawArray))); | 820 __ movl(result, FieldAddress(receiver, index, TIMES_2, sizeof(RawArray))); |
| 831 break; | 821 break; |
| 832 | 822 |
| 833 case kGrowableObjectArrayCid: { | 823 case kGrowableObjectArrayCid: { |
| 834 Register temp = locs()->temp(0).reg(); | 824 Register temp = locs()->temp(0).reg(); |
| 835 | |
| 836 __ cmpl(index, | |
| 837 FieldAddress(receiver, GrowableObjectArray::length_offset())); | |
| 838 __ j(ABOVE_EQUAL, deopt); | |
| 839 __ movl(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); | 825 __ movl(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); |
| 840 // Note that index is Smi, i.e, times 2. | 826 // Note that index is Smi, i.e, times 2. |
| 841 ASSERT(kSmiTagShift == 1); | 827 ASSERT(kSmiTagShift == 1); |
| 842 __ movl(result, FieldAddress(temp, index, TIMES_2, sizeof(RawArray))); | 828 __ movl(result, FieldAddress(temp, index, TIMES_2, sizeof(RawArray))); |
| 843 break; | 829 break; |
| 844 } | 830 } |
| 845 | 831 |
| 846 default: | 832 default: |
| 847 UNREACHABLE(); | 833 UNREACHABLE(); |
| 848 break; | 834 break; |
| 849 } | 835 } |
| 850 } | 836 } |
| 851 | 837 |
| 852 | 838 |
| 853 LocationSummary* StoreIndexedComp::MakeLocationSummary() const { | 839 LocationSummary* StoreIndexedComp::MakeLocationSummary() const { |
| 854 ASSERT((receiver_type() == kGrowableObjectArrayCid) || | 840 ASSERT((receiver_type() == kGrowableObjectArrayCid) || |
| 855 (receiver_type() == kArrayCid)); | 841 (receiver_type() == kArrayCid)); |
| 856 const intptr_t kNumInputs = 3; | 842 const intptr_t kNumInputs = 3; |
| 857 const intptr_t kNumTemps = receiver_type() == kGrowableObjectArrayCid ? 1 : 0; | 843 const intptr_t kNumTemps = receiver_type() == kGrowableObjectArrayCid ? 1 : 0; |
| 858 LocationSummary* locs = | 844 LocationSummary* locs = |
| 859 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 845 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 860 locs->set_in(0, Location::RequiresRegister()); | 846 locs->set_in(0, Location::RequiresRegister()); |
| 861 locs->set_in(1, Location::RequiresRegister()); | 847 locs->set_in(1, Location::RequiresRegister()); |
| 862 locs->set_in(2, Location::RequiresRegister()); | 848 locs->set_in(2, Location::RequiresRegister()); |
| 863 if (receiver_type() == kGrowableObjectArrayCid) { | 849 if (receiver_type() == kGrowableObjectArrayCid) { |
| 864 locs->set_temp(0, Location::RequiresRegister()); | 850 locs->set_temp(0, Location::RequiresRegister()); |
| 865 } | 851 } |
| 866 locs->set_out(Location::NoLocation()); | |
| 867 return locs; | 852 return locs; |
| 868 } | 853 } |
| 869 | 854 |
| 870 | 855 |
| 871 void StoreIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 856 void StoreIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 872 Register receiver = locs()->in(0).reg(); | 857 Register receiver = locs()->in(0).reg(); |
| 873 Register index = locs()->in(1).reg(); | 858 Register index = locs()->in(1).reg(); |
| 874 Register value = locs()->in(2).reg(); | 859 Register value = locs()->in(2).reg(); |
| 875 | 860 |
| 876 Label* deopt = compiler->AddDeoptStub(original()->deopt_id(), | |
| 877 original()->try_index(), | |
| 878 kDeoptStoreIndexed); | |
| 879 | |
| 880 switch (receiver_type()) { | 861 switch (receiver_type()) { |
| 881 case kArrayCid: | 862 case kArrayCid: |
| 882 case kImmutableArrayCid: | 863 case kImmutableArrayCid: |
| 883 __ cmpl(index, FieldAddress(receiver, Array::length_offset())); | |
| 884 __ j(ABOVE_EQUAL, deopt); | |
| 885 // Note that index is Smi, i.e, times 2. | 864 // Note that index is Smi, i.e, times 2. |
| 886 ASSERT(kSmiTagShift == 1); | 865 ASSERT(kSmiTagShift == 1); |
| 887 if (this->value()->NeedsStoreBuffer()) { | 866 if (this->value()->NeedsStoreBuffer()) { |
| 888 __ StoreIntoObject(receiver, | 867 __ StoreIntoObject(receiver, |
| 889 FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)), | 868 FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)), |
| 890 value); | 869 value); |
| 891 } else { | 870 } else { |
| 892 __ StoreIntoObjectNoBarrier(receiver, | 871 __ StoreIntoObjectNoBarrier(receiver, |
| 893 FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)), | 872 FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)), |
| 894 value); | 873 value); |
| 895 } | 874 } |
| 896 break; | 875 break; |
| 897 | 876 |
| 898 case kGrowableObjectArrayCid: { | 877 case kGrowableObjectArrayCid: { |
| 899 Register temp = locs()->temp(0).reg(); | 878 Register temp = locs()->temp(0).reg(); |
| 900 __ cmpl(index, | |
| 901 FieldAddress(receiver, GrowableObjectArray::length_offset())); | |
| 902 __ j(ABOVE_EQUAL, deopt); | |
| 903 __ movl(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); | 879 __ movl(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); |
| 904 // Note that index is Smi, i.e, times 2. | 880 // Note that index is Smi, i.e, times 2. |
| 905 ASSERT(kSmiTagShift == 1); | 881 ASSERT(kSmiTagShift == 1); |
| 906 if (this->value()->NeedsStoreBuffer()) { | 882 if (this->value()->NeedsStoreBuffer()) { |
| 907 __ StoreIntoObject(temp, | 883 __ StoreIntoObject(temp, |
| 908 FieldAddress(temp, index, TIMES_2, sizeof(RawArray)), | 884 FieldAddress(temp, index, TIMES_2, sizeof(RawArray)), |
| 909 value); | 885 value); |
| 910 } else { | 886 } else { |
| 911 __ StoreIntoObjectNoBarrier(temp, | 887 __ StoreIntoObjectNoBarrier(temp, |
| 912 FieldAddress(temp, index, TIMES_2, sizeof(RawArray)), | 888 FieldAddress(temp, index, TIMES_2, sizeof(RawArray)), |
| (...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2362 void CheckSmiComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 2338 void CheckSmiComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2363 Register value = locs()->in(0).reg(); | 2339 Register value = locs()->in(0).reg(); |
| 2364 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2340 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
| 2365 try_index(), | 2341 try_index(), |
| 2366 kDeoptCheckSmi); | 2342 kDeoptCheckSmi); |
| 2367 __ testl(value, Immediate(kSmiTagMask)); | 2343 __ testl(value, Immediate(kSmiTagMask)); |
| 2368 __ j(NOT_ZERO, deopt); | 2344 __ j(NOT_ZERO, deopt); |
| 2369 } | 2345 } |
| 2370 | 2346 |
| 2371 | 2347 |
| 2348 LocationSummary* CheckArrayBoundComp::MakeLocationSummary() const { |
| 2349 return LocationSummary::Make(2, |
| 2350 Location::NoLocation(), |
| 2351 LocationSummary::kNoCall); |
| 2352 } |
| 2353 |
| 2354 |
| 2355 void CheckArrayBoundComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2356 Register receiver = locs()->in(0).reg(); |
| 2357 Register index = locs()->in(1).reg(); |
| 2358 |
| 2359 const DeoptReasonId deopt_reason = |
| 2360 (array_type() == kGrowableObjectArrayCid) ? |
| 2361 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; |
| 2362 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
| 2363 try_index(), |
| 2364 deopt_reason); |
| 2365 switch (array_type()) { |
| 2366 case kArrayCid: |
| 2367 case kImmutableArrayCid: |
| 2368 __ cmpl(index, FieldAddress(receiver, Array::length_offset())); |
| 2369 break; |
| 2370 case kGrowableObjectArrayCid: |
| 2371 __ cmpl(index, |
| 2372 FieldAddress(receiver, GrowableObjectArray::length_offset())); |
| 2373 break; |
| 2374 } |
| 2375 __ j(ABOVE_EQUAL, deopt); |
| 2376 } |
| 2377 |
| 2378 |
| 2372 } // namespace dart | 2379 } // namespace dart |
| 2373 | 2380 |
| 2374 #undef __ | 2381 #undef __ |
| 2375 | 2382 |
| 2376 #endif // defined TARGET_ARCH_X64 | 2383 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |