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

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

Issue 12378039: Inline ByteArray setters like setUint8 in the optimizer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments Created 7 years, 9 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 1160
1161 1161
1162 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { 1162 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const {
1163 const intptr_t kNumInputs = 3; 1163 const intptr_t kNumInputs = 3;
1164 const intptr_t kNumTemps = 0; 1164 const intptr_t kNumTemps = 0;
1165 LocationSummary* locs = 1165 LocationSummary* locs =
1166 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 1166 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
1167 locs->set_in(0, Location::RequiresRegister()); 1167 locs->set_in(0, Location::RequiresRegister());
1168 // The smi index is either untagged (element size == 1), or it is left smi 1168 // The smi index is either untagged (element size == 1), or it is left smi
1169 // tagged (for all element sizes > 1). 1169 // tagged (for all element sizes > 1).
1170 intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(class_id()); 1170 if (index_scale() == 1) {
1171 if (index_scale == 1) {
1172 locs->set_in(1, CanBeImmediateIndex(index(), class_id()) 1171 locs->set_in(1, CanBeImmediateIndex(index(), class_id())
1173 ? Location::Constant( 1172 ? Location::Constant(
1174 index()->definition()->AsConstant()->value()) 1173 index()->definition()->AsConstant()->value())
1175 : Location::WritableRegister()); 1174 : Location::WritableRegister());
1176 } else { 1175 } else {
1177 locs->set_in(1, CanBeImmediateIndex(index(), class_id()) 1176 locs->set_in(1, CanBeImmediateIndex(index(), class_id())
1178 ? Location::Constant( 1177 ? Location::Constant(
1179 index()->definition()->AsConstant()->value()) 1178 index()->definition()->AsConstant()->value())
1180 : Location::RequiresRegister()); 1179 : Location::RequiresRegister());
1181 } 1180 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 return NULL; 1216 return NULL;
1218 } 1217 }
1219 return locs; 1218 return locs;
1220 } 1219 }
1221 1220
1222 1221
1223 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1222 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1224 Register array = locs()->in(0).reg(); 1223 Register array = locs()->in(0).reg();
1225 Location index = locs()->in(1); 1224 Location index = locs()->in(1);
1226 1225
1227 intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(class_id());
1228 Address element_address(kNoRegister, 0); 1226 Address element_address(kNoRegister, 0);
1229 if ((class_id() == kExternalUint8ArrayCid) || 1227 if ((class_id() == kExternalUint8ArrayCid) ||
1230 (class_id() == kExternalUint8ClampedArrayCid)) { 1228 (class_id() == kExternalUint8ClampedArrayCid)) {
1231 Register temp = locs()->temp(0).reg(); 1229 Register temp = locs()->temp(0).reg();
1232 element_address = index.IsRegister() 1230 element_address = index.IsRegister()
1233 ? FlowGraphCompiler::ExternalElementAddressForRegIndex( 1231 ? FlowGraphCompiler::ExternalElementAddressForRegIndex(
1234 class_id(), index_scale, temp, index.reg()) 1232 class_id(), index_scale(), temp, index.reg())
1235 : FlowGraphCompiler::ExternalElementAddressForIntIndex( 1233 : FlowGraphCompiler::ExternalElementAddressForIntIndex(
1236 class_id(), index_scale, temp, 1234 class_id(), index_scale(), temp,
1237 Smi::Cast(index.constant()).Value()); 1235 Smi::Cast(index.constant()).Value());
1238 __ movq(temp, 1236 __ movq(temp,
1239 FieldAddress(array, ExternalUint8Array::data_offset())); 1237 FieldAddress(array, ExternalUint8Array::data_offset()));
1240 } else { 1238 } else {
1241 element_address = index.IsRegister() 1239 element_address = index.IsRegister()
1242 ? FlowGraphCompiler::ElementAddressForRegIndex( 1240 ? FlowGraphCompiler::ElementAddressForRegIndex(
1243 class_id(), index_scale, array, index.reg()) 1241 class_id(), index_scale(), array, index.reg())
1244 : FlowGraphCompiler::ElementAddressForIntIndex( 1242 : FlowGraphCompiler::ElementAddressForIntIndex(
1245 class_id(), index_scale, array, 1243 class_id(), index_scale(), array,
1246 Smi::Cast(index.constant()).Value()); 1244 Smi::Cast(index.constant()).Value());
1247 } 1245 }
1248 1246
1247 if ((index_scale() == 1) && index.IsRegister()) {
1248 __ SmiUntag(index.reg());
1249 }
1249 switch (class_id()) { 1250 switch (class_id()) {
1250 case kArrayCid: 1251 case kArrayCid:
1251 if (ShouldEmitStoreBarrier()) { 1252 if (ShouldEmitStoreBarrier()) {
1252 Register value = locs()->in(2).reg(); 1253 Register value = locs()->in(2).reg();
1253 __ StoreIntoObject(array, element_address, value); 1254 __ StoreIntoObject(array, element_address, value);
1254 } else if (locs()->in(2).IsConstant()) { 1255 } else if (locs()->in(2).IsConstant()) {
1255 const Object& constant = locs()->in(2).constant(); 1256 const Object& constant = locs()->in(2).constant();
1256 __ StoreObject(element_address, constant); 1257 __ StoreObject(element_address, constant);
1257 } else { 1258 } else {
1258 Register value = locs()->in(2).reg(); 1259 Register value = locs()->in(2).reg();
1259 __ StoreIntoObjectNoBarrier(array, element_address, value); 1260 __ StoreIntoObjectNoBarrier(array, element_address, value);
1260 } 1261 }
1261 break; 1262 break;
1262 case kInt8ArrayCid: 1263 case kInt8ArrayCid:
1263 case kUint8ArrayCid: 1264 case kUint8ArrayCid:
1264 case kExternalUint8ArrayCid: 1265 case kExternalUint8ArrayCid:
1265 if (index.IsRegister()) {
1266 __ SmiUntag(index.reg());
1267 }
1268 if (locs()->in(2).IsConstant()) { 1266 if (locs()->in(2).IsConstant()) {
1269 const Smi& constant = Smi::Cast(locs()->in(2).constant()); 1267 const Smi& constant = Smi::Cast(locs()->in(2).constant());
1270 __ movb(element_address, 1268 __ movb(element_address,
1271 Immediate(static_cast<int8_t>(constant.Value()))); 1269 Immediate(static_cast<int8_t>(constant.Value())));
1272 } else { 1270 } else {
1273 ASSERT(locs()->in(2).reg() == RAX); 1271 ASSERT(locs()->in(2).reg() == RAX);
1274 __ SmiUntag(RAX); 1272 __ SmiUntag(RAX);
1275 __ movb(element_address, RAX); 1273 __ movb(element_address, RAX);
1276 } 1274 }
1277 break; 1275 break;
1278 case kUint8ClampedArrayCid: 1276 case kUint8ClampedArrayCid:
1279 case kExternalUint8ClampedArrayCid: { 1277 case kExternalUint8ClampedArrayCid: {
1280 if (index.IsRegister()) {
1281 __ SmiUntag(index.reg());
1282 }
1283 if (locs()->in(2).IsConstant()) { 1278 if (locs()->in(2).IsConstant()) {
1284 const Smi& constant = Smi::Cast(locs()->in(2).constant()); 1279 const Smi& constant = Smi::Cast(locs()->in(2).constant());
1285 intptr_t value = constant.Value(); 1280 intptr_t value = constant.Value();
1286 // Clamp to 0x0 or 0xFF respectively. 1281 // Clamp to 0x0 or 0xFF respectively.
1287 if (value > 0xFF) { 1282 if (value > 0xFF) {
1288 value = 0xFF; 1283 value = 0xFF;
1289 } else if (value < 0) { 1284 } else if (value < 0) {
1290 value = 0; 1285 value = 0;
1291 } 1286 }
1292 __ movb(element_address, 1287 __ movb(element_address,
(...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after
3163 PcDescriptors::kOther, 3158 PcDescriptors::kOther,
3164 locs()); 3159 locs());
3165 __ Drop(2); // Discard type arguments and receiver. 3160 __ Drop(2); // Discard type arguments and receiver.
3166 } 3161 }
3167 3162
3168 } // namespace dart 3163 } // namespace dart
3169 3164
3170 #undef __ 3165 #undef __
3171 3166
3172 #endif // defined TARGET_ARCH_X64 3167 #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