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

Side by Side Diff: Source/heap/Visitor.h

Issue 203363003: Remove do-nothing trace traits on primitive types (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | « Source/heap/HeapTest.cpp ('k') | Source/heap/Visitor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 for (typename Deque::const_iterator it = deque.begin(), end = deque.end( ); it != end; ++it) 476 for (typename Deque::const_iterator it = deque.begin(), end = deque.end( ); it != end; ++it)
477 TraceTrait<T>::trace(visitor, const_cast<T*>(&(*it))); 477 TraceTrait<T>::trace(visitor, const_cast<T*>(&(*it)));
478 } 478 }
479 }; 479 };
480 480
481 template<typename T, typename Traits = WTF::VectorTraits<T> > 481 template<typename T, typename Traits = WTF::VectorTraits<T> >
482 class HeapVectorBacking; 482 class HeapVectorBacking;
483 template<typename Key, typename Value, typename Extractor, typename Traits, type name KeyTraits> 483 template<typename Key, typename Value, typename Extractor, typename Traits, type name KeyTraits>
484 class HeapHashTableBacking; 484 class HeapHashTableBacking;
485 485
486 inline void doNothingTrace(Visitor*, void*) { }
487
488 // Non-class types like char don't have an trace method, so we provide a more
489 // specialized template instantiation here that will be selected in preference
490 // to the default. Most of them do nothing, since the type in question cannot
491 // point to other heap allocated objects.
492 #define ITERATE_DO_NOTHING_TYPES(f) \
493 f(uint8_t) \
494 f(void)
495
496 #define DECLARE_DO_NOTHING_TRAIT(type) \
497 template<> \
498 class TraceTrait<type> { \
499 public: \
500 static void checkGCInfo(Visitor*, const void*) { } \
501 static void mark(Visitor* visitor, const type* p) { \
502 visitor->mark(p, reinterpret_cast<TraceCallback>(0)); \
503 } \
504 }; \
505 template<> \
506 struct FinalizerTrait<type> { \
507 static void finalize(void*) { } \
508 static const bool nonTrivialFinalizer = false; \
509 }; \
510 template<> \
511 struct HEAP_EXPORT GCInfoTrait<type> { \
512 static const GCInfo* get() \
513 { \
514 return &info; \
515 } \
516 static const GCInfo info; \
517 };
518
519 ITERATE_DO_NOTHING_TYPES(DECLARE_DO_NOTHING_TRAIT)
520
521 #undef DECLARE_DO_NOTHING_TRAIT
522
523 template<typename T> 486 template<typename T>
524 class DefaultTraceTrait<T, false> { 487 class DefaultTraceTrait<T, false> {
525 public: 488 public:
526 static void mark(Visitor* visitor, const T* t) 489 static void mark(Visitor* visitor, const T* t)
527 { 490 {
528 // Default mark method of the trait just calls the two-argument mark 491 // Default mark method of the trait just calls the two-argument mark
529 // method on the visitor. The second argument is the static trace method 492 // method on the visitor. The second argument is the static trace method
530 // of the trait, which by default calls the instance method 493 // of the trait, which by default calls the instance method
531 // trace(Visitor*) on the object. 494 // trace(Visitor*) on the object.
532 visitor->mark(const_cast<T*>(t), &TraceTrait<T>::trace); 495 visitor->mark(const_cast<T*>(t), &TraceTrait<T>::trace);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 struct GCInfoTrait { 621 struct GCInfoTrait {
659 static const GCInfo* get() 622 static const GCInfo* get()
660 { 623 {
661 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); 624 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get();
662 } 625 }
663 }; 626 };
664 627
665 } 628 }
666 629
667 #endif 630 #endif
OLDNEW
« no previous file with comments | « Source/heap/HeapTest.cpp ('k') | Source/heap/Visitor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698