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

Side by Side Diff: runtime/vm/intermediate_language_ia32.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.h ('k') | runtime/vm/intermediate_language_x64.cc » ('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) 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_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 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 1325
1326 1326
1327 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { 1327 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const {
1328 const intptr_t kNumInputs = 3; 1328 const intptr_t kNumInputs = 3;
1329 const intptr_t kNumTemps = 0; 1329 const intptr_t kNumTemps = 0;
1330 LocationSummary* locs = 1330 LocationSummary* locs =
1331 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 1331 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
1332 locs->set_in(0, Location::RequiresRegister()); 1332 locs->set_in(0, Location::RequiresRegister());
1333 // The smi index is either untagged (element size == 1), or it is left smi 1333 // The smi index is either untagged (element size == 1), or it is left smi
1334 // tagged (for all element sizes > 1). 1334 // tagged (for all element sizes > 1).
1335 intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(class_id()); 1335 if (index_scale() == 1) {
1336 if (index_scale == 1) {
1337 locs->set_in(1, CanBeImmediateIndex(index(), class_id()) 1336 locs->set_in(1, CanBeImmediateIndex(index(), class_id())
1338 ? Location::Constant( 1337 ? Location::Constant(
1339 index()->definition()->AsConstant()->value()) 1338 index()->definition()->AsConstant()->value())
1340 : Location::WritableRegister()); 1339 : Location::WritableRegister());
1341 } else { 1340 } else {
1342 locs->set_in(1, CanBeImmediateIndex(index(), class_id()) 1341 locs->set_in(1, CanBeImmediateIndex(index(), class_id())
1343 ? Location::Constant( 1342 ? Location::Constant(
1344 index()->definition()->AsConstant()->value()) 1343 index()->definition()->AsConstant()->value())
1345 : Location::RequiresRegister()); 1344 : Location::RequiresRegister());
1346 } 1345 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 return NULL; 1387 return NULL;
1389 } 1388 }
1390 return locs; 1389 return locs;
1391 } 1390 }
1392 1391
1393 1392
1394 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1393 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1395 Register array = locs()->in(0).reg(); 1394 Register array = locs()->in(0).reg();
1396 Location index = locs()->in(1); 1395 Location index = locs()->in(1);
1397 1396
1398 intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(class_id());
1399
1400 Address element_address(kNoRegister, 0); 1397 Address element_address(kNoRegister, 0);
1401 if ((class_id() == kExternalUint8ArrayCid) || 1398 if ((class_id() == kExternalUint8ArrayCid) ||
1402 (class_id() == kExternalUint8ClampedArrayCid)) { 1399 (class_id() == kExternalUint8ClampedArrayCid)) {
1403 Register temp = locs()->temp(0).reg(); 1400 Register temp = locs()->temp(0).reg();
1404 element_address = index.IsRegister() 1401 element_address = index.IsRegister()
1405 ? FlowGraphCompiler::ExternalElementAddressForRegIndex( 1402 ? FlowGraphCompiler::ExternalElementAddressForRegIndex(
1406 class_id(), index_scale, temp, index.reg()) 1403 class_id(), index_scale(), temp, index.reg())
1407 : FlowGraphCompiler::ExternalElementAddressForIntIndex( 1404 : FlowGraphCompiler::ExternalElementAddressForIntIndex(
1408 class_id(), index_scale, temp, 1405 class_id(), index_scale(), temp,
1409 Smi::Cast(index.constant()).Value()); 1406 Smi::Cast(index.constant()).Value());
1410 __ movl(temp, 1407 __ movl(temp,
1411 FieldAddress(array, ExternalUint8Array::data_offset())); 1408 FieldAddress(array, ExternalUint8Array::data_offset()));
1412 } else { 1409 } else {
1413 element_address = index.IsRegister() 1410 element_address = index.IsRegister()
1414 ? FlowGraphCompiler::ElementAddressForRegIndex( 1411 ? FlowGraphCompiler::ElementAddressForRegIndex(
1415 class_id(), index_scale, array, index.reg()) 1412 class_id(), index_scale(), array, index.reg())
1416 : FlowGraphCompiler::ElementAddressForIntIndex( 1413 : FlowGraphCompiler::ElementAddressForIntIndex(
1417 class_id(), index_scale, array, Smi::Cast(index.constant()).Value()); 1414 class_id(), index_scale(), array,
1415 Smi::Cast(index.constant()).Value());
1418 } 1416 }
1419 1417
1418 if ((index_scale() == 1) && index.IsRegister()) {
1419 __ SmiUntag(index.reg());
1420 }
1420 switch (class_id()) { 1421 switch (class_id()) {
1421 case kArrayCid: 1422 case kArrayCid:
1422 if (ShouldEmitStoreBarrier()) { 1423 if (ShouldEmitStoreBarrier()) {
1423 Register value = locs()->in(2).reg(); 1424 Register value = locs()->in(2).reg();
1424 __ StoreIntoObject(array, element_address, value); 1425 __ StoreIntoObject(array, element_address, value);
1425 } else if (locs()->in(2).IsConstant()) { 1426 } else if (locs()->in(2).IsConstant()) {
1426 const Object& constant = locs()->in(2).constant(); 1427 const Object& constant = locs()->in(2).constant();
1427 __ StoreIntoObjectNoBarrier(array, element_address, constant); 1428 __ StoreIntoObjectNoBarrier(array, element_address, constant);
1428 } else { 1429 } else {
1429 Register value = locs()->in(2).reg(); 1430 Register value = locs()->in(2).reg();
1430 __ StoreIntoObjectNoBarrier(array, element_address, value); 1431 __ StoreIntoObjectNoBarrier(array, element_address, value);
1431 } 1432 }
1432 break; 1433 break;
1433 case kInt8ArrayCid: 1434 case kInt8ArrayCid:
1434 case kUint8ArrayCid: 1435 case kUint8ArrayCid:
1435 case kExternalUint8ArrayCid: 1436 case kExternalUint8ArrayCid:
1436 if (index.IsRegister()) {
1437 __ SmiUntag(index.reg());
1438 }
1439 if (locs()->in(2).IsConstant()) { 1437 if (locs()->in(2).IsConstant()) {
1440 const Smi& constant = Smi::Cast(locs()->in(2).constant()); 1438 const Smi& constant = Smi::Cast(locs()->in(2).constant());
1441 __ movb(element_address, 1439 __ movb(element_address,
1442 Immediate(static_cast<int8_t>(constant.Value()))); 1440 Immediate(static_cast<int8_t>(constant.Value())));
1443 } else { 1441 } else {
1444 ASSERT(locs()->in(2).reg() == EAX); 1442 ASSERT(locs()->in(2).reg() == EAX);
1445 __ SmiUntag(EAX); 1443 __ SmiUntag(EAX);
1446 __ movb(element_address, AL); 1444 __ movb(element_address, AL);
1447 } 1445 }
1448 break; 1446 break;
1449 case kUint8ClampedArrayCid: 1447 case kUint8ClampedArrayCid:
1450 case kExternalUint8ClampedArrayCid: { 1448 case kExternalUint8ClampedArrayCid: {
1451 if (index.IsRegister()) {
1452 __ SmiUntag(index.reg());
1453 }
1454 if (locs()->in(2).IsConstant()) { 1449 if (locs()->in(2).IsConstant()) {
1455 const Smi& constant = Smi::Cast(locs()->in(2).constant()); 1450 const Smi& constant = Smi::Cast(locs()->in(2).constant());
1456 intptr_t value = constant.Value(); 1451 intptr_t value = constant.Value();
1457 // Clamp to 0x0 or 0xFF respectively. 1452 // Clamp to 0x0 or 0xFF respectively.
1458 if (value > 0xFF) { 1453 if (value > 0xFF) {
1459 value = 0xFF; 1454 value = 0xFF;
1460 } else if (value < 0) { 1455 } else if (value < 0) {
1461 value = 0; 1456 value = 0;
1462 } 1457 }
1463 __ movb(element_address, 1458 __ movb(element_address,
(...skipping 2095 matching lines...) Expand 10 before | Expand all | Expand 10 after
3559 PcDescriptors::kOther, 3554 PcDescriptors::kOther,
3560 locs()); 3555 locs());
3561 __ Drop(2); // Discard type arguments and receiver. 3556 __ Drop(2); // Discard type arguments and receiver.
3562 } 3557 }
3563 3558
3564 } // namespace dart 3559 } // namespace dart
3565 3560
3566 #undef __ 3561 #undef __
3567 3562
3568 #endif // defined TARGET_ARCH_IA32 3563 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698