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

Side by Side Diff: vm/intrinsifier.cc

Issue 12095110: Restore factory names in the intrinsifier list to the way they were (is used in a special way durin… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/intrinsifier.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Class for intrinsifying functions. 4 // Class for intrinsifying functions.
5 5
6 #include "vm/intrinsifier.h" 6 #include "vm/intrinsifier.h"
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/object.h" 8 #include "vm/object.h"
9 #include "vm/symbols.h" 9 #include "vm/symbols.h"
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 58
59 // Returns true if the function matches function_name and class_name, with 59 // Returns true if the function matches function_name and class_name, with
60 // special recognition of corelib private classes. 60 // special recognition of corelib private classes.
61 static bool TestFunction(const Library& lib, 61 static bool TestFunction(const Library& lib,
62 const Function& function, 62 const Function& function,
63 const char* function_class_name, 63 const char* function_class_name,
64 const char* function_name, 64 const char* function_name,
65 const char* test_class_name, 65 const char* test_class_name,
66 const char* test_function_name) { 66 const char* test_function_name) {
67 // If test_function_name starts with a '.' we use that to indicate
68 // that it is a named constructor in the class. Therefore, if
69 // the class matches and the rest of the method name starting with
70 // the dot matches, we have found a match.
71 // We do not store the entire factory constructor name with the class
72 // (e.g: _GrowableObjectArray.withData) because the actual function name
73 // that we see here includes the private key.
74 if (test_function_name[0] == '.') {
75 function_name = strstr(function_name, ".");
76 if (function_name == NULL) {
77 return false;
78 }
79 }
67 return CompareNames(lib, test_class_name, function_class_name) && 80 return CompareNames(lib, test_class_name, function_class_name) &&
68 CompareNames(lib, test_function_name, function_name); 81 CompareNames(lib, test_function_name, function_name);
69 } 82 }
70 83
71 84
72 bool Intrinsifier::CanIntrinsify(const Function& function) { 85 bool Intrinsifier::CanIntrinsify(const Function& function) {
73 if (!FLAG_intrinsify) return false; 86 if (!FLAG_intrinsify) return false;
74 if (function.IsClosureFunction()) return false; 87 if (function.IsClosureFunction()) return false;
75 // Can occur because of compile-all flag. 88 // Can occur because of compile-all flag.
76 if (function.is_external()) return false; 89 if (function.is_external()) return false;
77 return function.is_intrinsic(); 90 return function.is_intrinsic();
78 } 91 }
79 92
80 93
81 void Intrinsifier::InitializeState() { 94 void Intrinsifier::InitializeState() {
82 Library& lib = Library::Handle(); 95 Library& lib = Library::Handle();
83 Class& cls = Class::Handle(); 96 Class& cls = Class::Handle();
84 Function& func = Function::Handle(); 97 Function& func = Function::Handle();
85 String& str = String::Handle(); 98 String& str = String::Handle();
86 99
87 #define SETUP_FUNCTION(class_name, function_name, destination, fp) \ 100 #define SETUP_FUNCTION(class_name, function_name, destination, fp) \
88 if (strcmp(#class_name, "::") == 0) { \ 101 if (strcmp(#class_name, "::") == 0) { \
89 str = String::New(#function_name); \ 102 str = String::New(#function_name); \
90 func = lib.LookupFunctionAllowPrivate(str); \ 103 func = lib.LookupFunctionAllowPrivate(str); \
91 } else { \ 104 } else { \
92 str = String::New(#class_name); \ 105 str = String::New(#class_name); \
93 cls = lib.LookupClassAllowPrivate(str); \ 106 cls = lib.LookupClassAllowPrivate(str); \
94 ASSERT(!cls.IsNull()); \ 107 ASSERT(!cls.IsNull()); \
95 str = String::New(#function_name); \ 108 if (#function_name[0] == '.') { \
109 str = String::New(#class_name#function_name); \
110 } else { \
111 str = String::New(#function_name); \
112 } \
96 func = cls.LookupFunctionAllowPrivate(str); \ 113 func = cls.LookupFunctionAllowPrivate(str); \
97 } \ 114 } \
98 ASSERT(!func.IsNull()); \ 115 ASSERT(!func.IsNull()); \
99 func.set_is_intrinsic(true); \ 116 func.set_is_intrinsic(true); \
100 117
101 // Set up all core lib functions that can be intrisified. 118 // Set up all core lib functions that can be intrisified.
102 lib = Library::CoreLibrary(); 119 lib = Library::CoreLibrary();
103 CORE_LIB_INTRINSIC_LIST(SETUP_FUNCTION); 120 CORE_LIB_INTRINSIC_LIST(SETUP_FUNCTION);
104 121
105 // Set up all math lib functions that can be intrisified. 122 // Set up all math lib functions that can be intrisified.
(...skipping 30 matching lines...) Expand all
136 SCALARLIST_LIB_INTRINSIC_LIST(FIND_INTRINSICS); 153 SCALARLIST_LIB_INTRINSIC_LIST(FIND_INTRINSICS);
137 } else if (lib.raw() == Library::MathLibrary()) { 154 } else if (lib.raw() == Library::MathLibrary()) {
138 MATH_LIB_INTRINSIC_LIST(FIND_INTRINSICS); 155 MATH_LIB_INTRINSIC_LIST(FIND_INTRINSICS);
139 } 156 }
140 return false; 157 return false;
141 158
142 #undef FIND_INTRINSICS 159 #undef FIND_INTRINSICS
143 } 160 }
144 161
145 } // namespace dart 162 } // namespace dart
OLDNEW
« no previous file with comments | « vm/intrinsifier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698