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" |
11 #include "vm/flow_graph_allocator.h" | 11 #include "vm/flow_graph_allocator.h" |
12 #include "vm/flow_graph_builder.h" | 12 #include "vm/flow_graph_builder.h" |
13 #include "vm/il_printer.h" | 13 #include "vm/il_printer.h" |
14 #include "vm/intermediate_language.h" | 14 #include "vm/intermediate_language.h" |
15 #include "vm/intrinsifier.h" | 15 #include "vm/intrinsifier.h" |
16 #include "vm/object.h" | 16 #include "vm/object.h" |
17 #include "vm/parser.h" | 17 #include "vm/parser.h" |
18 #include "vm/symbols.h" | 18 #include "vm/symbols.h" |
19 | 19 |
20 | 20 |
21 namespace dart { | 21 namespace dart { |
22 | 22 |
23 DEFINE_FLAG(bool, intrinsify, true, "Instrinsify when possible"); | 23 DEFINE_FLAG(bool, intrinsify, true, "Instrinsify when possible"); |
24 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); | |
25 DECLARE_FLAG(bool, code_comments); | 24 DECLARE_FLAG(bool, code_comments); |
26 DECLARE_FLAG(bool, print_flow_graph); | 25 DECLARE_FLAG(bool, print_flow_graph); |
27 DECLARE_FLAG(bool, print_flow_graph_optimized); | 26 DECLARE_FLAG(bool, print_flow_graph_optimized); |
28 | 27 |
29 bool Intrinsifier::CanIntrinsify(const Function& function) { | 28 bool Intrinsifier::CanIntrinsify(const Function& function) { |
30 if (!FLAG_intrinsify) return false; | 29 if (!FLAG_intrinsify) return false; |
31 if (function.IsClosureFunction()) return false; | 30 if (function.IsClosureFunction()) return false; |
32 // Can occur because of compile-all flag. | 31 // Can occur because of compile-all flag. |
33 if (function.is_external()) return false; | 32 if (function.is_external()) return false; |
34 return function.is_intrinsic(); | 33 return function.is_intrinsic(); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 case MethodRecognizer::k##enum_name: \ | 193 case MethodRecognizer::k##enum_name: \ |
195 compiler->assembler()->Comment("Intrinsic"); \ | 194 compiler->assembler()->Comment("Intrinsic"); \ |
196 enum_name(compiler->assembler()); \ | 195 enum_name(compiler->assembler()); \ |
197 break; | 196 break; |
198 | 197 |
199 switch (function.recognized_kind()) { | 198 switch (function.recognized_kind()) { |
200 ALL_INTRINSICS_NO_INTEGER_LIB_LIST(EMIT_CASE); | 199 ALL_INTRINSICS_NO_INTEGER_LIB_LIST(EMIT_CASE); |
201 default: | 200 default: |
202 break; | 201 break; |
203 } | 202 } |
204 // Integer intrinsics are in the core library, but we don't want to | 203 switch (function.recognized_kind()) { |
205 // intrinsify when Smi > 32 bits if we are looking for javascript integer | 204 CORE_INTEGER_LIB_INTRINSIC_LIST(EMIT_CASE) |
206 // overflow. | 205 default: |
207 if (!(FLAG_throw_on_javascript_int_overflow && (Smi::kBits >= 32))) { | 206 break; |
208 switch (function.recognized_kind()) { | |
209 CORE_INTEGER_LIB_INTRINSIC_LIST(EMIT_CASE) | |
210 default: | |
211 break; | |
212 } | |
213 } | 207 } |
214 #undef EMIT_INTRINSIC | 208 #undef EMIT_INTRINSIC |
215 } | 209 } |
216 | 210 |
217 | 211 |
218 static intptr_t CidForRepresentation(Representation rep) { | 212 static intptr_t CidForRepresentation(Representation rep) { |
219 switch (rep) { | 213 switch (rep) { |
220 case kUnboxedDouble: | 214 case kUnboxedDouble: |
221 return kDoubleCid; | 215 return kDoubleCid; |
222 case kUnboxedFloat32x4: | 216 case kUnboxedFloat32x4: |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 new UnaryDoubleOpInstr(Token::kNEGATE, | 877 new UnaryDoubleOpInstr(Token::kNEGATE, |
884 new Value(unboxed_value), | 878 new Value(unboxed_value), |
885 Thread::kNoDeoptId)); | 879 Thread::kNoDeoptId)); |
886 Definition* result = builder.AddDefinition( | 880 Definition* result = builder.AddDefinition( |
887 BoxInstr::Create(kUnboxedDouble, new Value(unboxed_result))); | 881 BoxInstr::Create(kUnboxedDouble, new Value(unboxed_result))); |
888 builder.AddIntrinsicReturn(new Value(result)); | 882 builder.AddIntrinsicReturn(new Value(result)); |
889 return true; | 883 return true; |
890 } | 884 } |
891 | 885 |
892 } // namespace dart | 886 } // namespace dart |
OLD | NEW |