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

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

Issue 19223002: Always try to inline certain core library functions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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') | no next file » | 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // Both names are private. Mangle test_name before comparison. 329 // Both names are private. Mangle test_name before comparison.
330 const String& test_name_symbol = String::Handle(Symbols::New(test_name)); 330 const String& test_name_symbol = String::Handle(Symbols::New(test_name));
331 return String::Handle(lib.PrivateName(test_name_symbol)).Equals(name); 331 return String::Handle(lib.PrivateName(test_name_symbol)).Equals(name);
332 } 332 }
333 333
334 334
335 static bool IsRecognizedLibrary(const Library& library) { 335 static bool IsRecognizedLibrary(const Library& library) {
336 // List of libraries where methods can be recognized. 336 // List of libraries where methods can be recognized.
337 return (library.raw() == Library::CoreLibrary()) 337 return (library.raw() == Library::CoreLibrary())
338 || (library.raw() == Library::MathLibrary()) 338 || (library.raw() == Library::MathLibrary())
339 || (library.raw() == Library::TypedDataLibrary()); 339 || (library.raw() == Library::TypedDataLibrary())
340 || (library.raw() == Library::CollectionDevLibrary());
340 } 341 }
341 342
342 343
343 MethodRecognizer::Kind MethodRecognizer::RecognizeKind( 344 MethodRecognizer::Kind MethodRecognizer::RecognizeKind(
344 const Function& function) { 345 const Function& function) {
345 const Class& function_class = Class::Handle(function.Owner()); 346 const Class& function_class = Class::Handle(function.Owner());
346 const Library& lib = Library::Handle(function_class.library()); 347 const Library& lib = Library::Handle(function_class.library());
347 if (!IsRecognizedLibrary(lib)) { 348 if (!IsRecognizedLibrary(lib)) {
348 return kUnknown; 349 return kUnknown;
349 } 350 }
350 351
351 const String& function_name = String::Handle(function.name()); 352 const String& function_name = String::Handle(function.name());
352 const String& class_name = String::Handle(function_class.Name()); 353 const String& class_name = String::Handle(function_class.Name());
353 354
354 #define RECOGNIZE_FUNCTION(test_class_name, test_function_name, enum_name, fp) \ 355 #define RECOGNIZE_FUNCTION(test_class_name, test_function_name, enum_name, fp) \
355 if (CompareNames(lib, #test_function_name, function_name) && \ 356 if (CompareNames(lib, #test_function_name, function_name) && \
356 CompareNames(lib, #test_class_name, class_name)) { \ 357 CompareNames(lib, #test_class_name, class_name)) { \
357 ASSERT(function.CheckSourceFingerprint(fp)); \ 358 ASSERT(function.CheckSourceFingerprint(fp)); \
358 return k##enum_name; \ 359 return k##enum_name; \
359 } 360 }
360 RECOGNIZED_LIST(RECOGNIZE_FUNCTION) 361 RECOGNIZED_LIST(RECOGNIZE_FUNCTION)
361 #undef RECOGNIZE_FUNCTION 362 #undef RECOGNIZE_FUNCTION
362 return kUnknown; 363 return kUnknown;
363 } 364 }
364 365
365 366
367 bool MethodRecognizer::AlwaysInline(const Function& function) {
368 const Class& function_class = Class::Handle(function.Owner());
369 const Library& lib = Library::Handle(function_class.library());
370 if (!IsRecognizedLibrary(lib)) {
371 return false;
372 }
373
374 const String& function_name = String::Handle(function.name());
375 const String& class_name = String::Handle(function_class.Name());
376
377 #define RECOGNIZE_FUNCTION(test_class_name, test_function_name, enum_name, fp) \
378 if (CompareNames(lib, #test_function_name, function_name) && \
379 CompareNames(lib, #test_class_name, class_name)) { \
380 ASSERT(function.CheckSourceFingerprint(fp)); \
381 return true; \
382 }
383 INLINE_WHITE_LIST(RECOGNIZE_FUNCTION)
384 #undef RECOGNIZE_FUNCTION
385 return false;
386 }
387
388
366 const char* MethodRecognizer::KindToCString(Kind kind) { 389 const char* MethodRecognizer::KindToCString(Kind kind) {
367 #define KIND_TO_STRING(class_name, function_name, enum_name, fp) \ 390 #define KIND_TO_STRING(class_name, function_name, enum_name, fp) \
368 if (kind == k##enum_name) return #enum_name; 391 if (kind == k##enum_name) return #enum_name;
369 RECOGNIZED_LIST(KIND_TO_STRING) 392 RECOGNIZED_LIST(KIND_TO_STRING)
370 #undef KIND_TO_STRING 393 #undef KIND_TO_STRING
371 return "?"; 394 return "?";
372 } 395 }
373 396
374 397
375 // ==== Support for visiting flow graphs. 398 // ==== Support for visiting flow graphs.
(...skipping 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after
2574 default: 2597 default:
2575 UNREACHABLE(); 2598 UNREACHABLE();
2576 } 2599 }
2577 return kPowRuntimeEntry; 2600 return kPowRuntimeEntry;
2578 } 2601 }
2579 2602
2580 2603
2581 #undef __ 2604 #undef __
2582 2605
2583 } // namespace dart 2606 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698