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

Side by Side Diff: runtime/vm/intrinsifier.cc

Issue 11358047: Add is_intrinsic and is_not_intrinsic bits to prevent repeated tests on the same function (inlining… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 | « no previous file | runtime/vm/object.h » ('j') | 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 9
10 namespace dart { 10 namespace dart {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return false; 62 return false;
63 } 63 }
64 } 64 }
65 return CompareNames(test_class_name, function_class_name) && 65 return CompareNames(test_class_name, function_class_name) &&
66 CompareNames(test_function_name, function_name); 66 CompareNames(test_function_name, function_name);
67 } 67 }
68 68
69 69
70 bool Intrinsifier::CanIntrinsify(const Function& function) { 70 bool Intrinsifier::CanIntrinsify(const Function& function) {
71 if (!FLAG_intrinsify) return false; 71 if (!FLAG_intrinsify) return false;
72 if (function.IsClosureFunction()) return false;
73 // Intrinsic kind is set lazily below.
74 if (function.intrinsic_kind() == Function::kIsIntrinsic) return true;
75 if (function.intrinsic_kind() == Function::kIsNotIntrinsic) return false;
72 // Closure functions may have different arguments. 76 // Closure functions may have different arguments.
73 if (function.IsClosureFunction()) return false;
74 const char* function_name = String::Handle(function.name()).ToCString(); 77 const char* function_name = String::Handle(function.name()).ToCString();
75 const Class& function_class = Class::Handle(function.Owner()); 78 const Class& function_class = Class::Handle(function.Owner());
76 const char* class_name = String::Handle(function_class.Name()).ToCString();
77 // Only core, math and scalarlist library methods can be intrinsified. 79 // Only core, math and scalarlist library methods can be intrinsified.
78 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 80 if ((function_class.library() != Library::CoreLibrary()) &&
79 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); 81 (function_class.library() != Library::CoreImplLibrary()) &&
80 const Library& math_lib = Library::Handle(Library::MathLibrary()); 82 (function_class.library() != Library::MathLibrary()) &&
81 const Library& scalarlist_lib = Library::Handle(Library::ScalarlistLibrary()); 83 (function_class.library() != Library::ScalarlistLibrary())) {
82 if ((function_class.library() != core_lib.raw()) &&
83 (function_class.library() != core_impl_lib.raw()) &&
84 (function_class.library() != math_lib.raw()) &&
85 (function_class.library() != scalarlist_lib.raw())) {
86 return false; 84 return false;
87 } 85 }
86 const char* class_name = String::Handle(function_class.Name()).ToCString();
88 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \ 87 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \
89 if (TestFunction(function, \ 88 if (TestFunction(function, \
90 class_name, function_name, \ 89 class_name, function_name, \
91 #test_class_name, #test_function_name)) { \ 90 #test_class_name, #test_function_name)) { \
91 function.set_intrinsic_kind(Function::kIsIntrinsic); \
92 return true; \ 92 return true; \
93 } \ 93 } \
94 94
95 INTRINSIC_LIST(FIND_INTRINSICS); 95 INTRINSIC_LIST(FIND_INTRINSICS);
96 #undef FIND_INTRINSICS 96 #undef FIND_INTRINSICS
97 function.set_intrinsic_kind(Function::kIsNotIntrinsic);
97 return false; 98 return false;
98 } 99 }
99 100
100 bool Intrinsifier::Intrinsify(const Function& function, Assembler* assembler) { 101 bool Intrinsifier::Intrinsify(const Function& function, Assembler* assembler) {
101 if (!CanIntrinsify(function)) return false; 102 if (!CanIntrinsify(function)) return false;
102 const char* function_name = String::Handle(function.name()).ToCString(); 103 const char* function_name = String::Handle(function.name()).ToCString();
103 const Class& function_class = Class::Handle(function.Owner()); 104 const Class& function_class = Class::Handle(function.Owner());
104 const char* class_name = String::Handle(function_class.Name()).ToCString(); 105 const char* class_name = String::Handle(function_class.Name()).ToCString();
105 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \ 106 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \
106 if (TestFunction(function, \ 107 if (TestFunction(function, \
107 class_name, function_name, \ 108 class_name, function_name, \
108 #test_class_name, #test_function_name)) { \ 109 #test_class_name, #test_function_name)) { \
109 return destination(assembler); \ 110 return destination(assembler); \
110 } \ 111 } \
111 112
112 INTRINSIC_LIST(FIND_INTRINSICS); 113 INTRINSIC_LIST(FIND_INTRINSICS);
113 #undef FIND_INTRINSICS 114 #undef FIND_INTRINSICS
114 return false; 115 return false;
115 } 116 }
116 117
117 } // namespace dart 118 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698