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

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

Powered by Google App Engine
This is Rietveld 408576698