| OLD | NEW | 
|     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  Loading... | 
|    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."); | 
|    41  |    43  | 
|    42 DECLARE_FLAG(int, optimization_counter_threshold); |    44 DECLARE_FLAG(int, optimization_counter_threshold); | 
|    43 DECLARE_FLAG(bool, warn_on_javascript_compatibility); |    45 DECLARE_FLAG(bool, warn_on_javascript_compatibility); | 
|    44 DECLARE_FLAG(bool, use_field_guards); |    46 DECLARE_FLAG(bool, use_field_guards); | 
|    45  |    47  | 
|    46 // Quick access to the locally defined zone() method. |    48 // Quick access to the locally defined zone() method. | 
|    47 #define Z (zone()) |    49 #define Z (zone()) | 
|    48  |    50  | 
|    49 // TODO(srdjan): Allow compiler to add constants as they are encountered in |    51 // TODO(srdjan): Allow compiler to add constants as they are encountered in | 
|    50 // the compilation. |    52 // the compilation. | 
| (...skipping 2606 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2657     return; |  2659     return; | 
|  2658   } |  2660   } | 
|  2659   arguments->Visit(&for_argument); |  2661   arguments->Visit(&for_argument); | 
|  2660   Append(for_argument); |  2662   Append(for_argument); | 
|  2661   StringInterpolateInstr* instr = |  2663   StringInterpolateInstr* instr = | 
|  2662       new(Z) StringInterpolateInstr(for_argument.value(), node->token_pos()); |  2664       new(Z) StringInterpolateInstr(for_argument.value(), node->token_pos()); | 
|  2663   ReturnDefinition(instr); |  2665   ReturnDefinition(instr); | 
|  2664 } |  2666 } | 
|  2665  |  2667  | 
|  2666  |  2668  | 
 |  2669 // TODO(rmacnak): De-dup closures in inlined-finally and track down other | 
 |  2670 // stragglers to use Class::closures instead. | 
 |  2671 static void CollectClosureFunction(const Function& function) { | 
 |  2672   if (function.HasCode()) return; | 
 |  2673  | 
 |  2674   Isolate* isolate = Isolate::Current(); | 
 |  2675   if (isolate->collected_closures() == GrowableObjectArray::null()) { | 
 |  2676     isolate->set_collected_closures( | 
 |  2677         GrowableObjectArray::Handle(GrowableObjectArray::New())); | 
 |  2678   } | 
 |  2679   const GrowableObjectArray& functions = | 
 |  2680       GrowableObjectArray::Handle(isolate, isolate->collected_closures()); | 
 |  2681   functions.Add(function); | 
 |  2682 } | 
 |  2683  | 
 |  2684  | 
|  2667 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { |  2685 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { | 
|  2668   const Function& function = node->function(); |  2686   const Function& function = node->function(); | 
 |  2687   if (FLAG_precompile_collect_closures) { | 
 |  2688     CollectClosureFunction(function); | 
 |  2689   } | 
|  2669  |  2690  | 
|  2670   if (function.IsImplicitStaticClosureFunction()) { |  2691   if (function.IsImplicitStaticClosureFunction()) { | 
|  2671     const Instance& closure = |  2692     const Instance& closure = | 
|  2672         Instance::ZoneHandle(Z, function.ImplicitStaticClosure()); |  2693         Instance::ZoneHandle(Z, function.ImplicitStaticClosure()); | 
|  2673     ReturnDefinition(new(Z) ConstantInstr(closure)); |  2694     ReturnDefinition(new(Z) ConstantInstr(closure)); | 
|  2674     return; |  2695     return; | 
|  2675   } |  2696   } | 
|  2676   const bool is_implicit = function.IsImplicitInstanceClosureFunction(); |  2697   const bool is_implicit = function.IsImplicitInstanceClosureFunction(); | 
|  2677   ASSERT(is_implicit || function.IsNonImplicitClosureFunction()); |  2698   ASSERT(is_implicit || function.IsNonImplicitClosureFunction()); | 
|  2678   // The context scope may have already been set by the non-optimizing |  2699   // The context scope may have already been set by the non-optimizing | 
| (...skipping 2128 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  4807   Report::MessageF(Report::kBailout, |  4828   Report::MessageF(Report::kBailout, | 
|  4808                    Script::Handle(function.script()), |  4829                    Script::Handle(function.script()), | 
|  4809                    function.token_pos(), |  4830                    function.token_pos(), | 
|  4810                    "FlowGraphBuilder Bailout: %s %s", |  4831                    "FlowGraphBuilder Bailout: %s %s", | 
|  4811                    String::Handle(function.name()).ToCString(), |  4832                    String::Handle(function.name()).ToCString(), | 
|  4812                    reason); |  4833                    reason); | 
|  4813   UNREACHABLE(); |  4834   UNREACHABLE(); | 
|  4814 } |  4835 } | 
|  4815  |  4836  | 
|  4816 }  // namespace dart |  4837 }  // namespace dart | 
| OLD | NEW |