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 21 matching lines...) Expand all Loading... |
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 DEFINE_FLAG(bool, warn_on_javascript_compatibility, false, | 40 DEFINE_FLAG(bool, warn_on_javascript_compatibility, false, |
41 "Warn on incompatibilities between vm and dart2js."); | 41 "Warn on incompatibilities between vm and dart2js."); |
| 42 |
| 43 DECLARE_FLAG(bool, enable_debugger); |
42 DECLARE_FLAG(bool, enable_type_checks); | 44 DECLARE_FLAG(bool, enable_type_checks); |
| 45 DECLARE_FLAG(int, optimization_counter_threshold); |
| 46 DECLARE_FLAG(bool, silent_warnings); |
43 DECLARE_FLAG(bool, warning_as_error); | 47 DECLARE_FLAG(bool, warning_as_error); |
44 DECLARE_FLAG(bool, silent_warnings); | |
45 | 48 |
46 | 49 |
47 // 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 |
48 // the compilation. | 51 // the compilation. |
49 const double kCommonDoubleConstants[] = | 52 const double kCommonDoubleConstants[] = |
50 {-1.0, -0.5, -0.1, 0.0, 0.1, 0.5, 1.0, 2.0, 4.0, 5.0, | 53 {-1.0, -0.5, -0.1, 0.0, 0.1, 0.5, 1.0, 2.0, 4.0, 5.0, |
51 10.0, 20.0, 30.0, 64.0, 255.0, NAN, | 54 10.0, 20.0, 30.0, 64.0, 255.0, NAN, |
52 // From dart:math | 55 // From dart:math |
53 2.718281828459045, 2.302585092994046, 0.6931471805599453, | 56 2.718281828459045, 2.302585092994046, 0.6931471805599453, |
54 1.4426950408889634, 0.4342944819032518, 3.1415926535897932, | 57 1.4426950408889634, 0.4342944819032518, 3.1415926535897932, |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 return_value = Bind(BuildLoadLocal(*temp)); | 995 return_value = Bind(BuildLoadLocal(*temp)); |
993 } | 996 } |
994 | 997 |
995 // Call to stub that checks whether the debugger is in single | 998 // Call to stub that checks whether the debugger is in single |
996 // step mode. This call must happen before the contexts are | 999 // step mode. This call must happen before the contexts are |
997 // unchained so that captured variables can be inspected. | 1000 // unchained so that captured variables can be inspected. |
998 // No debugger check is done in native functions or for return | 1001 // No debugger check is done in native functions or for return |
999 // statements for which there is no associated source position. | 1002 // statements for which there is no associated source position. |
1000 const Function& function = owner()->parsed_function()->function(); | 1003 const Function& function = owner()->parsed_function()->function(); |
1001 if ((node->token_pos() != Scanner::kNoSourcePos) && | 1004 if ((node->token_pos() != Scanner::kNoSourcePos) && |
1002 !function.is_native()) { | 1005 !function.is_native() && FLAG_enable_debugger) { |
1003 AddInstruction(new DebugStepCheckInstr(node->token_pos(), | 1006 AddInstruction(new DebugStepCheckInstr(node->token_pos(), |
1004 PcDescriptors::kReturn)); | 1007 PcDescriptors::kReturn)); |
1005 } | 1008 } |
1006 | 1009 |
1007 if (FLAG_enable_type_checks) { | 1010 if (FLAG_enable_type_checks) { |
1008 const bool is_implicit_dynamic_getter = | 1011 const bool is_implicit_dynamic_getter = |
1009 (!function.is_static() && | 1012 (!function.is_static() && |
1010 ((function.kind() == RawFunction::kImplicitGetter) || | 1013 ((function.kind() == RawFunction::kImplicitGetter) || |
1011 (function.kind() == RawFunction::kImplicitStaticFinalGetter))); | 1014 (function.kind() == RawFunction::kImplicitStaticFinalGetter))); |
1012 // Implicit getters do not need a type check at return, unless they compute | 1015 // Implicit getters do not need a type check at return, unless they compute |
(...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3101 | 3104 |
3102 | 3105 |
3103 // <Expression> ::= StoreLocal { local: LocalVariable | 3106 // <Expression> ::= StoreLocal { local: LocalVariable |
3104 // value: <Expression> } | 3107 // value: <Expression> } |
3105 void EffectGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { | 3108 void EffectGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { |
3106 // If the right hand side is an expression that does not contain | 3109 // If the right hand side is an expression that does not contain |
3107 // a safe point for the debugger to stop, add an explicit stub | 3110 // a safe point for the debugger to stop, add an explicit stub |
3108 // call. | 3111 // call. |
3109 if (node->value()->IsLiteralNode() || | 3112 if (node->value()->IsLiteralNode() || |
3110 node->value()->IsLoadLocalNode()) { | 3113 node->value()->IsLoadLocalNode()) { |
3111 AddInstruction(new DebugStepCheckInstr(node->token_pos(), | 3114 if (FLAG_enable_debugger) { |
3112 PcDescriptors::kRuntimeCall)); | 3115 AddInstruction(new DebugStepCheckInstr(node->token_pos(), |
| 3116 PcDescriptors::kRuntimeCall)); |
| 3117 } |
3113 } | 3118 } |
3114 | 3119 |
3115 ValueGraphVisitor for_value(owner()); | 3120 ValueGraphVisitor for_value(owner()); |
3116 node->value()->Visit(&for_value); | 3121 node->value()->Visit(&for_value); |
3117 Append(for_value); | 3122 Append(for_value); |
3118 Value* store_value = for_value.value(); | 3123 Value* store_value = for_value.value(); |
3119 if (FLAG_enable_type_checks) { | 3124 if (FLAG_enable_type_checks) { |
3120 store_value = BuildAssignableValue(node->value()->token_pos(), | 3125 store_value = BuildAssignableValue(node->value()->token_pos(), |
3121 store_value, | 3126 store_value, |
3122 node->local().type(), | 3127 node->local().type(), |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3512 Isolate::Current()->object_store()->empty_context()))))); | 3517 Isolate::Current()->object_store()->empty_context()))))); |
3513 } | 3518 } |
3514 | 3519 |
3515 // This check may be deleted if the generated code is leaf. | 3520 // This check may be deleted if the generated code is leaf. |
3516 // Native functions don't need a stack check at entry. | 3521 // Native functions don't need a stack check at entry. |
3517 const Function& function = owner()->parsed_function()->function(); | 3522 const Function& function = owner()->parsed_function()->function(); |
3518 if ((node == owner()->parsed_function()->node_sequence()) && | 3523 if ((node == owner()->parsed_function()->node_sequence()) && |
3519 !function.is_native()) { | 3524 !function.is_native()) { |
3520 // Always allocate CheckOverflowInstr so that deopt-ids match regardless | 3525 // Always allocate CheckOverflowInstr so that deopt-ids match regardless |
3521 // if we inline or not. | 3526 // if we inline or not. |
3522 CheckStackOverflowInstr* check = | 3527 if (!function.IsImplicitGetterFunction() && |
3523 new CheckStackOverflowInstr(function.token_pos(), 0); | 3528 !function.IsImplicitSetterFunction()) { |
3524 // If we are inlining don't actually attach the stack check. We must still | 3529 CheckStackOverflowInstr* check = |
3525 // create the stack check in order to allocate a deopt id. | 3530 new CheckStackOverflowInstr(function.token_pos(), 0); |
3526 if (!owner()->IsInlining()) { | 3531 // If we are inlining don't actually attach the stack check. We must still |
3527 AddInstruction(check); | 3532 // create the stack check in order to allocate a deopt id. |
| 3533 if (!owner()->IsInlining()) { |
| 3534 AddInstruction(check); |
| 3535 } |
3528 } | 3536 } |
3529 } | 3537 } |
3530 | 3538 |
3531 if (FLAG_enable_type_checks && | 3539 if (FLAG_enable_type_checks && |
3532 (node == owner()->parsed_function()->node_sequence())) { | 3540 (node == owner()->parsed_function()->node_sequence())) { |
3533 const Function& function = owner()->parsed_function()->function(); | 3541 const Function& function = owner()->parsed_function()->function(); |
3534 const int num_params = function.NumParameters(); | 3542 const int num_params = function.NumParameters(); |
3535 int pos = 0; | 3543 int pos = 0; |
3536 if (function.IsConstructor()) { | 3544 if (function.IsConstructor()) { |
3537 // Skip type checking of receiver and phase for constructor functions. | 3545 // Skip type checking of receiver and phase for constructor functions. |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3966 LanguageError::kBailout, | 3974 LanguageError::kBailout, |
3967 Heap::kNew, | 3975 Heap::kNew, |
3968 "FlowGraphBuilder Bailout: %s %s", | 3976 "FlowGraphBuilder Bailout: %s %s", |
3969 String::Handle(function.name()).ToCString(), | 3977 String::Handle(function.name()).ToCString(), |
3970 reason)); | 3978 reason)); |
3971 Isolate::Current()->long_jump_base()->Jump(1, error); | 3979 Isolate::Current()->long_jump_base()->Jump(1, error); |
3972 UNREACHABLE(); | 3980 UNREACHABLE(); |
3973 } | 3981 } |
3974 | 3982 |
3975 } // namespace dart | 3983 } // namespace dart |
OLD | NEW |