| 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/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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 func.set_is_intrinsic(true); \ | 116 func.set_is_intrinsic(true); \ |
| 117 | 117 |
| 118 // Set up all core lib functions that can be intrisified. | 118 // Set up all core lib functions that can be intrisified. |
| 119 lib = Library::CoreLibrary(); | 119 lib = Library::CoreLibrary(); |
| 120 CORE_LIB_INTRINSIC_LIST(SETUP_FUNCTION); | 120 CORE_LIB_INTRINSIC_LIST(SETUP_FUNCTION); |
| 121 | 121 |
| 122 // Set up all math lib functions that can be intrisified. | 122 // Set up all math lib functions that can be intrisified. |
| 123 lib = Library::MathLibrary(); | 123 lib = Library::MathLibrary(); |
| 124 MATH_LIB_INTRINSIC_LIST(SETUP_FUNCTION); | 124 MATH_LIB_INTRINSIC_LIST(SETUP_FUNCTION); |
| 125 | 125 |
| 126 // Set up all dart:typeddata lib functions that can be intrisified. | 126 // Set up all dart:typed_data lib functions that can be intrisified. |
| 127 lib = Library::TypedDataLibrary(); | 127 lib = Library::TypedDataLibrary(); |
| 128 TYPEDDATA_LIB_INTRINSIC_LIST(SETUP_FUNCTION); | 128 TYPED_DATA_LIB_INTRINSIC_LIST(SETUP_FUNCTION); |
| 129 | 129 |
| 130 #undef SETUP_FUNCTION | 130 #undef SETUP_FUNCTION |
| 131 } | 131 } |
| 132 | 132 |
| 133 | 133 |
| 134 bool Intrinsifier::Intrinsify(const Function& function, Assembler* assembler) { | 134 bool Intrinsifier::Intrinsify(const Function& function, Assembler* assembler) { |
| 135 if (!CanIntrinsify(function)) return false; | 135 if (!CanIntrinsify(function)) return false; |
| 136 | 136 |
| 137 const char* function_name = String::Handle(function.name()).ToCString(); | 137 const char* function_name = String::Handle(function.name()).ToCString(); |
| 138 const Class& function_class = Class::Handle(function.Owner()); | 138 const Class& function_class = Class::Handle(function.Owner()); |
| 139 const char* class_name = String::Handle(function_class.Name()).ToCString(); | 139 const char* class_name = String::Handle(function_class.Name()).ToCString(); |
| 140 const Library& lib = Library::Handle(function_class.library()); | 140 const Library& lib = Library::Handle(function_class.library()); |
| 141 | 141 |
| 142 #define FIND_INTRINSICS(test_class_name, test_function_name, destination, fp) \ | 142 #define FIND_INTRINSICS(test_class_name, test_function_name, destination, fp) \ |
| 143 if (TestFunction(lib, function, \ | 143 if (TestFunction(lib, function, \ |
| 144 class_name, function_name, \ | 144 class_name, function_name, \ |
| 145 #test_class_name, #test_function_name)) { \ | 145 #test_class_name, #test_function_name)) { \ |
| 146 ASSERT(function.CheckSourceFingerprint(fp)); \ | 146 ASSERT(function.CheckSourceFingerprint(fp)); \ |
| 147 return destination(assembler); \ | 147 return destination(assembler); \ |
| 148 } \ | 148 } \ |
| 149 | 149 |
| 150 if (lib.raw() == Library::CoreLibrary()) { | 150 if (lib.raw() == Library::CoreLibrary()) { |
| 151 CORE_LIB_INTRINSIC_LIST(FIND_INTRINSICS); | 151 CORE_LIB_INTRINSIC_LIST(FIND_INTRINSICS); |
| 152 } else if (lib.raw() == Library::TypedDataLibrary()) { | 152 } else if (lib.raw() == Library::TypedDataLibrary()) { |
| 153 TYPEDDATA_LIB_INTRINSIC_LIST(FIND_INTRINSICS); | 153 TYPED_DATA_LIB_INTRINSIC_LIST(FIND_INTRINSICS); |
| 154 } else if (lib.raw() == Library::MathLibrary()) { | 154 } else if (lib.raw() == Library::MathLibrary()) { |
| 155 MATH_LIB_INTRINSIC_LIST(FIND_INTRINSICS); | 155 MATH_LIB_INTRINSIC_LIST(FIND_INTRINSICS); |
| 156 } | 156 } |
| 157 return false; | 157 return false; |
| 158 | 158 |
| 159 #undef FIND_INTRINSICS | 159 #undef FIND_INTRINSICS |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace dart | 162 } // namespace dart |
| OLD | NEW |