Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: runtime/vm/flow_graph_inliner.cc

Issue 2411823003: VM support for running Kernel binaries. (Closed)
Patch Set: Address comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/flow_graph_compiler.cc ('k') | runtime/vm/hash_map.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/aot_optimizer.h" 7 #include "vm/aot_optimizer.h"
8 #include "vm/block_scheduler.h" 8 #include "vm/block_scheduler.h"
9 #include "vm/branch_optimizer.h" 9 #include "vm/branch_optimizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
11 #include "vm/kernel.h"
12 #include "vm/kernel_to_il.h"
11 #include "vm/flags.h" 13 #include "vm/flags.h"
12 #include "vm/flow_graph.h" 14 #include "vm/flow_graph.h"
13 #include "vm/flow_graph_builder.h" 15 #include "vm/flow_graph_builder.h"
14 #include "vm/flow_graph_compiler.h" 16 #include "vm/flow_graph_compiler.h"
15 #include "vm/flow_graph_type_propagator.h" 17 #include "vm/flow_graph_type_propagator.h"
16 #include "vm/il_printer.h" 18 #include "vm/il_printer.h"
17 #include "vm/jit_optimizer.h" 19 #include "vm/jit_optimizer.h"
18 #include "vm/longjump.h" 20 #include "vm/longjump.h"
19 #include "vm/object.h" 21 #include "vm/object.h"
20 #include "vm/object_store.h" 22 #include "vm/object_store.h"
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 thread()->set_deopt_id(0); 715 thread()->set_deopt_id(0);
714 Error& error = Error::Handle(); 716 Error& error = Error::Handle();
715 { 717 {
716 // Install bailout jump. 718 // Install bailout jump.
717 LongJumpScope jump; 719 LongJumpScope jump;
718 if (setjmp(*jump.Set()) == 0) { 720 if (setjmp(*jump.Set()) == 0) {
719 Isolate* isolate = Isolate::Current(); 721 Isolate* isolate = Isolate::Current();
720 // Makes sure no classes are loaded during parsing in background. 722 // Makes sure no classes are loaded during parsing in background.
721 const intptr_t loading_invalidation_gen_at_start = 723 const intptr_t loading_invalidation_gen_at_start =
722 isolate->loading_invalidation_gen(); 724 isolate->loading_invalidation_gen();
723 // Parse the callee function.
724 bool in_cache;
725 ParsedFunction* parsed_function;
726 {
727 CSTAT_TIMER_SCOPE(thread(), graphinliner_parse_timer);
728 parsed_function = GetParsedFunction(function, &in_cache);
729 }
730 725
731 if (Compiler::IsBackgroundCompilation()) { 726 if (Compiler::IsBackgroundCompilation()) {
732 if (isolate->IsTopLevelParsing() || 727 if (isolate->IsTopLevelParsing() ||
733 (loading_invalidation_gen_at_start != 728 (loading_invalidation_gen_at_start !=
734 isolate->loading_invalidation_gen())) { 729 isolate->loading_invalidation_gen())) {
735 // Loading occured while parsing. We need to abort here because 730 // Loading occured while parsing. We need to abort here because
736 // state changed while compiling. 731 // state changed while compiling.
737 Compiler::AbortBackgroundCompilation(Thread::kNoDeoptId, 732 Compiler::AbortBackgroundCompilation(Thread::kNoDeoptId,
738 "Loading occured while parsing in inliner"); 733 "Loading occured while parsing in inliner");
739 } 734 }
740 } 735 }
741 736
742 // Load IC data for the callee. 737 // Load IC data for the callee.
743 ZoneGrowableArray<const ICData*>* ic_data_array = 738 ZoneGrowableArray<const ICData*>* ic_data_array =
744 new(Z) ZoneGrowableArray<const ICData*>(); 739 new(Z) ZoneGrowableArray<const ICData*>();
745 const bool clone_ic_data = Compiler::IsBackgroundCompilation(); 740 const bool clone_ic_data = Compiler::IsBackgroundCompilation();
746 function.RestoreICDataMap(ic_data_array, clone_ic_data); 741 function.RestoreICDataMap(ic_data_array, clone_ic_data);
747 if (Compiler::IsBackgroundCompilation() && 742 if (Compiler::IsBackgroundCompilation() &&
748 (function.ic_data_array() == Array::null())) { 743 (function.ic_data_array() == Array::null())) {
749 Compiler::AbortBackgroundCompilation(Thread::kNoDeoptId, 744 Compiler::AbortBackgroundCompilation(Thread::kNoDeoptId,
750 "ICData cleared while inlining"); 745 "ICData cleared while inlining");
751 } 746 }
752 747
748 // Parse the callee function.
749 bool in_cache;
750 ParsedFunction* parsed_function;
751 {
752 CSTAT_TIMER_SCOPE(thread(), graphinliner_parse_timer);
753 parsed_function = GetParsedFunction(function, &in_cache);
754 }
755
753 // Build the callee graph. 756 // Build the callee graph.
754 InlineExitCollector* exit_collector = 757 InlineExitCollector* exit_collector =
755 new(Z) InlineExitCollector(caller_graph_, call); 758 new(Z) InlineExitCollector(caller_graph_, call);
756 FlowGraphBuilder builder(*parsed_function,
757 *ic_data_array,
758 exit_collector,
759 Compiler::kNoOSRDeoptId);
760 builder.SetInitialBlockId(caller_graph_->max_block_id());
761 FlowGraph* callee_graph; 759 FlowGraph* callee_graph;
762 { 760 if (UseKernelFrontEndFor(parsed_function)) {
763 CSTAT_TIMER_SCOPE(thread(), graphinliner_build_timer); 761 kernel::TreeNode* node = static_cast<kernel::TreeNode*>(
764 callee_graph = builder.BuildGraph(); 762 parsed_function->function().kernel_function());
763
764 kernel::FlowGraphBuilder builder(node,
765 parsed_function,
766 *ic_data_array,
767 exit_collector,
768 Compiler::kNoOSRDeoptId,
769 caller_graph_->max_block_id() + 1);
770 {
771 CSTAT_TIMER_SCOPE(thread(), graphinliner_build_timer);
772 callee_graph = builder.BuildGraph();
773 }
774 } else {
775 FlowGraphBuilder builder(*parsed_function,
776 *ic_data_array,
777 exit_collector,
778 Compiler::kNoOSRDeoptId);
779 builder.SetInitialBlockId(caller_graph_->max_block_id());
780 {
781 CSTAT_TIMER_SCOPE(thread(), graphinliner_build_timer);
782 callee_graph = builder.BuildGraph();
783 }
765 } 784 }
766 785
767 // The parameter stubs are a copy of the actual arguments providing 786 // The parameter stubs are a copy of the actual arguments providing
768 // concrete information about the values, for example constant values, 787 // concrete information about the values, for example constant values,
769 // without linking between the caller and callee graphs. 788 // without linking between the caller and callee graphs.
770 // TODO(zerny): Put more information in the stubs, eg, type information. 789 // TODO(zerny): Put more information in the stubs, eg, type information.
771 ZoneGrowableArray<Definition*>* param_stubs = 790 ZoneGrowableArray<Definition*>* param_stubs =
772 new(Z) ZoneGrowableArray<Definition*>( 791 new(Z) ZoneGrowableArray<Definition*>(
773 function.NumParameters()); 792 function.NumParameters());
774 793
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 for (intptr_t i = 0; i < function_cache_.length(); ++i) { 1150 for (intptr_t i = 0; i < function_cache_.length(); ++i) {
1132 ParsedFunction* parsed_function = function_cache_[i]; 1151 ParsedFunction* parsed_function = function_cache_[i];
1133 if (parsed_function->function().raw() == function.raw()) { 1152 if (parsed_function->function().raw() == function.raw()) {
1134 *in_cache = true; 1153 *in_cache = true;
1135 return parsed_function; 1154 return parsed_function;
1136 } 1155 }
1137 } 1156 }
1138 *in_cache = false; 1157 *in_cache = false;
1139 ParsedFunction* parsed_function = 1158 ParsedFunction* parsed_function =
1140 new(Z) ParsedFunction(thread(), function); 1159 new(Z) ParsedFunction(thread(), function);
1141 Parser::ParseFunction(parsed_function); 1160 if (!UseKernelFrontEndFor(parsed_function)) {
1142 parsed_function->AllocateVariables(); 1161 Parser::ParseFunction(parsed_function);
1162 parsed_function->AllocateVariables();
1163 }
1143 return parsed_function; 1164 return parsed_function;
1144 } 1165 }
1145 1166
1146 void InlineStaticCalls() { 1167 void InlineStaticCalls() {
1147 const GrowableArray<CallSites::StaticCallInfo>& call_info = 1168 const GrowableArray<CallSites::StaticCallInfo>& call_info =
1148 inlining_call_sites_->static_calls(); 1169 inlining_call_sites_->static_calls();
1149 TRACE_INLINING(THR_Print(" Static Calls (%" Pd ")\n", call_info.length())); 1170 TRACE_INLINING(THR_Print(" Static Calls (%" Pd ")\n", call_info.length()));
1150 for (intptr_t call_idx = 0; call_idx < call_info.length(); ++call_idx) { 1171 for (intptr_t call_idx = 0; call_idx < call_info.length(); ++call_idx) {
1151 StaticCallInstr* call = call_info[call_idx].call; 1172 StaticCallInstr* call = call_info[call_idx].call;
1152 const Function& target = call->function(); 1173 const Function& target = call->function();
(...skipping 2631 matching lines...) Expand 10 before | Expand all | Expand 10 after
3784 return true; 3805 return true;
3785 } 3806 }
3786 3807
3787 default: 3808 default:
3788 return false; 3809 return false;
3789 } 3810 }
3790 } 3811 }
3791 3812
3792 3813
3793 } // namespace dart 3814 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler.cc ('k') | runtime/vm/hash_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698