| 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, trace_type_check_elimination, false, | 38 DEFINE_FLAG(bool, trace_type_check_elimination, false, |
| 39 "Trace type check elimination at compile time."); | 39 "Trace type check elimination at compile time."); |
| 40 | 40 |
| 41 DECLARE_FLAG(bool, enable_debugger); | |
| 42 DECLARE_FLAG(bool, enable_type_checks); | 41 DECLARE_FLAG(bool, enable_type_checks); |
| 43 DECLARE_FLAG(int, optimization_counter_threshold); | 42 DECLARE_FLAG(int, optimization_counter_threshold); |
| 44 DECLARE_FLAG(bool, warn_on_javascript_compatibility); | 43 DECLARE_FLAG(bool, warn_on_javascript_compatibility); |
| 45 | 44 |
| 46 // Quick access to the locally defined isolate() method. | 45 // Quick access to the locally defined isolate() method. |
| 47 #define I (isolate()) | 46 #define I (isolate()) |
| 48 | 47 |
| 49 // TODO(srdjan): Allow compiler to add constants as they are encountered in | 48 // TODO(srdjan): Allow compiler to add constants as they are encountered in |
| 50 // the compilation. | 49 // the compilation. |
| 51 const double kCommonDoubleConstants[] = | 50 const double kCommonDoubleConstants[] = |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 } | 1005 } |
| 1007 return_value = Bind(BuildLoadLocal(*temp)); | 1006 return_value = Bind(BuildLoadLocal(*temp)); |
| 1008 } | 1007 } |
| 1009 | 1008 |
| 1010 // Call to stub that checks whether the debugger is in single | 1009 // Call to stub that checks whether the debugger is in single |
| 1011 // step mode. This call must happen before the contexts are | 1010 // step mode. This call must happen before the contexts are |
| 1012 // unchained so that captured variables can be inspected. | 1011 // unchained so that captured variables can be inspected. |
| 1013 // No debugger check is done in native functions or for return | 1012 // No debugger check is done in native functions or for return |
| 1014 // statements for which there is no associated source position. | 1013 // statements for which there is no associated source position. |
| 1015 const Function& function = owner()->parsed_function()->function(); | 1014 const Function& function = owner()->parsed_function()->function(); |
| 1016 if ((node->token_pos() != Scanner::kNoSourcePos) && | 1015 if ((node->token_pos() != Scanner::kNoSourcePos) && !function.is_native()) { |
| 1017 !function.is_native() && FLAG_enable_debugger) { | |
| 1018 AddInstruction(new(I) DebugStepCheckInstr(node->token_pos(), | 1016 AddInstruction(new(I) DebugStepCheckInstr(node->token_pos(), |
| 1019 RawPcDescriptors::kRuntimeCall)); | 1017 RawPcDescriptors::kRuntimeCall)); |
| 1020 } | 1018 } |
| 1021 | 1019 |
| 1022 if (FLAG_enable_type_checks) { | 1020 if (FLAG_enable_type_checks) { |
| 1023 const bool is_implicit_dynamic_getter = | 1021 const bool is_implicit_dynamic_getter = |
| 1024 (!function.is_static() && | 1022 (!function.is_static() && |
| 1025 ((function.kind() == RawFunction::kImplicitGetter) || | 1023 ((function.kind() == RawFunction::kImplicitGetter) || |
| 1026 (function.kind() == RawFunction::kImplicitStaticFinalGetter))); | 1024 (function.kind() == RawFunction::kImplicitStaticFinalGetter))); |
| 1027 // Implicit getters do not need a type check at return, unless they compute | 1025 // Implicit getters do not need a type check at return, unless they compute |
| (...skipping 2083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3111 | 3109 |
| 3112 | 3110 |
| 3113 // <Expression> ::= StoreLocal { local: LocalVariable | 3111 // <Expression> ::= StoreLocal { local: LocalVariable |
| 3114 // value: <Expression> } | 3112 // value: <Expression> } |
| 3115 void EffectGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { | 3113 void EffectGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { |
| 3116 // If the right hand side is an expression that does not contain | 3114 // If the right hand side is an expression that does not contain |
| 3117 // a safe point for the debugger to stop, add an explicit stub | 3115 // a safe point for the debugger to stop, add an explicit stub |
| 3118 // call. | 3116 // call. |
| 3119 if (node->value()->IsLiteralNode() || | 3117 if (node->value()->IsLiteralNode() || |
| 3120 node->value()->IsLoadLocalNode()) { | 3118 node->value()->IsLoadLocalNode()) { |
| 3121 if (FLAG_enable_debugger) { | 3119 AddInstruction(new(I) DebugStepCheckInstr( |
| 3122 AddInstruction(new(I) DebugStepCheckInstr( | 3120 node->token_pos(), RawPcDescriptors::kRuntimeCall)); |
| 3123 node->token_pos(), RawPcDescriptors::kRuntimeCall)); | |
| 3124 } | |
| 3125 } | 3121 } |
| 3126 | 3122 |
| 3127 ValueGraphVisitor for_value(owner()); | 3123 ValueGraphVisitor for_value(owner()); |
| 3128 node->value()->Visit(&for_value); | 3124 node->value()->Visit(&for_value); |
| 3129 Append(for_value); | 3125 Append(for_value); |
| 3130 Value* store_value = for_value.value(); | 3126 Value* store_value = for_value.value(); |
| 3131 if (FLAG_enable_type_checks) { | 3127 if (FLAG_enable_type_checks) { |
| 3132 store_value = BuildAssignableValue(node->value()->token_pos(), | 3128 store_value = BuildAssignableValue(node->value()->token_pos(), |
| 3133 store_value, | 3129 store_value, |
| 3134 node->local().type(), | 3130 node->local().type(), |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3960 Report::MessageF(Report::kBailout, | 3956 Report::MessageF(Report::kBailout, |
| 3961 Script::Handle(function.script()), | 3957 Script::Handle(function.script()), |
| 3962 function.token_pos(), | 3958 function.token_pos(), |
| 3963 "FlowGraphBuilder Bailout: %s %s", | 3959 "FlowGraphBuilder Bailout: %s %s", |
| 3964 String::Handle(function.name()).ToCString(), | 3960 String::Handle(function.name()).ToCString(), |
| 3965 reason); | 3961 reason); |
| 3966 UNREACHABLE(); | 3962 UNREACHABLE(); |
| 3967 } | 3963 } |
| 3968 | 3964 |
| 3969 } // namespace dart | 3965 } // namespace dart |
| OLD | NEW |