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/globals.h" // Needed here to get TARGET_ARCH_XXX. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX. |
6 | 6 |
7 #include "vm/flow_graph_compiler.h" | 7 #include "vm/flow_graph_compiler.h" |
8 | 8 |
| 9 #include "vm/cha.h" |
9 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
10 #include "vm/debugger.h" | 11 #include "vm/debugger.h" |
11 #include "vm/deopt_instructions.h" | 12 #include "vm/deopt_instructions.h" |
12 #include "vm/flow_graph_allocator.h" | 13 #include "vm/flow_graph_allocator.h" |
13 #include "vm/il_printer.h" | 14 #include "vm/il_printer.h" |
14 #include "vm/intrinsifier.h" | 15 #include "vm/intrinsifier.h" |
15 #include "vm/locations.h" | 16 #include "vm/locations.h" |
16 #include "vm/longjump.h" | 17 #include "vm/longjump.h" |
17 #include "vm/object_store.h" | 18 #include "vm/object_store.h" |
18 #include "vm/parser.h" | 19 #include "vm/parser.h" |
19 #include "vm/stub_code.h" | 20 #include "vm/stub_code.h" |
20 #include "vm/symbols.h" | 21 #include "vm/symbols.h" |
21 | 22 |
22 namespace dart { | 23 namespace dart { |
23 | 24 |
24 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); | 25 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); |
25 DECLARE_FLAG(bool, code_comments); | 26 DECLARE_FLAG(bool, code_comments); |
26 DECLARE_FLAG(bool, enable_type_checks); | 27 DECLARE_FLAG(bool, enable_type_checks); |
27 DECLARE_FLAG(bool, intrinsify); | 28 DECLARE_FLAG(bool, intrinsify); |
28 DECLARE_FLAG(bool, propagate_ic_data); | 29 DECLARE_FLAG(bool, propagate_ic_data); |
29 DECLARE_FLAG(bool, report_usage_count); | 30 DECLARE_FLAG(bool, report_usage_count); |
30 DECLARE_FLAG(int, optimization_counter_threshold); | 31 DECLARE_FLAG(int, optimization_counter_threshold); |
| 32 DECLARE_FLAG(bool, use_cha); |
31 | 33 |
32 void CompilerDeoptInfo::BuildReturnAddress(DeoptInfoBuilder* builder, | 34 void CompilerDeoptInfo::BuildReturnAddress(DeoptInfoBuilder* builder, |
33 const Function& function, | 35 const Function& function, |
34 intptr_t slot_ix) { | 36 intptr_t slot_ix) { |
35 builder->AddReturnAddressAfter(function, deopt_id(), slot_ix); | 37 builder->AddReturnAddressAfter(function, deopt_id(), slot_ix); |
36 } | 38 } |
37 | 39 |
38 | 40 |
39 void CompilerDeoptInfoWithStub::BuildReturnAddress(DeoptInfoBuilder* builder, | 41 void CompilerDeoptInfoWithStub::BuildReturnAddress(DeoptInfoBuilder* builder, |
40 const Function& function, | 42 const Function& function, |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 case kFloat64ArrayCid: | 999 case kFloat64ArrayCid: |
998 return FieldAddress(array, index, TIMES_4, Float64Array::data_offset()); | 1000 return FieldAddress(array, index, TIMES_4, Float64Array::data_offset()); |
999 case kUint8ArrayCid: | 1001 case kUint8ArrayCid: |
1000 return FieldAddress(array, index, TIMES_1, Uint8Array::data_offset()); | 1002 return FieldAddress(array, index, TIMES_1, Uint8Array::data_offset()); |
1001 default: | 1003 default: |
1002 UNIMPLEMENTED(); | 1004 UNIMPLEMENTED(); |
1003 return FieldAddress(SPREG, 0); | 1005 return FieldAddress(SPREG, 0); |
1004 } | 1006 } |
1005 } | 1007 } |
1006 | 1008 |
| 1009 |
| 1010 // Returns true if checking against this type is a direct class id comparison. |
| 1011 bool FlowGraphCompiler::TypeCheckAsClassEquality(const AbstractType& type) { |
| 1012 ASSERT(type.IsFinalized() && !type.IsMalformed()); |
| 1013 // Requires CHA, which can be applied in optimized code only, |
| 1014 if (!FLAG_use_cha || !is_optimizing()) return false; |
| 1015 if (!type.IsInstantiated()) return false; |
| 1016 const Class& type_class = Class::Handle(type.type_class()); |
| 1017 // Could be an interface check? |
| 1018 if (type_class.is_implemented()) return false; |
| 1019 const intptr_t type_cid = type_class.id(); |
| 1020 if (CHA::HasSubclasses(type_cid)) return false; |
| 1021 if (type_class.HasTypeArguments()) { |
| 1022 // Only raw types can be directly compared, thus disregarding type |
| 1023 // arguments. |
| 1024 const AbstractTypeArguments& type_arguments = |
| 1025 AbstractTypeArguments::Handle(type.arguments()); |
| 1026 const bool is_raw_type = type_arguments.IsNull() || |
| 1027 type_arguments.IsRaw(type_arguments.Length()); |
| 1028 return is_raw_type; |
| 1029 } |
| 1030 return true; |
| 1031 } |
| 1032 |
1007 } // namespace dart | 1033 } // namespace dart |
OLD | NEW |