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 // Class for intrinsifying functions. | 4 // Class for intrinsifying functions. |
5 | 5 |
6 #include "vm/assembler.h" | 6 #include "vm/assembler.h" |
7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/flow_graph.h" | 9 #include "vm/flow_graph.h" |
10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // Setup all dart:developer lib functions that can be intrinsified. | 88 // Setup all dart:developer lib functions that can be intrinsified. |
89 lib = Library::DeveloperLibrary(); | 89 lib = Library::DeveloperLibrary(); |
90 ASSERT(!lib.IsNull()); | 90 ASSERT(!lib.IsNull()); |
91 DEVELOPER_LIB_INTRINSIC_LIST(SETUP_FUNCTION); | 91 DEVELOPER_LIB_INTRINSIC_LIST(SETUP_FUNCTION); |
92 | 92 |
93 #undef SETUP_FUNCTION | 93 #undef SETUP_FUNCTION |
94 } | 94 } |
95 #endif // defined(DART_NO_SNAPSHOT). | 95 #endif // defined(DART_NO_SNAPSHOT). |
96 | 96 |
97 | 97 |
| 98 #if !defined(TARGET_ARCH_DBC) |
98 static void EmitCodeFor(FlowGraphCompiler* compiler, | 99 static void EmitCodeFor(FlowGraphCompiler* compiler, |
99 FlowGraph* graph) { | 100 FlowGraph* graph) { |
100 // The FlowGraph here is constructed by the intrinsics builder methods, and | 101 // The FlowGraph here is constructed by the intrinsics builder methods, and |
101 // is different from compiler->flow_graph(), the original method's flow graph. | 102 // is different from compiler->flow_graph(), the original method's flow graph. |
102 compiler->assembler()->Comment("Graph intrinsic"); | 103 compiler->assembler()->Comment("Graph intrinsic"); |
103 for (intptr_t i = 0; i < graph->reverse_postorder().length(); i++) { | 104 for (intptr_t i = 0; i < graph->reverse_postorder().length(); i++) { |
104 BlockEntryInstr* block = graph->reverse_postorder()[i]; | 105 BlockEntryInstr* block = graph->reverse_postorder()[i]; |
105 if (block->IsGraphEntry()) continue; // No code for graph entry needed. | 106 if (block->IsGraphEntry()) continue; // No code for graph entry needed. |
106 | 107 |
107 if (block->HasParallelMove()) { | 108 if (block->HasParallelMove()) { |
108 compiler->parallel_move_resolver()->EmitNativeCode( | 109 compiler->parallel_move_resolver()->EmitNativeCode( |
109 block->parallel_move()); | 110 block->parallel_move()); |
110 } | 111 } |
111 | 112 |
112 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { | 113 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { |
113 Instruction* instr = it.Current(); | 114 Instruction* instr = it.Current(); |
114 if (FLAG_code_comments) compiler->EmitComment(instr); | 115 if (FLAG_code_comments) compiler->EmitComment(instr); |
115 if (instr->IsParallelMove()) { | 116 if (instr->IsParallelMove()) { |
116 compiler->parallel_move_resolver()->EmitNativeCode( | 117 compiler->parallel_move_resolver()->EmitNativeCode( |
117 instr->AsParallelMove()); | 118 instr->AsParallelMove()); |
118 } else { | 119 } else { |
119 ASSERT(instr->locs() != NULL); | 120 ASSERT(instr->locs() != NULL); |
120 // Calls are not supported in intrinsics code. | 121 // Calls are not supported in intrinsics code. |
121 ASSERT(!instr->locs()->always_calls()); | 122 ASSERT(!instr->locs()->always_calls()); |
122 instr->EmitNativeCode(compiler); | 123 instr->EmitNativeCode(compiler); |
123 } | 124 } |
124 } | 125 } |
125 } | 126 } |
126 } | 127 } |
| 128 #endif |
127 | 129 |
128 | 130 |
129 bool Intrinsifier::GraphIntrinsify(const ParsedFunction& parsed_function, | 131 bool Intrinsifier::GraphIntrinsify(const ParsedFunction& parsed_function, |
130 FlowGraphCompiler* compiler) { | 132 FlowGraphCompiler* compiler) { |
| 133 #if defined(TARGET_ARCH_DBC) |
| 134 return false; |
| 135 #else |
131 ZoneGrowableArray<const ICData*>* ic_data_array = | 136 ZoneGrowableArray<const ICData*>* ic_data_array = |
132 new ZoneGrowableArray<const ICData*>(); | 137 new ZoneGrowableArray<const ICData*>(); |
133 FlowGraphBuilder builder(parsed_function, | 138 FlowGraphBuilder builder(parsed_function, |
134 *ic_data_array, | 139 *ic_data_array, |
135 NULL, // NULL = not inlining. | 140 NULL, // NULL = not inlining. |
136 Compiler::kNoOSRDeoptId); | 141 Compiler::kNoOSRDeoptId); |
137 | 142 |
138 intptr_t block_id = builder.AllocateBlockId(); | 143 intptr_t block_id = builder.AllocateBlockId(); |
139 TargetEntryInstr* normal_entry = | 144 TargetEntryInstr* normal_entry = |
140 new TargetEntryInstr(block_id, | 145 new TargetEntryInstr(block_id, |
(...skipping 26 matching lines...) Expand all Loading... |
167 allocator.AllocateRegisters(); | 172 allocator.AllocateRegisters(); |
168 | 173 |
169 if (FLAG_support_il_printer && | 174 if (FLAG_support_il_printer && |
170 FLAG_print_flow_graph && FlowGraphPrinter::ShouldPrint(function)) { | 175 FLAG_print_flow_graph && FlowGraphPrinter::ShouldPrint(function)) { |
171 THR_Print("Intrinsic graph after\n"); | 176 THR_Print("Intrinsic graph after\n"); |
172 FlowGraphPrinter printer(*graph); | 177 FlowGraphPrinter printer(*graph); |
173 printer.PrintBlocks(); | 178 printer.PrintBlocks(); |
174 } | 179 } |
175 EmitCodeFor(compiler, graph); | 180 EmitCodeFor(compiler, graph); |
176 return true; | 181 return true; |
| 182 #endif |
177 } | 183 } |
178 | 184 |
179 | 185 |
180 void Intrinsifier::Intrinsify(const ParsedFunction& parsed_function, | 186 void Intrinsifier::Intrinsify(const ParsedFunction& parsed_function, |
181 FlowGraphCompiler* compiler) { | 187 FlowGraphCompiler* compiler) { |
182 const Function& function = parsed_function.function(); | 188 const Function& function = parsed_function.function(); |
183 if (!CanIntrinsify(function)) { | 189 if (!CanIntrinsify(function)) { |
184 return; | 190 return; |
185 } | 191 } |
186 | 192 |
(...skipping 11 matching lines...) Expand all Loading... |
198 switch (function.recognized_kind()) { | 204 switch (function.recognized_kind()) { |
199 ALL_INTRINSICS_NO_INTEGER_LIB_LIST(EMIT_CASE); | 205 ALL_INTRINSICS_NO_INTEGER_LIB_LIST(EMIT_CASE); |
200 default: | 206 default: |
201 break; | 207 break; |
202 } | 208 } |
203 switch (function.recognized_kind()) { | 209 switch (function.recognized_kind()) { |
204 CORE_INTEGER_LIB_INTRINSIC_LIST(EMIT_CASE) | 210 CORE_INTEGER_LIB_INTRINSIC_LIST(EMIT_CASE) |
205 default: | 211 default: |
206 break; | 212 break; |
207 } | 213 } |
| 214 |
| 215 #if defined(TARGET_ARCH_DBC) |
| 216 switch (function.recognized_kind()) { |
| 217 GRAPH_INTRINSICS_LIST(EMIT_CASE) |
| 218 default: |
| 219 break; |
| 220 } |
| 221 #endif |
| 222 |
208 #undef EMIT_INTRINSIC | 223 #undef EMIT_INTRINSIC |
209 } | 224 } |
210 | 225 |
211 | 226 |
| 227 #if !defined(TARGET_ARCH_DBC) |
212 static intptr_t CidForRepresentation(Representation rep) { | 228 static intptr_t CidForRepresentation(Representation rep) { |
213 switch (rep) { | 229 switch (rep) { |
214 case kUnboxedDouble: | 230 case kUnboxedDouble: |
215 return kDoubleCid; | 231 return kDoubleCid; |
216 case kUnboxedFloat32x4: | 232 case kUnboxedFloat32x4: |
217 return kFloat32x4Cid; | 233 return kFloat32x4Cid; |
218 case kUnboxedUint32: | 234 case kUnboxedUint32: |
219 return kDynamicCid; // smi or mint. | 235 return kDynamicCid; // smi or mint. |
220 default: | 236 default: |
221 UNREACHABLE(); | 237 UNREACHABLE(); |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 builder.AddUnboxInstr(kUnboxedDouble, new Value(receiver)); | 891 builder.AddUnboxInstr(kUnboxedDouble, new Value(receiver)); |
876 Definition* unboxed_result = builder.AddDefinition( | 892 Definition* unboxed_result = builder.AddDefinition( |
877 new UnaryDoubleOpInstr(Token::kNEGATE, | 893 new UnaryDoubleOpInstr(Token::kNEGATE, |
878 new Value(unboxed_value), | 894 new Value(unboxed_value), |
879 Thread::kNoDeoptId)); | 895 Thread::kNoDeoptId)); |
880 Definition* result = builder.AddDefinition( | 896 Definition* result = builder.AddDefinition( |
881 BoxInstr::Create(kUnboxedDouble, new Value(unboxed_result))); | 897 BoxInstr::Create(kUnboxedDouble, new Value(unboxed_result))); |
882 builder.AddIntrinsicReturn(new Value(result)); | 898 builder.AddIntrinsicReturn(new Value(result)); |
883 return true; | 899 return true; |
884 } | 900 } |
| 901 #endif |
885 | 902 |
886 } // namespace dart | 903 } // namespace dart |
OLD | NEW |