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 #if !defined(DART_PRECOMPILED_RUNTIME) | 5 #if !defined(DART_PRECOMPILED_RUNTIME) |
6 | 6 |
7 #include "vm/flow_graph_builder.h" | 7 #include "vm/flow_graph_builder.h" |
8 | 8 |
9 #include "lib/invocation_mirror.h" | 9 #include "lib/invocation_mirror.h" |
10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 true, | 39 true, |
40 "Eliminate type checks when allowed by static type analysis."); | 40 "Eliminate type checks when allowed by static type analysis."); |
41 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); | 41 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); |
42 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); | 42 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); |
43 DEFINE_FLAG(bool, | 43 DEFINE_FLAG(bool, |
44 trace_type_check_elimination, | 44 trace_type_check_elimination, |
45 false, | 45 false, |
46 "Trace type check elimination at compile time."); | 46 "Trace type check elimination at compile time."); |
47 | 47 |
48 DECLARE_FLAG(bool, profile_vm); | 48 DECLARE_FLAG(bool, profile_vm); |
49 DECLARE_FLAG(bool, support_externalizable_strings); | |
50 | 49 |
51 // Quick access to the locally defined zone() method. | 50 // Quick access to the locally defined zone() method. |
52 #define Z (zone()) | 51 #define Z (zone()) |
53 | 52 |
54 // Quick access to the locally defined thread() method. | 53 // Quick access to the locally defined thread() method. |
55 #define T (thread()) | 54 #define T (thread()) |
56 | 55 |
57 // Quick synthetic token position. | 56 // Quick synthetic token position. |
58 #define ST(token_pos) ((token_pos).ToSynthetic()) | 57 #define ST(token_pos) ((token_pos).ToSynthetic()) |
59 | 58 |
(...skipping 3111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3171 Value* other = Bind(new (Z) LoadLocalInstr(*other_var, token_pos)); | 3170 Value* other = Bind(new (Z) LoadLocalInstr(*other_var, token_pos)); |
3172 // Receiver is not a number because numbers override equality. | 3171 // Receiver is not a number because numbers override equality. |
3173 const bool kNoNumberCheck = false; | 3172 const bool kNoNumberCheck = false; |
3174 StrictCompareInstr* compare = new (Z) | 3173 StrictCompareInstr* compare = new (Z) |
3175 StrictCompareInstr(token_pos, Token::kEQ_STRICT, receiver, other, | 3174 StrictCompareInstr(token_pos, Token::kEQ_STRICT, receiver, other, |
3176 kNoNumberCheck, owner()->GetNextDeoptId()); | 3175 kNoNumberCheck, owner()->GetNextDeoptId()); |
3177 return ReturnDefinition(compare); | 3176 return ReturnDefinition(compare); |
3178 } | 3177 } |
3179 case MethodRecognizer::kStringBaseLength: | 3178 case MethodRecognizer::kStringBaseLength: |
3180 case MethodRecognizer::kStringBaseIsEmpty: { | 3179 case MethodRecognizer::kStringBaseIsEmpty: { |
3181 // Treat length loads as mutable (i.e. affected by side effects) to | |
3182 // avoid hoisting them since we can't hoist the preceding class-check. | |
3183 // This is because of externalization of strings that affects their | |
3184 // class-id. | |
3185 LoadFieldInstr* load = BuildNativeGetter( | 3180 LoadFieldInstr* load = BuildNativeGetter( |
3186 node, MethodRecognizer::kStringBaseLength, String::length_offset(), | 3181 node, MethodRecognizer::kStringBaseLength, String::length_offset(), |
3187 Type::ZoneHandle(Z, Type::SmiType()), kSmiCid); | 3182 Type::ZoneHandle(Z, Type::SmiType()), kSmiCid); |
3188 load->set_is_immutable(!FLAG_support_externalizable_strings); | 3183 load->set_is_immutable(true); |
3189 if (kind == MethodRecognizer::kStringBaseLength) { | 3184 if (kind == MethodRecognizer::kStringBaseLength) { |
3190 return ReturnDefinition(load); | 3185 return ReturnDefinition(load); |
3191 } | 3186 } |
3192 ASSERT(kind == MethodRecognizer::kStringBaseIsEmpty); | 3187 ASSERT(kind == MethodRecognizer::kStringBaseIsEmpty); |
3193 Value* zero_val = | 3188 Value* zero_val = |
3194 Bind(new (Z) ConstantInstr(Smi::ZoneHandle(Z, Smi::New(0)))); | 3189 Bind(new (Z) ConstantInstr(Smi::ZoneHandle(Z, Smi::New(0)))); |
3195 Value* load_val = Bind(load); | 3190 Value* load_val = Bind(load); |
3196 StrictCompareInstr* compare = new (Z) StrictCompareInstr( | 3191 StrictCompareInstr* compare = new (Z) StrictCompareInstr( |
3197 token_pos, Token::kEQ_STRICT, load_val, zero_val, false, | 3192 token_pos, Token::kEQ_STRICT, load_val, zero_val, false, |
3198 owner()->GetNextDeoptId()); // No number check. | 3193 owner()->GetNextDeoptId()); // No number check. |
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4417 // Bail if the type has any type parameters. | 4412 // Bail if the type has any type parameters. |
4418 if (type_class.IsGeneric()) return false; | 4413 if (type_class.IsGeneric()) return false; |
4419 | 4414 |
4420 // Finally a simple class for instance of checking. | 4415 // Finally a simple class for instance of checking. |
4421 return true; | 4416 return true; |
4422 } | 4417 } |
4423 | 4418 |
4424 } // namespace dart | 4419 } // namespace dart |
4425 | 4420 |
4426 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 4421 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |