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

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') | runtime/vm/object.h » ('J')
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 // Intrinsic kind is set lazily below.
73 if (function.intrinsic_kind() == Function::kIsIntrinsic) return true;
74 if (function.intrinsic_kind() == Function::kIsNotIntrinsic) return false;
72 // Closure functions may have different arguments. 75 // Closure functions may have different arguments.
73 if (function.IsClosureFunction()) return false; 76 if (function.IsClosureFunction()) return false;
siva 2012/11/01 23:04:06 Should we do the closure function check first beca
srdjan 2012/11/01 23:08:18 Done.
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(); 79 const char* class_name = String::Handle(function_class.Name()).ToCString();
77 // Only core, math and scalarlist library methods can be intrinsified. 80 // Only core, math and scalarlist library methods can be intrinsified.
78 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 81 const Library& core_lib = Library::Handle(Library::CoreLibrary());
79 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); 82 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary());
80 const Library& math_lib = Library::Handle(Library::MathLibrary()); 83 const Library& math_lib = Library::Handle(Library::MathLibrary());
81 const Library& scalarlist_lib = Library::Handle(Library::ScalarlistLibrary()); 84 const Library& scalarlist_lib = Library::Handle(Library::ScalarlistLibrary());
82 if ((function_class.library() != core_lib.raw()) && 85 if ((function_class.library() != core_lib.raw()) &&
83 (function_class.library() != core_impl_lib.raw()) && 86 (function_class.library() != core_impl_lib.raw()) &&
84 (function_class.library() != math_lib.raw()) && 87 (function_class.library() != math_lib.raw()) &&
85 (function_class.library() != scalarlist_lib.raw())) { 88 (function_class.library() != scalarlist_lib.raw())) {
86 return false; 89 return false;
87 } 90 }
siva 2012/11/01 23:04:06 Not related to your current change I was wondering
srdjan 2012/11/01 23:08:18 Done.
88 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \ 91 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \
89 if (TestFunction(function, \ 92 if (TestFunction(function, \
90 class_name, function_name, \ 93 class_name, function_name, \
91 #test_class_name, #test_function_name)) { \ 94 #test_class_name, #test_function_name)) { \
95 function.set_intrinsic_kind(Function::kIsIntrinsic); \
92 return true; \ 96 return true; \
93 } \ 97 } \
94 98
95 INTRINSIC_LIST(FIND_INTRINSICS); 99 INTRINSIC_LIST(FIND_INTRINSICS);
96 #undef FIND_INTRINSICS 100 #undef FIND_INTRINSICS
101 function.set_intrinsic_kind(Function::kIsNotIntrinsic);
97 return false; 102 return false;
98 } 103 }
99 104
100 bool Intrinsifier::Intrinsify(const Function& function, Assembler* assembler) { 105 bool Intrinsifier::Intrinsify(const Function& function, Assembler* assembler) {
101 if (!CanIntrinsify(function)) return false; 106 if (!CanIntrinsify(function)) return false;
102 const char* function_name = String::Handle(function.name()).ToCString(); 107 const char* function_name = String::Handle(function.name()).ToCString();
103 const Class& function_class = Class::Handle(function.Owner()); 108 const Class& function_class = Class::Handle(function.Owner());
104 const char* class_name = String::Handle(function_class.Name()).ToCString(); 109 const char* class_name = String::Handle(function_class.Name()).ToCString();
105 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \ 110 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \
106 if (TestFunction(function, \ 111 if (TestFunction(function, \
107 class_name, function_name, \ 112 class_name, function_name, \
108 #test_class_name, #test_function_name)) { \ 113 #test_class_name, #test_function_name)) { \
109 return destination(assembler); \ 114 return destination(assembler); \
110 } \ 115 } \
111 116
112 INTRINSIC_LIST(FIND_INTRINSICS); 117 INTRINSIC_LIST(FIND_INTRINSICS);
113 #undef FIND_INTRINSICS 118 #undef FIND_INTRINSICS
114 return false; 119 return false;
115 } 120 }
116 121
117 } // namespace dart 122 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | runtime/vm/object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698