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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_builder.h" 5 #include "vm/flow_graph_builder.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/ast_printer.h" 8 #include "vm/ast_printer.h"
9 #include "vm/bit_vector.h" 9 #include "vm/bit_vector.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 ASSERT(is_implicit || function.IsNonImplicitClosureFunction()); 2476 ASSERT(is_implicit || function.IsNonImplicitClosureFunction());
2477 // The context scope may have already been set by the non-optimizing 2477 // The context scope may have already been set by the non-optimizing
2478 // compiler. If it was not, set it here. 2478 // compiler. If it was not, set it here.
2479 if (function.context_scope() == ContextScope::null()) { 2479 if (function.context_scope() == ContextScope::null()) {
2480 ASSERT(!is_implicit); 2480 ASSERT(!is_implicit);
2481 const ContextScope& context_scope = ContextScope::ZoneHandle( 2481 const ContextScope& context_scope = ContextScope::ZoneHandle(
2482 Z, node->scope()->PreserveOuterScope(owner()->context_level())); 2482 Z, node->scope()->PreserveOuterScope(owner()->context_level()));
2483 ASSERT(!function.HasCode()); 2483 ASSERT(!function.HasCode());
2484 ASSERT(function.context_scope() == ContextScope::null()); 2484 ASSERT(function.context_scope() == ContextScope::null());
2485 function.set_context_scope(context_scope); 2485 function.set_context_scope(context_scope);
2486 const Class& cls = Class::Handle(Z, owner()->function().Owner()); 2486
2487 // The closure is now properly setup, add it to the lookup table. 2487 // The closure is now properly setup, add it to the lookup table.
2488 // It is possible that the compiler creates more than one function 2488 // It is possible that the compiler creates more than one function
2489 // object for the same closure, e.g. when inlining nodes from 2489 // object for the same closure, e.g. when inlining nodes from
2490 // finally clauses. If we already have a function object for the 2490 // finally clauses. If we already have a function object for the
2491 // same closure, do not add a second one. We compare the origin 2491 // same closure, do not add a second one. We compare the script,
2492 // class, token position, and parent function to detect duplicates. 2492 // token position, and parent function to detect duplicates.
2493 // Note that we can have two different closure object for the same 2493 // Note that we can have two different closure object for the same
2494 // source text representation of the closure: one with a non-closurized 2494 // source text representation of the closure: one with a non-closurized
2495 // parent, and one with a closurized parent function. 2495 // parent, and one with a closurized parent function.
2496 2496
2497 const Function& found_func = Function::Handle( 2497 const Script& origin = Script::Handle(Z, function.script());
2498 Z, cls.LookupClosureFunction(function.token_pos())); 2498 const Function& found_func = Function::Handle(Z,
2499 2499 isolate()->LookupClosureFunction(origin, function.token_pos()));
2500 if (found_func.IsNull() || 2500 if (found_func.IsNull() ||
2501 (found_func.token_pos() != function.token_pos()) || 2501 (found_func.token_pos() != function.token_pos()) ||
2502 (found_func.script() != function.script()) || 2502 (found_func.script() != function.script()) ||
2503 (found_func.parent_function() != function.parent_function())) { 2503 (found_func.parent_function() != function.parent_function())) {
Ivan Posva 2015/11/13 17:47:51 Why would any of these tests for pos or script fai
hausner 2015/11/13 20:13:29 It seems that LookupClosureFunction was implemente
2504 cls.AddClosureFunction(function); 2504 isolate()->AddClosureFunction(function);
2505 } 2505 }
2506 } 2506 }
2507 ZoneGrowableArray<PushArgumentInstr*>* arguments = 2507 ZoneGrowableArray<PushArgumentInstr*>* arguments =
2508 new(Z) ZoneGrowableArray<PushArgumentInstr*>(1); 2508 new(Z) ZoneGrowableArray<PushArgumentInstr*>(1);
2509 ASSERT(function.context_scope() != ContextScope::null()); 2509 ASSERT(function.context_scope() != ContextScope::null());
2510 2510
2511 // The function type of a closure may have type arguments. In that case, 2511 // The function type of a closure may have type arguments. In that case,
2512 // pass the type arguments of the instantiator. 2512 // pass the type arguments of the instantiator.
2513 const Class& cls = Class::ZoneHandle(Z, function.signature_class()); 2513 const Class& cls = Class::ZoneHandle(Z, function.signature_class());
2514 ASSERT(!cls.IsNull()); 2514 ASSERT(!cls.IsNull());
(...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after
4613 Report::MessageF(Report::kBailout, 4613 Report::MessageF(Report::kBailout,
4614 Script::Handle(function.script()), 4614 Script::Handle(function.script()),
4615 function.token_pos(), 4615 function.token_pos(),
4616 "FlowGraphBuilder Bailout: %s %s", 4616 "FlowGraphBuilder Bailout: %s %s",
4617 String::Handle(function.name()).ToCString(), 4617 String::Handle(function.name()).ToCString(),
4618 reason); 4618 reason);
4619 UNREACHABLE(); 4619 UNREACHABLE();
4620 } 4620 }
4621 4621
4622 } // namespace dart 4622 } // namespace dart
OLDNEW
« runtime/vm/debugger.cc ('K') | « runtime/vm/debugger.cc ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698