| 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 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 compiler->GenerateCall(token_pos(), | 875 compiler->GenerateCall(token_pos(), |
| 876 &StubCode::CallNativeCFunctionLabel(), | 876 &StubCode::CallNativeCFunctionLabel(), |
| 877 PcDescriptors::kOther, | 877 PcDescriptors::kOther, |
| 878 locs()); | 878 locs()); |
| 879 __ popq(result); | 879 __ popq(result); |
| 880 } | 880 } |
| 881 | 881 |
| 882 | 882 |
| 883 LocationSummary* LoadIndexedInstr::MakeLocationSummary() const { | 883 LocationSummary* LoadIndexedInstr::MakeLocationSummary() const { |
| 884 const intptr_t kNumInputs = 2; | 884 const intptr_t kNumInputs = 2; |
| 885 if (receiver_type() == kGrowableObjectArrayCid) { | 885 return LocationSummary::Make(kNumInputs, |
| 886 const intptr_t kNumTemps = 1; | 886 Location::RequiresRegister(), |
| 887 LocationSummary* locs = | 887 LocationSummary::kNoCall); |
| 888 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | |
| 889 locs->set_in(0, Location::RequiresRegister()); | |
| 890 locs->set_in(1, Location::RequiresRegister()); | |
| 891 locs->set_temp(0, Location::RequiresRegister()); | |
| 892 locs->set_out(Location::RequiresRegister()); | |
| 893 return locs; | |
| 894 } else { | |
| 895 ASSERT((receiver_type() == kArrayCid) || | |
| 896 (receiver_type() == kImmutableArrayCid)); | |
| 897 return LocationSummary::Make(kNumInputs, | |
| 898 Location::RequiresRegister(), | |
| 899 LocationSummary::kNoCall); | |
| 900 } | |
| 901 } | 888 } |
| 902 | 889 |
| 903 | 890 |
| 904 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 891 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 905 Register receiver = locs()->in(0).reg(); | 892 Register array = locs()->in(0).reg(); |
| 906 Register index = locs()->in(1).reg(); | 893 Register index = locs()->in(1).reg(); |
| 907 Register result = locs()->out().reg(); | 894 Register result = locs()->out().reg(); |
| 908 | 895 |
| 909 switch (receiver_type()) { | 896 // Note that index is Smi, i.e, times 4. |
| 910 case kArrayCid: | 897 ASSERT(kSmiTagShift == 1); |
| 911 case kImmutableArrayCid: | 898 __ movq(result, FieldAddress(array, index, TIMES_4, sizeof(RawArray))); |
| 912 // Note that index is Smi, i.e, times 4. | |
| 913 ASSERT(kSmiTagShift == 1); | |
| 914 __ movq(result, FieldAddress(receiver, index, TIMES_4, sizeof(RawArray))); | |
| 915 break; | |
| 916 | |
| 917 case kGrowableObjectArrayCid: { | |
| 918 Register temp = locs()->temp(0).reg(); | |
| 919 __ movq(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); | |
| 920 // Note that index is Smi, i.e, times 4. | |
| 921 ASSERT(kSmiTagShift == 1); | |
| 922 __ movq(result, FieldAddress(temp, index, TIMES_4, sizeof(RawArray))); | |
| 923 break; | |
| 924 } | |
| 925 | |
| 926 default: | |
| 927 UNREACHABLE(); | |
| 928 break; | |
| 929 } | |
| 930 } | 899 } |
| 931 | 900 |
| 932 | 901 |
| 933 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { | 902 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { |
| 934 const intptr_t kNumInputs = 3; | 903 const intptr_t kNumInputs = 3; |
| 935 const intptr_t kNumTemps = | 904 const intptr_t kNumTemps = 0; |
| 936 (receiver_type() == kGrowableObjectArrayCid) ? 1 : 0; | |
| 937 LocationSummary* locs = | 905 LocationSummary* locs = |
| 938 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 906 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 939 locs->set_in(0, Location::RequiresRegister()); | 907 locs->set_in(0, Location::RequiresRegister()); |
| 940 locs->set_in(1, Location::RequiresRegister()); | 908 locs->set_in(1, Location::RequiresRegister()); |
| 941 locs->set_in(2, value()->NeedsStoreBuffer() ? Location::WritableRegister() | 909 locs->set_in(2, value()->NeedsStoreBuffer() ? Location::WritableRegister() |
| 942 : Location::RequiresRegister()); | 910 : Location::RequiresRegister()); |
| 943 if (receiver_type() == kGrowableObjectArrayCid) { | |
| 944 locs->set_temp(0, Location::RequiresRegister()); | |
| 945 } | |
| 946 return locs; | 911 return locs; |
| 947 } | 912 } |
| 948 | 913 |
| 949 | 914 |
| 950 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 915 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 951 Register receiver = locs()->in(0).reg(); | 916 Register array = locs()->in(0).reg(); |
| 952 Register index = locs()->in(1).reg(); | 917 Register index = locs()->in(1).reg(); |
| 953 Register value = locs()->in(2).reg(); | 918 Register value = locs()->in(2).reg(); |
| 954 | 919 |
| 955 switch (receiver_type()) { | 920 // Note that index is Smi, i.e, times 4. |
| 956 case kArrayCid: | 921 ASSERT(kSmiTagShift == 1); |
| 957 case kImmutableArrayCid: | 922 if (this->value()->NeedsStoreBuffer()) { |
| 958 // Note that index is Smi, i.e, times 4. | 923 __ StoreIntoObject(array, |
| 959 ASSERT(kSmiTagShift == 1); | 924 FieldAddress(array, index, TIMES_4, sizeof(RawArray)), |
| 960 if (this->value()->NeedsStoreBuffer()) { | 925 value); |
| 961 __ StoreIntoObject(receiver, | 926 } else { |
| 962 FieldAddress(receiver, index, TIMES_4, sizeof(RawArray)), | 927 __ StoreIntoObjectNoBarrier(array, |
| 963 value); | 928 FieldAddress(array, index, TIMES_4, sizeof(RawArray)), |
| 964 } else { | 929 value); |
| 965 __ StoreIntoObjectNoBarrier(receiver, | |
| 966 FieldAddress(receiver, index, TIMES_4, sizeof(RawArray)), | |
| 967 value); | |
| 968 } | |
| 969 break; | |
| 970 | |
| 971 case kGrowableObjectArrayCid: { | |
| 972 Register temp = locs()->temp(0).reg(); | |
| 973 __ movq(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); | |
| 974 // Note that index is Smi, i.e, times 4. | |
| 975 ASSERT(kSmiTagShift == 1); | |
| 976 if (this->value()->NeedsStoreBuffer()) { | |
| 977 __ StoreIntoObject(temp, | |
| 978 FieldAddress(temp, index, TIMES_4, sizeof(RawArray)), | |
| 979 value); | |
| 980 } else { | |
| 981 __ StoreIntoObjectNoBarrier(temp, | |
| 982 FieldAddress(temp, index, TIMES_4, sizeof(RawArray)), | |
| 983 value); | |
| 984 } | |
| 985 break; | |
| 986 } | |
| 987 | |
| 988 default: | |
| 989 UNREACHABLE(); | |
| 990 break; | |
| 991 } | 930 } |
| 992 } | 931 } |
| 993 | 932 |
| 994 | 933 |
| 995 LocationSummary* LoadInstanceFieldInstr::MakeLocationSummary() const { | 934 LocationSummary* LoadInstanceFieldInstr::MakeLocationSummary() const { |
| 996 // TODO(fschneider): For this instruction the input register may be | 935 // TODO(fschneider): For this instruction the input register may be |
| 997 // reused for the result (but is not required to) because the input | 936 // reused for the result (but is not required to) because the input |
| 998 // is not used after the result is defined. We should consider adding | 937 // is not used after the result is defined. We should consider adding |
| 999 // this information to the input policy. | 938 // this information to the input policy. |
| 1000 return LocationSummary::Make(1, | 939 return LocationSummary::Make(1, |
| (...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2310 __ j(ABOVE_EQUAL, deopt); | 2249 __ j(ABOVE_EQUAL, deopt); |
| 2311 } | 2250 } |
| 2312 } | 2251 } |
| 2313 | 2252 |
| 2314 | 2253 |
| 2315 } // namespace dart | 2254 } // namespace dart |
| 2316 | 2255 |
| 2317 #undef __ | 2256 #undef __ |
| 2318 | 2257 |
| 2319 #endif // defined TARGET_ARCH_X64 | 2258 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |