| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #include "vm/method_recognizer.h" |
| 6 |
| 7 #include "vm/object.h" |
| 8 #include "vm/symbols.h" |
| 9 |
| 10 namespace dart { |
| 11 |
| 12 MethodRecognizer::Kind MethodRecognizer::RecognizeKind( |
| 13 const Function& function) { |
| 14 return function.recognized_kind(); |
| 15 } |
| 16 |
| 17 |
| 18 bool MethodRecognizer::AlwaysInline(const Function& function) { |
| 19 return function.is_always_inline(); |
| 20 } |
| 21 |
| 22 |
| 23 bool MethodRecognizer::PolymorphicTarget(const Function& function) { |
| 24 return function.is_polymorphic_target(); |
| 25 } |
| 26 |
| 27 |
| 28 const char* MethodRecognizer::KindToCString(Kind kind) { |
| 29 #define KIND_TO_STRING(class_name, function_name, enum_name, fp) \ |
| 30 if (kind == k##enum_name) return #enum_name; |
| 31 RECOGNIZED_LIST(KIND_TO_STRING) |
| 32 #undef KIND_TO_STRING |
| 33 return "?"; |
| 34 } |
| 35 |
| 36 |
| 37 void MethodRecognizer::InitializeState() { |
| 38 GrowableArray<Library*> libs(3); |
| 39 libs.Add(&Library::ZoneHandle(Library::CoreLibrary())); |
| 40 libs.Add(&Library::ZoneHandle(Library::MathLibrary())); |
| 41 libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary())); |
| 42 libs.Add(&Library::ZoneHandle(Library::InternalLibrary())); |
| 43 libs.Add(&Library::ZoneHandle(Library::ProfilerLibrary())); |
| 44 Function& func = Function::Handle(); |
| 45 |
| 46 #define SET_RECOGNIZED_KIND(class_name, function_name, enum_name, fp) \ |
| 47 func = Library::GetFunction(libs, #class_name, #function_name); \ |
| 48 if (func.IsNull()) { \ |
| 49 OS::PrintErr("Missing %s::%s\n", #class_name, #function_name); \ |
| 50 UNREACHABLE(); \ |
| 51 } \ |
| 52 ASSERT(func.CheckSourceFingerprint(fp)); \ |
| 53 func.set_recognized_kind(k##enum_name); |
| 54 |
| 55 RECOGNIZED_LIST(SET_RECOGNIZED_KIND); |
| 56 |
| 57 #define SET_FUNCTION_BIT(class_name, function_name, dest, fp, setter_name) \ |
| 58 func = Library::GetFunction(libs, #class_name, #function_name); \ |
| 59 if (func.IsNull()) { \ |
| 60 OS::PrintErr("Missing %s::%s\n", #class_name, #function_name); \ |
| 61 UNREACHABLE(); \ |
| 62 } \ |
| 63 ASSERT(func.CheckSourceFingerprint(fp)); \ |
| 64 func.setter_name(true); |
| 65 |
| 66 #define SET_IS_ALWAYS_INLINE(class_name, function_name, dest, fp) \ |
| 67 SET_FUNCTION_BIT(class_name, function_name, dest, fp, set_is_always_inline) |
| 68 |
| 69 #define SET_IS_POLYMORPHIC_TARGET(class_name, function_name, dest, fp) \ |
| 70 SET_FUNCTION_BIT(class_name, function_name, dest, fp, \ |
| 71 set_is_polymorphic_target) |
| 72 |
| 73 INLINE_WHITE_LIST(SET_IS_ALWAYS_INLINE); |
| 74 POLYMORPHIC_TARGET_LIST(SET_IS_POLYMORPHIC_TARGET); |
| 75 |
| 76 #undef SET_RECOGNIZED_KIND |
| 77 #undef SET_IS_ALWAYS_INLINE |
| 78 #undef SET_IS_POLYMORPHIC_TARGET |
| 79 #undef SET_FUNCTION_BIT |
| 80 } |
| 81 |
| 82 } // namespace dart |
| OLD | NEW |