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

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

Issue 11092090: Inline indexed load and store of typed array float64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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') | tests/standalone/float_array_test.dart » ('j') | 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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 894
895 LocationSummary* LoadIndexedInstr::MakeLocationSummary() const { 895 LocationSummary* LoadIndexedInstr::MakeLocationSummary() const {
896 const intptr_t kNumInputs = 2; 896 const intptr_t kNumInputs = 2;
897 const intptr_t kNumTemps = 0; 897 const intptr_t kNumTemps = 0;
898 LocationSummary* locs = 898 LocationSummary* locs =
899 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 899 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
900 locs->set_in(0, Location::RequiresRegister()); 900 locs->set_in(0, Location::RequiresRegister());
901 locs->set_in(1, CanBeImmediateIndex(index()) 901 locs->set_in(1, CanBeImmediateIndex(index())
902 ? Location::RegisterOrConstant(index()) 902 ? Location::RegisterOrConstant(index())
903 : Location::RequiresRegister()); 903 : Location::RequiresRegister());
904 locs->set_out(Location::RequiresRegister()); 904 if (representation() == kUnboxedDouble) {
905 locs->set_out(Location::RequiresXmmRegister());
906 } else {
907 locs->set_out(Location::RequiresRegister());
908 }
905 return locs; 909 return locs;
906 } 910 }
907 911
908 912
909 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 913 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
910 Register array = locs()->in(0).reg(); 914 Register array = locs()->in(0).reg();
911 Register result = locs()->out().reg(); 915 Location index = locs()->in(1);
912 916
913 Location index = locs()->in(1); 917 FieldAddress element_address = index.IsRegister() ?
914 if (index.IsRegister()) { 918 FlowGraphCompiler::ElementAddressForRegIndex(
915 // Note that index is Smi, i.e, times 4. 919 class_id(), array, index.reg()) :
916 ASSERT(kSmiTagShift == 1); 920 FlowGraphCompiler::ElementAddressForIntIndex(
917 __ movq(result, 921 class_id(), array, Smi::Cast(index.constant()).Value());
918 FieldAddress(array, index.reg(), TIMES_4, sizeof(RawArray))); 922
923 if (representation() == kUnboxedDouble) {
924 __ movsd(locs()->out().xmm_reg(), element_address);
919 } else { 925 } else {
920 const int64_t disp = 926 __ movq(locs()->out().reg(), element_address);
921 Smi::Cast(index.constant()).Value() * kWordSize + sizeof(RawArray);
922 ASSERT(Utils::IsInt(32, disp));
923 __ movq(result, FieldAddress(array, static_cast<int32_t>(disp)));
924 } 927 }
925 } 928 }
926 929
927 930
928 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { 931 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const {
929 const intptr_t kNumInputs = 3; 932 const intptr_t kNumInputs = 3;
930 const intptr_t kNumTemps = 0; 933 const intptr_t kNumTemps = 0;
931 LocationSummary* locs = 934 LocationSummary* locs =
932 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 935 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
933 locs->set_in(0, Location::RequiresRegister()); 936 locs->set_in(0, Location::RequiresRegister());
934 locs->set_in(1, CanBeImmediateIndex(index()) 937 locs->set_in(1, CanBeImmediateIndex(index())
935 ? Location::RegisterOrConstant(index()) 938 ? Location::RegisterOrConstant(index())
936 : Location::RequiresRegister()); 939 : Location::RequiresRegister());
937 locs->set_in(2, ShouldEmitStoreBarrier() 940 if (RequiredInputRepresentation(2) == kUnboxedDouble) {
938 ? Location::WritableRegister() 941 // TODO(srdjan): Support Float64 constants.
939 : Location::RegisterOrConstant(value())); 942 locs->set_in(2, Location::RequiresXmmRegister());
943 } else {
944 locs->set_in(2, ShouldEmitStoreBarrier()
945 ? Location::WritableRegister()
946 : Location::RegisterOrConstant(value()));
947 }
940 return locs; 948 return locs;
941 } 949 }
942 950
943 951
944 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 952 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
945 Register array = locs()->in(0).reg(); 953 Register array = locs()->in(0).reg();
954 Location index = locs()->in(1);
955 FieldAddress element_address = index.IsRegister() ?
956 FlowGraphCompiler::ElementAddressForRegIndex(
957 class_id(), array, index.reg()) :
958 FlowGraphCompiler::ElementAddressForIntIndex(
959 class_id(), array, Smi::Cast(index.constant()).Value());
946 960
947 // Note that index is Smi, i.e, times 4. 961 if (class_id() == kFloat64ArrayCid) {
948 ASSERT(kSmiTagShift == 1); 962 __ movsd(element_address, locs()->in(2).xmm_reg());
949 Location index = locs()->in(1); 963 return;
950 FieldAddress field_address = index.IsConstant() 964 }
951 ? FieldAddress(
952 array,
953 static_cast<int32_t>(
954 Smi::Cast(index.constant()).Value() * kWordSize + sizeof(RawArray)))
955 : FieldAddress(array, index.reg(), TIMES_4, sizeof(RawArray));
956 965
957 if (ShouldEmitStoreBarrier()) { 966 if (ShouldEmitStoreBarrier()) {
958 Register value = locs()->in(2).reg(); 967 Register value = locs()->in(2).reg();
959 __ StoreIntoObject(array, field_address, value); 968 __ StoreIntoObject(array, element_address, value);
969 return;
970 }
971
972 if (locs()->in(2).IsConstant()) {
973 const Object& constant = locs()->in(2).constant();
974 __ StoreObject(element_address, constant);
960 } else { 975 } else {
961 if (locs()->in(2).IsConstant()) { 976 Register value = locs()->in(2).reg();
962 const Object& constant = locs()->in(2).constant(); 977 __ StoreIntoObjectNoBarrier(array, element_address, value);
963 __ StoreObject(field_address, constant);
964 } else {
965 Register value = locs()->in(2).reg();
966 __ StoreIntoObjectNoBarrier(array, field_address, value);
967 }
968 } 978 }
969 } 979 }
970 980
971 981
972 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary() const { 982 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary() const {
973 const intptr_t kNumInputs = 2; 983 const intptr_t kNumInputs = 2;
974 const intptr_t num_temps = 0; 984 const intptr_t num_temps = 0;
975 LocationSummary* summary = 985 LocationSummary* summary =
976 new LocationSummary(kNumInputs, num_temps, LocationSummary::kNoCall); 986 new LocationSummary(kNumInputs, num_temps, LocationSummary::kNoCall);
977 summary->set_in(0, Location::RequiresRegister()); 987 summary->set_in(0, Location::RequiresRegister());
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 2167 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
2158 locs->set_in(0, Location::RequiresRegister()); 2168 locs->set_in(0, Location::RequiresRegister());
2159 locs->set_in(1, Location::RegisterOrConstant(index())); 2169 locs->set_in(1, Location::RegisterOrConstant(index()));
2160 return locs; 2170 return locs;
2161 } 2171 }
2162 2172
2163 2173
2164 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2174 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2165 const DeoptReasonId deopt_reason = 2175 const DeoptReasonId deopt_reason =
2166 (array_type() == kGrowableObjectArrayCid) ? 2176 (array_type() == kGrowableObjectArrayCid) ?
2167 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; 2177 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray;
2168 Label* deopt = compiler->AddDeoptStub(deopt_id(), 2178 Label* deopt = compiler->AddDeoptStub(deopt_id(),
2169 deopt_reason); 2179 deopt_reason);
2170 ASSERT(array_type() == kArrayCid || 2180 ASSERT((array_type() == kArrayCid) ||
2171 array_type() == kImmutableArrayCid || 2181 (array_type() == kImmutableArrayCid) ||
2172 array_type() == kGrowableObjectArrayCid); 2182 (array_type() == kGrowableObjectArrayCid) ||
2173 intptr_t length_offset = (array_type() == kGrowableObjectArrayCid) 2183 (array_type() == kFloat64ArrayCid));
2174 ? GrowableObjectArray::length_offset() 2184 intptr_t length_offset = -1;
2175 : Array::length_offset(); 2185 if (array_type() == kGrowableObjectArrayCid) {
2186 length_offset = GrowableObjectArray::length_offset();
2187 } else if (array_type() == kFloat64ArrayCid) {
2188 length_offset = Float64Array::length_offset();
2189 } else {
2190 length_offset = Array::length_offset();
2191 }
2176 2192
2177 // This case should not have created a bound check instruction. 2193 // This case should not have created a bound check instruction.
2178 ASSERT(!(locs()->in(0).IsConstant() && locs()->in(1).IsConstant())); 2194 ASSERT(!(locs()->in(0).IsConstant() && locs()->in(1).IsConstant()));
2179 2195
2180 if (locs()->in(1).IsConstant()) { 2196 if (locs()->in(1).IsConstant()) {
2181 Register receiver = locs()->in(0).reg(); 2197 Register receiver = locs()->in(0).reg();
2182 const Object& constant = locs()->in(1).constant(); 2198 const Object& constant = locs()->in(1).constant();
2183 ASSERT(constant.IsSmi()); 2199 ASSERT(constant.IsSmi());
2184 const int64_t imm = 2200 const int64_t imm =
2185 reinterpret_cast<int64_t>(constant.raw()); 2201 reinterpret_cast<int64_t>(constant.raw());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 2270
2255 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2271 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2256 UNIMPLEMENTED(); 2272 UNIMPLEMENTED();
2257 } 2273 }
2258 2274
2259 } // namespace dart 2275 } // namespace dart
2260 2276
2261 #undef __ 2277 #undef __
2262 2278
2263 #endif // defined TARGET_ARCH_X64 2279 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | tests/standalone/float_array_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698