| OLD | NEW |
| 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 "lib/error.h" | 10 #include "lib/error.h" |
| 11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
| 12 #include "vm/flow_graph_compiler.h" | 12 #include "vm/flow_graph_compiler.h" |
| 13 #include "vm/locations.h" | 13 #include "vm/locations.h" |
| 14 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
| 15 #include "vm/parser.h" | 15 #include "vm/parser.h" |
| 16 #include "vm/stub_code.h" | 16 #include "vm/stub_code.h" |
| 17 #include "vm/symbols.h" | 17 #include "vm/symbols.h" |
| 18 | 18 |
| 19 #define __ compiler->assembler()-> |
| 20 |
| 19 namespace dart { | 21 namespace dart { |
| 20 | 22 |
| 21 DECLARE_FLAG(int, optimization_counter_threshold); | 23 DECLARE_FLAG(int, optimization_counter_threshold); |
| 22 DECLARE_FLAG(bool, propagate_ic_data); | 24 DECLARE_FLAG(bool, propagate_ic_data); |
| 23 | 25 |
| 24 LocationSummary* Instruction::MakeCallSummary() { | 26 LocationSummary* Instruction::MakeCallSummary() { |
| 25 UNIMPLEMENTED(); | 27 UNIMPLEMENTED(); |
| 26 return NULL; | 28 return NULL; |
| 27 } | 29 } |
| 28 | 30 |
| 29 | 31 |
| 30 LocationSummary* PushArgumentInstr::MakeLocationSummary() const { | 32 LocationSummary* PushArgumentInstr::MakeLocationSummary() const { |
| 31 UNIMPLEMENTED(); | 33 UNIMPLEMENTED(); |
| 32 return NULL; | 34 return NULL; |
| 33 } | 35 } |
| 34 | 36 |
| 35 | 37 |
| 36 void PushArgumentInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 38 void PushArgumentInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 37 UNIMPLEMENTED(); | 39 UNIMPLEMENTED(); |
| 38 } | 40 } |
| 39 | 41 |
| 40 | 42 |
| 41 LocationSummary* ReturnInstr::MakeLocationSummary() const { | 43 LocationSummary* ReturnInstr::MakeLocationSummary() const { |
| 42 UNIMPLEMENTED(); | 44 const intptr_t kNumInputs = 1; |
| 43 return NULL; | 45 const intptr_t kNumTemps = 0; |
| 46 LocationSummary* locs = |
| 47 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| 48 locs->set_in(0, Location::RegisterLocation(V0)); |
| 49 return locs; |
| 44 } | 50 } |
| 45 | 51 |
| 46 | 52 |
| 53 // Attempt optimized compilation at return instruction instead of at the entry. |
| 54 // The entry needs to be patchable, no inlined objects are allowed in the area |
| 55 // that will be overwritten by the patch instructions: a branch macro sequence. |
| 47 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 56 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 48 UNIMPLEMENTED(); | 57 Register result = locs()->in(0).reg(); |
| 58 ASSERT(result == V0); |
| 59 #if defined(DEBUG) |
| 60 // TODO(srdjan): Fix for functions with finally clause. |
| 61 // A finally clause may leave a previously pushed return value if it |
| 62 // has its own return instruction. Method that have finally are currently |
| 63 // not optimized. |
| 64 if (!compiler->HasFinally()) { |
| 65 Label stack_ok; |
| 66 __ Comment("Stack Check"); |
| 67 const int sp_fp_dist = compiler->StackSize() + (-kFirstLocalSlotIndex - 1); |
| 68 __ subu(T2, FP, SP); |
| 69 |
| 70 __ addiu(T2, T2, Immediate(-sp_fp_dist * kWordSize)); |
| 71 __ beq(T2, ZR, &stack_ok); |
| 72 __ break_(0); |
| 73 |
| 74 __ Bind(&stack_ok); |
| 75 } |
| 76 #endif |
| 77 __ LeaveDartFrame(); |
| 78 __ Ret(); |
| 79 |
| 80 // Generate 2 NOP instructions so that the debugger can patch the return |
| 81 // pattern (1 instruction) with a call to the debug stub (3 instructions). |
| 82 __ nop(); |
| 83 __ nop(); |
| 84 compiler->AddCurrentDescriptor(PcDescriptors::kReturn, |
| 85 Isolate::kNoDeoptId, |
| 86 token_pos()); |
| 49 } | 87 } |
| 50 | 88 |
| 51 | 89 |
| 52 LocationSummary* ClosureCallInstr::MakeLocationSummary() const { | 90 LocationSummary* ClosureCallInstr::MakeLocationSummary() const { |
| 53 UNIMPLEMENTED(); | 91 UNIMPLEMENTED(); |
| 54 return NULL; | 92 return NULL; |
| 55 } | 93 } |
| 56 | 94 |
| 57 | 95 |
| 58 LocationSummary* LoadLocalInstr::MakeLocationSummary() const { | 96 LocationSummary* LoadLocalInstr::MakeLocationSummary() const { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 71 return NULL; | 109 return NULL; |
| 72 } | 110 } |
| 73 | 111 |
| 74 | 112 |
| 75 void StoreLocalInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 113 void StoreLocalInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 76 UNIMPLEMENTED(); | 114 UNIMPLEMENTED(); |
| 77 } | 115 } |
| 78 | 116 |
| 79 | 117 |
| 80 LocationSummary* ConstantInstr::MakeLocationSummary() const { | 118 LocationSummary* ConstantInstr::MakeLocationSummary() const { |
| 81 UNIMPLEMENTED(); | 119 return LocationSummary::Make(0, |
| 82 return NULL; | 120 Location::RequiresRegister(), |
| 121 LocationSummary::kNoCall); |
| 83 } | 122 } |
| 84 | 123 |
| 85 | 124 |
| 86 void ConstantInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 125 void ConstantInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 87 UNIMPLEMENTED(); | 126 // The register allocator drops constant definitions that have no uses. |
| 127 if (!locs()->out().IsInvalid()) { |
| 128 Register result = locs()->out().reg(); |
| 129 __ LoadObject(result, value()); |
| 130 } |
| 88 } | 131 } |
| 89 | 132 |
| 90 | 133 |
| 91 LocationSummary* AssertAssignableInstr::MakeLocationSummary() const { | 134 LocationSummary* AssertAssignableInstr::MakeLocationSummary() const { |
| 92 UNIMPLEMENTED(); | 135 UNIMPLEMENTED(); |
| 93 return NULL; | 136 return NULL; |
| 94 } | 137 } |
| 95 | 138 |
| 96 | 139 |
| 97 LocationSummary* AssertBooleanInstr::MakeLocationSummary() const { | 140 LocationSummary* AssertBooleanInstr::MakeLocationSummary() const { |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 return NULL; | 422 return NULL; |
| 380 } | 423 } |
| 381 | 424 |
| 382 | 425 |
| 383 void CatchEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 426 void CatchEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 384 UNIMPLEMENTED(); | 427 UNIMPLEMENTED(); |
| 385 } | 428 } |
| 386 | 429 |
| 387 | 430 |
| 388 LocationSummary* CheckStackOverflowInstr::MakeLocationSummary() const { | 431 LocationSummary* CheckStackOverflowInstr::MakeLocationSummary() const { |
| 389 UNIMPLEMENTED(); | 432 const intptr_t kNumInputs = 0; |
| 390 return NULL; | 433 const intptr_t kNumTemps = 0; |
| 434 LocationSummary* summary = |
| 435 new LocationSummary(kNumInputs, |
| 436 kNumTemps, |
| 437 LocationSummary::kCallOnSlowPath); |
| 438 return summary; |
| 391 } | 439 } |
| 392 | 440 |
| 393 | 441 |
| 442 class CheckStackOverflowSlowPath : public SlowPathCode { |
| 443 public: |
| 444 explicit CheckStackOverflowSlowPath(CheckStackOverflowInstr* instruction) |
| 445 : instruction_(instruction) { } |
| 446 |
| 447 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| 448 __ Comment("CheckStackOverflowSlowPath"); |
| 449 __ Bind(entry_label()); |
| 450 compiler->SaveLiveRegisters(instruction_->locs()); |
| 451 // pending_deoptimization_env_ is needed to generate a runtime call that |
| 452 // may throw an exception. |
| 453 ASSERT(compiler->pending_deoptimization_env_ == NULL); |
| 454 compiler->pending_deoptimization_env_ = instruction_->env(); |
| 455 compiler->GenerateCallRuntime(instruction_->token_pos(), |
| 456 instruction_->deopt_id(), |
| 457 kStackOverflowRuntimeEntry, |
| 458 instruction_->locs()); |
| 459 compiler->pending_deoptimization_env_ = NULL; |
| 460 compiler->RestoreLiveRegisters(instruction_->locs()); |
| 461 __ b(exit_label()); |
| 462 } |
| 463 |
| 464 private: |
| 465 CheckStackOverflowInstr* instruction_; |
| 466 }; |
| 467 |
| 468 |
| 394 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 469 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 395 UNIMPLEMENTED(); | 470 CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this); |
| 471 compiler->AddSlowPathCode(slow_path); |
| 472 |
| 473 __ LoadImmediate(TMP, Isolate::Current()->stack_limit_address()); |
| 474 |
| 475 __ lw(TMP, Address(TMP)); |
| 476 __ subu(TMP, SP, TMP); |
| 477 __ blez(TMP, slow_path->entry_label()); |
| 478 |
| 479 __ Bind(slow_path->exit_label()); |
| 396 } | 480 } |
| 397 | 481 |
| 398 | 482 |
| 399 LocationSummary* BinarySmiOpInstr::MakeLocationSummary() const { | 483 LocationSummary* BinarySmiOpInstr::MakeLocationSummary() const { |
| 400 UNIMPLEMENTED(); | 484 UNIMPLEMENTED(); |
| 401 return NULL; | 485 return NULL; |
| 402 } | 486 } |
| 403 | 487 |
| 404 | 488 |
| 405 void BinarySmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 489 void BinarySmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 | 852 |
| 769 | 853 |
| 770 void CreateClosureInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 854 void CreateClosureInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 771 UNIMPLEMENTED(); | 855 UNIMPLEMENTED(); |
| 772 } | 856 } |
| 773 | 857 |
| 774 } // namespace dart | 858 } // namespace dart |
| 775 | 859 |
| 776 #endif // defined TARGET_ARCH_MIPS | 860 #endif // defined TARGET_ARCH_MIPS |
| 777 | 861 |
| OLD | NEW |