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 // Class for intrinsifying functions. | 4 // Class for intrinsifying functions. |
5 | 5 |
6 #include "vm/assembler.h" | 6 #include "vm/assembler.h" |
7 #include "vm/intrinsifier.h" | 7 #include "vm/intrinsifier.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } else { \ | 118 } else { \ |
119 str = String::New(#function_name); \ | 119 str = String::New(#function_name); \ |
120 } \ | 120 } \ |
121 func = cls.LookupFunctionAllowPrivate(str); \ | 121 func = cls.LookupFunctionAllowPrivate(str); \ |
122 } \ | 122 } \ |
123 ASSERT(!func.IsNull()); \ | 123 ASSERT(!func.IsNull()); \ |
124 func.set_is_intrinsic(true); | 124 func.set_is_intrinsic(true); |
125 | 125 |
126 // Set up all core lib functions that can be intrisified. | 126 // Set up all core lib functions that can be intrisified. |
127 lib = Library::CoreLibrary(); | 127 lib = Library::CoreLibrary(); |
| 128 ASSERT(!lib.IsNull()); |
128 CORE_LIB_INTRINSIC_LIST(SETUP_FUNCTION); | 129 CORE_LIB_INTRINSIC_LIST(SETUP_FUNCTION); |
129 | 130 |
130 // Integer intrinsics are in the core library, but we don't want to intrinsify | 131 // Integer intrinsics are in the core library, but we don't want to intrinsify |
131 // when Smi > 32 bits if we are looking for javascript integer overflow. | 132 // when Smi > 32 bits if we are looking for javascript integer overflow. |
132 if (!FLAG_throw_on_javascript_int_overflow || (Smi::kBits < 32)) { | 133 if (!FLAG_throw_on_javascript_int_overflow || (Smi::kBits < 32)) { |
133 CORE_INTEGER_LIB_INTRINSIC_LIST(SETUP_FUNCTION); | 134 CORE_INTEGER_LIB_INTRINSIC_LIST(SETUP_FUNCTION); |
134 } | 135 } |
135 | 136 |
136 // Set up all math lib functions that can be intrisified. | 137 // Set up all math lib functions that can be intrisified. |
137 lib = Library::MathLibrary(); | 138 lib = Library::MathLibrary(); |
| 139 ASSERT(!lib.IsNull()); |
138 MATH_LIB_INTRINSIC_LIST(SETUP_FUNCTION); | 140 MATH_LIB_INTRINSIC_LIST(SETUP_FUNCTION); |
139 | 141 |
140 // Set up all dart:typed_data lib functions that can be intrisified. | 142 // Set up all dart:typed_data lib functions that can be intrisified. |
141 lib = Library::TypedDataLibrary(); | 143 lib = Library::TypedDataLibrary(); |
| 144 ASSERT(!lib.IsNull()); |
142 TYPED_DATA_LIB_INTRINSIC_LIST(SETUP_FUNCTION); | 145 TYPED_DATA_LIB_INTRINSIC_LIST(SETUP_FUNCTION); |
143 | 146 |
| 147 // Setup all dart:profiler lib functions that can be intrinsified. |
| 148 lib = Library::ProfilerLibrary(); |
| 149 ASSERT(!lib.IsNull()); |
| 150 PROFILER_LIB_INTRINSIC_LIST(SETUP_FUNCTION); |
| 151 |
144 #undef SETUP_FUNCTION | 152 #undef SETUP_FUNCTION |
145 } | 153 } |
146 | 154 |
147 | 155 |
148 void Intrinsifier::Intrinsify(const Function& function, Assembler* assembler) { | 156 void Intrinsifier::Intrinsify(const Function& function, Assembler* assembler) { |
149 if (!CanIntrinsify(function)) return; | 157 if (!CanIntrinsify(function)) return; |
150 | 158 |
151 const char* function_name = String::Handle(function.name()).ToCString(); | 159 const char* function_name = String::Handle(function.name()).ToCString(); |
152 const Class& function_class = Class::Handle(function.Owner()); | 160 const Class& function_class = Class::Handle(function.Owner()); |
153 const char* class_name = String::Handle(function_class.Name()).ToCString(); | 161 const char* class_name = String::Handle(function_class.Name()).ToCString(); |
(...skipping 11 matching lines...) Expand all Loading... |
165 | 173 |
166 if (lib.raw() == Library::CoreLibrary()) { | 174 if (lib.raw() == Library::CoreLibrary()) { |
167 CORE_LIB_INTRINSIC_LIST(FIND_INTRINSICS); | 175 CORE_LIB_INTRINSIC_LIST(FIND_INTRINSICS); |
168 if (!FLAG_throw_on_javascript_int_overflow || (Smi::kBits < 32)) { | 176 if (!FLAG_throw_on_javascript_int_overflow || (Smi::kBits < 32)) { |
169 CORE_INTEGER_LIB_INTRINSIC_LIST(FIND_INTRINSICS); | 177 CORE_INTEGER_LIB_INTRINSIC_LIST(FIND_INTRINSICS); |
170 } | 178 } |
171 } else if (lib.raw() == Library::TypedDataLibrary()) { | 179 } else if (lib.raw() == Library::TypedDataLibrary()) { |
172 TYPED_DATA_LIB_INTRINSIC_LIST(FIND_INTRINSICS); | 180 TYPED_DATA_LIB_INTRINSIC_LIST(FIND_INTRINSICS); |
173 } else if (lib.raw() == Library::MathLibrary()) { | 181 } else if (lib.raw() == Library::MathLibrary()) { |
174 MATH_LIB_INTRINSIC_LIST(FIND_INTRINSICS); | 182 MATH_LIB_INTRINSIC_LIST(FIND_INTRINSICS); |
| 183 } else if (lib.raw() == Library::ProfilerLibrary()) { |
| 184 PROFILER_LIB_INTRINSIC_LIST(FIND_INTRINSICS); |
175 } | 185 } |
176 #undef FIND_INTRINSICS | 186 #undef FIND_INTRINSICS |
177 } | 187 } |
178 | 188 |
179 } // namespace dart | 189 } // namespace dart |
OLD | NEW |