Chromium Code Reviews| 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 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| 12 DEFINE_FLAG(bool, intrinsify, true, "Instrinsify when possible"); | 12 DEFINE_FLAG(bool, intrinsify, true, "Instrinsify when possible"); |
| 13 | 13 |
| 14 | 14 |
| 15 static bool CompareNames(const char* test_name, const char* name) { | 15 static bool CompareNames(const char* test_name, const char* name) { |
| 16 if (strcmp(test_name, name) == 0) { | 16 static const intptr_t kPrefixLength = 5; |
| 17 static const char* kGetterPrefix = "get:_"; | |
| 18 static const char* kSetterPrefix = "set:_"; | |
|
Florian Schneider
2013/01/07 13:15:48
I'd define those in one place and remove kPrefixLe
Vyacheslav Egorov (Google)
2013/01/07 15:02:47
I renamed & started to use strlen.
I am however
| |
| 19 | |
| 20 if (test_name[0] == '_') { | |
| 21 if (name[0] != '_') { | |
| 22 return false; | |
| 23 } | |
| 24 } else if (strncmp(test_name, kGetterPrefix, kPrefixLength) == 0) { | |
| 25 if (strncmp(name, kGetterPrefix, kPrefixLength) != 0) { | |
| 26 return false; | |
| 27 } | |
| 28 } else if (strncmp(test_name, kSetterPrefix, kPrefixLength) == 0) { | |
| 29 if (strncmp(name, kSetterPrefix, kPrefixLength) != 0) { | |
| 30 return false; | |
| 31 } | |
| 32 } else { | |
| 33 return (strcmp(test_name, name) == 0); | |
| 34 } | |
| 35 | |
| 36 // Check if the private class is member of core or scalarlist and matches | |
| 37 // the test_class_name. | |
| 38 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | |
| 39 const Library& scalarlist_lib = | |
| 40 Library::Handle(Library::ScalarlistLibrary()); | |
| 41 String& test_str = String::Handle(String::New(test_name)); | |
| 42 String& test_str_with_key = String::Handle(); | |
| 43 test_str_with_key = | |
| 44 String::Concat(test_str, String::Handle(core_lib.private_key())); | |
| 45 if (strcmp(test_str_with_key.ToCString(), name) == 0) { | |
| 17 return true; | 46 return true; |
| 18 } | 47 } |
| 19 if ((name[0] == '_') && (test_name[0] == '_')) { | 48 test_str_with_key = |
| 20 // Check if the private class is member of core or scalarlist and matches | 49 String::Concat(test_str, String::Handle(scalarlist_lib.private_key())); |
| 21 // the test_class_name. | 50 if (strcmp(test_str_with_key.ToCString(), name) == 0) { |
| 22 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 51 return true; |
| 23 const Library& scalarlist_lib = | |
| 24 Library::Handle(Library::ScalarlistLibrary()); | |
| 25 String& test_str = String::Handle(String::New(test_name)); | |
| 26 String& test_str_with_key = String::Handle(); | |
| 27 test_str_with_key = | |
| 28 String::Concat(test_str, String::Handle(core_lib.private_key())); | |
| 29 if (strcmp(test_str_with_key.ToCString(), name) == 0) { | |
| 30 return true; | |
| 31 } | |
| 32 test_str_with_key = | |
| 33 String::Concat(test_str, String::Handle(scalarlist_lib.private_key())); | |
| 34 if (strcmp(test_str_with_key.ToCString(), name) == 0) { | |
| 35 return true; | |
| 36 } | |
| 37 } | 52 } |
| 53 | |
| 38 return false; | 54 return false; |
| 39 } | 55 } |
| 40 | 56 |
| 41 | 57 |
| 42 // Returns true if the function matches function_name and class_name, with | 58 // Returns true if the function matches function_name and class_name, with |
| 43 // special recognition of corelib private classes. | 59 // special recognition of corelib private classes. |
| 44 static bool TestFunction(const Function& function, | 60 static bool TestFunction(const Function& function, |
| 45 const char* function_class_name, | 61 const char* function_class_name, |
| 46 const char* function_name, | 62 const char* function_name, |
| 47 const char* test_class_name, | 63 const char* test_class_name, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 ASSERT(function.CheckSourceFingerprint(fp)); \ | 122 ASSERT(function.CheckSourceFingerprint(fp)); \ |
| 107 return destination(assembler); \ | 123 return destination(assembler); \ |
| 108 } \ | 124 } \ |
| 109 | 125 |
| 110 INTRINSIC_LIST(FIND_INTRINSICS); | 126 INTRINSIC_LIST(FIND_INTRINSICS); |
| 111 #undef FIND_INTRINSICS | 127 #undef FIND_INTRINSICS |
| 112 return false; | 128 return false; |
| 113 } | 129 } |
| 114 | 130 |
| 115 } // namespace dart | 131 } // namespace dart |
| OLD | NEW |