| 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 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 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 LocationSummary::kNoCall); | 819 LocationSummary::kNoCall); |
| 820 } | 820 } |
| 821 } | 821 } |
| 822 | 822 |
| 823 | 823 |
| 824 void LoadIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 824 void LoadIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 825 Register receiver = locs()->in(0).reg(); | 825 Register receiver = locs()->in(0).reg(); |
| 826 Register index = locs()->in(1).reg(); | 826 Register index = locs()->in(1).reg(); |
| 827 Register result = locs()->out().reg(); | 827 Register result = locs()->out().reg(); |
| 828 | 828 |
| 829 const DeoptReasonId deopt_reason = | |
| 830 (receiver_type() == kGrowableObjectArrayCid) ? | |
| 831 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; | |
| 832 | |
| 833 Label* deopt = compiler->AddDeoptStub(original()->deopt_id(), | |
| 834 original()->try_index(), | |
| 835 deopt_reason); | |
| 836 | |
| 837 switch (receiver_type()) { | 829 switch (receiver_type()) { |
| 838 case kArrayCid: | 830 case kArrayCid: |
| 839 case kImmutableArrayCid: | 831 case kImmutableArrayCid: |
| 840 __ cmpq(index, FieldAddress(receiver, Array::length_offset())); | |
| 841 __ j(ABOVE_EQUAL, deopt); | |
| 842 // Note that index is Smi, i.e, times 4. | 832 // Note that index is Smi, i.e, times 4. |
| 843 ASSERT(kSmiTagShift == 1); | 833 ASSERT(kSmiTagShift == 1); |
| 844 __ movq(result, FieldAddress(receiver, index, TIMES_4, sizeof(RawArray))); | 834 __ movq(result, FieldAddress(receiver, index, TIMES_4, sizeof(RawArray))); |
| 845 break; | 835 break; |
| 846 | 836 |
| 847 case kGrowableObjectArrayCid: { | 837 case kGrowableObjectArrayCid: { |
| 848 Register temp = locs()->temp(0).reg(); | 838 Register temp = locs()->temp(0).reg(); |
| 849 | |
| 850 __ cmpq(index, | |
| 851 FieldAddress(receiver, GrowableObjectArray::length_offset())); | |
| 852 __ j(ABOVE_EQUAL, deopt); | |
| 853 __ movq(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); | 839 __ movq(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); |
| 854 // Note that index is Smi, i.e, times 4. | 840 // Note that index is Smi, i.e, times 4. |
| 855 ASSERT(kSmiTagShift == 1); | 841 ASSERT(kSmiTagShift == 1); |
| 856 __ movq(result, FieldAddress(temp, index, TIMES_4, sizeof(RawArray))); | 842 __ movq(result, FieldAddress(temp, index, TIMES_4, sizeof(RawArray))); |
| 857 break; | 843 break; |
| 858 } | 844 } |
| 859 | 845 |
| 860 default: | 846 default: |
| 861 UNREACHABLE(); | 847 UNREACHABLE(); |
| 862 break; | 848 break; |
| 863 } | 849 } |
| 864 } | 850 } |
| 865 | 851 |
| 866 | 852 |
| 867 LocationSummary* StoreIndexedComp::MakeLocationSummary() const { | 853 LocationSummary* StoreIndexedComp::MakeLocationSummary() const { |
| 868 const intptr_t kNumInputs = 3; | 854 const intptr_t kNumInputs = 3; |
| 869 if (receiver_type() == kGrowableObjectArrayCid) { | 855 if (receiver_type() == kGrowableObjectArrayCid) { |
| 870 const intptr_t kNumTemps = 1; | 856 const intptr_t kNumTemps = 1; |
| 871 LocationSummary* locs = | 857 LocationSummary* locs = |
| 872 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 858 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 873 locs->set_in(0, Location::RequiresRegister()); | 859 locs->set_in(0, Location::RequiresRegister()); |
| 874 locs->set_in(1, Location::RequiresRegister()); | 860 locs->set_in(1, Location::RequiresRegister()); |
| 875 locs->set_in(2, Location::RequiresRegister()); | 861 locs->set_in(2, Location::RequiresRegister()); |
| 876 locs->set_temp(0, Location::RequiresRegister()); | 862 locs->set_temp(0, Location::RequiresRegister()); |
| 877 locs->set_out(Location::NoLocation()); | |
| 878 return locs; | 863 return locs; |
| 879 } else { | 864 } else { |
| 880 ASSERT(receiver_type() == kArrayCid); | 865 ASSERT(receiver_type() == kArrayCid); |
| 881 return LocationSummary::Make(kNumInputs, | 866 return LocationSummary::Make(kNumInputs, |
| 882 Location::NoLocation(), | 867 Location::NoLocation(), |
| 883 LocationSummary::kNoCall); | 868 LocationSummary::kNoCall); |
| 884 } | 869 } |
| 885 } | 870 } |
| 886 | 871 |
| 887 | 872 |
| 888 void StoreIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 873 void StoreIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 889 Register receiver = locs()->in(0).reg(); | 874 Register receiver = locs()->in(0).reg(); |
| 890 Register index = locs()->in(1).reg(); | 875 Register index = locs()->in(1).reg(); |
| 891 Register value = locs()->in(2).reg(); | 876 Register value = locs()->in(2).reg(); |
| 892 | 877 |
| 893 Label* deopt = compiler->AddDeoptStub(original()->deopt_id(), | |
| 894 original()->try_index(), | |
| 895 kDeoptStoreIndexed); | |
| 896 | |
| 897 switch (receiver_type()) { | 878 switch (receiver_type()) { |
| 898 case kArrayCid: | 879 case kArrayCid: |
| 899 case kImmutableArrayCid: | 880 case kImmutableArrayCid: |
| 900 __ cmpq(index, FieldAddress(receiver, Array::length_offset())); | |
| 901 __ j(ABOVE_EQUAL, deopt); | |
| 902 // Note that index is Smi, i.e, times 4. | 881 // Note that index is Smi, i.e, times 4. |
| 903 ASSERT(kSmiTagShift == 1); | 882 ASSERT(kSmiTagShift == 1); |
| 904 if (this->value()->NeedsStoreBuffer()) { | 883 if (this->value()->NeedsStoreBuffer()) { |
| 905 __ StoreIntoObject(receiver, | 884 __ StoreIntoObject(receiver, |
| 906 FieldAddress(receiver, index, TIMES_4, sizeof(RawArray)), | 885 FieldAddress(receiver, index, TIMES_4, sizeof(RawArray)), |
| 907 value); | 886 value); |
| 908 } else { | 887 } else { |
| 909 __ StoreIntoObjectNoBarrier(receiver, | 888 __ StoreIntoObjectNoBarrier(receiver, |
| 910 FieldAddress(receiver, index, TIMES_4, sizeof(RawArray)), | 889 FieldAddress(receiver, index, TIMES_4, sizeof(RawArray)), |
| 911 value); | 890 value); |
| 912 } | 891 } |
| 913 break; | 892 break; |
| 914 | 893 |
| 915 case kGrowableObjectArrayCid: { | 894 case kGrowableObjectArrayCid: { |
| 916 Register temp = locs()->temp(0).reg(); | 895 Register temp = locs()->temp(0).reg(); |
| 917 __ cmpq(index, | |
| 918 FieldAddress(receiver, GrowableObjectArray::length_offset())); | |
| 919 __ j(ABOVE_EQUAL, deopt); | |
| 920 __ movq(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); | 896 __ movq(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); |
| 921 // Note that index is Smi, i.e, times 4. | 897 // Note that index is Smi, i.e, times 4. |
| 922 ASSERT(kSmiTagShift == 1); | 898 ASSERT(kSmiTagShift == 1); |
| 923 if (this->value()->NeedsStoreBuffer()) { | 899 if (this->value()->NeedsStoreBuffer()) { |
| 924 __ StoreIntoObject(temp, | 900 __ StoreIntoObject(temp, |
| 925 FieldAddress(temp, index, TIMES_4, sizeof(RawArray)), | 901 FieldAddress(temp, index, TIMES_4, sizeof(RawArray)), |
| 926 value); | 902 value); |
| 927 } else { | 903 } else { |
| 928 __ StoreIntoObjectNoBarrier(temp, | 904 __ StoreIntoObjectNoBarrier(temp, |
| 929 FieldAddress(temp, index, TIMES_4, sizeof(RawArray)), | 905 FieldAddress(temp, index, TIMES_4, sizeof(RawArray)), |
| (...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2371 void CheckSmiComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 2347 void CheckSmiComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2372 Register value = locs()->in(0).reg(); | 2348 Register value = locs()->in(0).reg(); |
| 2373 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2349 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
| 2374 try_index(), | 2350 try_index(), |
| 2375 kDeoptCheckSmi); | 2351 kDeoptCheckSmi); |
| 2376 __ testq(value, Immediate(kSmiTagMask)); | 2352 __ testq(value, Immediate(kSmiTagMask)); |
| 2377 __ j(NOT_ZERO, deopt); | 2353 __ j(NOT_ZERO, deopt); |
| 2378 } | 2354 } |
| 2379 | 2355 |
| 2380 | 2356 |
| 2357 LocationSummary* CheckArrayBoundComp::MakeLocationSummary() const { |
| 2358 return LocationSummary::Make(2, |
| 2359 Location::NoLocation(), |
| 2360 LocationSummary::kNoCall); |
| 2361 } |
| 2362 |
| 2363 |
| 2364 void CheckArrayBoundComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2365 Register receiver = locs()->in(0).reg(); |
| 2366 Register index = locs()->in(1).reg(); |
| 2367 |
| 2368 const DeoptReasonId deopt_reason = |
| 2369 (array_type() == kGrowableObjectArrayCid) ? |
| 2370 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; |
| 2371 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
| 2372 try_index(), |
| 2373 deopt_reason); |
| 2374 switch (array_type()) { |
| 2375 case kArrayCid: |
| 2376 case kImmutableArrayCid: |
| 2377 __ cmpq(index, FieldAddress(receiver, Array::length_offset())); |
| 2378 break; |
| 2379 case kGrowableObjectArrayCid: |
| 2380 __ cmpq(index, |
| 2381 FieldAddress(receiver, GrowableObjectArray::length_offset())); |
| 2382 break; |
| 2383 } |
| 2384 __ j(ABOVE_EQUAL, deopt); |
| 2385 } |
| 2386 |
| 2387 |
| 2381 } // namespace dart | 2388 } // namespace dart |
| 2382 | 2389 |
| 2383 #undef __ | 2390 #undef __ |
| 2384 | 2391 |
| 2385 #endif // defined TARGET_ARCH_X64 | 2392 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |