| 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 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 DEFINE_FLAG(bool, intrinsify, true, "Instrinsify when possible"); | 13 DEFINE_FLAG(bool, intrinsify, true, "Instrinsify when possible"); |
| 14 | 14 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); |
| 15 | 15 |
| 16 static bool CompareNames(const Library& lib, | 16 static bool CompareNames(const Library& lib, |
| 17 const char* test_name, | 17 const char* test_name, |
| 18 const char* name) { | 18 const char* name) { |
| 19 static const char* kPrivateGetterPrefix = "get:_"; | 19 static const char* kPrivateGetterPrefix = "get:_"; |
| 20 static const char* kPrivateSetterPrefix = "set:_"; | 20 static const char* kPrivateSetterPrefix = "set:_"; |
| 21 | 21 |
| 22 if (test_name[0] == '_') { | 22 if (test_name[0] == '_') { |
| 23 if (name[0] != '_') { | 23 if (name[0] != '_') { |
| 24 return false; | 24 return false; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 return CompareNames(lib, test_class_name, function_class_name) && | 80 return CompareNames(lib, test_class_name, function_class_name) && |
| 81 CompareNames(lib, test_function_name, function_name); | 81 CompareNames(lib, test_function_name, function_name); |
| 82 } | 82 } |
| 83 | 83 |
| 84 | 84 |
| 85 bool Intrinsifier::CanIntrinsify(const Function& function) { | 85 bool Intrinsifier::CanIntrinsify(const Function& function) { |
| 86 if (!FLAG_intrinsify) return false; | 86 if (!FLAG_intrinsify) return false; |
| 87 if (function.IsClosureFunction()) return false; | 87 if (function.IsClosureFunction()) return false; |
| 88 // Can occur because of compile-all flag. | 88 // Can occur because of compile-all flag. |
| 89 if (function.is_external()) return false; | 89 if (function.is_external()) return false; |
| 90 if (FLAG_throw_on_javascript_int_overflow) return false; |
| 90 return function.is_intrinsic(); | 91 return function.is_intrinsic(); |
| 91 } | 92 } |
| 92 | 93 |
| 93 | 94 |
| 94 void Intrinsifier::InitializeState() { | 95 void Intrinsifier::InitializeState() { |
| 95 Isolate* isolate = Isolate::Current(); | 96 Isolate* isolate = Isolate::Current(); |
| 96 Library& lib = Library::Handle(isolate); | 97 Library& lib = Library::Handle(isolate); |
| 97 Class& cls = Class::Handle(isolate); | 98 Class& cls = Class::Handle(isolate); |
| 98 Function& func = Function::Handle(isolate); | 99 Function& func = Function::Handle(isolate); |
| 99 String& str = String::Handle(isolate); | 100 String& str = String::Handle(isolate); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 TYPED_DATA_LIB_INTRINSIC_LIST(FIND_INTRINSICS); | 158 TYPED_DATA_LIB_INTRINSIC_LIST(FIND_INTRINSICS); |
| 158 } else if (lib.raw() == Library::MathLibrary()) { | 159 } else if (lib.raw() == Library::MathLibrary()) { |
| 159 MATH_LIB_INTRINSIC_LIST(FIND_INTRINSICS); | 160 MATH_LIB_INTRINSIC_LIST(FIND_INTRINSICS); |
| 160 } | 161 } |
| 161 return false; | 162 return false; |
| 162 | 163 |
| 163 #undef FIND_INTRINSICS | 164 #undef FIND_INTRINSICS |
| 164 } | 165 } |
| 165 | 166 |
| 166 } // namespace dart | 167 } // namespace dart |
| OLD | NEW |