hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp
changeset 29580 a67a581cfe11
parent 28507 354ef83ee258
equal deleted inserted replaced
29477:82f545c6572b 29580:a67a581cfe11
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    56   }
    56   }
    57 }
    57 }
    58 
    58 
    59 
    59 
    60 void PtrQueue::enqueue_known_active(void* ptr) {
    60 void PtrQueue::enqueue_known_active(void* ptr) {
    61   assert(0 <= _index && _index <= _sz, "Invariant.");
    61   assert(_index <= _sz, "Invariant.");
    62   assert(_index == 0 || _buf != NULL, "invariant");
    62   assert(_index == 0 || _buf != NULL, "invariant");
    63 
    63 
    64   while (_index == 0) {
    64   while (_index == 0) {
    65     handle_zero_index();
    65     handle_zero_index();
    66   }
    66   }
    67 
    67 
    68   assert(_index > 0, "postcondition");
    68   assert(_index > 0, "postcondition");
    69   _index -= oopSize;
    69   _index -= oopSize;
    70   _buf[byte_index_to_index((int)_index)] = ptr;
    70   _buf[byte_index_to_index((int)_index)] = ptr;
    71   assert(0 <= _index && _index <= _sz, "Invariant.");
    71   assert(_index <= _sz, "Invariant.");
    72 }
    72 }
    73 
    73 
    74 void PtrQueue::locking_enqueue_completed_buffer(void** buf) {
    74 void PtrQueue::locking_enqueue_completed_buffer(void** buf) {
    75   assert(_lock->owned_by_self(), "Required.");
    75   assert(_lock->owned_by_self(), "Required.");
    76 
    76 
   192   }
   192   }
   193   // Reallocate the buffer
   193   // Reallocate the buffer
   194   _buf = qset()->allocate_buffer();
   194   _buf = qset()->allocate_buffer();
   195   _sz = qset()->buffer_size();
   195   _sz = qset()->buffer_size();
   196   _index = _sz;
   196   _index = _sz;
   197   assert(0 <= _index && _index <= _sz, "Invariant.");
       
   198 }
   197 }
   199 
   198 
   200 bool PtrQueueSet::process_or_enqueue_complete_buffer(void** buf) {
   199 bool PtrQueueSet::process_or_enqueue_complete_buffer(void** buf) {
   201   if (Thread::current()->is_Java_thread()) {
   200   if (Thread::current()->is_Java_thread()) {
   202     // We don't lock. It is fine to be epsilon-precise here.
   201     // We don't lock. It is fine to be epsilon-precise here.