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