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

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

Issue 10909169: Add support for WritableRegister policy in the register allocator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | Annotate | Revision Log
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 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 925
926 default: 926 default:
927 UNREACHABLE(); 927 UNREACHABLE();
928 break; 928 break;
929 } 929 }
930 } 930 }
931 931
932 932
933 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { 933 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const {
934 const intptr_t kNumInputs = 3; 934 const intptr_t kNumInputs = 3;
935 const intptr_t kNumTemps =
936 (receiver_type() == kGrowableObjectArrayCid) ? 1 : 0;
937 LocationSummary* locs =
938 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
939 locs->set_in(0, Location::RequiresRegister());
940 locs->set_in(1, Location::RequiresRegister());
941 locs->set_in(2, value()->NeedsStoreBuffer() ? Location::WritableRegister()
942 : Location::RequiresRegister());
935 if (receiver_type() == kGrowableObjectArrayCid) { 943 if (receiver_type() == kGrowableObjectArrayCid) {
936 const intptr_t kNumTemps = 1;
937 LocationSummary* locs =
938 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
939 locs->set_in(0, Location::RequiresRegister());
940 locs->set_in(1, Location::RequiresRegister());
941 locs->set_in(2, Location::RequiresRegister());
942 locs->set_temp(0, Location::RequiresRegister()); 944 locs->set_temp(0, Location::RequiresRegister());
943 return locs;
944 } else {
945 ASSERT(receiver_type() == kArrayCid);
946 return LocationSummary::Make(kNumInputs,
947 Location::NoLocation(),
948 LocationSummary::kNoCall);
949 } 945 }
946 return locs;
950 } 947 }
951 948
952 949
953 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 950 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
954 Register receiver = locs()->in(0).reg(); 951 Register receiver = locs()->in(0).reg();
955 Register index = locs()->in(1).reg(); 952 Register index = locs()->in(1).reg();
956 Register value = locs()->in(2).reg(); 953 Register value = locs()->in(2).reg();
957 954
958 switch (receiver_type()) { 955 switch (receiver_type()) {
959 case kArrayCid: 956 case kArrayCid:
960 case kImmutableArrayCid: 957 case kImmutableArrayCid:
961 // Note that index is Smi, i.e, times 4. 958 // Note that index is Smi, i.e, times 4.
962 ASSERT(kSmiTagShift == 1); 959 ASSERT(kSmiTagShift == 1);
963 if (this->value()->NeedsStoreBuffer()) { 960 if (this->value()->NeedsStoreBuffer()) {
964 __ StoreIntoObject(receiver, 961 __ StoreIntoObject(
962 receiver,
965 FieldAddress(receiver, index, TIMES_4, sizeof(RawArray)), 963 FieldAddress(receiver, index, TIMES_4, sizeof(RawArray)),
966 value); 964 value);
967 } else { 965 } else {
968 __ StoreIntoObjectNoBarrier(receiver, 966 __ StoreIntoObjectNoBarrier(receiver,
969 FieldAddress(receiver, index, TIMES_4, sizeof(RawArray)), 967 FieldAddress(receiver, index, TIMES_4, sizeof(RawArray)),
970 value); 968 value);
971 } 969 }
972 break; 970 break;
973 971
974 case kGrowableObjectArrayCid: { 972 case kGrowableObjectArrayCid: {
975 Register temp = locs()->temp(0).reg(); 973 Register temp = locs()->temp(0).reg();
976 __ movq(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); 974 __ movq(temp, FieldAddress(receiver, GrowableObjectArray::data_offset()));
977 // Note that index is Smi, i.e, times 4. 975 // Note that index is Smi, i.e, times 4.
978 ASSERT(kSmiTagShift == 1); 976 ASSERT(kSmiTagShift == 1);
979 if (this->value()->NeedsStoreBuffer()) { 977 if (this->value()->NeedsStoreBuffer()) {
980 __ StoreIntoObject(temp, 978 __ StoreIntoObject(
979 temp,
981 FieldAddress(temp, index, TIMES_4, sizeof(RawArray)), 980 FieldAddress(temp, index, TIMES_4, sizeof(RawArray)),
982 value); 981 value);
983 } else { 982 } else {
984 __ StoreIntoObjectNoBarrier(temp, 983 __ StoreIntoObjectNoBarrier(temp,
985 FieldAddress(temp, index, TIMES_4, sizeof(RawArray)), 984 FieldAddress(temp, index, TIMES_4, sizeof(RawArray)),
986 value); 985 value);
987 } 986 }
988 break; 987 break;
989 } 988 }
990 989
(...skipping 21 matching lines...) Expand all
1012 __ movq(result_reg, FieldAddress(instance_reg, field().Offset())); 1011 __ movq(result_reg, FieldAddress(instance_reg, field().Offset()));
1013 } 1012 }
1014 1013
1015 1014
1016 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary() const { 1015 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary() const {
1017 const intptr_t kNumInputs = 2; 1016 const intptr_t kNumInputs = 2;
1018 const intptr_t num_temps = 0; 1017 const intptr_t num_temps = 0;
1019 LocationSummary* summary = 1018 LocationSummary* summary =
1020 new LocationSummary(kNumInputs, num_temps, LocationSummary::kNoCall); 1019 new LocationSummary(kNumInputs, num_temps, LocationSummary::kNoCall);
1021 summary->set_in(0, Location::RequiresRegister()); 1020 summary->set_in(0, Location::RequiresRegister());
1022 summary->set_in(1, Location::RequiresRegister()); 1021 summary->set_in(1,
1022 value()->NeedsStoreBuffer() ? Location::WritableRegister()
1023 : Location::RequiresRegister());
1023 return summary; 1024 return summary;
1024 } 1025 }
1025 1026
1026 1027
1027 void StoreInstanceFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1028 void StoreInstanceFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1028 Register instance_reg = locs()->in(0).reg(); 1029 Register instance_reg = locs()->in(0).reg();
1029 Register value_reg = locs()->in(1).reg(); 1030 Register value_reg = locs()->in(1).reg();
1030 if (this->value()->NeedsStoreBuffer()) { 1031 if (this->value()->NeedsStoreBuffer()) {
1031 __ StoreIntoObject(instance_reg, 1032 __ StoreIntoObject(instance_reg,
1032 FieldAddress(instance_reg, field().Offset()), value_reg); 1033 FieldAddress(instance_reg, field().Offset()),
1034 value_reg);
1033 } else { 1035 } else {
1034 __ StoreIntoObjectNoBarrier(instance_reg, 1036 __ StoreIntoObjectNoBarrier(instance_reg,
1035 FieldAddress(instance_reg, field().Offset()), value_reg); 1037 FieldAddress(instance_reg, field().Offset()), value_reg);
1036 } 1038 }
1037 } 1039 }
1038 1040
1039 1041
1040 LocationSummary* LoadStaticFieldInstr::MakeLocationSummary() const { 1042 LocationSummary* LoadStaticFieldInstr::MakeLocationSummary() const {
1041 return LocationSummary::Make(0, 1043 return LocationSummary::Make(0,
1042 Location::RequiresRegister(), 1044 Location::RequiresRegister(),
1043 LocationSummary::kNoCall); 1045 LocationSummary::kNoCall);
1044 } 1046 }
1045 1047
1046 1048
1047 void LoadStaticFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1049 void LoadStaticFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1048 Register result = locs()->out().reg(); 1050 Register result = locs()->out().reg();
1049 __ LoadObject(result, field()); 1051 __ LoadObject(result, field());
1050 __ movq(result, FieldAddress(result, Field::value_offset())); 1052 __ movq(result, FieldAddress(result, Field::value_offset()));
1051 } 1053 }
1052 1054
1053 1055
1054 LocationSummary* StoreStaticFieldInstr::MakeLocationSummary() const { 1056 LocationSummary* StoreStaticFieldInstr::MakeLocationSummary() const {
1055 LocationSummary* locs = new LocationSummary(1, 1, LocationSummary::kNoCall); 1057 LocationSummary* locs = new LocationSummary(1, 1, LocationSummary::kNoCall);
1056 locs->set_in(0, Location::RequiresRegister()); 1058 locs->set_in(0, value()->NeedsStoreBuffer() ? Location::WritableRegister()
1059 : Location::RequiresRegister());
1057 locs->set_temp(0, Location::RequiresRegister()); 1060 locs->set_temp(0, Location::RequiresRegister());
1058 locs->set_out(is_used() ? Location::SameAsFirstInput()
1059 : Location::NoLocation());
1060 return locs; 1061 return locs;
1061 } 1062 }
1062 1063
1063 1064
1064 void StoreStaticFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1065 void StoreStaticFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1065 Register value = locs()->in(0).reg(); 1066 Register value = locs()->in(0).reg();
1066 Register temp = locs()->temp(0).reg(); 1067 Register temp = locs()->temp(0).reg();
1067 ASSERT(!is_used() || (locs()->out().reg() == value));
1068 1068
1069 __ LoadObject(temp, field()); 1069 __ LoadObject(temp, field());
1070 if (this->value()->NeedsStoreBuffer()) { 1070 if (this->value()->NeedsStoreBuffer()) {
1071 __ StoreIntoObject(temp, FieldAddress(temp, Field::value_offset()), value); 1071 __ StoreIntoObject(temp,
Ivan Posva 2012/09/11 11:57:30 ditto
Vyacheslav Egorov (Google) 2012/09/11 12:18:05 Done.
1072 FieldAddress(temp, Field::value_offset()),
1073 value);
1072 } else { 1074 } else {
1073 __ StoreIntoObjectNoBarrier( 1075 __ StoreIntoObjectNoBarrier(
1074 temp, FieldAddress(temp, Field::value_offset()), value); 1076 temp, FieldAddress(temp, Field::value_offset()), value);
1075 } 1077 }
1076 } 1078 }
1077 1079
1078 1080
1079 LocationSummary* InstanceOfInstr::MakeLocationSummary() const { 1081 LocationSummary* InstanceOfInstr::MakeLocationSummary() const {
1080 const intptr_t kNumInputs = 3; 1082 const intptr_t kNumInputs = 3;
1081 const intptr_t kNumTemps = 0; 1083 const intptr_t kNumTemps = 0;
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2313 __ j(ABOVE_EQUAL, deopt); 2315 __ j(ABOVE_EQUAL, deopt);
2314 } 2316 }
2315 } 2317 }
2316 2318
2317 2319
2318 } // namespace dart 2320 } // namespace dart
2319 2321
2320 #undef __ 2322 #undef __
2321 2323
2322 #endif // defined TARGET_ARCH_X64 2324 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698