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

Side by Side Diff: runtime/vm/flow_graph_builder.cc

Issue 1409523003: Trace through const objects instead of spying on flow graph construction to find closure functions.… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler.cc » ('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/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 20 matching lines...) Expand all
31 31
32 namespace dart { 32 namespace dart {
33 33
34 DEFINE_FLAG(bool, eliminate_type_checks, true, 34 DEFINE_FLAG(bool, eliminate_type_checks, true,
35 "Eliminate type checks when allowed by static type analysis."); 35 "Eliminate type checks when allowed by static type analysis.");
36 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); 36 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree.");
37 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); 37 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables.");
38 DEFINE_FLAG(bool, support_debugger, true, "Emit code needed for debugging"); 38 DEFINE_FLAG(bool, support_debugger, true, "Emit code needed for debugging");
39 DEFINE_FLAG(bool, trace_type_check_elimination, false, 39 DEFINE_FLAG(bool, trace_type_check_elimination, false,
40 "Trace type check elimination at compile time."); 40 "Trace type check elimination at compile time.");
41 DEFINE_FLAG(bool, precompile_collect_closures, false,
42 "Collect all closure functions referenced from compiled code.");
43 41
44 DECLARE_FLAG(int, optimization_counter_threshold); 42 DECLARE_FLAG(int, optimization_counter_threshold);
45 DECLARE_FLAG(bool, profile_vm); 43 DECLARE_FLAG(bool, profile_vm);
46 DECLARE_FLAG(bool, warn_on_javascript_compatibility); 44 DECLARE_FLAG(bool, warn_on_javascript_compatibility);
47 DECLARE_FLAG(bool, use_field_guards); 45 DECLARE_FLAG(bool, use_field_guards);
48 46
49 // Quick access to the locally defined zone() method. 47 // Quick access to the locally defined zone() method.
50 #define Z (zone()) 48 #define Z (zone())
51 49
52 // TODO(srdjan): Allow compiler to add constants as they are encountered in 50 // TODO(srdjan): Allow compiler to add constants as they are encountered in
(...skipping 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after
2518 return; 2516 return;
2519 } 2517 }
2520 arguments->Visit(&for_argument); 2518 arguments->Visit(&for_argument);
2521 Append(for_argument); 2519 Append(for_argument);
2522 StringInterpolateInstr* instr = 2520 StringInterpolateInstr* instr =
2523 new(Z) StringInterpolateInstr(for_argument.value(), node->token_pos()); 2521 new(Z) StringInterpolateInstr(for_argument.value(), node->token_pos());
2524 ReturnDefinition(instr); 2522 ReturnDefinition(instr);
2525 } 2523 }
2526 2524
2527 2525
2528 // TODO(rmacnak): De-dup closures in inlined-finally and track down other
2529 // stragglers to use Class::closures instead.
2530 static void CollectClosureFunction(const Function& function) {
2531 if (function.HasCode()) return;
2532
2533 // Although this is only called when precompiling, this can happen before
2534 // Dart_Precompile as part of loading code, so check for a non-null work
2535 // list.
2536 Thread* thread = Thread::Current();
2537 Isolate* isolate = thread->isolate();
2538 if (isolate->collected_closures() != GrowableObjectArray::null()) {
2539 const GrowableObjectArray& functions =
2540 GrowableObjectArray::Handle(thread->zone(),
2541 isolate->collected_closures());
2542 functions.Add(function);
2543 }
2544 }
2545
2546
2547 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { 2526 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) {
2548 const Function& function = node->function(); 2527 const Function& function = node->function();
2549 if (FLAG_precompile_collect_closures) {
2550 CollectClosureFunction(function);
2551 }
2552
2553 if (function.IsImplicitStaticClosureFunction()) { 2528 if (function.IsImplicitStaticClosureFunction()) {
2554 const Instance& closure = 2529 const Instance& closure =
2555 Instance::ZoneHandle(Z, function.ImplicitStaticClosure()); 2530 Instance::ZoneHandle(Z, function.ImplicitStaticClosure());
2556 ReturnDefinition(new(Z) ConstantInstr(closure)); 2531 ReturnDefinition(new(Z) ConstantInstr(closure));
2557 return; 2532 return;
2558 } 2533 }
2534
2559 const bool is_implicit = function.IsImplicitInstanceClosureFunction(); 2535 const bool is_implicit = function.IsImplicitInstanceClosureFunction();
2560 ASSERT(is_implicit || function.IsNonImplicitClosureFunction()); 2536 ASSERT(is_implicit || function.IsNonImplicitClosureFunction());
2561 // The context scope may have already been set by the non-optimizing 2537 // The context scope may have already been set by the non-optimizing
2562 // compiler. If it was not, set it here. 2538 // compiler. If it was not, set it here.
2563 if (function.context_scope() == ContextScope::null()) { 2539 if (function.context_scope() == ContextScope::null()) {
2564 ASSERT(!is_implicit); 2540 ASSERT(!is_implicit);
2565 const ContextScope& context_scope = ContextScope::ZoneHandle( 2541 const ContextScope& context_scope = ContextScope::ZoneHandle(
2566 Z, node->scope()->PreserveOuterScope(owner()->context_level())); 2542 Z, node->scope()->PreserveOuterScope(owner()->context_level()));
2567 ASSERT(!function.HasCode()); 2543 ASSERT(!function.HasCode());
2568 ASSERT(function.context_scope() == ContextScope::null()); 2544 ASSERT(function.context_scope() == ContextScope::null());
(...skipping 2128 matching lines...) Expand 10 before | Expand all | Expand 10 after
4697 Report::MessageF(Report::kBailout, 4673 Report::MessageF(Report::kBailout,
4698 Script::Handle(function.script()), 4674 Script::Handle(function.script()),
4699 function.token_pos(), 4675 function.token_pos(),
4700 "FlowGraphBuilder Bailout: %s %s", 4676 "FlowGraphBuilder Bailout: %s %s",
4701 String::Handle(function.name()).ToCString(), 4677 String::Handle(function.name()).ToCString(),
4702 reason); 4678 reason);
4703 UNREACHABLE(); 4679 UNREACHABLE();
4704 } 4680 }
4705 4681
4706 } // namespace dart 4682 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698