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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 1261673004: Non-tree-shaking --precompile. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/flow_graph_compiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_builder.cc
diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc
index 9457956bf2f65d371e659271540ca62f499993b4..8a66665bd16a0152178e73ddad8e15efb8c560d4 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -38,6 +38,8 @@ DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables.");
DEFINE_FLAG(bool, support_debugger, true, "Emit code needed for debugging");
DEFINE_FLAG(bool, trace_type_check_elimination, false,
"Trace type check elimination at compile time.");
+DEFINE_FLAG(bool, precompile_collect_closures, false,
+ "Collect all closure functions referenced from compiled code.");
DECLARE_FLAG(int, optimization_counter_threshold);
DECLARE_FLAG(bool, warn_on_javascript_compatibility);
@@ -2664,8 +2666,27 @@ void EffectGraphVisitor::VisitStringInterpolateNode(
}
+// TODO(rmacnak): De-dup closures in inlined-finally and track down other
+// stragglers to use Class::closures instead.
+static void CollectClosureFunction(const Function& function) {
+ if (function.HasCode()) return;
+
+ Isolate* isolate = Isolate::Current();
+ if (isolate->collected_closures() == GrowableObjectArray::null()) {
+ isolate->set_collected_closures(
+ GrowableObjectArray::Handle(GrowableObjectArray::New()));
+ }
+ const GrowableObjectArray& functions =
+ GrowableObjectArray::Handle(isolate, isolate->collected_closures());
+ functions.Add(function);
+}
+
+
void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) {
const Function& function = node->function();
+ if (FLAG_precompile_collect_closures) {
+ CollectClosureFunction(function);
+ }
if (function.IsImplicitStaticClosureFunction()) {
const Instance& closure =
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/flow_graph_compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698