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