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

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

Issue 306483005: - Use isolate where it is appropriate. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, 254 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
255 deopt_id_after, 255 deopt_id_after,
256 token_pos()); 256 token_pos());
257 } 257 }
258 __ Drop(argument_count); 258 __ Drop(argument_count);
259 } 259 }
260 260
261 261
262 LocationSummary* LoadLocalInstr::MakeLocationSummary(Isolate* isolate, 262 LocationSummary* LoadLocalInstr::MakeLocationSummary(Isolate* isolate,
263 bool opt) const { 263 bool opt) const {
264 return LocationSummary::Make(0, 264 return LocationSummary::Make(isolate,
265 0,
265 Location::RequiresRegister(), 266 Location::RequiresRegister(),
266 LocationSummary::kNoCall); 267 LocationSummary::kNoCall);
267 } 268 }
268 269
269 270
270 void LoadLocalInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 271 void LoadLocalInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
271 __ TraceSimMsg("LoadLocalInstr"); 272 __ TraceSimMsg("LoadLocalInstr");
272 Register result = locs()->out(0).reg(); 273 Register result = locs()->out(0).reg();
273 __ lw(result, Address(FP, local().index() * kWordSize)); 274 __ lw(result, Address(FP, local().index() * kWordSize));
274 } 275 }
275 276
276 277
277 LocationSummary* StoreLocalInstr::MakeLocationSummary(Isolate* isolate, 278 LocationSummary* StoreLocalInstr::MakeLocationSummary(Isolate* isolate,
278 bool opt) const { 279 bool opt) const {
279 return LocationSummary::Make(1, 280 return LocationSummary::Make(isolate,
281 1,
280 Location::SameAsFirstInput(), 282 Location::SameAsFirstInput(),
281 LocationSummary::kNoCall); 283 LocationSummary::kNoCall);
282 } 284 }
283 285
284 286
285 void StoreLocalInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 287 void StoreLocalInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
286 __ TraceSimMsg("StoreLocalInstr"); 288 __ TraceSimMsg("StoreLocalInstr");
287 Register value = locs()->in(0).reg(); 289 Register value = locs()->in(0).reg();
288 Register result = locs()->out(0).reg(); 290 Register result = locs()->out(0).reg();
289 ASSERT(result == value); // Assert that register assignment is correct. 291 ASSERT(result == value); // Assert that register assignment is correct.
290 __ sw(value, Address(FP, local().index() * kWordSize)); 292 __ sw(value, Address(FP, local().index() * kWordSize));
291 } 293 }
292 294
293 295
294 LocationSummary* ConstantInstr::MakeLocationSummary(Isolate* isolate, 296 LocationSummary* ConstantInstr::MakeLocationSummary(Isolate* isolate,
295 bool opt) const { 297 bool opt) const {
296 return LocationSummary::Make(0, 298 return LocationSummary::Make(isolate,
299 0,
297 Location::RequiresRegister(), 300 Location::RequiresRegister(),
298 LocationSummary::kNoCall); 301 LocationSummary::kNoCall);
299 } 302 }
300 303
301 304
302 void ConstantInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 305 void ConstantInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
303 // The register allocator drops constant definitions that have no uses. 306 // The register allocator drops constant definitions that have no uses.
304 if (!locs()->out(0).IsInvalid()) { 307 if (!locs()->out(0).IsInvalid()) {
305 __ TraceSimMsg("ConstantInstr"); 308 __ TraceSimMsg("ConstantInstr");
306 Register result = locs()->out(0).reg(); 309 Register result = locs()->out(0).reg();
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 PcDescriptors::kOther, 906 PcDescriptors::kOther,
904 locs()); 907 locs());
905 __ Pop(result); 908 __ Pop(result);
906 } 909 }
907 910
908 911
909 LocationSummary* StringFromCharCodeInstr::MakeLocationSummary(Isolate* isolate, 912 LocationSummary* StringFromCharCodeInstr::MakeLocationSummary(Isolate* isolate,
910 bool opt) const { 913 bool opt) const {
911 const intptr_t kNumInputs = 1; 914 const intptr_t kNumInputs = 1;
912 // TODO(fschneider): Allow immediate operands for the char code. 915 // TODO(fschneider): Allow immediate operands for the char code.
913 return LocationSummary::Make(kNumInputs, 916 return LocationSummary::Make(isolate,
917 kNumInputs,
914 Location::RequiresRegister(), 918 Location::RequiresRegister(),
915 LocationSummary::kNoCall); 919 LocationSummary::kNoCall);
916 } 920 }
917 921
918 922
919 void StringFromCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 923 void StringFromCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
920 Register char_code = locs()->in(0).reg(); 924 Register char_code = locs()->in(0).reg();
921 Register result = locs()->out(0).reg(); 925 Register result = locs()->out(0).reg();
922 926
923 __ TraceSimMsg("StringFromCharCodeInstr"); 927 __ TraceSimMsg("StringFromCharCodeInstr");
924 928
925 __ LoadImmediate(result, 929 __ LoadImmediate(result,
926 reinterpret_cast<uword>(Symbols::PredefinedAddress())); 930 reinterpret_cast<uword>(Symbols::PredefinedAddress()));
927 __ AddImmediate(result, Symbols::kNullCharCodeSymbolOffset * kWordSize); 931 __ AddImmediate(result, Symbols::kNullCharCodeSymbolOffset * kWordSize);
928 __ sll(TMP, char_code, 1); // Char code is a smi. 932 __ sll(TMP, char_code, 1); // Char code is a smi.
929 __ addu(TMP, TMP, result); 933 __ addu(TMP, TMP, result);
930 __ lw(result, Address(TMP)); 934 __ lw(result, Address(TMP));
931 } 935 }
932 936
933 937
934 LocationSummary* StringToCharCodeInstr::MakeLocationSummary(Isolate* isolate, 938 LocationSummary* StringToCharCodeInstr::MakeLocationSummary(Isolate* isolate,
935 bool opt) const { 939 bool opt) const {
936 const intptr_t kNumInputs = 1; 940 const intptr_t kNumInputs = 1;
937 return LocationSummary::Make(kNumInputs, 941 return LocationSummary::Make(isolate,
942 kNumInputs,
938 Location::RequiresRegister(), 943 Location::RequiresRegister(),
939 LocationSummary::kNoCall); 944 LocationSummary::kNoCall);
940 } 945 }
941 946
942 947
943 void StringToCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 948 void StringToCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
944 __ TraceSimMsg("StringToCharCodeInstr"); 949 __ TraceSimMsg("StringToCharCodeInstr");
945 950
946 ASSERT(cid_ == kOneByteStringCid); 951 ASSERT(cid_ == kOneByteStringCid);
947 Register str = locs()->in(0).reg(); 952 Register str = locs()->in(0).reg();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 kNumberOfArguments, 986 kNumberOfArguments,
982 kNoArgumentNames, 987 kNoArgumentNames,
983 locs()); 988 locs());
984 ASSERT(locs()->out(0).reg() == V0); 989 ASSERT(locs()->out(0).reg() == V0);
985 } 990 }
986 991
987 992
988 LocationSummary* LoadUntaggedInstr::MakeLocationSummary(Isolate* isolate, 993 LocationSummary* LoadUntaggedInstr::MakeLocationSummary(Isolate* isolate,
989 bool opt) const { 994 bool opt) const {
990 const intptr_t kNumInputs = 1; 995 const intptr_t kNumInputs = 1;
991 return LocationSummary::Make(kNumInputs, 996 return LocationSummary::Make(isolate,
997 kNumInputs,
992 Location::RequiresRegister(), 998 Location::RequiresRegister(),
993 LocationSummary::kNoCall); 999 LocationSummary::kNoCall);
994 } 1000 }
995 1001
996 1002
997 void LoadUntaggedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1003 void LoadUntaggedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
998 Register object = locs()->in(0).reg(); 1004 Register object = locs()->in(0).reg();
999 Register result = locs()->out(0).reg(); 1005 Register result = locs()->out(0).reg();
1000 __ LoadFromOffset(result, object, offset() - kHeapObjectTag); 1006 __ LoadFromOffset(result, object, offset() - kHeapObjectTag);
1001 } 1007 }
1002 1008
1003 1009
1004 LocationSummary* LoadClassIdInstr::MakeLocationSummary(Isolate* isolate, 1010 LocationSummary* LoadClassIdInstr::MakeLocationSummary(Isolate* isolate,
1005 bool opt) const { 1011 bool opt) const {
1006 const intptr_t kNumInputs = 1; 1012 const intptr_t kNumInputs = 1;
1007 return LocationSummary::Make(kNumInputs, 1013 return LocationSummary::Make(isolate,
1014 kNumInputs,
1008 Location::RequiresRegister(), 1015 Location::RequiresRegister(),
1009 LocationSummary::kNoCall); 1016 LocationSummary::kNoCall);
1010 } 1017 }
1011 1018
1012 1019
1013 void LoadClassIdInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1020 void LoadClassIdInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1014 Register object = locs()->in(0).reg(); 1021 Register object = locs()->in(0).reg();
1015 Register result = locs()->out(0).reg(); 1022 Register result = locs()->out(0).reg();
1016 Label load, done; 1023 Label load, done;
1017 __ andi(CMPRES1, object, Immediate(kSmiTagMask)); 1024 __ andi(CMPRES1, object, Immediate(kSmiTagMask));
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 public: 1807 public:
1801 StoreInstanceFieldSlowPath(StoreInstanceFieldInstr* instruction, 1808 StoreInstanceFieldSlowPath(StoreInstanceFieldInstr* instruction,
1802 const Class& cls) 1809 const Class& cls)
1803 : instruction_(instruction), cls_(cls) { } 1810 : instruction_(instruction), cls_(cls) { }
1804 1811
1805 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 1812 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
1806 __ Comment("StoreInstanceFieldSlowPath"); 1813 __ Comment("StoreInstanceFieldSlowPath");
1807 __ Bind(entry_label()); 1814 __ Bind(entry_label());
1808 const Code& stub = 1815 const Code& stub =
1809 Code::Handle(StubCode::GetAllocationStubForClass(cls_)); 1816 Code::Handle(StubCode::GetAllocationStubForClass(cls_));
1810 const ExternalLabel label(cls_.ToCString(), stub.EntryPoint()); 1817 const ExternalLabel label(stub.EntryPoint());
1811 1818
1812 LocationSummary* locs = instruction_->locs(); 1819 LocationSummary* locs = instruction_->locs();
1813 locs->live_registers()->Remove(locs->out(0)); 1820 locs->live_registers()->Remove(locs->out(0));
1814 1821
1815 compiler->SaveLiveRegisters(locs); 1822 compiler->SaveLiveRegisters(locs);
1816 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. 1823 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position.
1817 &label, 1824 &label,
1818 PcDescriptors::kOther, 1825 PcDescriptors::kOther,
1819 locs); 1826 locs);
1820 __ mov(locs->temp(0).reg(), V0); 1827 __ mov(locs->temp(0).reg(), V0);
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 public: 2213 public:
2207 explicit BoxDoubleSlowPath(Instruction* instruction) 2214 explicit BoxDoubleSlowPath(Instruction* instruction)
2208 : instruction_(instruction) { } 2215 : instruction_(instruction) { }
2209 2216
2210 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 2217 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
2211 __ Comment("BoxDoubleSlowPath"); 2218 __ Comment("BoxDoubleSlowPath");
2212 __ Bind(entry_label()); 2219 __ Bind(entry_label());
2213 const Class& double_class = compiler->double_class(); 2220 const Class& double_class = compiler->double_class();
2214 const Code& stub = 2221 const Code& stub =
2215 Code::Handle(StubCode::GetAllocationStubForClass(double_class)); 2222 Code::Handle(StubCode::GetAllocationStubForClass(double_class));
2216 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint()); 2223 const ExternalLabel label(stub.EntryPoint());
2217 2224
2218 LocationSummary* locs = instruction_->locs(); 2225 LocationSummary* locs = instruction_->locs();
2219 locs->live_registers()->Remove(locs->out(0)); 2226 locs->live_registers()->Remove(locs->out(0));
2220 2227
2221 compiler->SaveLiveRegisters(locs); 2228 compiler->SaveLiveRegisters(locs);
2222 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. 2229 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position.
2223 &label, 2230 &label,
2224 PcDescriptors::kOther, 2231 PcDescriptors::kOther,
2225 locs); 2232 locs);
2226 if (locs->out(0).reg() != V0) { 2233 if (locs->out(0).reg() != V0) {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 } 2464 }
2458 2465
2459 2466
2460 void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2467 void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2461 Register temp = T1; 2468 Register temp = T1;
2462 ASSERT(locs()->temp(0).reg() == temp); 2469 ASSERT(locs()->temp(0).reg() == temp);
2463 ASSERT(locs()->out(0).reg() == V0); 2470 ASSERT(locs()->out(0).reg() == V0);
2464 2471
2465 __ TraceSimMsg("AllocateContextInstr"); 2472 __ TraceSimMsg("AllocateContextInstr");
2466 __ LoadImmediate(temp, num_context_variables()); 2473 __ LoadImmediate(temp, num_context_variables());
2467 const ExternalLabel label("alloc_context", 2474 const ExternalLabel label(StubCode::AllocateContextEntryPoint());
2468 StubCode::AllocateContextEntryPoint());
2469 compiler->GenerateCall(token_pos(), 2475 compiler->GenerateCall(token_pos(),
2470 &label, 2476 &label,
2471 PcDescriptors::kOther, 2477 PcDescriptors::kOther,
2472 locs()); 2478 locs());
2473 } 2479 }
2474 2480
2475 2481
2476 LocationSummary* CloneContextInstr::MakeLocationSummary(Isolate* isolate, 2482 LocationSummary* CloneContextInstr::MakeLocationSummary(Isolate* isolate,
2477 bool opt) const { 2483 bool opt) const {
2478 const intptr_t kNumInputs = 1; 2484 const intptr_t kNumInputs = 1;
(...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after
4622 // We can fall through if the successor is the next block in the list. 4628 // We can fall through if the successor is the next block in the list.
4623 // Otherwise, we need a jump. 4629 // Otherwise, we need a jump.
4624 if (!compiler->CanFallThroughTo(successor())) { 4630 if (!compiler->CanFallThroughTo(successor())) {
4625 __ b(compiler->GetJumpLabel(successor())); 4631 __ b(compiler->GetJumpLabel(successor()));
4626 } 4632 }
4627 } 4633 }
4628 4634
4629 4635
4630 LocationSummary* CurrentContextInstr::MakeLocationSummary(Isolate* isolate, 4636 LocationSummary* CurrentContextInstr::MakeLocationSummary(Isolate* isolate,
4631 bool opt) const { 4637 bool opt) const {
4632 return LocationSummary::Make(0, 4638 return LocationSummary::Make(isolate,
4639 0,
4633 Location::RequiresRegister(), 4640 Location::RequiresRegister(),
4634 LocationSummary::kNoCall); 4641 LocationSummary::kNoCall);
4635 } 4642 }
4636 4643
4637 4644
4638 void CurrentContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4645 void CurrentContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4639 __ mov(locs()->out(0).reg(), CTX); 4646 __ mov(locs()->out(0).reg(), CTX);
4640 } 4647 }
4641 4648
4642 4649
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
4718 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT); 4725 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT);
4719 4726
4720 BranchLabels labels = compiler->CreateBranchLabels(branch); 4727 BranchLabels labels = compiler->CreateBranchLabels(branch);
4721 Condition true_condition = EmitComparisonCode(compiler, labels); 4728 Condition true_condition = EmitComparisonCode(compiler, labels);
4722 EmitBranchOnCondition(compiler, true_condition, labels); 4729 EmitBranchOnCondition(compiler, true_condition, labels);
4723 } 4730 }
4724 4731
4725 4732
4726 LocationSummary* BooleanNegateInstr::MakeLocationSummary(Isolate* isolate, 4733 LocationSummary* BooleanNegateInstr::MakeLocationSummary(Isolate* isolate,
4727 bool opt) const { 4734 bool opt) const {
4728 return LocationSummary::Make(1, 4735 return LocationSummary::Make(isolate,
4736 1,
4729 Location::RequiresRegister(), 4737 Location::RequiresRegister(),
4730 LocationSummary::kNoCall); 4738 LocationSummary::kNoCall);
4731 } 4739 }
4732 4740
4733 4741
4734 void BooleanNegateInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4742 void BooleanNegateInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4735 Register value = locs()->in(0).reg(); 4743 Register value = locs()->in(0).reg();
4736 Register result = locs()->out(0).reg(); 4744 Register result = locs()->out(0).reg();
4737 4745
4738 __ LoadObject(result, Bool::True()); 4746 __ LoadObject(result, Bool::True());
4739 __ LoadObject(TMP, Bool::False()); 4747 __ LoadObject(TMP, Bool::False());
4740 __ subu(CMPRES1, value, result); 4748 __ subu(CMPRES1, value, result);
4741 __ movz(result, TMP, CMPRES1); // If value is True, move False into result. 4749 __ movz(result, TMP, CMPRES1); // If value is True, move False into result.
4742 } 4750 }
4743 4751
4744 4752
4745 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Isolate* isolate, 4753 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Isolate* isolate,
4746 bool opt) const { 4754 bool opt) const {
4747 return MakeCallSummary(); 4755 return MakeCallSummary();
4748 } 4756 }
4749 4757
4750 4758
4751 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4759 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4752 __ TraceSimMsg("AllocateObjectInstr"); 4760 __ TraceSimMsg("AllocateObjectInstr");
4753 __ Comment("AllocateObjectInstr"); 4761 __ Comment("AllocateObjectInstr");
4754 const Code& stub = Code::Handle(StubCode::GetAllocationStubForClass(cls())); 4762 const Code& stub = Code::Handle(StubCode::GetAllocationStubForClass(cls()));
4755 const ExternalLabel label(cls().ToCString(), stub.EntryPoint()); 4763 const ExternalLabel label(stub.EntryPoint());
4756 compiler->GenerateCall(token_pos(), 4764 compiler->GenerateCall(token_pos(),
4757 &label, 4765 &label,
4758 PcDescriptors::kOther, 4766 PcDescriptors::kOther,
4759 locs()); 4767 locs());
4760 __ Drop(ArgumentCount()); // Discard arguments. 4768 __ Drop(ArgumentCount()); // Discard arguments.
4761 } 4769 }
4762 4770
4763 } // namespace dart 4771 } // namespace dart
4764 4772
4765 #endif // defined TARGET_ARCH_MIPS 4773 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698