hotspot/src/share/vm/gc_implementation/parallelScavenge/prefetchQueue.hpp
changeset 360 21d113ecbf6a
parent 1 489c9b5090e2
child 670 ddf3e9583f2f
equal deleted inserted replaced
357:f4edb0d9f109 360:21d113ecbf6a
    31 
    31 
    32 const int PREFETCH_QUEUE_SIZE  = 8;
    32 const int PREFETCH_QUEUE_SIZE  = 8;
    33 
    33 
    34 class PrefetchQueue : public CHeapObj {
    34 class PrefetchQueue : public CHeapObj {
    35  private:
    35  private:
    36   oop*                         _prefetch_queue[PREFETCH_QUEUE_SIZE];
    36   void* _prefetch_queue[PREFETCH_QUEUE_SIZE];
    37   unsigned int                 _prefetch_index;
    37   uint  _prefetch_index;
    38 
    38 
    39  public:
    39  public:
    40   int length() { return PREFETCH_QUEUE_SIZE; }
    40   int length() { return PREFETCH_QUEUE_SIZE; }
    41 
    41 
    42   inline void clear() {
    42   inline void clear() {
    44       _prefetch_queue[i] = NULL;
    44       _prefetch_queue[i] = NULL;
    45     }
    45     }
    46     _prefetch_index = 0;
    46     _prefetch_index = 0;
    47   }
    47   }
    48 
    48 
    49   inline oop* push_and_pop(oop* p) {
    49   template <class T> inline void* push_and_pop(T* p) {
    50     Prefetch::write((*p)->mark_addr(), 0);
    50     oop o = oopDesc::load_decode_heap_oop_not_null(p);
       
    51     Prefetch::write(o->mark_addr(), 0);
    51     // This prefetch is intended to make sure the size field of array
    52     // This prefetch is intended to make sure the size field of array
    52     // oops is in cache. It assumes the the object layout is
    53     // oops is in cache. It assumes the the object layout is
    53     // mark -> klass -> size, and that mark and klass are heapword
    54     // mark -> klass -> size, and that mark and klass are heapword
    54     // sized. If this should change, this prefetch will need updating!
    55     // sized. If this should change, this prefetch will need updating!
    55     Prefetch::write((*p)->mark_addr() + (HeapWordSize*2), 0);
    56     Prefetch::write(o->mark_addr() + (HeapWordSize*2), 0);
    56     _prefetch_queue[_prefetch_index++] = p;
    57     _prefetch_queue[_prefetch_index++] = p;
    57     _prefetch_index &= (PREFETCH_QUEUE_SIZE-1);
    58     _prefetch_index &= (PREFETCH_QUEUE_SIZE-1);
    58     return _prefetch_queue[_prefetch_index];
    59     return _prefetch_queue[_prefetch_index];
    59   }
    60   }
    60 
    61 
    61   // Stores a NULL pointer in the pop'd location.
    62   // Stores a NULL pointer in the pop'd location.
    62   inline oop* pop() {
    63   inline void* pop() {
    63     _prefetch_queue[_prefetch_index++] = NULL;
    64     _prefetch_queue[_prefetch_index++] = NULL;
    64     _prefetch_index &= (PREFETCH_QUEUE_SIZE-1);
    65     _prefetch_index &= (PREFETCH_QUEUE_SIZE-1);
    65     return _prefetch_queue[_prefetch_index];
    66     return _prefetch_queue[_prefetch_index];
    66   }
    67   }
    67 };
    68 };