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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 1436243005: Collect closure functions in isolate (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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/debugger.cc ('k') | runtime/vm/isolate.h » ('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 1c4325c33256440bde8d933a9eaba3983882b1a2..309ad042e9efd3b368a2eb3155f2a7ba5269ae33 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -2483,25 +2483,18 @@ void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) {
ASSERT(!function.HasCode());
ASSERT(function.context_scope() == ContextScope::null());
function.set_context_scope(context_scope);
- const Class& cls = Class::Handle(Z, owner()->function().Owner());
+
// The closure is now properly setup, add it to the lookup table.
// It is possible that the compiler creates more than one function
// object for the same closure, e.g. when inlining nodes from
// finally clauses. If we already have a function object for the
- // same closure, do not add a second one. We compare the origin
- // class, token position, and parent function to detect duplicates.
- // Note that we can have two different closure object for the same
- // source text representation of the closure: one with a non-closurized
- // parent, and one with a closurized parent function.
-
- const Function& found_func = Function::Handle(
- Z, cls.LookupClosureFunction(function.token_pos()));
-
- if (found_func.IsNull() ||
- (found_func.token_pos() != function.token_pos()) ||
- (found_func.script() != function.script()) ||
- (found_func.parent_function() != function.parent_function())) {
- cls.AddClosureFunction(function);
+ // same closure, do not add a second one. We compare token position,
+ // and parent function to detect duplicates.
+ const Function& parent = Function::Handle(function.parent_function());
+ const Function& found_func = Function::Handle(Z,
+ isolate()->LookupClosureFunction(parent, function.token_pos()));
+ if (found_func.IsNull()) {
+ isolate()->AddClosureFunction(function);
}
}
ZoneGrowableArray<PushArgumentInstr*>* arguments =
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698