| 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_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
| 6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
| 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(R0)); |
| 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 == R0); |
| 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 __ sub(R2, FP, ShifterOperand(SP)); |
| 66 // + 1 for saved PP. |
| 67 __ CompareImmediate(R2, (compiler->StackSize() + 1) * kWordSize); |
| 68 __ bkpt(0, NE); |
| 69 } |
| 70 #endif |
| 71 AssemblerMacros::LeaveDartFrame(compiler->assembler()); |
| 72 __ Ret(); |
| 73 |
| 74 // Generate 2 NOP instructions so that the debugger can patch the return |
| 75 // pattern (1 instruction) with a call to the debug stub (3 instructions). |
| 76 __ nop(); |
| 77 __ nop(); |
| 78 compiler->AddCurrentDescriptor(PcDescriptors::kReturn, |
| 79 Isolate::kNoDeoptId, |
| 80 token_pos()); |
| 49 } | 81 } |
| 50 | 82 |
| 51 | 83 |
| 52 LocationSummary* ClosureCallInstr::MakeLocationSummary() const { | 84 LocationSummary* ClosureCallInstr::MakeLocationSummary() const { |
| 53 UNIMPLEMENTED(); | 85 UNIMPLEMENTED(); |
| 54 return NULL; | 86 return NULL; |
| 55 } | 87 } |
| 56 | 88 |
| 57 | 89 |
| 58 LocationSummary* LoadLocalInstr::MakeLocationSummary() const { | 90 LocationSummary* LoadLocalInstr::MakeLocationSummary() const { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 71 return NULL; | 103 return NULL; |
| 72 } | 104 } |
| 73 | 105 |
| 74 | 106 |
| 75 void StoreLocalInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 107 void StoreLocalInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 76 UNIMPLEMENTED(); | 108 UNIMPLEMENTED(); |
| 77 } | 109 } |
| 78 | 110 |
| 79 | 111 |
| 80 LocationSummary* ConstantInstr::MakeLocationSummary() const { | 112 LocationSummary* ConstantInstr::MakeLocationSummary() const { |
| 81 UNIMPLEMENTED(); | 113 return LocationSummary::Make(0, |
| 82 return NULL; | 114 Location::RequiresRegister(), |
| 115 LocationSummary::kNoCall); |
| 83 } | 116 } |
| 84 | 117 |
| 85 | 118 |
| 86 void ConstantInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 119 void ConstantInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 87 UNIMPLEMENTED(); | 120 // The register allocator drops constant definitions that have no uses. |
| 121 if (!locs()->out().IsInvalid()) { |
| 122 Register result = locs()->out().reg(); |
| 123 __ LoadObject(result, value()); |
| 124 } |
| 88 } | 125 } |
| 89 | 126 |
| 90 | 127 |
| 91 LocationSummary* AssertAssignableInstr::MakeLocationSummary() const { | 128 LocationSummary* AssertAssignableInstr::MakeLocationSummary() const { |
| 92 UNIMPLEMENTED(); | 129 UNIMPLEMENTED(); |
| 93 return NULL; | 130 return NULL; |
| 94 } | 131 } |
| 95 | 132 |
| 96 | 133 |
| 97 LocationSummary* AssertBooleanInstr::MakeLocationSummary() const { | 134 LocationSummary* AssertBooleanInstr::MakeLocationSummary() const { |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 return NULL; | 394 return NULL; |
| 358 } | 395 } |
| 359 | 396 |
| 360 | 397 |
| 361 void CatchEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 398 void CatchEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 362 UNIMPLEMENTED(); | 399 UNIMPLEMENTED(); |
| 363 } | 400 } |
| 364 | 401 |
| 365 | 402 |
| 366 LocationSummary* CheckStackOverflowInstr::MakeLocationSummary() const { | 403 LocationSummary* CheckStackOverflowInstr::MakeLocationSummary() const { |
| 367 UNIMPLEMENTED(); | 404 const intptr_t kNumInputs = 0; |
| 368 return NULL; | 405 const intptr_t kNumTemps = 0; |
| 406 LocationSummary* summary = |
| 407 new LocationSummary(kNumInputs, |
| 408 kNumTemps, |
| 409 LocationSummary::kCallOnSlowPath); |
| 410 return summary; |
| 369 } | 411 } |
| 370 | 412 |
| 371 | 413 |
| 414 class CheckStackOverflowSlowPath : public SlowPathCode { |
| 415 public: |
| 416 explicit CheckStackOverflowSlowPath(CheckStackOverflowInstr* instruction) |
| 417 : instruction_(instruction) { } |
| 418 |
| 419 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| 420 __ Comment("CheckStackOverflowSlowPath"); |
| 421 __ Bind(entry_label()); |
| 422 compiler->SaveLiveRegisters(instruction_->locs()); |
| 423 // pending_deoptimization_env_ is needed to generate a runtime call that |
| 424 // may throw an exception. |
| 425 ASSERT(compiler->pending_deoptimization_env_ == NULL); |
| 426 compiler->pending_deoptimization_env_ = instruction_->env(); |
| 427 compiler->GenerateCallRuntime(instruction_->token_pos(), |
| 428 instruction_->deopt_id(), |
| 429 kStackOverflowRuntimeEntry, |
| 430 instruction_->locs()); |
| 431 compiler->pending_deoptimization_env_ = NULL; |
| 432 compiler->RestoreLiveRegisters(instruction_->locs()); |
| 433 __ b(exit_label()); |
| 434 } |
| 435 |
| 436 private: |
| 437 CheckStackOverflowInstr* instruction_; |
| 438 }; |
| 439 |
| 440 |
| 372 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 441 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 373 UNIMPLEMENTED(); | 442 CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this); |
| 443 compiler->AddSlowPathCode(slow_path); |
| 444 |
| 445 __ LoadImmediate(IP, Isolate::Current()->stack_limit_address()); |
| 446 __ ldr(IP, Address(IP)); |
| 447 __ cmp(SP, ShifterOperand(IP)); |
| 448 __ b(slow_path->entry_label(), LS); |
| 449 __ Bind(slow_path->exit_label()); |
| 374 } | 450 } |
| 375 | 451 |
| 376 | 452 |
| 377 LocationSummary* BinarySmiOpInstr::MakeLocationSummary() const { | 453 LocationSummary* BinarySmiOpInstr::MakeLocationSummary() const { |
| 378 UNIMPLEMENTED(); | 454 UNIMPLEMENTED(); |
| 379 return NULL; | 455 return NULL; |
| 380 } | 456 } |
| 381 | 457 |
| 382 | 458 |
| 383 void BinarySmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 459 void BinarySmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 | 822 |
| 747 | 823 |
| 748 void CreateClosureInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 824 void CreateClosureInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 749 UNIMPLEMENTED(); | 825 UNIMPLEMENTED(); |
| 750 } | 826 } |
| 751 | 827 |
| 752 } // namespace dart | 828 } // namespace dart |
| 753 | 829 |
| 754 #endif // defined TARGET_ARCH_ARM | 830 #endif // defined TARGET_ARCH_ARM |
| 755 | 831 |
| OLD | NEW |