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_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 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 914 Register array = locs()->in(0).reg(); | 914 Register array = locs()->in(0).reg(); |
| 915 Location index = locs()->in(1); | 915 Location index = locs()->in(1); |
| 916 | 916 |
| 917 FieldAddress element_address = index.IsRegister() ? | 917 FieldAddress element_address = index.IsRegister() ? |
| 918 FlowGraphCompiler::ElementAddressForRegIndex( | 918 FlowGraphCompiler::ElementAddressForRegIndex( |
| 919 class_id(), array, index.reg()) : | 919 class_id(), array, index.reg()) : |
| 920 FlowGraphCompiler::ElementAddressForIntIndex( | 920 FlowGraphCompiler::ElementAddressForIntIndex( |
| 921 class_id(), array, Smi::Cast(index.constant()).Value()); | 921 class_id(), array, Smi::Cast(index.constant()).Value()); |
| 922 | 922 |
| 923 if (representation() == kUnboxedDouble) { | 923 if (representation() == kUnboxedDouble) { |
| 924 __ movsd(locs()->out().xmm_reg(), element_address); | 924 if (class_id() == kFloat32ArrayCid) { |
| 925 // Load single precision float. | |
| 926 __ movss(locs()->out().xmm_reg(), element_address); | |
| 927 // Promote to double. | |
| 928 __ cvtss2sd(locs()->out().xmm_reg(), locs()->out().xmm_reg()); | |
| 929 } else if (class_id() == kFloat64ArrayCid) { | |
| 930 __ movsd(locs()->out().xmm_reg(), element_address); | |
|
srdjan
2012/10/19 00:58:33
} else {
ASSERT( ..)
...
}
| |
| 931 } | |
| 925 } else { | 932 } else { |
| 926 __ movq(locs()->out().reg(), element_address); | 933 __ movq(locs()->out().reg(), element_address); |
| 927 } | 934 } |
| 928 } | 935 } |
| 929 | 936 |
| 930 | 937 |
| 931 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { | 938 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { |
| 932 const intptr_t kNumInputs = 3; | 939 const intptr_t kNumInputs = 3; |
| 933 const intptr_t kNumTemps = 0; | 940 const intptr_t kNumTemps = class_id() == kFloat32ArrayCid ? 1 : 0; |
| 934 LocationSummary* locs = | 941 LocationSummary* locs = |
| 935 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 942 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 943 if (class_id() == kFloat32ArrayCid) { | |
| 944 locs->set_temp(0, Location::RequiresXmmRegister()); | |
| 945 } | |
| 936 locs->set_in(0, Location::RequiresRegister()); | 946 locs->set_in(0, Location::RequiresRegister()); |
| 937 locs->set_in(1, CanBeImmediateIndex(index()) | 947 locs->set_in(1, CanBeImmediateIndex(index()) |
| 938 ? Location::RegisterOrConstant(index()) | 948 ? Location::RegisterOrConstant(index()) |
| 939 : Location::RequiresRegister()); | 949 : Location::RequiresRegister()); |
| 940 if (RequiredInputRepresentation(2) == kUnboxedDouble) { | 950 if (RequiredInputRepresentation(2) == kUnboxedDouble) { |
| 941 // TODO(srdjan): Support Float64 constants. | 951 // TODO(srdjan): Support Float64 constants. |
| 942 locs->set_in(2, Location::RequiresXmmRegister()); | 952 locs->set_in(2, Location::RequiresXmmRegister()); |
| 943 } else { | 953 } else { |
| 944 locs->set_in(2, ShouldEmitStoreBarrier() | 954 locs->set_in(2, ShouldEmitStoreBarrier() |
| 945 ? Location::WritableRegister() | 955 ? Location::WritableRegister() |
| 946 : Location::RegisterOrConstant(value())); | 956 : Location::RegisterOrConstant(value())); |
| 947 } | 957 } |
| 948 return locs; | 958 return locs; |
| 949 } | 959 } |
| 950 | 960 |
| 951 | 961 |
| 952 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 962 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 953 Register array = locs()->in(0).reg(); | 963 Register array = locs()->in(0).reg(); |
| 954 Location index = locs()->in(1); | 964 Location index = locs()->in(1); |
| 955 FieldAddress element_address = index.IsRegister() ? | 965 FieldAddress element_address = index.IsRegister() ? |
| 956 FlowGraphCompiler::ElementAddressForRegIndex( | 966 FlowGraphCompiler::ElementAddressForRegIndex( |
| 957 class_id(), array, index.reg()) : | 967 class_id(), array, index.reg()) : |
| 958 FlowGraphCompiler::ElementAddressForIntIndex( | 968 FlowGraphCompiler::ElementAddressForIntIndex( |
| 959 class_id(), array, Smi::Cast(index.constant()).Value()); | 969 class_id(), array, Smi::Cast(index.constant()).Value()); |
| 960 | 970 |
| 971 if (class_id() == kFloat32ArrayCid) { | |
| 972 // Convert to single precision. | |
| 973 __ cvtsd2ss(locs()->temp(0).xmm_reg(), locs()->in(2).xmm_reg()); | |
| 974 // Store. | |
| 975 __ movss(element_address, locs()->temp(0).xmm_reg()); | |
| 976 return; | |
| 977 } | |
| 978 | |
| 961 if (class_id() == kFloat64ArrayCid) { | 979 if (class_id() == kFloat64ArrayCid) { |
| 962 __ movsd(element_address, locs()->in(2).xmm_reg()); | 980 __ movsd(element_address, locs()->in(2).xmm_reg()); |
| 963 return; | 981 return; |
| 964 } | 982 } |
| 965 | 983 |
| 966 if (ShouldEmitStoreBarrier()) { | 984 if (ShouldEmitStoreBarrier()) { |
| 967 Register value = locs()->in(2).reg(); | 985 Register value = locs()->in(2).reg(); |
| 968 __ StoreIntoObject(array, element_address, value); | 986 __ StoreIntoObject(array, element_address, value); |
| 969 return; | 987 return; |
| 970 } | 988 } |
| (...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2173 | 2191 |
| 2174 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2192 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2175 const DeoptReasonId deopt_reason = | 2193 const DeoptReasonId deopt_reason = |
| 2176 (array_type() == kGrowableObjectArrayCid) ? | 2194 (array_type() == kGrowableObjectArrayCid) ? |
| 2177 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; | 2195 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; |
| 2178 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2196 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
| 2179 deopt_reason); | 2197 deopt_reason); |
| 2180 ASSERT((array_type() == kArrayCid) || | 2198 ASSERT((array_type() == kArrayCid) || |
| 2181 (array_type() == kImmutableArrayCid) || | 2199 (array_type() == kImmutableArrayCid) || |
| 2182 (array_type() == kGrowableObjectArrayCid) || | 2200 (array_type() == kGrowableObjectArrayCid) || |
| 2183 (array_type() == kFloat64ArrayCid)); | 2201 (array_type() == kFloat64ArrayCid) || |
| 2202 (array_type() == kFloat32ArrayCid)); | |
| 2184 intptr_t length_offset = -1; | 2203 intptr_t length_offset = -1; |
| 2185 if (array_type() == kGrowableObjectArrayCid) { | 2204 if (array_type() == kGrowableObjectArrayCid) { |
| 2186 length_offset = GrowableObjectArray::length_offset(); | 2205 length_offset = GrowableObjectArray::length_offset(); |
| 2187 } else if (array_type() == kFloat64ArrayCid) { | 2206 } else if (array_type() == kFloat64ArrayCid) { |
| 2188 length_offset = Float64Array::length_offset(); | 2207 length_offset = Float64Array::length_offset(); |
| 2208 } else if (array_type() == kFloat32ArrayCid) { | |
| 2209 length_offset = Float32Array::length_offset(); | |
| 2189 } else { | 2210 } else { |
| 2190 length_offset = Array::length_offset(); | 2211 length_offset = Array::length_offset(); |
| 2191 } | 2212 } |
| 2192 | 2213 |
| 2193 // This case should not have created a bound check instruction. | 2214 // This case should not have created a bound check instruction. |
| 2194 ASSERT(!(locs()->in(0).IsConstant() && locs()->in(1).IsConstant())); | 2215 ASSERT(!(locs()->in(0).IsConstant() && locs()->in(1).IsConstant())); |
| 2195 | 2216 |
| 2196 if (locs()->in(1).IsConstant()) { | 2217 if (locs()->in(1).IsConstant()) { |
| 2197 Register receiver = locs()->in(0).reg(); | 2218 Register receiver = locs()->in(0).reg(); |
| 2198 const Object& constant = locs()->in(1).constant(); | 2219 const Object& constant = locs()->in(1).constant(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2270 | 2291 |
| 2271 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2292 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2272 UNIMPLEMENTED(); | 2293 UNIMPLEMENTED(); |
| 2273 } | 2294 } |
| 2274 | 2295 |
| 2275 } // namespace dart | 2296 } // namespace dart |
| 2276 | 2297 |
| 2277 #undef __ | 2298 #undef __ |
| 2278 | 2299 |
| 2279 #endif // defined TARGET_ARCH_X64 | 2300 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |