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