Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1822)

Unified Diff: runtime/vm/intermediate_language.cc

Issue 10914313: Mangle private names in the method recognizer otherwise they are not recognized. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cleanup Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language.cc
diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc
index c85c8ca9559e6b0d3bed70c6db6964cc8ca67963..ee9297e53f96ebf9201282ae08c467777f7a9701 100644
--- a/runtime/vm/intermediate_language.cc
+++ b/runtime/vm/intermediate_language.cc
@@ -120,6 +120,18 @@ GraphEntryInstr::GraphEntryInstr(TargetEntryInstr* normal_entry)
}
+static bool CompareNames(const Library& lib,
+ const char* test_name,
+ const String& name) {
+ // If both names are private mangle test_name before comparison.
+ if ((name.CharAt(0) == '_') && (test_name[0] == '_')) {
+ const String& test_name_symbol = String::Handle(Symbols::New(test_name));
+ return String::Handle(lib.PrivateName(test_name_symbol)).Equals(name);
+ }
+ return name.Equals(test_name);
+}
+
+
MethodRecognizer::Kind MethodRecognizer::RecognizeKind(
const Function& function) {
// Only core and math library methods can be recognized.
@@ -132,15 +144,13 @@ MethodRecognizer::Kind MethodRecognizer::RecognizeKind(
(function_class.library() != math_lib.raw())) {
return kUnknown;
}
- const String& recognize_name = String::Handle(function.name());
- const String& recognize_class = String::Handle(function_class.Name());
- String& test_function_name = String::Handle();
- String& test_class_name = String::Handle();
-#define RECOGNIZE_FUNCTION(class_name, function_name, enum_name) \
- test_function_name = Symbols::New(#function_name); \
- test_class_name = Symbols::New(#class_name); \
- if (recognize_name.Equals(test_function_name) && \
- recognize_class.Equals(test_class_name)) { \
+ const Library& lib = Library::Handle(function_class.library());
+ const String& function_name = String::Handle(function.name());
+ const String& class_name = String::Handle(function_class.Name());
+
+#define RECOGNIZE_FUNCTION(test_class_name, test_function_name, enum_name) \
+ if (CompareNames(lib, #test_function_name, function_name) && \
+ CompareNames(lib, #test_class_name, class_name)) { \
return k##enum_name; \
}
RECOGNIZED_LIST(RECOGNIZE_FUNCTION)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698