| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/precompiler.h" | 5 #include "vm/precompiler.h" |
| 6 | 6 |
| 7 #include "vm/aot_optimizer.h" | 7 #include "vm/aot_optimizer.h" |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
| 10 #include "vm/branch_optimizer.h" | 10 #include "vm/branch_optimizer.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "vm/timer.h" | 42 #include "vm/timer.h" |
| 43 | 43 |
| 44 namespace dart { | 44 namespace dart { |
| 45 | 45 |
| 46 | 46 |
| 47 #define T (thread()) | 47 #define T (thread()) |
| 48 #define I (isolate()) | 48 #define I (isolate()) |
| 49 #define Z (zone()) | 49 #define Z (zone()) |
| 50 | 50 |
| 51 | 51 |
| 52 DEFINE_FLAG(bool, collect_dynamic_function_names, false, |
| 53 "In precompilation collects all dynamic function names in order to" |
| 54 " identify unique targets"); |
| 52 DEFINE_FLAG(bool, print_unique_targets, false, "Print unique dynaic targets"); | 55 DEFINE_FLAG(bool, print_unique_targets, false, "Print unique dynaic targets"); |
| 53 DEFINE_FLAG(bool, trace_precompiler, false, "Trace precompiler."); | 56 DEFINE_FLAG(bool, trace_precompiler, false, "Trace precompiler."); |
| 54 DEFINE_FLAG(int, max_speculative_inlining_attempts, 1, | 57 DEFINE_FLAG(int, max_speculative_inlining_attempts, 1, |
| 55 "Max number of attempts with speculative inlining (precompilation only)"); | 58 "Max number of attempts with speculative inlining (precompilation only)"); |
| 56 | 59 |
| 57 DECLARE_FLAG(bool, allocation_sinking); | 60 DECLARE_FLAG(bool, allocation_sinking); |
| 58 DECLARE_FLAG(bool, common_subexpression_elimination); | 61 DECLARE_FLAG(bool, common_subexpression_elimination); |
| 59 DECLARE_FLAG(bool, constant_propagation); | 62 DECLARE_FLAG(bool, constant_propagation); |
| 60 DECLARE_FLAG(bool, loop_invariant_code_motion); | 63 DECLARE_FLAG(bool, loop_invariant_code_motion); |
| 61 DECLARE_FLAG(bool, print_flow_graph); | 64 DECLARE_FLAG(bool, print_flow_graph); |
| 62 DECLARE_FLAG(bool, print_flow_graph_optimized); | 65 DECLARE_FLAG(bool, print_flow_graph_optimized); |
| 63 DECLARE_FLAG(bool, range_analysis); | 66 DECLARE_FLAG(bool, range_analysis); |
| 64 DECLARE_FLAG(bool, trace_compiler); | 67 DECLARE_FLAG(bool, trace_compiler); |
| 65 DECLARE_FLAG(bool, trace_optimizing_compiler); | 68 DECLARE_FLAG(bool, trace_optimizing_compiler); |
| 66 DECLARE_FLAG(bool, trace_bailout); | 69 DECLARE_FLAG(bool, trace_bailout); |
| 67 DECLARE_FLAG(bool, use_inlining); | 70 DECLARE_FLAG(bool, use_inlining); |
| 68 DECLARE_FLAG(bool, verify_compiler); | 71 DECLARE_FLAG(bool, verify_compiler); |
| 72 DECLARE_FLAG(bool, precompilation); |
| 69 DECLARE_FLAG(bool, huge_method_cutoff_in_code_size); | 73 DECLARE_FLAG(bool, huge_method_cutoff_in_code_size); |
| 74 DECLARE_FLAG(bool, load_deferred_eagerly); |
| 70 DECLARE_FLAG(bool, trace_failed_optimization_attempts); | 75 DECLARE_FLAG(bool, trace_failed_optimization_attempts); |
| 71 DECLARE_FLAG(bool, trace_inlining_intervals); | 76 DECLARE_FLAG(bool, trace_inlining_intervals); |
| 72 DECLARE_FLAG(bool, trace_irregexp); | 77 DECLARE_FLAG(bool, trace_irregexp); |
| 73 | 78 |
| 74 #ifdef DART_PRECOMPILER | 79 #ifdef DART_PRECOMPILER |
| 75 | 80 |
| 76 class PrecompileParsedFunctionHelper : public ValueObject { | 81 class PrecompileParsedFunctionHelper : public ValueObject { |
| 77 public: | 82 public: |
| 78 PrecompileParsedFunctionHelper(ParsedFunction* parsed_function, | 83 PrecompileParsedFunctionHelper(ParsedFunction* parsed_function, |
| 79 bool optimized) | 84 bool optimized) |
| (...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1877 } | 1882 } |
| 1878 ASSERT(!parsed_function()->HasDeferredPrefixes()); | 1883 ASSERT(!parsed_function()->HasDeferredPrefixes()); |
| 1879 ASSERT(FLAG_load_deferred_eagerly); | 1884 ASSERT(FLAG_load_deferred_eagerly); |
| 1880 } | 1885 } |
| 1881 | 1886 |
| 1882 | 1887 |
| 1883 // Return false if bailed out. | 1888 // Return false if bailed out. |
| 1884 // If optimized_result_code is not NULL then it is caller's responsibility | 1889 // If optimized_result_code is not NULL then it is caller's responsibility |
| 1885 // to install code. | 1890 // to install code. |
| 1886 bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { | 1891 bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
| 1887 ASSERT(FLAG_precompiled_mode); | 1892 ASSERT(FLAG_precompilation); |
| 1888 const Function& function = parsed_function()->function(); | 1893 const Function& function = parsed_function()->function(); |
| 1889 if (optimized() && !function.IsOptimizable()) { | 1894 if (optimized() && !function.IsOptimizable()) { |
| 1890 return false; | 1895 return false; |
| 1891 } | 1896 } |
| 1892 bool is_compiled = false; | 1897 bool is_compiled = false; |
| 1893 Zone* const zone = thread()->zone(); | 1898 Zone* const zone = thread()->zone(); |
| 1894 #ifndef PRODUCT | 1899 #ifndef PRODUCT |
| 1895 TimelineStream* compiler_timeline = isolate()->GetCompilerStream(); | 1900 TimelineStream* compiler_timeline = isolate()->GetCompilerStream(); |
| 1896 #endif // !PRODUCT | 1901 #endif // !PRODUCT |
| 1897 CSTAT_TIMER_SCOPE(thread(), codegen_timer); | 1902 CSTAT_TIMER_SCOPE(thread(), codegen_timer); |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2392 thread()->set_deopt_id(prev_deopt_id); | 2397 thread()->set_deopt_id(prev_deopt_id); |
| 2393 } | 2398 } |
| 2394 return is_compiled; | 2399 return is_compiled; |
| 2395 } | 2400 } |
| 2396 | 2401 |
| 2397 | 2402 |
| 2398 static RawError* PrecompileFunctionHelper(CompilationPipeline* pipeline, | 2403 static RawError* PrecompileFunctionHelper(CompilationPipeline* pipeline, |
| 2399 const Function& function, | 2404 const Function& function, |
| 2400 bool optimized) { | 2405 bool optimized) { |
| 2401 // Check that we optimize, except if the function is not optimizable. | 2406 // Check that we optimize, except if the function is not optimizable. |
| 2402 ASSERT(FLAG_precompiled_mode); | 2407 ASSERT(FLAG_precompilation); |
| 2403 ASSERT(!function.IsOptimizable() || optimized); | 2408 ASSERT(!function.IsOptimizable() || optimized); |
| 2404 ASSERT(!function.HasCode()); | 2409 ASSERT(!function.HasCode()); |
| 2405 LongJumpScope jump; | 2410 LongJumpScope jump; |
| 2406 if (setjmp(*jump.Set()) == 0) { | 2411 if (setjmp(*jump.Set()) == 0) { |
| 2407 Thread* const thread = Thread::Current(); | 2412 Thread* const thread = Thread::Current(); |
| 2408 StackZone stack_zone(thread); | 2413 StackZone stack_zone(thread); |
| 2409 Zone* const zone = stack_zone.GetZone(); | 2414 Zone* const zone = stack_zone.GetZone(); |
| 2410 const bool trace_compiler = | 2415 const bool trace_compiler = |
| 2411 FLAG_trace_compiler || | 2416 FLAG_trace_compiler || |
| 2412 (FLAG_trace_optimizing_compiler && optimized); | 2417 (FLAG_trace_optimizing_compiler && optimized); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2489 | 2494 |
| 2490 | 2495 |
| 2491 RawError* Precompiler::CompileFunction(Thread* thread, | 2496 RawError* Precompiler::CompileFunction(Thread* thread, |
| 2492 const Function& function) { | 2497 const Function& function) { |
| 2493 VMTagScope tagScope(thread, VMTag::kCompileUnoptimizedTagId); | 2498 VMTagScope tagScope(thread, VMTag::kCompileUnoptimizedTagId); |
| 2494 TIMELINE_FUNCTION_COMPILATION_DURATION(thread, "Function", function); | 2499 TIMELINE_FUNCTION_COMPILATION_DURATION(thread, "Function", function); |
| 2495 | 2500 |
| 2496 CompilationPipeline* pipeline = | 2501 CompilationPipeline* pipeline = |
| 2497 CompilationPipeline::New(thread->zone(), function); | 2502 CompilationPipeline::New(thread->zone(), function); |
| 2498 | 2503 |
| 2499 ASSERT(FLAG_precompiled_mode); | 2504 ASSERT(FLAG_precompilation); |
| 2500 const bool optimized = function.IsOptimizable(); // False for natives. | 2505 const bool optimized = function.IsOptimizable(); // False for natives. |
| 2501 return PrecompileFunctionHelper(pipeline, function, optimized); | 2506 return PrecompileFunctionHelper(pipeline, function, optimized); |
| 2502 } | 2507 } |
| 2503 | 2508 |
| 2504 #endif // DART_PRECOMPILER | 2509 #endif // DART_PRECOMPILER |
| 2505 | 2510 |
| 2506 } // namespace dart | 2511 } // namespace dart |
| OLD | NEW |