| 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 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 957 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 958 Register array = locs()->in(0).reg(); | 958 Register array = locs()->in(0).reg(); |
| 959 Location index = locs()->in(1); | 959 Location index = locs()->in(1); |
| 960 FieldAddress element_address = index.IsRegister() ? | 960 FieldAddress element_address = index.IsRegister() ? |
| 961 FlowGraphCompiler::ElementAddressForRegIndex( | 961 FlowGraphCompiler::ElementAddressForRegIndex( |
| 962 class_id(), array, index.reg()) : | 962 class_id(), array, index.reg()) : |
| 963 FlowGraphCompiler::ElementAddressForIntIndex( | 963 FlowGraphCompiler::ElementAddressForIntIndex( |
| 964 class_id(), array, Smi::Cast(index.constant()).Value()); | 964 class_id(), array, Smi::Cast(index.constant()).Value()); |
| 965 | 965 |
| 966 if (representation() == kUnboxedDouble) { | 966 if (representation() == kUnboxedDouble) { |
| 967 __ movsd(locs()->out().xmm_reg(), element_address); | 967 if (class_id() == kFloat32ArrayCid) { |
| 968 // Load single precision float. |
| 969 __ movss(locs()->out().xmm_reg(), element_address); |
| 970 // Promote to double. |
| 971 __ cvtss2sd(locs()->out().xmm_reg(), locs()->out().xmm_reg()); |
| 972 } else { |
| 973 ASSERT(class_id() == kFloat64ArrayCid); |
| 974 __ movsd(locs()->out().xmm_reg(), element_address); |
| 975 } |
| 968 } else { | 976 } else { |
| 969 __ movl(locs()->out().reg(), element_address); | 977 __ movl(locs()->out().reg(), element_address); |
| 970 } | 978 } |
| 971 } | 979 } |
| 972 | 980 |
| 973 | 981 |
| 974 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { | 982 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { |
| 975 const intptr_t kNumInputs = 3; | 983 const intptr_t kNumInputs = 3; |
| 976 const intptr_t kNumTemps = 0; | 984 const intptr_t kNumTemps = class_id() == kFloat32ArrayCid ? 1 : 0; |
| 977 LocationSummary* locs = | 985 LocationSummary* locs = |
| 978 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 986 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 987 if (class_id() == kFloat32ArrayCid) { |
| 988 locs->set_temp(0, Location::RequiresXmmRegister()); |
| 989 } |
| 979 locs->set_in(0, Location::RequiresRegister()); | 990 locs->set_in(0, Location::RequiresRegister()); |
| 980 locs->set_in(1, CanBeImmediateIndex(index()) | 991 locs->set_in(1, CanBeImmediateIndex(index()) |
| 981 ? Location::RegisterOrConstant(index()) | 992 ? Location::RegisterOrConstant(index()) |
| 982 : Location::RequiresRegister()); | 993 : Location::RequiresRegister()); |
| 983 if (RequiredInputRepresentation(2) == kUnboxedDouble) { | 994 if (RequiredInputRepresentation(2) == kUnboxedDouble) { |
| 984 // TODO(srdjan): Support Float64 constants. | 995 // TODO(srdjan): Support Float64 constants. |
| 985 locs->set_in(2, Location::RequiresXmmRegister()); | 996 locs->set_in(2, Location::RequiresXmmRegister()); |
| 986 } else { | 997 } else { |
| 987 locs->set_in(2, ShouldEmitStoreBarrier() | 998 locs->set_in(2, ShouldEmitStoreBarrier() |
| 988 ? Location::WritableRegister() | 999 ? Location::WritableRegister() |
| 989 : Location::RegisterOrConstant(value())); | 1000 : Location::RegisterOrConstant(value())); |
| 990 } | 1001 } |
| 991 return locs; | 1002 return locs; |
| 992 } | 1003 } |
| 993 | 1004 |
| 994 | 1005 |
| 995 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1006 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 996 Register array = locs()->in(0).reg(); | 1007 Register array = locs()->in(0).reg(); |
| 997 Location index = locs()->in(1); | 1008 Location index = locs()->in(1); |
| 998 | 1009 |
| 999 FieldAddress element_address = index.IsRegister() ? | 1010 FieldAddress element_address = index.IsRegister() ? |
| 1000 FlowGraphCompiler::ElementAddressForRegIndex( | 1011 FlowGraphCompiler::ElementAddressForRegIndex( |
| 1001 class_id(), array, index.reg()) : | 1012 class_id(), array, index.reg()) : |
| 1002 FlowGraphCompiler::ElementAddressForIntIndex( | 1013 FlowGraphCompiler::ElementAddressForIntIndex( |
| 1003 class_id(), array, Smi::Cast(index.constant()).Value()); | 1014 class_id(), array, Smi::Cast(index.constant()).Value()); |
| 1004 | 1015 |
| 1016 if (class_id() == kFloat32ArrayCid) { |
| 1017 // Convert to single precision. |
| 1018 __ cvtsd2ss(locs()->temp(0).xmm_reg(), locs()->in(2).xmm_reg()); |
| 1019 // Store. |
| 1020 __ movss(element_address, locs()->temp(0).xmm_reg()); |
| 1021 return; |
| 1022 } |
| 1023 |
| 1005 if (class_id() == kFloat64ArrayCid) { | 1024 if (class_id() == kFloat64ArrayCid) { |
| 1006 __ movsd(element_address, locs()->in(2).xmm_reg()); | 1025 __ movsd(element_address, locs()->in(2).xmm_reg()); |
| 1007 return; | 1026 return; |
| 1008 } | 1027 } |
| 1009 | 1028 |
| 1010 if (ShouldEmitStoreBarrier()) { | 1029 if (ShouldEmitStoreBarrier()) { |
| 1011 Register value = locs()->in(2).reg(); | 1030 Register value = locs()->in(2).reg(); |
| 1012 __ StoreIntoObject(array, element_address, value); | 1031 __ StoreIntoObject(array, element_address, value); |
| 1013 return; | 1032 return; |
| 1014 } | 1033 } |
| (...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2206 | 2225 |
| 2207 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2226 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2208 const DeoptReasonId deopt_reason = | 2227 const DeoptReasonId deopt_reason = |
| 2209 (array_type() == kGrowableObjectArrayCid) ? | 2228 (array_type() == kGrowableObjectArrayCid) ? |
| 2210 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; | 2229 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; |
| 2211 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2230 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
| 2212 deopt_reason); | 2231 deopt_reason); |
| 2213 ASSERT((array_type() == kArrayCid) || | 2232 ASSERT((array_type() == kArrayCid) || |
| 2214 (array_type() == kImmutableArrayCid) || | 2233 (array_type() == kImmutableArrayCid) || |
| 2215 (array_type() == kGrowableObjectArrayCid) || | 2234 (array_type() == kGrowableObjectArrayCid) || |
| 2216 (array_type() == kFloat64ArrayCid)); | 2235 (array_type() == kFloat64ArrayCid) || |
| 2236 (array_type() == kFloat32ArrayCid)); |
| 2217 intptr_t length_offset = -1; | 2237 intptr_t length_offset = -1; |
| 2218 if (array_type() == kGrowableObjectArrayCid) { | 2238 if (array_type() == kGrowableObjectArrayCid) { |
| 2219 length_offset = GrowableObjectArray::length_offset(); | 2239 length_offset = GrowableObjectArray::length_offset(); |
| 2220 } else if (array_type() == kFloat64ArrayCid) { | 2240 } else if (array_type() == kFloat64ArrayCid) { |
| 2221 length_offset = Float64Array::length_offset(); | 2241 length_offset = Float64Array::length_offset(); |
| 2242 } else if (array_type() == kFloat32ArrayCid) { |
| 2243 length_offset = Float32Array::length_offset(); |
| 2222 } else { | 2244 } else { |
| 2223 length_offset = Array::length_offset(); | 2245 length_offset = Array::length_offset(); |
| 2224 } | 2246 } |
| 2225 // This case should not have created a bound check instruction. | 2247 // This case should not have created a bound check instruction. |
| 2226 ASSERT(!(locs()->in(0).IsConstant() && locs()->in(1).IsConstant())); | 2248 ASSERT(!(locs()->in(0).IsConstant() && locs()->in(1).IsConstant())); |
| 2227 | 2249 |
| 2228 if (locs()->in(1).IsConstant()) { | 2250 if (locs()->in(1).IsConstant()) { |
| 2229 Register receiver = locs()->in(0).reg(); | 2251 Register receiver = locs()->in(0).reg(); |
| 2230 const Object& constant = locs()->in(1).constant(); | 2252 const Object& constant = locs()->in(1).constant(); |
| 2231 ASSERT(constant.IsSmi()); | 2253 ASSERT(constant.IsSmi()); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2546 __ pcmpeqq(XMM0, XMM0); // Generate all 1's. | 2568 __ pcmpeqq(XMM0, XMM0); // Generate all 1's. |
| 2547 __ pxor(value, XMM0); | 2569 __ pxor(value, XMM0); |
| 2548 } | 2570 } |
| 2549 | 2571 |
| 2550 | 2572 |
| 2551 } // namespace dart | 2573 } // namespace dart |
| 2552 | 2574 |
| 2553 #undef __ | 2575 #undef __ |
| 2554 | 2576 |
| 2555 #endif // defined TARGET_ARCH_X64 | 2577 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |