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/cpu.h" | 8 #include "vm/cpu.h" |
9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
10 #include "vm/flow_graph.h" | 10 #include "vm/flow_graph.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 #if defined(DART_NO_SNAPSHOT) | 61 #if defined(DART_NO_SNAPSHOT) |
62 void Intrinsifier::InitializeState() { | 62 void Intrinsifier::InitializeState() { |
63 Thread* thread = Thread::Current(); | 63 Thread* thread = Thread::Current(); |
64 Zone* zone = thread->zone(); | 64 Zone* zone = thread->zone(); |
65 Library& lib = Library::Handle(zone); | 65 Library& lib = Library::Handle(zone); |
66 Class& cls = Class::Handle(zone); | 66 Class& cls = Class::Handle(zone); |
67 Function& func = Function::Handle(zone); | 67 Function& func = Function::Handle(zone); |
68 String& str = String::Handle(zone); | 68 String& str = String::Handle(zone); |
69 Error& error = Error::Handle(zone); | 69 Error& error = Error::Handle(zone); |
70 | 70 |
71 #define SETUP_FUNCTION(class_name, function_name, destination, type, fp) \ | 71 #define SETUP_FUNCTION(class_name, function_name, destination, fp) \ |
72 if (strcmp(#class_name, "::") == 0) { \ | 72 if (strcmp(#class_name, "::") == 0) { \ |
73 str = String::New(#function_name); \ | 73 str = String::New(#function_name); \ |
74 func = lib.LookupFunctionAllowPrivate(str); \ | 74 func = lib.LookupFunctionAllowPrivate(str); \ |
75 } else { \ | 75 } else { \ |
76 str = String::New(#class_name); \ | 76 str = String::New(#class_name); \ |
77 cls = lib.LookupClassAllowPrivate(str); \ | 77 cls = lib.LookupClassAllowPrivate(str); \ |
78 ASSERT(!cls.IsNull()); \ | 78 ASSERT(!cls.IsNull()); \ |
79 error = cls.EnsureIsFinalized(thread); \ | 79 error = cls.EnsureIsFinalized(thread); \ |
80 if (!error.IsNull()) { \ | 80 if (!error.IsNull()) { \ |
81 OS::PrintErr("%s\n", error.ToErrorCString()); \ | 81 OS::PrintErr("%s\n", error.ToErrorCString()); \ |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 intptr_t block_id = builder.AllocateBlockId(); | 173 intptr_t block_id = builder.AllocateBlockId(); |
174 TargetEntryInstr* normal_entry = | 174 TargetEntryInstr* normal_entry = |
175 new TargetEntryInstr(block_id, | 175 new TargetEntryInstr(block_id, |
176 CatchClauseNode::kInvalidTryIndex); | 176 CatchClauseNode::kInvalidTryIndex); |
177 GraphEntryInstr* graph_entry = new GraphEntryInstr( | 177 GraphEntryInstr* graph_entry = new GraphEntryInstr( |
178 parsed_function, normal_entry, Compiler::kNoOSRDeoptId); | 178 parsed_function, normal_entry, Compiler::kNoOSRDeoptId); |
179 FlowGraph* graph = new FlowGraph(parsed_function, graph_entry, block_id); | 179 FlowGraph* graph = new FlowGraph(parsed_function, graph_entry, block_id); |
180 const Function& function = parsed_function.function(); | 180 const Function& function = parsed_function.function(); |
181 switch (function.recognized_kind()) { | 181 switch (function.recognized_kind()) { |
182 #define EMIT_CASE(class_name, function_name, enum_name, type, fp) \ | 182 #define EMIT_CASE(class_name, function_name, enum_name, fp) \ |
183 case MethodRecognizer::k##enum_name: \ | 183 case MethodRecognizer::k##enum_name: \ |
184 if (!Build_##enum_name(graph)) return false; \ | 184 if (!Build_##enum_name(graph)) return false; \ |
185 break; | 185 break; |
186 | 186 |
187 GRAPH_INTRINSICS_LIST(EMIT_CASE); | 187 GRAPH_INTRINSICS_LIST(EMIT_CASE); |
188 default: | 188 default: |
189 return false; | 189 return false; |
190 #undef EMIT_CASE | 190 #undef EMIT_CASE |
191 } | 191 } |
192 | 192 |
(...skipping 27 matching lines...) Expand all Loading... |
220 const Function& function = parsed_function.function(); | 220 const Function& function = parsed_function.function(); |
221 if (!CanIntrinsify(function)) { | 221 if (!CanIntrinsify(function)) { |
222 return; | 222 return; |
223 } | 223 } |
224 | 224 |
225 ASSERT(!compiler->flow_graph().IsCompiledForOsr()); | 225 ASSERT(!compiler->flow_graph().IsCompiledForOsr()); |
226 if (GraphIntrinsify(parsed_function, compiler)) { | 226 if (GraphIntrinsify(parsed_function, compiler)) { |
227 return; | 227 return; |
228 } | 228 } |
229 | 229 |
230 #define EMIT_CASE(class_name, function_name, enum_name, type, fp) \ | 230 #define EMIT_CASE(class_name, function_name, enum_name, fp) \ |
231 case MethodRecognizer::k##enum_name: \ | 231 case MethodRecognizer::k##enum_name: \ |
232 compiler->assembler()->Comment("Intrinsic"); \ | 232 compiler->assembler()->Comment("Intrinsic"); \ |
233 enum_name(compiler->assembler()); \ | 233 enum_name(compiler->assembler()); \ |
234 break; | 234 break; |
235 | 235 |
236 switch (function.recognized_kind()) { | 236 switch (function.recognized_kind()) { |
237 ALL_INTRINSICS_NO_INTEGER_LIB_LIST(EMIT_CASE); | 237 ALL_INTRINSICS_NO_INTEGER_LIB_LIST(EMIT_CASE); |
238 default: | 238 default: |
239 break; | 239 break; |
240 } | 240 } |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); | 1230 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); |
1231 BlockBuilder builder(flow_graph, normal_entry); | 1231 BlockBuilder builder(flow_graph, normal_entry); |
1232 | 1232 |
1233 return BuildInvokeMathCFunction(&builder, | 1233 return BuildInvokeMathCFunction(&builder, |
1234 MethodRecognizer::kDoubleRound); | 1234 MethodRecognizer::kDoubleRound); |
1235 } | 1235 } |
1236 #endif // !defined(TARGET_ARCH_DBC) | 1236 #endif // !defined(TARGET_ARCH_DBC) |
1237 | 1237 |
1238 | 1238 |
1239 } // namespace dart | 1239 } // namespace dart |
OLD | NEW |