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

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

Issue 2331033003: DBC: A couple allocation fastpaths. (Closed)
Patch Set: Address comments Created 4 years, 3 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
« no previous file with comments | « runtime/vm/constants_dbc.h ('k') | runtime/vm/simulator_dbc.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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_DBC. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_DBC.
6 #if defined(TARGET_ARCH_DBC) 6 #if defined(TARGET_ARCH_DBC)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 __ Bind(&is_true); 676 __ Bind(&is_true);
677 __ LoadConstant(result_reg, Bool::True()); 677 __ LoadConstant(result_reg, Bool::True());
678 __ Bind(&done); 678 __ Bind(&done);
679 } 679 }
680 680
681 681
682 EMIT_NATIVE_CODE(CreateArray, 682 EMIT_NATIVE_CODE(CreateArray,
683 2, Location::RequiresRegister(), 683 2, Location::RequiresRegister(),
684 LocationSummary::kCall) { 684 LocationSummary::kCall) {
685 if (compiler->is_optimizing()) { 685 if (compiler->is_optimizing()) {
686 __ Push(locs()->in(0).reg()); 686 const Register length = locs()->in(kLengthPos).reg();
687 __ Push(locs()->in(1).reg()); 687 const Register type_arguments = locs()->in(kElementTypePos).reg();
688 } 688 const Register out = locs()->out(0).reg();
689 __ CreateArrayTOS(); 689 __ CreateArrayOpt(out, length, type_arguments);
690 compiler->RecordSafepoint(locs()); 690 __ Push(type_arguments);
691 if (compiler->is_optimizing()) { 691 __ Push(length);
692 __ PopLocal(locs()->out(0).reg()); 692 __ CreateArrayTOS();
693 compiler->RecordSafepoint(locs());
694 __ PopLocal(out);
695 } else {
696 __ CreateArrayTOS();
697 compiler->RecordSafepoint(locs());
693 } 698 }
694 } 699 }
695 700
696 701
697 EMIT_NATIVE_CODE(StoreIndexed, 3, Location::NoLocation(), 702 EMIT_NATIVE_CODE(StoreIndexed, 3, Location::NoLocation(),
698 LocationSummary::kNoCall, 1) { 703 LocationSummary::kNoCall, 1) {
699 if (!compiler->is_optimizing()) { 704 if (!compiler->is_optimizing()) {
700 ASSERT(class_id() == kArrayCid); 705 ASSERT(class_id() == kArrayCid);
701 __ StoreIndexedTOS(); 706 __ StoreIndexedTOS();
702 return; 707 return;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 const Register str = locs()->in(0).reg(); 908 const Register str = locs()->in(0).reg();
904 const Register result = locs()->out(0).reg(); // Result char code is a smi. 909 const Register result = locs()->out(0).reg(); // Result char code is a smi.
905 __ StringToCharCode(result, str); 910 __ StringToCharCode(result, str);
906 } 911 }
907 912
908 913
909 EMIT_NATIVE_CODE(AllocateObject, 914 EMIT_NATIVE_CODE(AllocateObject,
910 0, Location::RequiresRegister(), 915 0, Location::RequiresRegister(),
911 LocationSummary::kCall) { 916 LocationSummary::kCall) {
912 if (ArgumentCount() == 1) { 917 if (ArgumentCount() == 1) {
918 // Allocate with type arguments.
913 __ PushConstant(cls()); 919 __ PushConstant(cls());
914 __ AllocateT(); 920 __ AllocateT();
915 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, 921 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther,
916 Thread::kNoDeoptId, 922 Thread::kNoDeoptId,
917 token_pos()); 923 token_pos());
924 compiler->RecordSafepoint(locs());
925 if (compiler->is_optimizing()) {
926 __ PopLocal(locs()->out(0).reg());
927 }
928 } else if (compiler->is_optimizing()) {
929 // If we're optimizing, try a streamlined fastpath.
930 const intptr_t instance_size = cls().instance_size();
931 Isolate* isolate = Isolate::Current();
932 if (Heap::IsAllocatableInNewSpace(instance_size) &&
933 !cls().TraceAllocation(isolate)) {
934 uword tags = 0;
935 tags = RawObject::SizeTag::update(instance_size, tags);
936 ASSERT(cls().id() != kIllegalCid);
937 tags = RawObject::ClassIdTag::update(cls().id(), tags);
938 if (Smi::IsValid(tags)) {
939 const intptr_t tags_kidx = __ AddConstant(Smi::Handle(Smi::New(tags)));
940 __ AllocateOpt(locs()->out(0).reg(), tags_kidx);
941 }
942 }
943 const intptr_t kidx = __ AddConstant(cls());
944 __ Allocate(kidx);
945 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther,
946 Thread::kNoDeoptId,
947 token_pos());
948 compiler->RecordSafepoint(locs());
949 __ PopLocal(locs()->out(0).reg());
918 } else { 950 } else {
919 const intptr_t kidx = __ AddConstant(cls()); 951 const intptr_t kidx = __ AddConstant(cls());
920 __ Allocate(kidx); 952 __ Allocate(kidx);
921 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, 953 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther,
922 Thread::kNoDeoptId, 954 Thread::kNoDeoptId,
923 token_pos()); 955 token_pos());
924 } 956 compiler->RecordSafepoint(locs());
925 compiler->RecordSafepoint(locs());
926 if (compiler->is_optimizing()) {
927 __ PopLocal(locs()->out(0).reg());
928 } 957 }
929 } 958 }
930 959
931 960
932 EMIT_NATIVE_CODE(StoreInstanceField, 2) { 961 EMIT_NATIVE_CODE(StoreInstanceField, 2) {
933 ASSERT(!HasTemp()); 962 ASSERT(!HasTemp());
934 ASSERT(offset_in_bytes() % kWordSize == 0); 963 ASSERT(offset_in_bytes() % kWordSize == 0);
935 if (compiler->is_optimizing()) { 964 if (compiler->is_optimizing()) {
936 const Register value = locs()->in(1).reg(); 965 const Register value = locs()->in(1).reg();
937 const Register instance = locs()->in(0).reg(); 966 const Register instance = locs()->in(0).reg();
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 UNREACHABLE(); 1435 UNREACHABLE();
1407 break; 1436 break;
1408 } 1437 }
1409 } 1438 }
1410 1439
1411 1440
1412 EMIT_NATIVE_CODE(Box, 1, Location::RequiresRegister(), LocationSummary::kCall) { 1441 EMIT_NATIVE_CODE(Box, 1, Location::RequiresRegister(), LocationSummary::kCall) {
1413 ASSERT(from_representation() == kUnboxedDouble); 1442 ASSERT(from_representation() == kUnboxedDouble);
1414 const Register value = locs()->in(0).reg(); 1443 const Register value = locs()->in(0).reg();
1415 const Register out = locs()->out(0).reg(); 1444 const Register out = locs()->out(0).reg();
1445 const intptr_t instance_size = compiler->double_class().instance_size();
1446 Isolate* isolate = Isolate::Current();
1447 ASSERT(Heap::IsAllocatableInNewSpace(instance_size));
1448 if (!compiler->double_class().TraceAllocation(isolate)) {
1449 uword tags = 0;
1450 tags = RawObject::SizeTag::update(instance_size, tags);
1451 tags = RawObject::ClassIdTag::update(compiler->double_class().id(), tags);
1452 if (Smi::IsValid(tags)) {
1453 const intptr_t tags_kidx = __ AddConstant(Smi::Handle(Smi::New(tags)));
1454 __ AllocateOpt(out, tags_kidx);
1455 }
1456 }
1416 const intptr_t kidx = __ AddConstant(compiler->double_class()); 1457 const intptr_t kidx = __ AddConstant(compiler->double_class());
1417 __ Allocate(kidx); 1458 __ Allocate(kidx);
1418 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, 1459 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther,
1419 Thread::kNoDeoptId, 1460 Thread::kNoDeoptId,
1420 token_pos()); 1461 token_pos());
1421 compiler->RecordSafepoint(locs()); 1462 compiler->RecordSafepoint(locs());
1422 // __ Allocate puts the box at the top of the stack. 1463 __ PopLocal(out);
1423 __ WriteIntoDouble(out, value); 1464 __ WriteIntoDouble(out, value);
1424 } 1465 }
1425 1466
1426 1467
1427 EMIT_NATIVE_CODE(Unbox, 1, Location::RequiresRegister()) { 1468 EMIT_NATIVE_CODE(Unbox, 1, Location::RequiresRegister()) {
1428 ASSERT(representation() == kUnboxedDouble); 1469 ASSERT(representation() == kUnboxedDouble);
1429 const intptr_t value_cid = value()->Type()->ToCid(); 1470 const intptr_t value_cid = value()->Type()->ToCid();
1430 const intptr_t box_cid = BoxCid(); 1471 const intptr_t box_cid = BoxCid();
1431 const Register box = locs()->in(0).reg(); 1472 const Register box = locs()->in(0).reg();
1432 const Register result = locs()->out(0).reg(); 1473 const Register result = locs()->out(0).reg();
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 __ IfULe(length, index); 1784 __ IfULe(length, index);
1744 compiler->EmitDeopt(deopt_id(), 1785 compiler->EmitDeopt(deopt_id(),
1745 ICData::kDeoptCheckArrayBound, 1786 ICData::kDeoptCheckArrayBound,
1746 (generalized_ ? ICData::kGeneralized : 0) | 1787 (generalized_ ? ICData::kGeneralized : 0) |
1747 (licm_hoisted_ ? ICData::kHoisted : 0)); 1788 (licm_hoisted_ ? ICData::kHoisted : 0));
1748 } 1789 }
1749 1790
1750 } // namespace dart 1791 } // namespace dart
1751 1792
1752 #endif // defined TARGET_ARCH_DBC 1793 #endif // defined TARGET_ARCH_DBC
OLDNEW
« no previous file with comments | « runtime/vm/constants_dbc.h ('k') | runtime/vm/simulator_dbc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698