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

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

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

Powered by Google App Engine
This is Rietveld 408576698