| 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/compiler.h" | 5 #include "vm/compiler.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 | 8 |
| 9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
| 10 #include "vm/block_scheduler.h" | 10 #include "vm/block_scheduler.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 Code::Handle(function.unoptimized_code()).EntryPoint()); | 256 Code::Handle(function.unoptimized_code()).EntryPoint()); |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 | 259 |
| 260 | 260 |
| 261 // Return false if bailed out. | 261 // Return false if bailed out. |
| 262 static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function, | 262 static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function, |
| 263 bool optimized, | 263 bool optimized, |
| 264 intptr_t osr_id) { | 264 intptr_t osr_id) { |
| 265 const Function& function = parsed_function->function(); | 265 const Function& function = parsed_function->function(); |
| 266 if (optimized && !function.is_optimizable()) { | 266 if (optimized && !function.IsOptimizable()) { |
| 267 return false; | 267 return false; |
| 268 } | 268 } |
| 269 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer); | 269 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer); |
| 270 bool is_compiled = false; | 270 bool is_compiled = false; |
| 271 Isolate* isolate = Isolate::Current(); | 271 Isolate* isolate = Isolate::Current(); |
| 272 HANDLESCOPE(isolate); | 272 HANDLESCOPE(isolate); |
| 273 | 273 |
| 274 // We may reattempt compilation if the function needs to be assembled using | 274 // We may reattempt compilation if the function needs to be assembled using |
| 275 // far branches on ARM and MIPS. In the else branch of the setjmp call, | 275 // far branches on ARM and MIPS. In the else branch of the setjmp call, |
| 276 // done is set to false, and use_far_branches is set to true if there is a | 276 // done is set to false, and use_far_branches is set to true if there is a |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 const bool success = | 779 const bool success = |
| 780 CompileParsedFunctionHelper(parsed_function, optimized, osr_id); | 780 CompileParsedFunctionHelper(parsed_function, optimized, osr_id); |
| 781 if (optimized && !success) { | 781 if (optimized && !success) { |
| 782 // Optimizer bailed out. Disable optimizations and to never try again. | 782 // Optimizer bailed out. Disable optimizations and to never try again. |
| 783 if (FLAG_trace_compiler) { | 783 if (FLAG_trace_compiler) { |
| 784 OS::Print("--> disabling optimizations for '%s'\n", | 784 OS::Print("--> disabling optimizations for '%s'\n", |
| 785 function.ToFullyQualifiedCString()); | 785 function.ToFullyQualifiedCString()); |
| 786 } else if (FLAG_trace_failed_optimization_attempts) { | 786 } else if (FLAG_trace_failed_optimization_attempts) { |
| 787 OS::Print("Cannot optimize: %s\n", function.ToFullyQualifiedCString()); | 787 OS::Print("Cannot optimize: %s\n", function.ToFullyQualifiedCString()); |
| 788 } | 788 } |
| 789 function.set_is_optimizable(false); | 789 function.SetIsOptimizable(false); |
| 790 isolate->set_long_jump_base(base); | 790 isolate->set_long_jump_base(base); |
| 791 return Error::null(); | 791 return Error::null(); |
| 792 } | 792 } |
| 793 | 793 |
| 794 ASSERT(success); | 794 ASSERT(success); |
| 795 per_compile_timer.Stop(); | 795 per_compile_timer.Stop(); |
| 796 | 796 |
| 797 if (FLAG_trace_compiler) { | 797 if (FLAG_trace_compiler) { |
| 798 OS::Print("--> '%s' entry: %#" Px " size: %" Pd " time: %" Pd64 " us\n", | 798 OS::Print("--> '%s' entry: %#" Px " size: %" Pd " time: %" Pd64 " us\n", |
| 799 function.ToFullyQualifiedCString(), | 799 function.ToFullyQualifiedCString(), |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 false, // not abstract | 932 false, // not abstract |
| 933 false, // not external | 933 false, // not external |
| 934 false, // not native | 934 false, // not native |
| 935 Class::Handle(Type::Handle(Type::Function()).type_class()), | 935 Class::Handle(Type::Handle(Type::Function()).type_class()), |
| 936 fragment->token_pos())); | 936 fragment->token_pos())); |
| 937 | 937 |
| 938 func.set_result_type(Type::Handle(Type::DynamicType())); | 938 func.set_result_type(Type::Handle(Type::DynamicType())); |
| 939 func.set_num_fixed_parameters(0); | 939 func.set_num_fixed_parameters(0); |
| 940 func.SetNumOptionalParameters(0, true); | 940 func.SetNumOptionalParameters(0, true); |
| 941 // Manually generated AST, do not recompile. | 941 // Manually generated AST, do not recompile. |
| 942 func.set_is_optimizable(false); | 942 func.SetIsOptimizable(false); |
| 943 | 943 |
| 944 // We compile the function here, even though InvokeStatic() below | 944 // We compile the function here, even though InvokeStatic() below |
| 945 // would compile func automatically. We are checking fewer invariants | 945 // would compile func automatically. We are checking fewer invariants |
| 946 // here. | 946 // here. |
| 947 ParsedFunction* parsed_function = new ParsedFunction(func); | 947 ParsedFunction* parsed_function = new ParsedFunction(func); |
| 948 parsed_function->SetNodeSequence(fragment); | 948 parsed_function->SetNodeSequence(fragment); |
| 949 parsed_function->set_default_parameter_values(Object::null_array()); | 949 parsed_function->set_default_parameter_values(Object::null_array()); |
| 950 parsed_function->EnsureExpressionTemp(); | 950 parsed_function->EnsureExpressionTemp(); |
| 951 fragment->scope()->AddVariable(parsed_function->expression_temp_var()); | 951 fragment->scope()->AddVariable(parsed_function->expression_temp_var()); |
| 952 parsed_function->AllocateVariables(); | 952 parsed_function->AllocateVariables(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 963 Object::Handle(isolate->object_store()->sticky_error()); | 963 Object::Handle(isolate->object_store()->sticky_error()); |
| 964 isolate->object_store()->clear_sticky_error(); | 964 isolate->object_store()->clear_sticky_error(); |
| 965 isolate->set_long_jump_base(base); | 965 isolate->set_long_jump_base(base); |
| 966 return result.raw(); | 966 return result.raw(); |
| 967 } | 967 } |
| 968 UNREACHABLE(); | 968 UNREACHABLE(); |
| 969 return Object::null(); | 969 return Object::null(); |
| 970 } | 970 } |
| 971 | 971 |
| 972 } // namespace dart | 972 } // namespace dart |
| OLD | NEW |