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/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 namespace dart { | 33 namespace dart { |
34 | 34 |
35 DEFINE_FLAG(bool, eliminate_type_checks, true, | 35 DEFINE_FLAG(bool, eliminate_type_checks, true, |
36 "Eliminate type checks when allowed by static type analysis."); | 36 "Eliminate type checks when allowed by static type analysis."); |
37 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); | 37 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); |
38 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); | 38 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); |
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 | 41 |
42 DECLARE_FLAG(bool, profile_vm); | 42 DECLARE_FLAG(bool, profile_vm); |
| 43 DECLARE_FLAG(bool, support_externalizable_strings); |
43 | 44 |
44 // Quick access to the locally defined zone() method. | 45 // Quick access to the locally defined zone() method. |
45 #define Z (zone()) | 46 #define Z (zone()) |
46 | 47 |
47 // Quick synthetic token position. | 48 // Quick synthetic token position. |
48 #define ST(token_pos) ((token_pos).ToSynthetic()) | 49 #define ST(token_pos) ((token_pos).ToSynthetic()) |
49 | 50 |
50 // 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 |
51 // the compilation. | 52 // the compilation. |
52 const double kCommonDoubleConstants[] = | 53 const double kCommonDoubleConstants[] = |
(...skipping 3408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3461 } | 3462 } |
3462 case MethodRecognizer::kStringBaseLength: | 3463 case MethodRecognizer::kStringBaseLength: |
3463 case MethodRecognizer::kStringBaseIsEmpty: { | 3464 case MethodRecognizer::kStringBaseIsEmpty: { |
3464 // Treat length loads as mutable (i.e. affected by side effects) to | 3465 // Treat length loads as mutable (i.e. affected by side effects) to |
3465 // avoid hoisting them since we can't hoist the preceding class-check. | 3466 // avoid hoisting them since we can't hoist the preceding class-check. |
3466 // This is because of externalization of strings that affects their | 3467 // This is because of externalization of strings that affects their |
3467 // class-id. | 3468 // class-id. |
3468 LoadFieldInstr* load = BuildNativeGetter( | 3469 LoadFieldInstr* load = BuildNativeGetter( |
3469 node, MethodRecognizer::kStringBaseLength, String::length_offset(), | 3470 node, MethodRecognizer::kStringBaseLength, String::length_offset(), |
3470 Type::ZoneHandle(Z, Type::SmiType()), kSmiCid); | 3471 Type::ZoneHandle(Z, Type::SmiType()), kSmiCid); |
| 3472 load->set_is_immutable(!FLAG_support_externalizable_strings); |
3471 if (kind == MethodRecognizer::kStringBaseLength) { | 3473 if (kind == MethodRecognizer::kStringBaseLength) { |
3472 return ReturnDefinition(load); | 3474 return ReturnDefinition(load); |
3473 } | 3475 } |
3474 ASSERT(kind == MethodRecognizer::kStringBaseIsEmpty); | 3476 ASSERT(kind == MethodRecognizer::kStringBaseIsEmpty); |
3475 Value* zero_val = Bind(new(Z) ConstantInstr( | 3477 Value* zero_val = Bind(new(Z) ConstantInstr( |
3476 Smi::ZoneHandle(Z, Smi::New(0)))); | 3478 Smi::ZoneHandle(Z, Smi::New(0)))); |
3477 Value* load_val = Bind(load); | 3479 Value* load_val = Bind(load); |
3478 StrictCompareInstr* compare = | 3480 StrictCompareInstr* compare = |
3479 new(Z) StrictCompareInstr(token_pos, | 3481 new(Z) StrictCompareInstr(token_pos, |
3480 Token::kEQ_STRICT, | 3482 Token::kEQ_STRICT, |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4662 Script::Handle(function.script()), | 4664 Script::Handle(function.script()), |
4663 function.token_pos(), | 4665 function.token_pos(), |
4664 Report::AtLocation, | 4666 Report::AtLocation, |
4665 "FlowGraphBuilder Bailout: %s %s", | 4667 "FlowGraphBuilder Bailout: %s %s", |
4666 String::Handle(function.name()).ToCString(), | 4668 String::Handle(function.name()).ToCString(), |
4667 reason); | 4669 reason); |
4668 UNREACHABLE(); | 4670 UNREACHABLE(); |
4669 } | 4671 } |
4670 | 4672 |
4671 } // namespace dart | 4673 } // namespace dart |
OLD | NEW |