| 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 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 | 938 |
| 939 LocationSummary* LoadIndexedInstr::MakeLocationSummary() const { | 939 LocationSummary* LoadIndexedInstr::MakeLocationSummary() const { |
| 940 const intptr_t kNumInputs = 2; | 940 const intptr_t kNumInputs = 2; |
| 941 const intptr_t kNumTemps = 0; | 941 const intptr_t kNumTemps = 0; |
| 942 LocationSummary* locs = | 942 LocationSummary* locs = |
| 943 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 943 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 944 locs->set_in(0, Location::RequiresRegister()); | 944 locs->set_in(0, Location::RequiresRegister()); |
| 945 locs->set_in(1, CanBeImmediateIndex(index()) | 945 locs->set_in(1, CanBeImmediateIndex(index()) |
| 946 ? Location::RegisterOrConstant(index()) | 946 ? Location::RegisterOrConstant(index()) |
| 947 : Location::RequiresRegister()); | 947 : Location::RequiresRegister()); |
| 948 locs->set_out(Location::RequiresRegister()); | 948 if (representation() == kUnboxedDouble) { |
| 949 locs->set_out(Location::RequiresXmmRegister()); |
| 950 } else { |
| 951 locs->set_out(Location::RequiresRegister()); |
| 952 } |
| 949 return locs; | 953 return locs; |
| 950 } | 954 } |
| 951 | 955 |
| 952 | 956 |
| 953 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 957 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 954 Register array = locs()->in(0).reg(); | 958 Register array = locs()->in(0).reg(); |
| 955 Register result = locs()->out().reg(); | |
| 956 Location index = locs()->in(1); | 959 Location index = locs()->in(1); |
| 957 if (index.IsRegister()) { | 960 FieldAddress element_address = index.IsRegister() ? |
| 958 // Note that index is Smi, i.e, times 2. | 961 FlowGraphCompiler::ElementAddressForRegIndex( |
| 959 ASSERT(kSmiTagShift == 1); | 962 class_id(), array, index.reg()) : |
| 960 __ movl(result, | 963 FlowGraphCompiler::ElementAddressForIntIndex( |
| 961 FieldAddress(array, index.reg(), TIMES_2, sizeof(RawArray))); | 964 class_id(), array, Smi::Cast(index.constant()).Value()); |
| 965 |
| 966 if (representation() == kUnboxedDouble) { |
| 967 __ movsd(locs()->out().xmm_reg(), element_address); |
| 962 } else { | 968 } else { |
| 963 const int32_t disp = | 969 __ movl(locs()->out().reg(), element_address); |
| 964 Smi::Cast(index.constant()).Value() * kWordSize + sizeof(RawArray); | |
| 965 __ movl(result, FieldAddress(array, disp)); | |
| 966 } | 970 } |
| 967 } | 971 } |
| 968 | 972 |
| 969 | 973 |
| 970 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { | 974 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { |
| 971 const intptr_t kNumInputs = 3; | 975 const intptr_t kNumInputs = 3; |
| 972 const intptr_t kNumTemps = 0; | 976 const intptr_t kNumTemps = 0; |
| 973 LocationSummary* locs = | 977 LocationSummary* locs = |
| 974 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 978 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 975 locs->set_in(0, Location::RequiresRegister()); | 979 locs->set_in(0, Location::RequiresRegister()); |
| 976 locs->set_in(1, CanBeImmediateIndex(index()) | 980 locs->set_in(1, CanBeImmediateIndex(index()) |
| 977 ? Location::RegisterOrConstant(index()) | 981 ? Location::RegisterOrConstant(index()) |
| 978 : Location::RequiresRegister()); | 982 : Location::RequiresRegister()); |
| 979 locs->set_in(2, ShouldEmitStoreBarrier() | 983 if (RequiredInputRepresentation(2) == kUnboxedDouble) { |
| 980 ? Location::WritableRegister() | 984 // TODO(srdjan): Support Float64 constants. |
| 981 : Location::RegisterOrConstant(value())); | 985 locs->set_in(2, Location::RequiresXmmRegister()); |
| 986 } else { |
| 987 locs->set_in(2, ShouldEmitStoreBarrier() |
| 988 ? Location::WritableRegister() |
| 989 : Location::RegisterOrConstant(value())); |
| 990 } |
| 982 return locs; | 991 return locs; |
| 983 } | 992 } |
| 984 | 993 |
| 985 | 994 |
| 986 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 995 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 987 Register array = locs()->in(0).reg(); | 996 Register array = locs()->in(0).reg(); |
| 997 Location index = locs()->in(1); |
| 988 | 998 |
| 989 // Note that index is Smi, i.e, times 2. | 999 FieldAddress element_address = index.IsRegister() ? |
| 990 ASSERT(kSmiTagShift == 1); | 1000 FlowGraphCompiler::ElementAddressForRegIndex( |
| 991 Location index = locs()->in(1); | 1001 class_id(), array, index.reg()) : |
| 992 FieldAddress field_address = index.IsConstant() | 1002 FlowGraphCompiler::ElementAddressForIntIndex( |
| 993 ? FieldAddress( | 1003 class_id(), array, Smi::Cast(index.constant()).Value()); |
| 994 array, | 1004 |
| 995 Smi::Cast(index.constant()).Value() * kWordSize + sizeof(RawArray)) | 1005 if (class_id() == kFloat64ArrayCid) { |
| 996 : FieldAddress(array, index.reg(), TIMES_2, sizeof(RawArray)); | 1006 __ movsd(element_address, locs()->in(2).xmm_reg()); |
| 1007 return; |
| 1008 } |
| 997 | 1009 |
| 998 if (ShouldEmitStoreBarrier()) { | 1010 if (ShouldEmitStoreBarrier()) { |
| 999 Register value = locs()->in(2).reg(); | 1011 Register value = locs()->in(2).reg(); |
| 1000 __ StoreIntoObject(array, field_address, value); | 1012 __ StoreIntoObject(array, element_address, value); |
| 1013 return; |
| 1014 } |
| 1015 |
| 1016 if (locs()->in(2).IsConstant()) { |
| 1017 const Object& constant = locs()->in(2).constant(); |
| 1018 __ StoreIntoObjectNoBarrier(array, element_address, constant); |
| 1001 } else { | 1019 } else { |
| 1002 if (locs()->in(2).IsConstant()) { | 1020 Register value = locs()->in(2).reg(); |
| 1003 const Object& constant = locs()->in(2).constant(); | 1021 __ StoreIntoObjectNoBarrier(array, element_address, value); |
| 1004 __ StoreIntoObjectNoBarrier(array, field_address, constant); | |
| 1005 } else { | |
| 1006 Register value = locs()->in(2).reg(); | |
| 1007 __ StoreIntoObjectNoBarrier(array, field_address, value); | |
| 1008 } | |
| 1009 } | 1022 } |
| 1010 } | 1023 } |
| 1011 | 1024 |
| 1012 | 1025 |
| 1013 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary() const { | 1026 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary() const { |
| 1014 const intptr_t kNumInputs = 2; | 1027 const intptr_t kNumInputs = 2; |
| 1015 const intptr_t num_temps = 0; | 1028 const intptr_t num_temps = 0; |
| 1016 LocationSummary* summary = | 1029 LocationSummary* summary = |
| 1017 new LocationSummary(kNumInputs, num_temps, LocationSummary::kNoCall); | 1030 new LocationSummary(kNumInputs, num_temps, LocationSummary::kNoCall); |
| 1018 summary->set_in(0, Location::RequiresRegister()); | 1031 summary->set_in(0, Location::RequiresRegister()); |
| (...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2187 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 2200 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 2188 locs->set_in(0, Location::RegisterOrConstant(array())); | 2201 locs->set_in(0, Location::RegisterOrConstant(array())); |
| 2189 locs->set_in(1, Location::RegisterOrConstant(index())); | 2202 locs->set_in(1, Location::RegisterOrConstant(index())); |
| 2190 return locs; | 2203 return locs; |
| 2191 } | 2204 } |
| 2192 | 2205 |
| 2193 | 2206 |
| 2194 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2207 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2195 const DeoptReasonId deopt_reason = | 2208 const DeoptReasonId deopt_reason = |
| 2196 (array_type() == kGrowableObjectArrayCid) ? | 2209 (array_type() == kGrowableObjectArrayCid) ? |
| 2197 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; | 2210 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; |
| 2198 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2211 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
| 2199 deopt_reason); | 2212 deopt_reason); |
| 2200 ASSERT(array_type() == kArrayCid || | 2213 ASSERT((array_type() == kArrayCid) || |
| 2201 array_type() == kImmutableArrayCid || | 2214 (array_type() == kImmutableArrayCid) || |
| 2202 array_type() == kGrowableObjectArrayCid); | 2215 (array_type() == kGrowableObjectArrayCid) || |
| 2203 intptr_t length_offset = (array_type() == kGrowableObjectArrayCid) | 2216 (array_type() == kFloat64ArrayCid)); |
| 2204 ? GrowableObjectArray::length_offset() | 2217 intptr_t length_offset = -1; |
| 2205 : Array::length_offset(); | 2218 if (array_type() == kGrowableObjectArrayCid) { |
| 2219 length_offset = GrowableObjectArray::length_offset(); |
| 2220 } else if (array_type() == kFloat64ArrayCid) { |
| 2221 length_offset = Float64Array::length_offset(); |
| 2222 } else { |
| 2223 length_offset = Array::length_offset(); |
| 2224 } |
| 2206 // This case should not have created a bound check instruction. | 2225 // This case should not have created a bound check instruction. |
| 2207 ASSERT(!(locs()->in(0).IsConstant() && locs()->in(1).IsConstant())); | 2226 ASSERT(!(locs()->in(0).IsConstant() && locs()->in(1).IsConstant())); |
| 2208 | 2227 |
| 2209 if (locs()->in(1).IsConstant()) { | 2228 if (locs()->in(1).IsConstant()) { |
| 2210 Register receiver = locs()->in(0).reg(); | 2229 Register receiver = locs()->in(0).reg(); |
| 2211 const Object& constant = locs()->in(1).constant(); | 2230 const Object& constant = locs()->in(1).constant(); |
| 2212 ASSERT(constant.IsSmi()); | 2231 ASSERT(constant.IsSmi()); |
| 2213 const int32_t imm = | 2232 const int32_t imm = |
| 2214 reinterpret_cast<int32_t>(constant.raw()); | 2233 reinterpret_cast<int32_t>(constant.raw()); |
| 2215 __ cmpl(FieldAddress(receiver, length_offset), Immediate(imm)); | 2234 __ cmpl(FieldAddress(receiver, length_offset), Immediate(imm)); |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2527 __ pcmpeqq(XMM0, XMM0); // Generate all 1's. | 2546 __ pcmpeqq(XMM0, XMM0); // Generate all 1's. |
| 2528 __ pxor(value, XMM0); | 2547 __ pxor(value, XMM0); |
| 2529 } | 2548 } |
| 2530 | 2549 |
| 2531 | 2550 |
| 2532 } // namespace dart | 2551 } // namespace dart |
| 2533 | 2552 |
| 2534 #undef __ | 2553 #undef __ |
| 2535 | 2554 |
| 2536 #endif // defined TARGET_ARCH_X64 | 2555 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |