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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 252893002: Fix registration of closure functions (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 | « no previous file | runtime/vm/object.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
===================================================================
--- runtime/vm/flow_graph_builder.cc (revision 35485)
+++ runtime/vm/flow_graph_builder.cc (working copy)
@@ -2192,22 +2192,24 @@
const Class& cls = Class::Handle(
owner()->parsed_function()->function().Owner());
// The closure is now properly setup, add it to the lookup table.
-#if DEBUG
+ // 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 represntation of the closure: one with a non-closurized
+ // parent, and one with a closurized parent function.
+
const Function& found_func = Function::Handle(
cls.LookupClosureFunction(function.token_pos()));
- ASSERT(found_func.IsNull() ||
- (found_func.token_pos() != function.token_pos()) ||
- // TODO(hausner): The following check should not be necessary.
- // Since we only lookup based on the token_pos we can get
- // duplicate entries due to closurized and non-closurized parent
- // functions (see Parser::ParseFunctionStatement).
- // We need two ways to lookup in this cache: One way to cache the
- // appropriate closure function and one way to find the functions
- // while debugging (we might need to set breakpoints in multiple
- // different function for a single token index.)
- (found_func.parent_function() != function.parent_function()));
-#endif // DEBUG
- cls.AddClosureFunction(function);
+
+ 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);
+ }
}
ZoneGrowableArray<PushArgumentInstr*>* arguments =
new ZoneGrowableArray<PushArgumentInstr*>(1);
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698