Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: runtime/vm/intrinsifier.cc

Issue 11779018: Fix Intrinsifier and MethodRecognizer to correctly match private getters and setters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address Florian's comments Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 char* kPrivateGetterPrefix = "get:_";
17 static const char* kPrivateSetterPrefix = "set:_";
18
19 if (test_name[0] == '_') {
20 if (name[0] != '_') {
21 return false;
22 }
23 } else if (strncmp(test_name,
24 kPrivateGetterPrefix,
25 strlen(kPrivateGetterPrefix)) == 0) {
26 if (strncmp(name,
27 kPrivateGetterPrefix,
28 strlen(kPrivateGetterPrefix)) != 0) {
29 return false;
30 }
31 } else if (strncmp(test_name,
32 kPrivateSetterPrefix,
33 strlen(kPrivateSetterPrefix)) == 0) {
34 if (strncmp(name,
35 kPrivateSetterPrefix,
36 strlen(kPrivateSetterPrefix)) != 0) {
37 return false;
38 }
39 } else {
40 return (strcmp(test_name, name) == 0);
41 }
42
43 // Check if the private class is member of core or scalarlist and matches
44 // the test_class_name.
45 const Library& core_lib = Library::Handle(Library::CoreLibrary());
46 const Library& scalarlist_lib =
47 Library::Handle(Library::ScalarlistLibrary());
48 String& test_str = String::Handle(String::New(test_name));
49 String& test_str_with_key = String::Handle();
50 test_str_with_key =
51 String::Concat(test_str, String::Handle(core_lib.private_key()));
52 if (strcmp(test_str_with_key.ToCString(), name) == 0) {
17 return true; 53 return true;
18 } 54 }
19 if ((name[0] == '_') && (test_name[0] == '_')) { 55 test_str_with_key =
20 // Check if the private class is member of core or scalarlist and matches 56 String::Concat(test_str, String::Handle(scalarlist_lib.private_key()));
21 // the test_class_name. 57 if (strcmp(test_str_with_key.ToCString(), name) == 0) {
22 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 58 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 } 59 }
60
38 return false; 61 return false;
39 } 62 }
40 63
41 64
42 // Returns true if the function matches function_name and class_name, with 65 // Returns true if the function matches function_name and class_name, with
43 // special recognition of corelib private classes. 66 // special recognition of corelib private classes.
44 static bool TestFunction(const Function& function, 67 static bool TestFunction(const Function& function,
45 const char* function_class_name, 68 const char* function_class_name,
46 const char* function_name, 69 const char* function_name,
47 const char* test_class_name, 70 const char* test_class_name,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 ASSERT(function.CheckSourceFingerprint(fp)); \ 129 ASSERT(function.CheckSourceFingerprint(fp)); \
107 return destination(assembler); \ 130 return destination(assembler); \
108 } \ 131 } \
109 132
110 INTRINSIC_LIST(FIND_INTRINSICS); 133 INTRINSIC_LIST(FIND_INTRINSICS);
111 #undef FIND_INTRINSICS 134 #undef FIND_INTRINSICS
112 return false; 135 return false;
113 } 136 }
114 137
115 } // namespace dart 138 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698