| 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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/flow_graph_allocator.h" | 9 #include "vm/flow_graph_allocator.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 const String& name) { | 222 const String& name) { |
| 223 // If both names are private mangle test_name before comparison. | 223 // If both names are private mangle test_name before comparison. |
| 224 if ((name.CharAt(0) == '_') && (test_name[0] == '_')) { | 224 if ((name.CharAt(0) == '_') && (test_name[0] == '_')) { |
| 225 const String& test_name_symbol = String::Handle(Symbols::New(test_name)); | 225 const String& test_name_symbol = String::Handle(Symbols::New(test_name)); |
| 226 return String::Handle(lib.PrivateName(test_name_symbol)).Equals(name); | 226 return String::Handle(lib.PrivateName(test_name_symbol)).Equals(name); |
| 227 } | 227 } |
| 228 return name.Equals(test_name); | 228 return name.Equals(test_name); |
| 229 } | 229 } |
| 230 | 230 |
| 231 | 231 |
| 232 static bool IsRecognizedLibrary(const Library& library) { |
| 233 // List of libraries where methods can be recognized. |
| 234 return (library.raw() == Library::CoreLibrary()) |
| 235 || (library.raw() == Library::MathLibrary()) |
| 236 || (library.raw() == Library::ScalarlistLibrary()); |
| 237 } |
| 238 |
| 232 MethodRecognizer::Kind MethodRecognizer::RecognizeKind( | 239 MethodRecognizer::Kind MethodRecognizer::RecognizeKind( |
| 233 const Function& function) { | 240 const Function& function) { |
| 234 // Only core and math library methods can be recognized. | |
| 235 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | |
| 236 const Library& math_lib = Library::Handle(Library::MathLibrary()); | |
| 237 const Class& function_class = Class::Handle(function.Owner()); | 241 const Class& function_class = Class::Handle(function.Owner()); |
| 238 if ((function_class.library() != core_lib.raw()) && | 242 const Library& lib = Library::Handle(function_class.library()); |
| 239 (function_class.library() != math_lib.raw())) { | 243 if (!IsRecognizedLibrary(lib)) { |
| 240 return kUnknown; | 244 return kUnknown; |
| 241 } | 245 } |
| 242 const Library& lib = Library::Handle(function_class.library()); | 246 |
| 243 const String& function_name = String::Handle(function.name()); | 247 const String& function_name = String::Handle(function.name()); |
| 244 const String& class_name = String::Handle(function_class.Name()); | 248 const String& class_name = String::Handle(function_class.Name()); |
| 245 | 249 |
| 246 #define RECOGNIZE_FUNCTION(test_class_name, test_function_name, enum_name, fp) \ | 250 #define RECOGNIZE_FUNCTION(test_class_name, test_function_name, enum_name, fp) \ |
| 247 if (CompareNames(lib, #test_function_name, function_name) && \ | 251 if (CompareNames(lib, #test_function_name, function_name) && \ |
| 248 CompareNames(lib, #test_class_name, class_name)) { \ | 252 CompareNames(lib, #test_class_name, class_name)) { \ |
| 249 ASSERT(function.CheckSourceFingerprint(fp)); \ | 253 ASSERT(function.CheckSourceFingerprint(fp)); \ |
| 250 return k##enum_name; \ | 254 return k##enum_name; \ |
| 251 } | 255 } |
| 252 RECOGNIZED_LIST(RECOGNIZE_FUNCTION) | 256 RECOGNIZED_LIST(RECOGNIZE_FUNCTION) |
| (...skipping 2510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2763 default: | 2767 default: |
| 2764 UNREACHABLE(); | 2768 UNREACHABLE(); |
| 2765 return -1; | 2769 return -1; |
| 2766 } | 2770 } |
| 2767 } | 2771 } |
| 2768 | 2772 |
| 2769 | 2773 |
| 2770 #undef __ | 2774 #undef __ |
| 2771 | 2775 |
| 2772 } // namespace dart | 2776 } // namespace dart |
| OLD | NEW |