Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: runtime/vm/intermediate_language_x64.cc

Issue 11198072: Inline load and store index on Float32Arrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Test suites pass Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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);
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 intptr_t kNumTemps = 0;
941 if (class_id() == kFloat32ArrayCid) {
942 kNumTemps = 1;
943 }
srdjan 2012/10/19 00:41:53 ditto
934 LocationSummary* locs = 944 LocationSummary* locs =
935 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 945 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
946 if (class_id() == kFloat32ArrayCid) {
947 locs->set_temp(0, Location::RequiresXmmRegister());
948 }
936 locs->set_in(0, Location::RequiresRegister()); 949 locs->set_in(0, Location::RequiresRegister());
937 locs->set_in(1, CanBeImmediateIndex(index()) 950 locs->set_in(1, CanBeImmediateIndex(index())
938 ? Location::RegisterOrConstant(index()) 951 ? Location::RegisterOrConstant(index())
939 : Location::RequiresRegister()); 952 : Location::RequiresRegister());
940 if (RequiredInputRepresentation(2) == kUnboxedDouble) { 953 if (RequiredInputRepresentation(2) == kUnboxedDouble) {
941 // TODO(srdjan): Support Float64 constants. 954 // TODO(srdjan): Support Float64 constants.
942 locs->set_in(2, Location::RequiresXmmRegister()); 955 locs->set_in(2, Location::RequiresXmmRegister());
943 } else { 956 } else {
944 locs->set_in(2, ShouldEmitStoreBarrier() 957 locs->set_in(2, ShouldEmitStoreBarrier()
945 ? Location::WritableRegister() 958 ? Location::WritableRegister()
946 : Location::RegisterOrConstant(value())); 959 : Location::RegisterOrConstant(value()));
947 } 960 }
948 return locs; 961 return locs;
949 } 962 }
950 963
951 964
952 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 965 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
953 Register array = locs()->in(0).reg(); 966 Register array = locs()->in(0).reg();
954 Location index = locs()->in(1); 967 Location index = locs()->in(1);
955 FieldAddress element_address = index.IsRegister() ? 968 FieldAddress element_address = index.IsRegister() ?
956 FlowGraphCompiler::ElementAddressForRegIndex( 969 FlowGraphCompiler::ElementAddressForRegIndex(
957 class_id(), array, index.reg()) : 970 class_id(), array, index.reg()) :
958 FlowGraphCompiler::ElementAddressForIntIndex( 971 FlowGraphCompiler::ElementAddressForIntIndex(
959 class_id(), array, Smi::Cast(index.constant()).Value()); 972 class_id(), array, Smi::Cast(index.constant()).Value());
960 973
974 if (class_id() == kFloat32ArrayCid) {
975 // Convert to single precision.
976 __ cvtsd2ss(locs()->temp(0).xmm_reg(), locs()->in(2).xmm_reg());
977 // Store.
978 __ movss(element_address, locs()->temp(0).xmm_reg());
979 return;
980 }
981
961 if (class_id() == kFloat64ArrayCid) { 982 if (class_id() == kFloat64ArrayCid) {
962 __ movsd(element_address, locs()->in(2).xmm_reg()); 983 __ movsd(element_address, locs()->in(2).xmm_reg());
963 return; 984 return;
964 } 985 }
965 986
966 if (ShouldEmitStoreBarrier()) { 987 if (ShouldEmitStoreBarrier()) {
967 Register value = locs()->in(2).reg(); 988 Register value = locs()->in(2).reg();
968 __ StoreIntoObject(array, element_address, value); 989 __ StoreIntoObject(array, element_address, value);
969 return; 990 return;
970 } 991 }
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 2194
2174 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2195 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2175 const DeoptReasonId deopt_reason = 2196 const DeoptReasonId deopt_reason =
2176 (array_type() == kGrowableObjectArrayCid) ? 2197 (array_type() == kGrowableObjectArrayCid) ?
2177 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; 2198 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray;
2178 Label* deopt = compiler->AddDeoptStub(deopt_id(), 2199 Label* deopt = compiler->AddDeoptStub(deopt_id(),
2179 deopt_reason); 2200 deopt_reason);
2180 ASSERT((array_type() == kArrayCid) || 2201 ASSERT((array_type() == kArrayCid) ||
2181 (array_type() == kImmutableArrayCid) || 2202 (array_type() == kImmutableArrayCid) ||
2182 (array_type() == kGrowableObjectArrayCid) || 2203 (array_type() == kGrowableObjectArrayCid) ||
2183 (array_type() == kFloat64ArrayCid)); 2204 (array_type() == kFloat64ArrayCid) ||
2205 (array_type() == kFloat32ArrayCid));
2184 intptr_t length_offset = -1; 2206 intptr_t length_offset = -1;
2185 if (array_type() == kGrowableObjectArrayCid) { 2207 if (array_type() == kGrowableObjectArrayCid) {
2186 length_offset = GrowableObjectArray::length_offset(); 2208 length_offset = GrowableObjectArray::length_offset();
2187 } else if (array_type() == kFloat64ArrayCid) { 2209 } else if (array_type() == kFloat64ArrayCid) {
2188 length_offset = Float64Array::length_offset(); 2210 length_offset = Float64Array::length_offset();
2211 } else if (array_type() == kFloat32ArrayCid) {
2212 length_offset = Float32Array::length_offset();
2189 } else { 2213 } else {
2190 length_offset = Array::length_offset(); 2214 length_offset = Array::length_offset();
2191 } 2215 }
2192 2216
2193 // This case should not have created a bound check instruction. 2217 // This case should not have created a bound check instruction.
2194 ASSERT(!(locs()->in(0).IsConstant() && locs()->in(1).IsConstant())); 2218 ASSERT(!(locs()->in(0).IsConstant() && locs()->in(1).IsConstant()));
2195 2219
2196 if (locs()->in(1).IsConstant()) { 2220 if (locs()->in(1).IsConstant()) {
2197 Register receiver = locs()->in(0).reg(); 2221 Register receiver = locs()->in(0).reg();
2198 const Object& constant = locs()->in(1).constant(); 2222 const Object& constant = locs()->in(1).constant();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 2294
2271 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2295 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2272 UNIMPLEMENTED(); 2296 UNIMPLEMENTED();
2273 } 2297 }
2274 2298
2275 } // namespace dart 2299 } // namespace dart
2276 2300
2277 #undef __ 2301 #undef __
2278 2302
2279 #endif // defined TARGET_ARCH_X64 2303 #endif // defined TARGET_ARCH_X64
OLDNEW
« runtime/vm/intermediate_language_ia32.cc ('K') | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698