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

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

Issue 10911214: Split array loads/stores for growable arrays into two IL instructions. (Closed) Base URL: http://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_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 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 __ movl(EDX, Immediate(arg_count)); 858 __ movl(EDX, Immediate(arg_count));
859 compiler->GenerateCall(token_pos(), 859 compiler->GenerateCall(token_pos(),
860 &StubCode::CallNativeCFunctionLabel(), 860 &StubCode::CallNativeCFunctionLabel(),
861 PcDescriptors::kOther, 861 PcDescriptors::kOther,
862 locs()); 862 locs());
863 __ popl(result); 863 __ popl(result);
864 } 864 }
865 865
866 866
867 LocationSummary* LoadIndexedInstr::MakeLocationSummary() const { 867 LocationSummary* LoadIndexedInstr::MakeLocationSummary() const {
868 ASSERT((receiver_type() == kGrowableObjectArrayCid) ||
869 (receiver_type() == kArrayCid) ||
870 (receiver_type() == kImmutableArrayCid));
srdjan 2012/09/12 07:06:40 Why is this assert removed? Shouldn't it check tha
Florian Schneider 2012/09/12 08:27:29 I removed receiver_type() from LoadIndexed complet
871 const intptr_t kNumInputs = 2; 868 const intptr_t kNumInputs = 2;
872 const intptr_t kNumTemps = receiver_type() == kGrowableObjectArrayCid ? 1 : 0; 869 return LocationSummary::Make(kNumInputs,
873 LocationSummary* locs = 870 Location::RequiresRegister(),
874 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 871 LocationSummary::kNoCall);
875 locs->set_in(0, Location::RequiresRegister());
876 locs->set_in(1, Location::RequiresRegister());
877 if (receiver_type() == kGrowableObjectArrayCid) {
878 locs->set_temp(0, Location::RequiresRegister());
879 }
880 locs->set_out(Location::RequiresRegister());
881 return locs;
882 } 872 }
883 873
884 874
885 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 875 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
886 Register receiver = locs()->in(0).reg(); 876 Register array = locs()->in(0).reg();
887 Register index = locs()->in(1).reg(); 877 Register index = locs()->in(1).reg();
888 Register result = locs()->out().reg(); 878 Register result = locs()->out().reg();
889 879
890 switch (receiver_type()) { 880 // Note that index is Smi, i.e, times 2.
891 case kArrayCid: 881 ASSERT(kSmiTagShift == 1);
892 case kImmutableArrayCid: 882 __ movl(result, FieldAddress(array, index, TIMES_2, sizeof(RawArray)));
893 // Note that index is Smi, i.e, times 2.
894 ASSERT(kSmiTagShift == 1);
895 __ movl(result, FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)));
896 break;
897
898 case kGrowableObjectArrayCid: {
899 Register temp = locs()->temp(0).reg();
900 __ movl(temp, FieldAddress(receiver, GrowableObjectArray::data_offset()));
901 // Note that index is Smi, i.e, times 2.
902 ASSERT(kSmiTagShift == 1);
903 __ movl(result, FieldAddress(temp, index, TIMES_2, sizeof(RawArray)));
904 break;
905 }
906
907 default:
908 UNREACHABLE();
909 break;
910 }
911 } 883 }
912 884
913 885
914 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { 886 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const {
915 ASSERT((receiver_type() == kGrowableObjectArrayCid) ||
916 (receiver_type() == kArrayCid));
srdjan 2012/09/12 07:06:40 Why is this assert removed? Shouldn't we check for
Florian Schneider 2012/09/12 08:27:29 I removed receiver_type() from StoreIndexed as wel
917 const intptr_t kNumInputs = 3; 887 const intptr_t kNumInputs = 3;
918 const intptr_t kNumTemps = receiver_type() == kGrowableObjectArrayCid ? 1 : 0; 888 const intptr_t kNumTemps = 0;
919 LocationSummary* locs = 889 LocationSummary* locs =
920 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 890 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
921 locs->set_in(0, Location::RequiresRegister()); 891 locs->set_in(0, Location::RequiresRegister());
922 locs->set_in(1, Location::RequiresRegister()); 892 locs->set_in(1, Location::RequiresRegister());
923 locs->set_in(2, value()->NeedsStoreBuffer() ? Location::WritableRegister() 893 locs->set_in(2, value()->NeedsStoreBuffer() ? Location::WritableRegister()
924 : Location::RequiresRegister()); 894 : Location::RequiresRegister());
925 if (receiver_type() == kGrowableObjectArrayCid) {
926 locs->set_temp(0, Location::RequiresRegister());
927 }
928 return locs; 895 return locs;
929 } 896 }
930 897
931 898
932 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 899 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
933 Register receiver = locs()->in(0).reg(); 900 Register array = locs()->in(0).reg();
934 Register index = locs()->in(1).reg(); 901 Register index = locs()->in(1).reg();
935 Register value = locs()->in(2).reg(); 902 Register value = locs()->in(2).reg();
936 903
937 switch (receiver_type()) { 904 // Note that index is Smi, i.e, times 2.
938 case kArrayCid: 905 ASSERT(kSmiTagShift == 1);
939 case kImmutableArrayCid: 906 if (this->value()->NeedsStoreBuffer()) {
940 // Note that index is Smi, i.e, times 2. 907 __ StoreIntoObject(array,
941 ASSERT(kSmiTagShift == 1); 908 FieldAddress(array, index, TIMES_2, sizeof(RawArray)),
942 if (this->value()->NeedsStoreBuffer()) { 909 value);
943 __ StoreIntoObject(receiver, 910 } else {
944 FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)), 911 __ StoreIntoObjectNoBarrier(array,
945 value); 912 FieldAddress(array, index, TIMES_2, sizeof(RawArray)),
946 } else { 913 value);
947 __ StoreIntoObjectNoBarrier(receiver,
948 FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)),
949 value);
950 }
951 break;
952
953 case kGrowableObjectArrayCid: {
954 Register temp = locs()->temp(0).reg();
955 __ movl(temp, FieldAddress(receiver, GrowableObjectArray::data_offset()));
956 // Note that index is Smi, i.e, times 2.
957 ASSERT(kSmiTagShift == 1);
958 if (this->value()->NeedsStoreBuffer()) {
959 __ StoreIntoObject(temp,
960 FieldAddress(temp, index, TIMES_2, sizeof(RawArray)),
961 value);
962 } else {
963 __ StoreIntoObjectNoBarrier(temp,
964 FieldAddress(temp, index, TIMES_2, sizeof(RawArray)),
965 value);
966 }
967 break;
968 }
969
970 default:
971 UNREACHABLE();
972 break;
973 } 914 }
974 } 915 }
975 916
976 917
977 LocationSummary* LoadInstanceFieldInstr::MakeLocationSummary() const { 918 LocationSummary* LoadInstanceFieldInstr::MakeLocationSummary() const {
978 // TODO(fschneider): For this instruction the input register may be 919 // TODO(fschneider): For this instruction the input register may be
979 // reused for the result (but is not required to) because the input 920 // reused for the result (but is not required to) because the input
980 // is not used after the result is defined. We should consider adding 921 // is not used after the result is defined. We should consider adding
981 // this information to the input policy. 922 // this information to the input policy.
982 return LocationSummary::Make(1, 923 return LocationSummary::Make(1,
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 __ j(ABOVE_EQUAL, deopt); 2226 __ j(ABOVE_EQUAL, deopt);
2286 } 2227 }
2287 } 2228 }
2288 2229
2289 2230
2290 } // namespace dart 2231 } // namespace dart
2291 2232
2292 #undef __ 2233 #undef __
2293 2234
2294 #endif // defined TARGET_ARCH_X64 2235 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698