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

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
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/isolate.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) 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 token position,
2492 // class, token position, and parent function to detect duplicates. 2492 // and parent function to detect duplicates.
2493 // Note that we can have two different closure object for the same 2493 const Function& parent = Function::Handle(function.parent_function());
2494 // source text representation of the closure: one with a non-closurized 2494 const Function& found_func = Function::Handle(Z,
2495 // parent, and one with a closurized parent function. 2495 isolate()->LookupClosureFunction(parent, function.token_pos()));
2496 2496 if (found_func.IsNull()) {
2497 const Function& found_func = Function::Handle( 2497 isolate()->AddClosureFunction(function);
2498 Z, cls.LookupClosureFunction(function.token_pos()));
2499
2500 if (found_func.IsNull() ||
2501 (found_func.token_pos() != function.token_pos()) ||
2502 (found_func.script() != function.script()) ||
2503 (found_func.parent_function() != function.parent_function())) {
2504 cls.AddClosureFunction(function);
2505 } 2498 }
2506 } 2499 }
2507 ZoneGrowableArray<PushArgumentInstr*>* arguments = 2500 ZoneGrowableArray<PushArgumentInstr*>* arguments =
2508 new(Z) ZoneGrowableArray<PushArgumentInstr*>(1); 2501 new(Z) ZoneGrowableArray<PushArgumentInstr*>(1);
2509 ASSERT(function.context_scope() != ContextScope::null()); 2502 ASSERT(function.context_scope() != ContextScope::null());
2510 2503
2511 // The function type of a closure may have type arguments. In that case, 2504 // The function type of a closure may have type arguments. In that case,
2512 // pass the type arguments of the instantiator. 2505 // pass the type arguments of the instantiator.
2513 const Class& cls = Class::ZoneHandle(Z, function.signature_class()); 2506 const Class& cls = Class::ZoneHandle(Z, function.signature_class());
2514 ASSERT(!cls.IsNull()); 2507 ASSERT(!cls.IsNull());
(...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after
4613 Report::MessageF(Report::kBailout, 4606 Report::MessageF(Report::kBailout,
4614 Script::Handle(function.script()), 4607 Script::Handle(function.script()),
4615 function.token_pos(), 4608 function.token_pos(),
4616 "FlowGraphBuilder Bailout: %s %s", 4609 "FlowGraphBuilder Bailout: %s %s",
4617 String::Handle(function.name()).ToCString(), 4610 String::Handle(function.name()).ToCString(),
4618 reason); 4611 reason);
4619 UNREACHABLE(); 4612 UNREACHABLE();
4620 } 4613 }
4621 4614
4622 } // namespace dart 4615 } // namespace dart
OLDNEW
« 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