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

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

Issue 10933045: Add immediate operand support for indexed operations. (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 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 __ movl(ECX, Immediate(reinterpret_cast<uword>(native_c_function()))); 857 __ movl(ECX, Immediate(reinterpret_cast<uword>(native_c_function())));
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 static bool CanBeIndexImmediate(Value* index) {
Vyacheslav Egorov (Google) 2012/09/12 12:55:06 CanBeImmediateIndex?
Florian Schneider 2012/09/12 13:28:35 Done.
868 if (!index->definition()->IsConstant()) return false;
869 const Object& constant = index->definition()->AsConstant()->value();
870 const Smi& smi_const = Smi::Cast(constant);
871 int64_t disp = smi_const.AsInt64Value() * kWordSize + sizeof(RawArray);
872 return Utils::IsInt(32, disp);
873 }
874
875
867 LocationSummary* LoadIndexedInstr::MakeLocationSummary() const { 876 LocationSummary* LoadIndexedInstr::MakeLocationSummary() const {
868 const intptr_t kNumInputs = 2; 877 const intptr_t kNumInputs = 2;
869 return LocationSummary::Make(kNumInputs, 878 const intptr_t kNumTemps = 0;
870 Location::RequiresRegister(), 879 LocationSummary* locs =
871 LocationSummary::kNoCall); 880 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
881 locs->set_in(0, Location::RequiresRegister());
882 locs->set_in(1, CanBeIndexImmediate(index())
883 ? Location::RegisterOrConstant(index())
884 : Location::RequiresRegister());
885 locs->set_out(Location::RequiresRegister());
886 return locs;
887 }
888
889
890 static int32_t RawSmi(const Object& constant) {
Vyacheslav Egorov (Google) 2012/09/12 12:55:06 I don't like that the name clashes with RawSmi cla
srdjan 2012/09/12 12:56:16 RawSmi is the name of the raw smi object. I would
Florian Schneider 2012/09/12 13:28:35 Removed and replaced with Smi::Cast(...) instead.
891 ASSERT(constant.IsSmi());
892 return reinterpret_cast<int32_t>(constant.raw());
872 } 893 }
873 894
874 895
875 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 896 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
876 Register array = locs()->in(0).reg(); 897 Register array = locs()->in(0).reg();
877 Register index = locs()->in(1).reg();
878 Register result = locs()->out().reg(); 898 Register result = locs()->out().reg();
879 899
880 // Note that index is Smi, i.e, times 2. 900 // Note that index is Smi, i.e, times 2.
881 ASSERT(kSmiTagShift == 1); 901 ASSERT(kSmiTagShift == 1);
882 __ movl(result, FieldAddress(array, index, TIMES_2, sizeof(RawArray))); 902 if (locs()->in(1).IsRegister()) {
903 Register index = locs()->in(1).reg();
904 __ movl(result, FieldAddress(array, index, TIMES_2, sizeof(RawArray)));
905 } else {
906 int32_t disp = RawSmi(locs()->in(1).constant()) * 2 + sizeof(RawArray);
Vyacheslav Egorov (Google) 2012/09/12 12:55:06 How about just Smi::Cast(locs()->in(1).constant())
srdjan 2012/09/12 12:56:16 You could get also Smi::Value(...)do * 4.
Florian Schneider 2012/09/12 13:28:35 Done. Using Smi::Value() * kWordSize.
907 __ movl(result, FieldAddress(array, disp));
908 }
883 } 909 }
884 910
885 911
886 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { 912 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const {
887 const intptr_t kNumInputs = 3; 913 const intptr_t kNumInputs = 3;
888 const intptr_t kNumTemps = 0; 914 const intptr_t kNumTemps = 0;
889 LocationSummary* locs = 915 LocationSummary* locs =
890 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 916 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
891 locs->set_in(0, Location::RequiresRegister()); 917 locs->set_in(0, Location::RequiresRegister());
892 locs->set_in(1, Location::RequiresRegister()); 918 locs->set_in(1, CanBeIndexImmediate(index())
893 locs->set_in(2, value()->NeedsStoreBuffer() ? Location::WritableRegister() 919 ? Location::RegisterOrConstant(index())
894 : Location::RequiresRegister()); 920 : Location::RequiresRegister());
921 locs->set_in(2, value()->NeedsStoreBuffer()
922 ? Location::WritableRegister()
923 : Location::RegisterOrConstant(value()));
895 return locs; 924 return locs;
896 } 925 }
897 926
898 927
899 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 928 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
900 Register array = locs()->in(0).reg(); 929 Register array = locs()->in(0).reg();
901 Register index = locs()->in(1).reg();
902 Register value = locs()->in(2).reg();
903 930
904 // Note that index is Smi, i.e, times 2. 931 // Note that index is Smi, i.e, times 2.
905 ASSERT(kSmiTagShift == 1); 932 ASSERT(kSmiTagShift == 1);
933 FieldAddress field_address = locs()->in(1).IsConstant()
934 ? FieldAddress(array,
935 RawSmi(locs()->in(1).constant()) * 2 + sizeof(RawArray))
Vyacheslav Egorov (Google) 2012/09/12 12:55:06 see above.
Florian Schneider 2012/09/12 13:28:35 Done.
936 : FieldAddress(array, locs()->in(1).reg(), TIMES_2, sizeof(RawArray));
937
906 if (this->value()->NeedsStoreBuffer()) { 938 if (this->value()->NeedsStoreBuffer()) {
907 __ StoreIntoObject(array, 939 Register value = locs()->in(2).reg();
908 FieldAddress(array, index, TIMES_2, sizeof(RawArray)), 940 __ StoreIntoObject(array, field_address, value);
909 value);
910 } else { 941 } else {
911 __ StoreIntoObjectNoBarrier(array, 942 if (locs()->in(2).IsConstant()) {
912 FieldAddress(array, index, TIMES_2, sizeof(RawArray)), 943 const Object& constant = locs()->in(2).constant();
913 value); 944 __ StoreIntoObjectNoBarrier(array, field_address, constant);
945 } else {
946 Register value = locs()->in(2).reg();
947 __ StoreIntoObjectNoBarrier(array, field_address, value);
948 }
914 } 949 }
915 } 950 }
916 951
917 952
918 LocationSummary* LoadInstanceFieldInstr::MakeLocationSummary() const { 953 LocationSummary* LoadInstanceFieldInstr::MakeLocationSummary() const {
919 // TODO(fschneider): For this instruction the input register may be 954 // TODO(fschneider): For this instruction the input register may be
920 // reused for the result (but is not required to) because the input 955 // reused for the result (but is not required to) because the input
921 // is not used after the result is defined. We should consider adding 956 // is not used after the result is defined. We should consider adding
922 // this information to the input policy. 957 // this information to the input policy.
923 return LocationSummary::Make(1, 958 return LocationSummary::Make(1,
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 __ j(ABOVE_EQUAL, deopt); 2314 __ j(ABOVE_EQUAL, deopt);
2280 } 2315 }
2281 } 2316 }
2282 2317
2283 2318
2284 } // namespace dart 2319 } // namespace dart
2285 2320
2286 #undef __ 2321 #undef __
2287 2322
2288 #endif // defined TARGET_ARCH_X64 2323 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698