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

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

Issue 11365196: Move JSSyntaxRegExp to core as a private member. This removes the last refrences to dart:coreimpl. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix two pending TODO's. Created 8 years, 1 month 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
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 if (strcmp(test_name, name) == 0) {
17 return true; 17 return true;
18 } 18 }
19 if ((name[0] == '_') && (test_name[0] == '_')) { 19 if ((name[0] == '_') && (test_name[0] == '_')) {
20 // Check if the private class is member of core, coreimpl or 20 // Check if the private class is member of core or scalarlist and matches
21 // scalarlist and matches the test_class_name. 21 // the test_class_name.
22 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 22 const Library& core_lib = Library::Handle(Library::CoreLibrary());
23 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary());
24 const Library& scalarlist_lib = 23 const Library& scalarlist_lib =
25 Library::Handle(Library::ScalarlistLibrary()); 24 Library::Handle(Library::ScalarlistLibrary());
26 String& test_str = String::Handle(String::New(test_name)); 25 String& test_str = String::Handle(String::New(test_name));
27 String& test_str_with_key = String::Handle(); 26 String& test_str_with_key = String::Handle();
28 test_str_with_key = 27 test_str_with_key =
29 String::Concat(test_str, String::Handle(core_lib.private_key())); 28 String::Concat(test_str, String::Handle(core_lib.private_key()));
30 if (strcmp(test_str_with_key.ToCString(), name) == 0) { 29 if (strcmp(test_str_with_key.ToCString(), name) == 0) {
31 return true; 30 return true;
32 } 31 }
33 test_str_with_key = 32 test_str_with_key =
34 String::Concat(test_str, String::Handle(core_impl_lib.private_key()));
35 if (strcmp(test_str_with_key.ToCString(), name) == 0) {
36 return true;
37 }
38 test_str_with_key =
39 String::Concat(test_str, String::Handle(scalarlist_lib.private_key())); 33 String::Concat(test_str, String::Handle(scalarlist_lib.private_key()));
40 if (strcmp(test_str_with_key.ToCString(), name) == 0) { 34 if (strcmp(test_str_with_key.ToCString(), name) == 0) {
41 return true; 35 return true;
42 } 36 }
43 } 37 }
44 return false; 38 return false;
Ivan Posva 2012/11/13 18:26:28 How does this differ from the code above?
Anders Johnsen 2012/11/13 18:40:26 Bad merge.
45 } 39 }
46 40
47 41
48 // Returns true if the function matches function_name and class_name, with 42 // Returns true if the function matches function_name and class_name, with
49 // special recognition of corelib private classes. 43 // special recognition of corelib private classes.
50 static bool TestFunction(const Function& function, 44 static bool TestFunction(const Function& function,
51 const char* function_class_name, 45 const char* function_class_name,
52 const char* function_name, 46 const char* function_name,
53 const char* test_class_name, 47 const char* test_class_name,
54 const char* test_function_name) { 48 const char* test_function_name) {
(...skipping 16 matching lines...) Expand all
71 if (!FLAG_intrinsify) return false; 65 if (!FLAG_intrinsify) return false;
72 if (function.IsClosureFunction()) return false; 66 if (function.IsClosureFunction()) return false;
73 // Intrinsic kind is set lazily below. 67 // Intrinsic kind is set lazily below.
74 if (function.intrinsic_kind() == Function::kIsIntrinsic) return true; 68 if (function.intrinsic_kind() == Function::kIsIntrinsic) return true;
75 if (function.intrinsic_kind() == Function::kIsNotIntrinsic) return false; 69 if (function.intrinsic_kind() == Function::kIsNotIntrinsic) return false;
76 // Closure functions may have different arguments. 70 // Closure functions may have different arguments.
77 const char* function_name = String::Handle(function.name()).ToCString(); 71 const char* function_name = String::Handle(function.name()).ToCString();
78 const Class& function_class = Class::Handle(function.Owner()); 72 const Class& function_class = Class::Handle(function.Owner());
79 // Only core, math and scalarlist library methods can be intrinsified. 73 // Only core, math and scalarlist library methods can be intrinsified.
80 if ((function_class.library() != Library::CoreLibrary()) && 74 if ((function_class.library() != Library::CoreLibrary()) &&
81 (function_class.library() != Library::CoreImplLibrary()) &&
82 (function_class.library() != Library::MathLibrary()) && 75 (function_class.library() != Library::MathLibrary()) &&
83 (function_class.library() != Library::ScalarlistLibrary())) { 76 (function_class.library() != Library::ScalarlistLibrary())) {
84 return false; 77 return false;
85 } 78 }
86 const char* class_name = String::Handle(function_class.Name()).ToCString(); 79 const char* class_name = String::Handle(function_class.Name()).ToCString();
87 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \ 80 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \
88 if (TestFunction(function, \ 81 if (TestFunction(function, \
89 class_name, function_name, \ 82 class_name, function_name, \
90 #test_class_name, #test_function_name)) { \ 83 #test_class_name, #test_function_name)) { \
91 function.set_intrinsic_kind(Function::kIsIntrinsic); \ 84 function.set_intrinsic_kind(Function::kIsIntrinsic); \
(...skipping 17 matching lines...) Expand all
109 #test_class_name, #test_function_name)) { \ 102 #test_class_name, #test_function_name)) { \
110 return destination(assembler); \ 103 return destination(assembler); \
111 } \ 104 } \
112 105
113 INTRINSIC_LIST(FIND_INTRINSICS); 106 INTRINSIC_LIST(FIND_INTRINSICS);
114 #undef FIND_INTRINSICS 107 #undef FIND_INTRINSICS
115 return false; 108 return false;
116 } 109 }
117 110
118 } // namespace dart 111 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698