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

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

Issue 11421024: Use fingerprint to detect changes in methods that are intrinsified. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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/intrinsifier.h ('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 {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 } 58 }
59 return CompareNames(test_class_name, function_class_name) && 59 return CompareNames(test_class_name, function_class_name) &&
60 CompareNames(test_function_name, function_name); 60 CompareNames(test_function_name, function_name);
61 } 61 }
62 62
63 63
64 bool Intrinsifier::CanIntrinsify(const Function& function) { 64 bool Intrinsifier::CanIntrinsify(const Function& function) {
65 if (!FLAG_intrinsify) return false; 65 if (!FLAG_intrinsify) return false;
66 if (function.IsClosureFunction()) return false; 66 if (function.IsClosureFunction()) return false;
67 // Can occur because of compile-all flag.
68 if (function.is_external()) return false;
67 // Intrinsic kind is set lazily below. 69 // Intrinsic kind is set lazily below.
68 if (function.intrinsic_kind() == Function::kIsIntrinsic) return true; 70 if (function.intrinsic_kind() == Function::kIsIntrinsic) return true;
69 if (function.intrinsic_kind() == Function::kIsNotIntrinsic) return false; 71 if (function.intrinsic_kind() == Function::kIsNotIntrinsic) return false;
70 // Closure functions may have different arguments. 72 // Closure functions may have different arguments.
71 const char* function_name = String::Handle(function.name()).ToCString(); 73 const char* function_name = String::Handle(function.name()).ToCString();
72 const Class& function_class = Class::Handle(function.Owner()); 74 const Class& function_class = Class::Handle(function.Owner());
73 // Only core, math and scalarlist library methods can be intrinsified. 75 // Only core, math and scalarlist library methods can be intrinsified.
74 if ((function_class.library() != Library::CoreLibrary()) && 76 if ((function_class.library() != Library::CoreLibrary()) &&
75 (function_class.library() != Library::MathLibrary()) && 77 (function_class.library() != Library::MathLibrary()) &&
76 (function_class.library() != Library::ScalarlistLibrary())) { 78 (function_class.library() != Library::ScalarlistLibrary())) {
77 return false; 79 return false;
78 } 80 }
79 const char* class_name = String::Handle(function_class.Name()).ToCString(); 81 const char* class_name = String::Handle(function_class.Name()).ToCString();
80 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \ 82 #define FIND_INTRINSICS(test_class_name, test_function_name, destination, fp) \
81 if (TestFunction(function, \ 83 if (TestFunction(function, \
82 class_name, function_name, \ 84 class_name, function_name, \
83 #test_class_name, #test_function_name)) { \ 85 #test_class_name, #test_function_name)) { \
84 function.set_intrinsic_kind(Function::kIsIntrinsic); \ 86 function.set_intrinsic_kind(Function::kIsIntrinsic); \
85 return true; \ 87 return true; \
86 } \ 88 } \
87 89
88 INTRINSIC_LIST(FIND_INTRINSICS); 90 INTRINSIC_LIST(FIND_INTRINSICS);
89 #undef FIND_INTRINSICS 91 #undef FIND_INTRINSICS
90 function.set_intrinsic_kind(Function::kIsNotIntrinsic); 92 function.set_intrinsic_kind(Function::kIsNotIntrinsic);
91 return false; 93 return false;
92 } 94 }
93 95
96
97 static bool CheckFingerprint(const Function& function, intptr_t fp) {
98 if (function.SourceFingerprint() != fp) {
99 OS::Print("FP mismatch while intrinsifying %s:"
100 " expecting %"Pd" found %d\n",
101 function.ToFullyQualifiedCString(),
102 fp,
103 function.SourceFingerprint());
104 return false;
105 }
106 return true;
107 }
108
109
94 bool Intrinsifier::Intrinsify(const Function& function, Assembler* assembler) { 110 bool Intrinsifier::Intrinsify(const Function& function, Assembler* assembler) {
95 if (!CanIntrinsify(function)) return false; 111 if (!CanIntrinsify(function)) return false;
96 const char* function_name = String::Handle(function.name()).ToCString(); 112 const char* function_name = String::Handle(function.name()).ToCString();
97 const Class& function_class = Class::Handle(function.Owner()); 113 const Class& function_class = Class::Handle(function.Owner());
98 const char* class_name = String::Handle(function_class.Name()).ToCString(); 114 const char* class_name = String::Handle(function_class.Name()).ToCString();
99 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \ 115 #define FIND_INTRINSICS(test_class_name, test_function_name, destination, fp) \
100 if (TestFunction(function, \ 116 if (TestFunction(function, \
101 class_name, function_name, \ 117 class_name, function_name, \
102 #test_class_name, #test_function_name)) { \ 118 #test_class_name, #test_function_name)) { \
119 ASSERT(CheckFingerprint(function, fp)); \
103 return destination(assembler); \ 120 return destination(assembler); \
104 } \ 121 } \
105 122
106 INTRINSIC_LIST(FIND_INTRINSICS); 123 INTRINSIC_LIST(FIND_INTRINSICS);
107 #undef FIND_INTRINSICS 124 #undef FIND_INTRINSICS
108 return false; 125 return false;
109 } 126 }
110 127
111 } // namespace dart 128 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698