| 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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 __ testl(index, Immediate(kSmiTagMask)); | 894 __ testl(index, Immediate(kSmiTagMask)); |
| 895 __ j(NOT_ZERO, deopt); | 895 __ j(NOT_ZERO, deopt); |
| 896 | 896 |
| 897 switch (receiver_type()) { | 897 switch (receiver_type()) { |
| 898 case kArrayCid: | 898 case kArrayCid: |
| 899 case kImmutableArrayCid: | 899 case kImmutableArrayCid: |
| 900 __ cmpl(index, FieldAddress(receiver, Array::length_offset())); | 900 __ cmpl(index, FieldAddress(receiver, Array::length_offset())); |
| 901 __ j(ABOVE_EQUAL, deopt); | 901 __ j(ABOVE_EQUAL, deopt); |
| 902 // Note that index is Smi, i.e, times 2. | 902 // Note that index is Smi, i.e, times 2. |
| 903 ASSERT(kSmiTagShift == 1); | 903 ASSERT(kSmiTagShift == 1); |
| 904 __ StoreIntoObject(receiver, | 904 if (this->value()->BindsToConstant()) { |
| 905 FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)), | 905 // Compile time constants are Smi or allocated in the old space. |
| 906 value); | 906 __ movl(FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)), |
| 907 value); |
| 908 } else { |
| 909 __ StoreIntoObject(receiver, |
| 910 FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)), |
| 911 value); |
| 912 } |
| 907 break; | 913 break; |
| 908 | 914 |
| 909 case kGrowableObjectArrayCid: { | 915 case kGrowableObjectArrayCid: { |
| 910 __ cmpl(index, | 916 __ cmpl(index, |
| 911 FieldAddress(receiver, GrowableObjectArray::length_offset())); | 917 FieldAddress(receiver, GrowableObjectArray::length_offset())); |
| 912 __ j(ABOVE_EQUAL, deopt); | 918 __ j(ABOVE_EQUAL, deopt); |
| 913 __ movl(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); | 919 __ movl(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); |
| 914 // Note that index is Smi, i.e, times 2. | 920 // Note that index is Smi, i.e, times 2. |
| 915 ASSERT(kSmiTagShift == 1); | 921 ASSERT(kSmiTagShift == 1); |
| 916 __ StoreIntoObject(temp, | 922 if (this->value()->BindsToConstant()) { |
| 917 FieldAddress(temp, index, TIMES_2, sizeof(RawArray)), | 923 // Compile time constants are Smi or allocated in the old space. |
| 918 value); | 924 __ movl(FieldAddress(temp, index, TIMES_2, sizeof(RawArray)), |
| 925 value); |
| 926 } else { |
| 927 __ StoreIntoObject(temp, |
| 928 FieldAddress(temp, index, TIMES_2, sizeof(RawArray)), |
| 929 value); |
| 930 } |
| 919 break; | 931 break; |
| 920 } | 932 } |
| 921 | 933 |
| 922 default: | 934 default: |
| 923 UNREACHABLE(); | 935 UNREACHABLE(); |
| 924 break; | 936 break; |
| 925 } | 937 } |
| 926 } | 938 } |
| 927 | 939 |
| 928 | 940 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 949 // Smis do not have instance fields (Smi class is always first). | 961 // Smis do not have instance fields (Smi class is always first). |
| 950 // Use 'result' as temporary register. | 962 // Use 'result' as temporary register. |
| 951 ASSERT(result_reg != instance_reg); | 963 ASSERT(result_reg != instance_reg); |
| 952 ASSERT(ic_data() != NULL); | 964 ASSERT(ic_data() != NULL); |
| 953 compiler->EmitClassChecksNoSmi(*ic_data(), instance_reg, result_reg, deopt); | 965 compiler->EmitClassChecksNoSmi(*ic_data(), instance_reg, result_reg, deopt); |
| 954 } | 966 } |
| 955 __ movl(result_reg, FieldAddress(instance_reg, field().Offset())); | 967 __ movl(result_reg, FieldAddress(instance_reg, field().Offset())); |
| 956 } | 968 } |
| 957 | 969 |
| 958 | 970 |
| 971 LocationSummary* StoreInstanceFieldComp::MakeLocationSummary() const { |
| 972 const intptr_t kNumInputs = 2; |
| 973 const intptr_t num_temps = HasICData() ? 1 : 0; |
| 974 LocationSummary* summary = |
| 975 new LocationSummary(kNumInputs, num_temps, LocationSummary::kNoCall); |
| 976 summary->set_in(0, Location::RequiresRegister()); |
| 977 summary->set_in(1, Location::RequiresRegister()); |
| 978 if (HasICData()) { |
| 979 summary->set_temp(0, Location::RequiresRegister()); |
| 980 } |
| 981 return summary; |
| 982 } |
| 983 |
| 984 |
| 985 void StoreInstanceFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 986 Register instance_reg = locs()->in(0).reg(); |
| 987 Register value_reg = locs()->in(1).reg(); |
| 988 |
| 989 if (HasICData()) { |
| 990 ASSERT(original() != NULL); |
| 991 Label* deopt = compiler->AddDeoptStub(original()->deopt_id(), |
| 992 original()->try_index(), |
| 993 kDeoptInstanceGetterSameTarget); |
| 994 // Smis do not have instance fields (Smi class is always first). |
| 995 Register temp_reg = locs()->temp(0).reg(); |
| 996 ASSERT(temp_reg != instance_reg); |
| 997 ASSERT(temp_reg != value_reg); |
| 998 ASSERT(ic_data() != NULL); |
| 999 compiler->EmitClassChecksNoSmi(*ic_data(), instance_reg, temp_reg, deopt); |
| 1000 } |
| 1001 if (this->value()->BindsToConstant()) { |
| 1002 // Compile time constants are Smi or allocated in the old space. |
| 1003 __ movl(FieldAddress(instance_reg, field().Offset()), value_reg); |
| 1004 } else { |
| 1005 __ StoreIntoObject(instance_reg, |
| 1006 FieldAddress(instance_reg, field().Offset()), value_reg); |
| 1007 } |
| 1008 } |
| 1009 |
| 1010 |
| 959 LocationSummary* LoadStaticFieldComp::MakeLocationSummary() const { | 1011 LocationSummary* LoadStaticFieldComp::MakeLocationSummary() const { |
| 960 return LocationSummary::Make(0, | 1012 return LocationSummary::Make(0, |
| 961 Location::RequiresRegister(), | 1013 Location::RequiresRegister(), |
| 962 LocationSummary::kNoCall); | 1014 LocationSummary::kNoCall); |
| 963 } | 1015 } |
| 964 | 1016 |
| 965 | 1017 |
| 966 void LoadStaticFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1018 void LoadStaticFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 967 Register result = locs()->out().reg(); | 1019 Register result = locs()->out().reg(); |
| 968 __ LoadObject(result, field()); | 1020 __ LoadObject(result, field()); |
| 969 __ movl(result, FieldAddress(result, Field::value_offset())); | 1021 __ movl(result, FieldAddress(result, Field::value_offset())); |
| 970 } | 1022 } |
| 971 | 1023 |
| 972 | 1024 |
| 1025 LocationSummary* StoreStaticFieldComp::MakeLocationSummary() const { |
| 1026 LocationSummary* locs = new LocationSummary(1, 1, LocationSummary::kNoCall); |
| 1027 locs->set_in(0, Location::RequiresRegister()); |
| 1028 locs->set_temp(0, Location::RequiresRegister()); |
| 1029 locs->set_out(Location::SameAsFirstInput()); |
| 1030 return locs; |
| 1031 } |
| 1032 |
| 1033 |
| 1034 void StoreStaticFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1035 Register value = locs()->in(0).reg(); |
| 1036 Register temp = locs()->temp(0).reg(); |
| 1037 ASSERT(locs()->out().reg() == value); |
| 1038 |
| 1039 __ LoadObject(temp, field()); |
| 1040 if (this->value()->BindsToConstant()) { |
| 1041 // Compile time constants are Smi or allocated in the old space. |
| 1042 __ movl(FieldAddress(temp, Field::value_offset()), value); |
| 1043 } else { |
| 1044 __ StoreIntoObject(temp, FieldAddress(temp, Field::value_offset()), value); |
| 1045 } |
| 1046 } |
| 1047 |
| 1048 |
| 973 LocationSummary* InstanceOfComp::MakeLocationSummary() const { | 1049 LocationSummary* InstanceOfComp::MakeLocationSummary() const { |
| 974 const intptr_t kNumInputs = 3; | 1050 const intptr_t kNumInputs = 3; |
| 975 const intptr_t kNumTemps = 0; | 1051 const intptr_t kNumTemps = 0; |
| 976 LocationSummary* summary = | 1052 LocationSummary* summary = |
| 977 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 1053 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| 978 summary->set_in(0, Location::RegisterLocation(EAX)); | 1054 summary->set_in(0, Location::RegisterLocation(EAX)); |
| 979 summary->set_in(1, Location::RegisterLocation(ECX)); | 1055 summary->set_in(1, Location::RegisterLocation(ECX)); |
| 980 summary->set_in(2, Location::RegisterLocation(EDX)); | 1056 summary->set_in(2, Location::RegisterLocation(EDX)); |
| 981 summary->set_out(Location::RegisterLocation(EAX)); | 1057 summary->set_out(Location::RegisterLocation(EAX)); |
| 982 return summary; | 1058 return summary; |
| (...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2354 __ testl(value, Immediate(kSmiTagMask)); | 2430 __ testl(value, Immediate(kSmiTagMask)); |
| 2355 __ j(NOT_ZERO, deopt); | 2431 __ j(NOT_ZERO, deopt); |
| 2356 } | 2432 } |
| 2357 | 2433 |
| 2358 | 2434 |
| 2359 } // namespace dart | 2435 } // namespace dart |
| 2360 | 2436 |
| 2361 #undef __ | 2437 #undef __ |
| 2362 | 2438 |
| 2363 #endif // defined TARGET_ARCH_X64 | 2439 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |