| 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 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 flow_graph->ComputeSSA(0, NULL); | 1959 flow_graph->ComputeSSA(0, NULL); |
| 1960 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 1960 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 1961 if (print_flow_graph) { | 1961 if (print_flow_graph) { |
| 1962 FlowGraphPrinter::PrintGraph("After SSA", flow_graph); | 1962 FlowGraphPrinter::PrintGraph("After SSA", flow_graph); |
| 1963 } | 1963 } |
| 1964 } | 1964 } |
| 1965 | 1965 |
| 1966 // Maps inline_id_to_function[inline_id] -> function. Top scope | 1966 // Maps inline_id_to_function[inline_id] -> function. Top scope |
| 1967 // function has inline_id 0. The map is populated by the inliner. | 1967 // function has inline_id 0. The map is populated by the inliner. |
| 1968 GrowableArray<const Function*> inline_id_to_function; | 1968 GrowableArray<const Function*> inline_id_to_function; |
| 1969 // Token position where inlining occured. |
| 1970 GrowableArray<TokenPosition> inline_id_to_token_pos; |
| 1969 // For a given inlining-id(index) specifies the caller's inlining-id. | 1971 // For a given inlining-id(index) specifies the caller's inlining-id. |
| 1970 GrowableArray<intptr_t> caller_inline_id; | 1972 GrowableArray<intptr_t> caller_inline_id; |
| 1971 // Collect all instance fields that are loaded in the graph and | 1973 // Collect all instance fields that are loaded in the graph and |
| 1972 // have non-generic type feedback attached to them that can | 1974 // have non-generic type feedback attached to them that can |
| 1973 // potentially affect optimizations. | 1975 // potentially affect optimizations. |
| 1974 if (optimized()) { | 1976 if (optimized()) { |
| 1975 #ifndef PRODUCT | 1977 #ifndef PRODUCT |
| 1976 TimelineDurationScope tds(thread(), | 1978 TimelineDurationScope tds(thread(), |
| 1977 compiler_timeline, | 1979 compiler_timeline, |
| 1978 "OptimizationPasses"); | 1980 "OptimizationPasses"); |
| 1979 #endif // !PRODUCT | 1981 #endif // !PRODUCT |
| 1980 inline_id_to_function.Add(&function); | 1982 inline_id_to_function.Add(&function); |
| 1983 inline_id_to_token_pos.Add(function.token_pos()); |
| 1981 // Top scope function has no caller (-1). | 1984 // Top scope function has no caller (-1). |
| 1982 caller_inline_id.Add(-1); | 1985 caller_inline_id.Add(-1); |
| 1983 CSTAT_TIMER_SCOPE(thread(), graphoptimizer_timer); | 1986 CSTAT_TIMER_SCOPE(thread(), graphoptimizer_timer); |
| 1984 | 1987 |
| 1985 AotOptimizer optimizer(flow_graph, | 1988 AotOptimizer optimizer(flow_graph, |
| 1986 use_speculative_inlining, | 1989 use_speculative_inlining, |
| 1987 &inlining_black_list); | 1990 &inlining_black_list); |
| 1988 optimizer.PopulateWithICData(); | 1991 optimizer.PopulateWithICData(); |
| 1989 | 1992 |
| 1990 optimizer.ApplyClassIds(); | 1993 optimizer.ApplyClassIds(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2014 // Propagate types to create more inlining opportunities. | 2017 // Propagate types to create more inlining opportunities. |
| 2015 FlowGraphTypePropagator::Propagate(flow_graph); | 2018 FlowGraphTypePropagator::Propagate(flow_graph); |
| 2016 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 2019 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 2017 | 2020 |
| 2018 // Use propagated class-ids to create more inlining opportunities. | 2021 // Use propagated class-ids to create more inlining opportunities. |
| 2019 optimizer.ApplyClassIds(); | 2022 optimizer.ApplyClassIds(); |
| 2020 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 2023 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 2021 | 2024 |
| 2022 FlowGraphInliner inliner(flow_graph, | 2025 FlowGraphInliner inliner(flow_graph, |
| 2023 &inline_id_to_function, | 2026 &inline_id_to_function, |
| 2027 &inline_id_to_token_pos, |
| 2024 &caller_inline_id, | 2028 &caller_inline_id, |
| 2025 use_speculative_inlining, | 2029 use_speculative_inlining, |
| 2026 &inlining_black_list); | 2030 &inlining_black_list); |
| 2027 inliner.Inline(); | 2031 inliner.Inline(); |
| 2028 // Use lists are maintained and validated by the inliner. | 2032 // Use lists are maintained and validated by the inliner. |
| 2029 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 2033 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 2030 } | 2034 } |
| 2031 | 2035 |
| 2032 // Propagate types and eliminate more type tests. | 2036 // Propagate types and eliminate more type tests. |
| 2033 FlowGraphTypePropagator::Propagate(flow_graph); | 2037 FlowGraphTypePropagator::Propagate(flow_graph); |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2310 if (print_flow_graph) { | 2314 if (print_flow_graph) { |
| 2311 FlowGraphPrinter::PrintGraph("After Optimizations", flow_graph); | 2315 FlowGraphPrinter::PrintGraph("After Optimizations", flow_graph); |
| 2312 } | 2316 } |
| 2313 } | 2317 } |
| 2314 | 2318 |
| 2315 ASSERT(inline_id_to_function.length() == caller_inline_id.length()); | 2319 ASSERT(inline_id_to_function.length() == caller_inline_id.length()); |
| 2316 Assembler assembler(use_far_branches); | 2320 Assembler assembler(use_far_branches); |
| 2317 FlowGraphCompiler graph_compiler(&assembler, flow_graph, | 2321 FlowGraphCompiler graph_compiler(&assembler, flow_graph, |
| 2318 *parsed_function(), optimized(), | 2322 *parsed_function(), optimized(), |
| 2319 inline_id_to_function, | 2323 inline_id_to_function, |
| 2324 inline_id_to_token_pos, |
| 2320 caller_inline_id); | 2325 caller_inline_id); |
| 2321 { | 2326 { |
| 2322 CSTAT_TIMER_SCOPE(thread(), graphcompiler_timer); | 2327 CSTAT_TIMER_SCOPE(thread(), graphcompiler_timer); |
| 2323 #ifndef PRODUCT | 2328 #ifndef PRODUCT |
| 2324 TimelineDurationScope tds(thread(), | 2329 TimelineDurationScope tds(thread(), |
| 2325 compiler_timeline, | 2330 compiler_timeline, |
| 2326 "CompileGraph"); | 2331 "CompileGraph"); |
| 2327 #endif // !PRODUCT | 2332 #endif // !PRODUCT |
| 2328 graph_compiler.CompileGraph(); | 2333 graph_compiler.CompileGraph(); |
| 2329 pipeline->FinalizeCompilation(); | 2334 pipeline->FinalizeCompilation(); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2497 CompilationPipeline::New(thread->zone(), function); | 2502 CompilationPipeline::New(thread->zone(), function); |
| 2498 | 2503 |
| 2499 ASSERT(FLAG_precompiled_mode); | 2504 ASSERT(FLAG_precompiled_mode); |
| 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 |