| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/flow_graph_inliner.h" | 5 #include "vm/flow_graph_inliner.h" |
| 6 | 6 |
| 7 #include "vm/block_scheduler.h" | 7 #include "vm/block_scheduler.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/flow_graph.h" | 10 #include "vm/flow_graph.h" |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 } | 611 } |
| 612 } | 612 } |
| 613 | 613 |
| 614 bool TryInlining(const Function& function, | 614 bool TryInlining(const Function& function, |
| 615 const Array& argument_names, | 615 const Array& argument_names, |
| 616 InlinedCallData* call_data) { | 616 InlinedCallData* call_data) { |
| 617 TRACE_INLINING(THR_Print(" => %s (deopt count %d)\n", | 617 TRACE_INLINING(THR_Print(" => %s (deopt count %d)\n", |
| 618 function.ToCString(), | 618 function.ToCString(), |
| 619 function.deoptimization_counter())); | 619 function.deoptimization_counter())); |
| 620 | 620 |
| 621 // Make a handle for the unoptimized code so that it is not disconnected | |
| 622 // from the function while we are trying to inline it. | |
| 623 const Code& unoptimized_code = Code::Handle(function.unoptimized_code()); | |
| 624 // Abort if the inlinable bit on the function is low. | 621 // Abort if the inlinable bit on the function is low. |
| 625 if (!function.CanBeInlined()) { | 622 if (!function.CanBeInlined()) { |
| 626 TRACE_INLINING(THR_Print(" Bailout: not inlinable\n")); | 623 TRACE_INLINING(THR_Print(" Bailout: not inlinable\n")); |
| 627 PRINT_INLINING_TREE("Not inlinable", | 624 PRINT_INLINING_TREE("Not inlinable", |
| 628 &call_data->caller, &function, call_data->call); | 625 &call_data->caller, &function, call_data->call); |
| 629 return false; | 626 return false; |
| 630 } | 627 } |
| 631 | 628 |
| 632 // Abort if this function has deoptimized too much. | 629 // Abort if this function has deoptimized too much. |
| 633 if (function.deoptimization_counter() >= | 630 if (function.deoptimization_counter() >= |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 FlowGraph::AddToGuardedFields(caller_graph_->guarded_fields(), | 852 FlowGraph::AddToGuardedFields(caller_graph_->guarded_fields(), |
| 856 (*callee_graph->guarded_fields())[i]); | 853 (*callee_graph->guarded_fields())[i]); |
| 857 } | 854 } |
| 858 // When inlined, we add the deferred prefixes of the callee to the | 855 // When inlined, we add the deferred prefixes of the callee to the |
| 859 // caller's list of deferred prefixes. | 856 // caller's list of deferred prefixes. |
| 860 caller_graph()->AddToDeferredPrefixes(callee_graph->deferred_prefixes()); | 857 caller_graph()->AddToDeferredPrefixes(callee_graph->deferred_prefixes()); |
| 861 | 858 |
| 862 FlowGraphInliner::SetInliningId(callee_graph, | 859 FlowGraphInliner::SetInliningId(callee_graph, |
| 863 inliner_->NextInlineId(callee_graph->function(), | 860 inliner_->NextInlineId(callee_graph->function(), |
| 864 call_data->caller_inlining_id_)); | 861 call_data->caller_inlining_id_)); |
| 865 // We allocate a ZoneHandle for the unoptimized code so that it cannot be | |
| 866 // disconnected from its function during the rest of compilation. | |
| 867 Code::ZoneHandle(unoptimized_code.raw()); | |
| 868 TRACE_INLINING(THR_Print(" Success\n")); | 862 TRACE_INLINING(THR_Print(" Success\n")); |
| 869 PRINT_INLINING_TREE(NULL, | 863 PRINT_INLINING_TREE(NULL, |
| 870 &call_data->caller, &function, call); | 864 &call_data->caller, &function, call); |
| 871 return true; | 865 return true; |
| 872 } else { | 866 } else { |
| 873 Error& error = Error::Handle(); | 867 Error& error = Error::Handle(); |
| 874 error = isolate()->object_store()->sticky_error(); | 868 error = isolate()->object_store()->sticky_error(); |
| 875 isolate()->object_store()->clear_sticky_error(); | 869 isolate()->object_store()->clear_sticky_error(); |
| 876 thread()->set_deopt_id(prev_deopt_id); | 870 thread()->set_deopt_id(prev_deopt_id); |
| 877 TRACE_INLINING(THR_Print(" Bailout: %s\n", error.ToErrorCString())); | 871 TRACE_INLINING(THR_Print(" Bailout: %s\n", error.ToErrorCString())); |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1884 intptr_t FlowGraphInliner::NextInlineId(const Function& function, | 1878 intptr_t FlowGraphInliner::NextInlineId(const Function& function, |
| 1885 intptr_t parent_id) { | 1879 intptr_t parent_id) { |
| 1886 const intptr_t id = inline_id_to_function_->length(); | 1880 const intptr_t id = inline_id_to_function_->length(); |
| 1887 inline_id_to_function_->Add(&function); | 1881 inline_id_to_function_->Add(&function); |
| 1888 caller_inline_id_->Add(parent_id); | 1882 caller_inline_id_->Add(parent_id); |
| 1889 return id; | 1883 return id; |
| 1890 } | 1884 } |
| 1891 | 1885 |
| 1892 | 1886 |
| 1893 } // namespace dart | 1887 } // namespace dart |
| OLD | NEW |