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

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

Issue 10919267: Introduce a VM-only dart:scalarlist library for byte arrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move init call for scalarlist lib Created 8 years, 3 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/bootstrap_nocorelib.cc ('k') | runtime/vm/object.h » ('j') | 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 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 corelib and matches the 20 // Check if the private class is member of core, coreimpl or
21 // test_class_name. 21 // scalarlist and matches 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()); 23 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary());
24 const Library& scalarlist_lib =
25 Library::Handle(Library::ScalarlistLibrary());
24 String& test_str = String::Handle(String::New(test_name)); 26 String& test_str = String::Handle(String::New(test_name));
25 String& test_str_with_key = String::Handle(); 27 String& test_str_with_key = String::Handle();
26 test_str_with_key = 28 test_str_with_key =
27 String::Concat(test_str, String::Handle(core_lib.private_key())); 29 String::Concat(test_str, String::Handle(core_lib.private_key()));
28 if (strcmp(test_str_with_key.ToCString(), name) == 0) { 30 if (strcmp(test_str_with_key.ToCString(), name) == 0) {
29 return true; 31 return true;
30 } 32 }
31 test_str_with_key = 33 test_str_with_key =
32 String::Concat(test_str, String::Handle(core_impl_lib.private_key())); 34 String::Concat(test_str, String::Handle(core_impl_lib.private_key()));
33 if (strcmp(test_str_with_key.ToCString(), name) == 0) { 35 if (strcmp(test_str_with_key.ToCString(), name) == 0) {
34 return true; 36 return true;
35 } 37 }
38 test_str_with_key =
39 String::Concat(test_str, String::Handle(scalarlist_lib.private_key()));
40 if (strcmp(test_str_with_key.ToCString(), name) == 0) {
41 return true;
42 }
36 } 43 }
37 return false; 44 return false;
38 } 45 }
39 46
40 47
41 // Returns true if the function matches function_name and class_name, with 48 // Returns true if the function matches function_name and class_name, with
42 // special recognition of corelib private classes. 49 // special recognition of corelib private classes.
43 static bool TestFunction(const Function& function, 50 static bool TestFunction(const Function& function,
44 const char* function_class_name, 51 const char* function_class_name,
45 const char* function_name, 52 const char* function_name,
46 const char* test_class_name, 53 const char* test_class_name,
47 const char* test_function_name) { 54 const char* test_function_name) {
48 return CompareNames(test_class_name, function_class_name) && 55 return CompareNames(test_class_name, function_class_name) &&
49 CompareNames(test_function_name, function_name); 56 CompareNames(test_function_name, function_name);
50 } 57 }
51 58
52 59
53 bool Intrinsifier::CanIntrinsify(const Function& function) { 60 bool Intrinsifier::CanIntrinsify(const Function& function) {
54 if (!FLAG_intrinsify) return false; 61 if (!FLAG_intrinsify) return false;
55 // Closure functions may have different arguments. 62 // Closure functions may have different arguments.
56 if (function.IsClosureFunction()) return false; 63 if (function.IsClosureFunction()) return false;
57 const char* function_name = String::Handle(function.name()).ToCString(); 64 const char* function_name = String::Handle(function.name()).ToCString();
58 const Class& function_class = Class::Handle(function.Owner()); 65 const Class& function_class = Class::Handle(function.Owner());
59 const char* class_name = String::Handle(function_class.Name()).ToCString(); 66 const char* class_name = String::Handle(function_class.Name()).ToCString();
60 // Only core and math library methods can be intrinsified. 67 // Only core, math and scalarlist library methods can be intrinsified.
61 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 68 const Library& core_lib = Library::Handle(Library::CoreLibrary());
62 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); 69 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary());
63 const Library& math_lib = Library::Handle(Library::MathLibrary()); 70 const Library& math_lib = Library::Handle(Library::MathLibrary());
71 const Library& scalarlist_lib = Library::Handle(Library::ScalarlistLibrary());
64 if ((function_class.library() != core_lib.raw()) && 72 if ((function_class.library() != core_lib.raw()) &&
65 (function_class.library() != core_impl_lib.raw()) && 73 (function_class.library() != core_impl_lib.raw()) &&
66 (function_class.library() != math_lib.raw())) { 74 (function_class.library() != math_lib.raw()) &&
75 (function_class.library() != scalarlist_lib.raw())) {
67 return false; 76 return false;
68 } 77 }
69 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \ 78 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \
70 if (TestFunction(function, \ 79 if (TestFunction(function, \
71 class_name, function_name, \ 80 class_name, function_name, \
72 #test_class_name, #test_function_name)) { \ 81 #test_class_name, #test_function_name)) { \
73 return true; \ 82 return true; \
74 } \ 83 } \
75 84
76 INTRINSIC_LIST(FIND_INTRINSICS); 85 INTRINSIC_LIST(FIND_INTRINSICS);
(...skipping 12 matching lines...) Expand all
89 #test_class_name, #test_function_name)) { \ 98 #test_class_name, #test_function_name)) { \
90 return destination(assembler); \ 99 return destination(assembler); \
91 } \ 100 } \
92 101
93 INTRINSIC_LIST(FIND_INTRINSICS); 102 INTRINSIC_LIST(FIND_INTRINSICS);
94 #undef FIND_INTRINSICS 103 #undef FIND_INTRINSICS
95 return false; 104 return false;
96 } 105 }
97 106
98 } // namespace dart 107 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/bootstrap_nocorelib.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698