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

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

Issue 11412137: Reenable function source fingerprint checks. Added checks to MethodRecognizer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intrinsifier.cc » ('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 4
5 #include "vm/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/flow_graph_allocator.h" 9 #include "vm/flow_graph_allocator.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 const String& name) { 220 const String& name) {
221 // If both names are private mangle test_name before comparison. 221 // If both names are private mangle test_name before comparison.
222 if ((name.CharAt(0) == '_') && (test_name[0] == '_')) { 222 if ((name.CharAt(0) == '_') && (test_name[0] == '_')) {
223 const String& test_name_symbol = String::Handle(Symbols::New(test_name)); 223 const String& test_name_symbol = String::Handle(Symbols::New(test_name));
224 return String::Handle(lib.PrivateName(test_name_symbol)).Equals(name); 224 return String::Handle(lib.PrivateName(test_name_symbol)).Equals(name);
225 } 225 }
226 return name.Equals(test_name); 226 return name.Equals(test_name);
227 } 227 }
228 228
229 229
230 static bool CheckFingerprint(const Function& function, intptr_t fp) {
231 if (function.SourceFingerprint() != fp) {
232 OS::Print("FP mismatch while recogbnizing method %s:"
233 " expecting %"Pd" found %d\n",
234 function.ToFullyQualifiedCString(),
235 fp,
236 function.SourceFingerprint());
237 return false;
238 }
239 return true;
240 }
siva 2012/11/21 22:02:50 We could make this a static function in class Func
srdjan 2012/11/21 22:10:36 Done.
241
242
230 MethodRecognizer::Kind MethodRecognizer::RecognizeKind( 243 MethodRecognizer::Kind MethodRecognizer::RecognizeKind(
231 const Function& function) { 244 const Function& function) {
232 // Only core and math library methods can be recognized. 245 // Only core and math library methods can be recognized.
233 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 246 const Library& core_lib = Library::Handle(Library::CoreLibrary());
234 const Library& math_lib = Library::Handle(Library::MathLibrary()); 247 const Library& math_lib = Library::Handle(Library::MathLibrary());
235 const Class& function_class = Class::Handle(function.Owner()); 248 const Class& function_class = Class::Handle(function.Owner());
236 if ((function_class.library() != core_lib.raw()) && 249 if ((function_class.library() != core_lib.raw()) &&
237 (function_class.library() != math_lib.raw())) { 250 (function_class.library() != math_lib.raw())) {
238 return kUnknown; 251 return kUnknown;
239 } 252 }
240 const Library& lib = Library::Handle(function_class.library()); 253 const Library& lib = Library::Handle(function_class.library());
241 const String& function_name = String::Handle(function.name()); 254 const String& function_name = String::Handle(function.name());
242 const String& class_name = String::Handle(function_class.Name()); 255 const String& class_name = String::Handle(function_class.Name());
243 256
244 #define RECOGNIZE_FUNCTION(test_class_name, test_function_name, enum_name) \ 257 #define RECOGNIZE_FUNCTION(test_class_name, test_function_name, enum_name, fp) \
245 if (CompareNames(lib, #test_function_name, function_name) && \ 258 if (CompareNames(lib, #test_function_name, function_name) && \
246 CompareNames(lib, #test_class_name, class_name)) { \ 259 CompareNames(lib, #test_class_name, class_name)) { \
260 ASSERT(CheckFingerprint(function, fp)); \
247 return k##enum_name; \ 261 return k##enum_name; \
248 } 262 }
249 RECOGNIZED_LIST(RECOGNIZE_FUNCTION) 263 RECOGNIZED_LIST(RECOGNIZE_FUNCTION)
250 #undef RECOGNIZE_FUNCTION 264 #undef RECOGNIZE_FUNCTION
251 return kUnknown; 265 return kUnknown;
252 } 266 }
253 267
254 268
255 const char* MethodRecognizer::KindToCString(Kind kind) { 269 const char* MethodRecognizer::KindToCString(Kind kind) {
256 #define KIND_TO_STRING(class_name, function_name, enum_name) \ 270 #define KIND_TO_STRING(class_name, function_name, enum_name, fp) \
257 if (kind == k##enum_name) return #enum_name; 271 if (kind == k##enum_name) return #enum_name;
258 RECOGNIZED_LIST(KIND_TO_STRING) 272 RECOGNIZED_LIST(KIND_TO_STRING)
259 #undef KIND_TO_STRING 273 #undef KIND_TO_STRING
260 return "?"; 274 return "?";
261 } 275 }
262 276
263 277
264 // ==== Support for visiting flow graphs. 278 // ==== Support for visiting flow graphs.
265 #define DEFINE_ACCEPT(ShortName) \ 279 #define DEFINE_ACCEPT(ShortName) \
266 void ShortName##Instr::Accept(FlowGraphVisitor* visitor) { \ 280 void ShortName##Instr::Accept(FlowGraphVisitor* visitor) { \
(...skipping 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2653 return Array::length_offset(); 2667 return Array::length_offset();
2654 default: 2668 default:
2655 UNREACHABLE(); 2669 UNREACHABLE();
2656 return -1; 2670 return -1;
2657 } 2671 }
2658 } 2672 }
2659 2673
2660 #undef __ 2674 #undef __
2661 2675
2662 } // namespace dart 2676 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intrinsifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698