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

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

Issue 2258493004: DBC: Fixes typed data bugs. Adds unboxed int32 instructions (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 4 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 29 matching lines...) Expand all
40 M(BoxInt64) \ 40 M(BoxInt64) \
41 M(MergedMath) \ 41 M(MergedMath) \
42 M(GuardFieldClass) \ 42 M(GuardFieldClass) \
43 M(GuardFieldLength) \ 43 M(GuardFieldLength) \
44 M(IfThenElse) \ 44 M(IfThenElse) \
45 M(ExtractNthOutput) \ 45 M(ExtractNthOutput) \
46 M(BinaryUint32Op) \ 46 M(BinaryUint32Op) \
47 M(ShiftUint32Op) \ 47 M(ShiftUint32Op) \
48 M(UnaryUint32Op) \ 48 M(UnaryUint32Op) \
49 M(UnboxedIntConverter) \ 49 M(UnboxedIntConverter) \
50 M(BoxInteger32) \
51 M(UnboxInteger32) \
52 50
53 // List of instructions that are not used by DBC. 51 // List of instructions that are not used by DBC.
54 // Things we aren't planning to implement for DBC: 52 // Things we aren't planning to implement for DBC:
55 // - Unboxed SIMD, 53 // - Unboxed SIMD,
56 // - Unboxed Mint, 54 // - Unboxed Mint,
57 // - Optimized RegExps, 55 // - Optimized RegExps,
58 // - Precompilation. 56 // - Precompilation.
59 #define FOR_EACH_UNREACHABLE_INSTRUCTION(M) \ 57 #define FOR_EACH_UNREACHABLE_INSTRUCTION(M) \
60 M(CaseInsensitiveCompareUC16) \ 58 M(CaseInsensitiveCompareUC16) \
61 M(GenericCheckBound) \ 59 M(GenericCheckBound) \
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 } 694 }
697 695
698 696
699 EMIT_NATIVE_CODE(StoreIndexed, 3, Location::NoLocation(), 697 EMIT_NATIVE_CODE(StoreIndexed, 3, Location::NoLocation(),
700 LocationSummary::kNoCall, 1) { 698 LocationSummary::kNoCall, 1) {
701 if (!compiler->is_optimizing()) { 699 if (!compiler->is_optimizing()) {
702 ASSERT(class_id() == kArrayCid); 700 ASSERT(class_id() == kArrayCid);
703 __ StoreIndexedTOS(); 701 __ StoreIndexedTOS();
704 return; 702 return;
705 } 703 }
706
707 const Register array = locs()->in(kArrayPos).reg(); 704 const Register array = locs()->in(kArrayPos).reg();
708 const Register index = locs()->in(kIndexPos).reg(); 705 const Register index = locs()->in(kIndexPos).reg();
709 const Register value = locs()->in(kValuePos).reg(); 706 const Register value = locs()->in(kValuePos).reg();
710 const Register temp = locs()->temp(0).reg(); 707 const Register temp = locs()->temp(0).reg();
711 switch (class_id()) { 708 switch (class_id()) {
712 case kArrayCid: 709 case kArrayCid:
713 __ StoreIndexed(array, index, value); 710 __ StoreIndexed(array, index, value);
714 break; 711 break;
715 case kTypedDataUint8ArrayCid: 712 case kTypedDataUint8ArrayCid:
716 case kTypedDataInt8ArrayCid: 713 case kTypedDataInt8ArrayCid:
717 case kExternalOneByteStringCid: 714 case kExternalOneByteStringCid:
718 case kExternalTypedDataUint8ArrayCid: 715 case kExternalTypedDataUint8ArrayCid:
719 ASSERT(index_scale() == 1); 716 ASSERT(index_scale() == 1);
720 if (IsExternal()) { 717 if (IsExternal()) {
721 __ StoreIndexedExternalUint8(array, index, value); 718 __ StoreIndexedExternalUint8(array, index, value);
722 } else { 719 } else {
723 __ StoreIndexedUint8(array, index, value); 720 __ StoreIndexedUint8(array, index, value);
724 } 721 }
725 break; 722 break;
726 case kTypedDataFloat64ArrayCid: 723 case kTypedDataInt32ArrayCid:
727 if (IsExternal() || ((index_scale() != 8) && (index_scale() != 1))) { 724 case kTypedDataUint32ArrayCid: {
725 if (IsExternal()) {
728 Unsupported(compiler); 726 Unsupported(compiler);
729 UNREACHABLE(); 727 UNREACHABLE();
730 } 728 }
731 if (index_scale() == 1) { 729 if (index_scale() != 1) {
732 __ ShrImm(temp, index, 3); 730 __ ShlImm(temp, index, Utils::ShiftForPowerOfTwo(index_scale()));
733 } else { 731 } else {
734 __ Move(temp, index); 732 __ Move(temp, index);
735 } 733 }
734 __ StoreIndexedUint32(array, temp, value);
735 break;
736 }
737 case kTypedDataFloat64ArrayCid:
738 if (IsExternal()) {
739 Unsupported(compiler);
740 UNREACHABLE();
741 }
742 if (index_scale() != 1) {
743 __ ShlImm(temp, index, Utils::ShiftForPowerOfTwo(index_scale()));
744 } else {
745 __ Move(temp, index);
746 }
736 __ StoreIndexedFloat64(array, temp, value); 747 __ StoreIndexedFloat64(array, temp, value);
737 break; 748 break;
738 default: 749 default:
739 Unsupported(compiler); 750 Unsupported(compiler);
740 UNREACHABLE(); 751 UNREACHABLE();
741 break; 752 break;
742 } 753 }
743 } 754 }
744 755
745 756
746 EMIT_NATIVE_CODE(LoadIndexed, 2, Location::RequiresRegister()) { 757 EMIT_NATIVE_CODE(LoadIndexed, 2, Location::RequiresRegister(),
758 LocationSummary::kNoCall, 1) {
747 ASSERT(compiler->is_optimizing()); 759 ASSERT(compiler->is_optimizing());
748 const Register array = locs()->in(0).reg(); 760 const Register array = locs()->in(0).reg();
749 const Register index = locs()->in(1).reg(); 761 const Register index = locs()->in(1).reg();
762 const Register temp = locs()->temp(0).reg();
750 const Register result = locs()->out(0).reg(); 763 const Register result = locs()->out(0).reg();
751 switch (class_id()) { 764 switch (class_id()) {
752 case kArrayCid: 765 case kArrayCid:
753 __ LoadIndexed(result, array, index); 766 __ LoadIndexed(result, array, index);
754 break; 767 break;
755 case kTypedDataUint8ArrayCid: 768 case kTypedDataUint8ArrayCid:
756 case kTypedDataUint8ClampedArrayCid: 769 case kTypedDataUint8ClampedArrayCid:
757 case kExternalOneByteStringCid: 770 case kExternalOneByteStringCid:
758 case kExternalTypedDataUint8ArrayCid: 771 case kExternalTypedDataUint8ArrayCid:
759 case kExternalTypedDataUint8ClampedArrayCid: 772 case kExternalTypedDataUint8ClampedArrayCid:
(...skipping 17 matching lines...) Expand all
777 __ LoadIndexedOneByteString(result, array, index); 790 __ LoadIndexedOneByteString(result, array, index);
778 break; 791 break;
779 case kTwoByteStringCid: 792 case kTwoByteStringCid:
780 if (index_scale() != 2) { 793 if (index_scale() != 2) {
781 // TODO(zra): Fix-up index. 794 // TODO(zra): Fix-up index.
782 Unsupported(compiler); 795 Unsupported(compiler);
783 UNREACHABLE(); 796 UNREACHABLE();
784 } 797 }
785 __ LoadIndexedTwoByteString(result, array, index); 798 __ LoadIndexedTwoByteString(result, array, index);
786 break; 799 break;
800 case kTypedDataInt32ArrayCid:
801 ASSERT(representation() == kUnboxedInt32);
802 if (index_scale() != 1) {
803 __ ShlImm(temp, index, Utils::ShiftForPowerOfTwo(index_scale()));
804 } else {
805 __ Move(temp, index);
806 }
807 __ LoadIndexedInt32(result, array, temp);
808 break;
809 case kTypedDataUint32ArrayCid:
810 ASSERT(representation() == kUnboxedUint32);
811 if (index_scale() != 1) {
812 __ ShlImm(temp, index, Utils::ShiftForPowerOfTwo(index_scale()));
813 } else {
814 __ Move(temp, index);
815 }
816 __ LoadIndexedUint32(result, array, temp);
817 break;
787 case kTypedDataFloat64ArrayCid: 818 case kTypedDataFloat64ArrayCid:
788 if ((index_scale() != 8) && (index_scale() != 1)) { 819 if (index_scale() != 1) {
789 Unsupported(compiler); 820 __ ShlImm(temp, index, Utils::ShiftForPowerOfTwo(index_scale()));
790 UNREACHABLE(); 821 } else {
822 __ Move(temp, index);
791 } 823 }
792 if (index_scale() == 1) { 824 __ LoadIndexedFloat64(result, array, temp);
793 __ ShrImm(index, index, 3);
794 }
795 __ LoadIndexedFloat64(result, array, index);
796 break; 825 break;
797 default: 826 default:
798 Unsupported(compiler); 827 Unsupported(compiler);
799 UNREACHABLE(); 828 UNREACHABLE();
800 break; 829 break;
801 } 830 }
802 } 831 }
803 832
804 833
805 EMIT_NATIVE_CODE(StringInterpolate, 834 EMIT_NATIVE_CODE(StringInterpolate,
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 __ IfEqNull(box); 1430 __ IfEqNull(box);
1402 compiler->EmitDeopt(GetDeoptId(), ICData::kDeoptCheckClass); 1431 compiler->EmitDeopt(GetDeoptId(), ICData::kDeoptCheckClass);
1403 __ UnboxDouble(result, box); 1432 __ UnboxDouble(result, box);
1404 } else { 1433 } else {
1405 __ CheckedUnboxDouble(result, box); 1434 __ CheckedUnboxDouble(result, box);
1406 compiler->EmitDeopt(GetDeoptId(), ICData::kDeoptCheckClass); 1435 compiler->EmitDeopt(GetDeoptId(), ICData::kDeoptCheckClass);
1407 } 1436 }
1408 } 1437 }
1409 1438
1410 1439
1440 EMIT_NATIVE_CODE(UnboxInteger32, 1, Location::RequiresRegister()) {
1441 #if defined(ARCH_IS_64_BIT)
1442 const Register out = locs()->out(0).reg();
1443 const Register value = locs()->in(0).reg();
1444 const bool may_truncate = is_truncating() || !CanDeoptimize();
1445 __ UnboxInt32(out, value, may_truncate);
1446 if (CanDeoptimize()) {
1447 compiler->EmitDeopt(GetDeoptId(), ICData::kDeoptUnboxInteger);
1448 } else {
1449 __ Nop(0);
1450 }
1451 #else
1452 Unsupported(compiler);
1453 UNREACHABLE();
1454 #endif // defined(ARCH_IS_64_BIT)
1455 }
1456
1457
1458 EMIT_NATIVE_CODE(BoxInteger32, 1, Location::RequiresRegister()) {
1459 #if defined(ARCH_IS_64_BIT)
1460 const Register out = locs()->out(0).reg();
1461 const Register value = locs()->in(0).reg();
1462 if (from_representation() == kUnboxedInt32) {
1463 __ BoxInt32(out, value);
1464 } else {
1465 ASSERT(from_representation() == kUnboxedUint32);
1466 __ BoxUint32(out, value);
1467 }
1468 #else
1469 Unsupported(compiler);
1470 UNREACHABLE();
1471 #endif // defined(ARCH_IS_64_BIT)
1472 }
1473
1474
1411 EMIT_NATIVE_CODE(DoubleToSmi, 1, Location::RequiresRegister()) { 1475 EMIT_NATIVE_CODE(DoubleToSmi, 1, Location::RequiresRegister()) {
1412 const Register value = locs()->in(0).reg(); 1476 const Register value = locs()->in(0).reg();
1413 const Register result = locs()->out(0).reg(); 1477 const Register result = locs()->out(0).reg();
1414 __ DoubleToSmi(result, value); 1478 __ DoubleToSmi(result, value);
1415 compiler->EmitDeopt(deopt_id(), ICData::kDeoptDoubleToSmi); 1479 compiler->EmitDeopt(deopt_id(), ICData::kDeoptDoubleToSmi);
1416 } 1480 }
1417 1481
1418 1482
1419 EMIT_NATIVE_CODE(SmiToDouble, 1, Location::RequiresRegister()) { 1483 EMIT_NATIVE_CODE(SmiToDouble, 1, Location::RequiresRegister()) {
1420 const Register value = locs()->in(0).reg(); 1484 const Register value = locs()->in(0).reg();
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 __ IfULe(length, index); 1734 __ IfULe(length, index);
1671 compiler->EmitDeopt(deopt_id(), 1735 compiler->EmitDeopt(deopt_id(),
1672 ICData::kDeoptCheckArrayBound, 1736 ICData::kDeoptCheckArrayBound,
1673 (generalized_ ? ICData::kGeneralized : 0) | 1737 (generalized_ ? ICData::kGeneralized : 0) |
1674 (licm_hoisted_ ? ICData::kHoisted : 0)); 1738 (licm_hoisted_ ? ICData::kHoisted : 0));
1675 } 1739 }
1676 1740
1677 } // namespace dart 1741 } // namespace dart
1678 1742
1679 #endif // defined TARGET_ARCH_DBC 1743 #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