| OLD | NEW |
| 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "lib/error.h" | 8 #include "lib/error.h" |
| 9 #include "vm/flow_graph_compiler.h" | 9 #include "vm/flow_graph_compiler.h" |
| 10 #include "vm/locations.h" | 10 #include "vm/locations.h" |
| 11 #include "vm/object_store.h" | 11 #include "vm/object_store.h" |
| 12 #include "vm/parser.h" | 12 #include "vm/parser.h" |
| 13 #include "vm/stub_code.h" | 13 #include "vm/stub_code.h" |
| 14 | 14 |
| 15 #define __ compiler->assembler()-> | 15 #define __ compiler->assembler()-> |
| 16 | 16 |
| 17 namespace dart { | 17 namespace dart { |
| 18 | 18 |
| 19 | 19 |
| 20 static LocationSummary* MakeSimpleLocationSummary( |
| 21 intptr_t input_count, Location out) { |
| 22 LocationSummary* summary = new LocationSummary(input_count, 0); |
| 23 for (intptr_t i = 0; i < input_count; i++) { |
| 24 summary->set_in(i, Location::RequiresRegister()); |
| 25 } |
| 26 summary->set_out(out); |
| 27 return summary; |
| 28 } |
| 29 |
| 30 |
| 20 // True iff. the arguments to a call will be properly pushed and can | 31 // True iff. the arguments to a call will be properly pushed and can |
| 21 // be popped after the call. | 32 // be popped after the call. |
| 22 template <typename T> static bool VerifyCallComputation(T* comp) { | 33 template <typename T> static bool VerifyCallComputation(T* comp) { |
| 23 // Argument values should be consecutive temps. | 34 // Argument values should be consecutive temps. |
| 24 // | 35 // |
| 25 // TODO(kmillikin): implement stack height tracking so we can also assert | 36 // TODO(kmillikin): implement stack height tracking so we can also assert |
| 26 // they are on top of the stack. | 37 // they are on top of the stack. |
| 27 intptr_t previous = -1; | 38 intptr_t previous = -1; |
| 28 for (int i = 0; i < comp->ArgumentCount(); ++i) { | 39 for (int i = 0; i < comp->ArgumentCount(); ++i) { |
| 29 Value* val = comp->ArgumentAt(i); | 40 Value* val = comp->ArgumentAt(i); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 45 v2->AsUse()->definition()->temp_index(); | 56 v2->AsUse()->definition()->temp_index(); |
| 46 } | 57 } |
| 47 | 58 |
| 48 | 59 |
| 49 void BindInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 60 void BindInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 50 computation()->EmitNativeCode(compiler); | 61 computation()->EmitNativeCode(compiler); |
| 51 __ pushq(locs()->out().reg()); | 62 __ pushq(locs()->out().reg()); |
| 52 } | 63 } |
| 53 | 64 |
| 54 | 65 |
| 55 static LocationSummary* MakeSimpleLocationSummary( | 66 LocationSummary* ThrowInstr::MakeLocationSummary() const { |
| 56 intptr_t input_count, Location out) { | 67 const int kNumInputs = 0; |
| 57 LocationSummary* summary = new LocationSummary(input_count, 0); | 68 const int kNumTemps = 0; |
| 58 for (intptr_t i = 0; i < input_count; i++) { | 69 return new LocationSummary(kNumInputs, kNumTemps); |
| 59 summary->set_in(i, Location::RequiresRegister()); | |
| 60 } | |
| 61 summary->set_out(out); | |
| 62 return summary; | |
| 63 } | 70 } |
| 64 | 71 |
| 65 | 72 |
| 73 void ThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 74 ASSERT(exception()->IsUse()); |
| 75 compiler->GenerateCallRuntime(cid(), |
| 76 token_index(), |
| 77 try_index(), |
| 78 kThrowRuntimeEntry); |
| 79 __ int3(); |
| 80 } |
| 81 |
| 82 |
| 83 LocationSummary* ReThrowInstr::MakeLocationSummary() const { |
| 84 const int kNumInputs = 0; |
| 85 const int kNumTemps = 0; |
| 86 return new LocationSummary(kNumInputs, kNumTemps); |
| 87 } |
| 88 |
| 89 |
| 90 void ReThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 91 ASSERT(exception()->IsUse()); |
| 92 ASSERT(stack_trace()->IsUse()); |
| 93 compiler->GenerateCallRuntime(cid(), |
| 94 token_index(), |
| 95 try_index(), |
| 96 kReThrowRuntimeEntry); |
| 97 __ int3(); |
| 98 } |
| 99 |
| 100 |
| 101 LocationSummary* BranchInstr::MakeLocationSummary() const { |
| 102 const int kNumInputs = 1; |
| 103 const int kNumTemps = 1; |
| 104 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps); |
| 105 locs->set_in(0, Location::RequiresRegister()); |
| 106 locs->set_temp(0, Location::RequiresRegister()); |
| 107 return locs; |
| 108 } |
| 109 |
| 110 |
| 111 void BranchInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 112 Register value = locs()->in(0).reg(); |
| 113 Register temp = locs()->temp(0).reg(); |
| 114 |
| 115 __ LoadObject(temp, Bool::ZoneHandle(Bool::True())); |
| 116 __ cmpq(value, temp); |
| 117 if (compiler->IsNextBlock(false_successor())) { |
| 118 // If the next block is the false sucessor we will fall through to it if |
| 119 // comparison with true fails. |
| 120 __ j(EQUAL, compiler->GetBlockLabel(true_successor())); |
| 121 } else { |
| 122 // If the next block is the true sucessor we negate comparison and fall |
| 123 // through to it. |
| 124 __ j(NOT_EQUAL, compiler->GetBlockLabel(false_successor())); |
| 125 } |
| 126 } |
| 127 |
| 128 |
| 66 LocationSummary* CurrentContextComp::MakeLocationSummary() const { | 129 LocationSummary* CurrentContextComp::MakeLocationSummary() const { |
| 67 return MakeSimpleLocationSummary(0, Location::RequiresRegister()); | 130 return MakeSimpleLocationSummary(0, Location::RequiresRegister()); |
| 68 } | 131 } |
| 69 | 132 |
| 70 | 133 |
| 71 void CurrentContextComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 134 void CurrentContextComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 72 __ movq(locs()->out().reg(), CTX); | 135 __ movq(locs()->out().reg(), CTX); |
| 73 } | 136 } |
| 74 | 137 |
| 75 | 138 |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 if (locs()->out().reg() != RAX) { | 1028 if (locs()->out().reg() != RAX) { |
| 966 __ movq(locs()->out().reg(), RAX); | 1029 __ movq(locs()->out().reg(), RAX); |
| 967 } | 1030 } |
| 968 } | 1031 } |
| 969 | 1032 |
| 970 } // namespace dart | 1033 } // namespace dart |
| 971 | 1034 |
| 972 #undef __ | 1035 #undef __ |
| 973 | 1036 |
| 974 #endif // defined TARGET_ARCH_X64 | 1037 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |