OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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/method_recognizer.h" | 5 #include "vm/method_recognizer.h" |
6 | 6 |
7 #include "vm/object.h" | 7 #include "vm/object.h" |
8 #include "vm/symbols.h" | 8 #include "vm/symbols.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
11 | 11 |
12 MethodRecognizer::Kind MethodRecognizer::RecognizeKind( | 12 MethodRecognizer::Kind MethodRecognizer::RecognizeKind( |
13 const Function& function) { | 13 const Function& function) { |
14 return function.recognized_kind(); | 14 return function.recognized_kind(); |
15 } | 15 } |
16 | 16 |
17 | |
18 bool MethodRecognizer::AlwaysInline(const Function& function) { | 17 bool MethodRecognizer::AlwaysInline(const Function& function) { |
19 return function.always_inline(); | 18 return function.always_inline(); |
20 } | 19 } |
21 | 20 |
22 | |
23 bool MethodRecognizer::PolymorphicTarget(const Function& function) { | 21 bool MethodRecognizer::PolymorphicTarget(const Function& function) { |
24 return function.is_polymorphic_target(); | 22 return function.is_polymorphic_target(); |
25 } | 23 } |
26 | 24 |
27 | |
28 intptr_t MethodRecognizer::ResultCid(const Function& function) { | 25 intptr_t MethodRecognizer::ResultCid(const Function& function) { |
29 switch (function.recognized_kind()) { | 26 switch (function.recognized_kind()) { |
30 #define DEFINE_CASE(cname, fname, ename, result_type, fingerprint) \ | 27 #define DEFINE_CASE(cname, fname, ename, result_type, fingerprint) \ |
31 case k##ename: \ | 28 case k##ename: \ |
32 return k##result_type##Cid; | 29 return k##result_type##Cid; |
33 RECOGNIZED_LIST(DEFINE_CASE) | 30 RECOGNIZED_LIST(DEFINE_CASE) |
34 #undef DEFINE_CASE | 31 #undef DEFINE_CASE |
35 default: | 32 default: |
36 return kDynamicCid; | 33 return kDynamicCid; |
37 } | 34 } |
38 } | 35 } |
39 | 36 |
40 | |
41 intptr_t MethodRecognizer::MethodKindToReceiverCid(Kind kind) { | 37 intptr_t MethodRecognizer::MethodKindToReceiverCid(Kind kind) { |
42 switch (kind) { | 38 switch (kind) { |
43 case kImmutableArrayGetIndexed: | 39 case kImmutableArrayGetIndexed: |
44 return kImmutableArrayCid; | 40 return kImmutableArrayCid; |
45 | 41 |
46 case kObjectArrayGetIndexed: | 42 case kObjectArrayGetIndexed: |
47 case kObjectArraySetIndexed: | 43 case kObjectArraySetIndexed: |
48 return kArrayCid; | 44 return kArrayCid; |
49 | 45 |
50 case kGrowableArrayGetIndexed: | 46 case kGrowableArrayGetIndexed: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 case kFloat64x2ArraySetIndexed: | 107 case kFloat64x2ArraySetIndexed: |
112 return kTypedDataFloat64x2ArrayCid; | 108 return kTypedDataFloat64x2ArrayCid; |
113 | 109 |
114 default: | 110 default: |
115 break; | 111 break; |
116 } | 112 } |
117 UNREACHABLE(); | 113 UNREACHABLE(); |
118 return kIllegalCid; | 114 return kIllegalCid; |
119 } | 115 } |
120 | 116 |
121 | |
122 #define KIND_TO_STRING(class_name, function_name, enum_name, type, fp) \ | 117 #define KIND_TO_STRING(class_name, function_name, enum_name, type, fp) \ |
123 #enum_name, | 118 #enum_name, |
124 static const char* recognized_list_method_name[] = { | 119 static const char* recognized_list_method_name[] = { |
125 "Unknown", RECOGNIZED_LIST(KIND_TO_STRING)}; | 120 "Unknown", RECOGNIZED_LIST(KIND_TO_STRING)}; |
126 #undef KIND_TO_STRING | 121 #undef KIND_TO_STRING |
127 | 122 |
128 const char* MethodRecognizer::KindToCString(Kind kind) { | 123 const char* MethodRecognizer::KindToCString(Kind kind) { |
129 if (kind > kUnknown && kind < kNumRecognizedMethods) | 124 if (kind > kUnknown && kind < kNumRecognizedMethods) |
130 return recognized_list_method_name[kind]; | 125 return recognized_list_method_name[kind]; |
131 return "?"; | 126 return "?"; |
132 } | 127 } |
133 | 128 |
134 | |
135 #if !defined(DART_PRECOMPILED_RUNTIME) | 129 #if !defined(DART_PRECOMPILED_RUNTIME) |
136 void MethodRecognizer::InitializeState() { | 130 void MethodRecognizer::InitializeState() { |
137 GrowableArray<Library*> libs(3); | 131 GrowableArray<Library*> libs(3); |
138 libs.Add(&Library::ZoneHandle(Library::CoreLibrary())); | 132 libs.Add(&Library::ZoneHandle(Library::CoreLibrary())); |
139 libs.Add(&Library::ZoneHandle(Library::CollectionLibrary())); | 133 libs.Add(&Library::ZoneHandle(Library::CollectionLibrary())); |
140 libs.Add(&Library::ZoneHandle(Library::MathLibrary())); | 134 libs.Add(&Library::ZoneHandle(Library::MathLibrary())); |
141 libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary())); | 135 libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary())); |
142 libs.Add(&Library::ZoneHandle(Library::InternalLibrary())); | 136 libs.Add(&Library::ZoneHandle(Library::InternalLibrary())); |
143 libs.Add(&Library::ZoneHandle(Library::DeveloperLibrary())); | 137 libs.Add(&Library::ZoneHandle(Library::DeveloperLibrary())); |
144 libs.Add(&Library::ZoneHandle(Library::AsyncLibrary())); | 138 libs.Add(&Library::ZoneHandle(Library::AsyncLibrary())); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 INLINE_BLACK_LIST(SET_IS_NEVER_INLINE); | 172 INLINE_BLACK_LIST(SET_IS_NEVER_INLINE); |
179 POLYMORPHIC_TARGET_LIST(SET_IS_POLYMORPHIC_TARGET); | 173 POLYMORPHIC_TARGET_LIST(SET_IS_POLYMORPHIC_TARGET); |
180 | 174 |
181 #undef SET_RECOGNIZED_KIND | 175 #undef SET_RECOGNIZED_KIND |
182 #undef SET_IS_ALWAYS_INLINE | 176 #undef SET_IS_ALWAYS_INLINE |
183 #undef SET_IS_POLYMORPHIC_TARGET | 177 #undef SET_IS_POLYMORPHIC_TARGET |
184 #undef SET_FUNCTION_BIT | 178 #undef SET_FUNCTION_BIT |
185 } | 179 } |
186 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 180 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
187 | 181 |
188 | |
189 } // namespace dart | 182 } // namespace dart |
OLD | NEW |