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

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

Issue 25050004: Add a is_recognized bit to function kind field. Improves performance of method recognizer and thus … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_allocator.h" 10 #include "vm/flow_graph_allocator.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // List of libraries where methods can be recognized. 355 // List of libraries where methods can be recognized.
356 return (library.raw() == Library::CoreLibrary()) 356 return (library.raw() == Library::CoreLibrary())
357 || (library.raw() == Library::MathLibrary()) 357 || (library.raw() == Library::MathLibrary())
358 || (library.raw() == Library::TypedDataLibrary()) 358 || (library.raw() == Library::TypedDataLibrary())
359 || (library.raw() == Library::CollectionDevLibrary()); 359 || (library.raw() == Library::CollectionDevLibrary());
360 } 360 }
361 361
362 362
363 MethodRecognizer::Kind MethodRecognizer::RecognizeKind( 363 MethodRecognizer::Kind MethodRecognizer::RecognizeKind(
364 const Function& function) { 364 const Function& function) {
365 const Class& function_class = Class::Handle(function.Owner()); 365 if (!function.is_recognized()) {
366 const Library& lib = Library::Handle(function_class.library());
367 if (!IsRecognizedLibrary(lib)) {
368 return kUnknown; 366 return kUnknown;
369 } 367 }
370 368
369 const Class& function_class = Class::Handle(function.Owner());
370 const Library& lib = Library::Handle(function_class.library());
371 const String& function_name = String::Handle(function.name()); 371 const String& function_name = String::Handle(function.name());
372 const String& class_name = String::Handle(function_class.Name()); 372 const String& class_name = String::Handle(function_class.Name());
373 373
374 #define RECOGNIZE_FUNCTION(test_class_name, test_function_name, enum_name, fp) \ 374 #define RECOGNIZE_FUNCTION(test_class_name, test_function_name, enum_name, fp) \
375 if (CompareNames(lib, #test_function_name, function_name) && \ 375 if (CompareNames(lib, #test_function_name, function_name) && \
376 CompareNames(lib, #test_class_name, class_name)) { \ 376 CompareNames(lib, #test_class_name, class_name)) { \
377 ASSERT(function.CheckSourceFingerprint(fp)); \ 377 ASSERT(function.CheckSourceFingerprint(fp)); \
378 return k##enum_name; \ 378 return k##enum_name; \
379 } 379 }
380 RECOGNIZED_LIST(RECOGNIZE_FUNCTION) 380 RECOGNIZED_LIST(RECOGNIZE_FUNCTION)
381 #undef RECOGNIZE_FUNCTION 381 #undef RECOGNIZE_FUNCTION
382 UNREACHABLE();
382 return kUnknown; 383 return kUnknown;
383 } 384 }
384 385
385 386
386 bool MethodRecognizer::AlwaysInline(const Function& function) { 387 bool MethodRecognizer::AlwaysInline(const Function& function) {
387 const Class& function_class = Class::Handle(function.Owner()); 388 const Class& function_class = Class::Handle(function.Owner());
388 const Library& lib = Library::Handle(function_class.library()); 389 const Library& lib = Library::Handle(function_class.library());
389 if (!IsRecognizedLibrary(lib)) { 390 if (!IsRecognizedLibrary(lib)) {
390 return false; 391 return false;
391 } 392 }
(...skipping 15 matching lines...) Expand all
407 408
408 const char* MethodRecognizer::KindToCString(Kind kind) { 409 const char* MethodRecognizer::KindToCString(Kind kind) {
409 #define KIND_TO_STRING(class_name, function_name, enum_name, fp) \ 410 #define KIND_TO_STRING(class_name, function_name, enum_name, fp) \
410 if (kind == k##enum_name) return #enum_name; 411 if (kind == k##enum_name) return #enum_name;
411 RECOGNIZED_LIST(KIND_TO_STRING) 412 RECOGNIZED_LIST(KIND_TO_STRING)
412 #undef KIND_TO_STRING 413 #undef KIND_TO_STRING
413 return "?"; 414 return "?";
414 } 415 }
415 416
416 417
418 void MethodRecognizer::InitializeState() {
419 GrowableArray<Library*> libs(3);
420 libs.Add(&Library::ZoneHandle(Library::CoreLibrary()));
421 libs.Add(&Library::ZoneHandle(Library::MathLibrary()));
422 libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary()));
423 Function& func = Function::Handle();
424
425 #define SET_IS_RECOGNIZED(class_name, function_name, dest, fp) \
426 func = Library::GetFunction(libs, #class_name, #function_name); \
427 ASSERT(!func.IsNull()); \
428 func.set_is_recognized(true); \
429
430 RECOGNIZED_LIST(SET_IS_RECOGNIZED);
431
432 #undef SET_IS_RECOGNIZED
433 }
434
417 // ==== Support for visiting flow graphs. 435 // ==== Support for visiting flow graphs.
436
418 #define DEFINE_ACCEPT(ShortName) \ 437 #define DEFINE_ACCEPT(ShortName) \
419 void ShortName##Instr::Accept(FlowGraphVisitor* visitor) { \ 438 void ShortName##Instr::Accept(FlowGraphVisitor* visitor) { \
420 visitor->Visit##ShortName(this); \ 439 visitor->Visit##ShortName(this); \
421 } 440 }
422 441
423 FOR_EACH_INSTRUCTION(DEFINE_ACCEPT) 442 FOR_EACH_INSTRUCTION(DEFINE_ACCEPT)
424 443
425 #undef DEFINE_ACCEPT 444 #undef DEFINE_ACCEPT
426 445
427 446
(...skipping 2240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2668 return kCosRuntimeEntry; 2687 return kCosRuntimeEntry;
2669 default: 2688 default:
2670 UNREACHABLE(); 2689 UNREACHABLE();
2671 } 2690 }
2672 return kSinRuntimeEntry; 2691 return kSinRuntimeEntry;
2673 } 2692 }
2674 2693
2675 #undef __ 2694 #undef __
2676 2695
2677 } // namespace dart 2696 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698