src/hotspot/share/gc/z/zRelocationSet.inline.hpp
changeset 54163 790679f86a51
parent 50525 767cdb97f103
child 59249 29b0d0b61615
equal deleted inserted replaced
54162:f344a0c6e19e 54163:790679f86a51
     1 /*
     1 /*
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2017, 2019, 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.
    31 inline ZRelocationSetIteratorImpl<parallel>::ZRelocationSetIteratorImpl(ZRelocationSet* relocation_set) :
    31 inline ZRelocationSetIteratorImpl<parallel>::ZRelocationSetIteratorImpl(ZRelocationSet* relocation_set) :
    32     _relocation_set(relocation_set),
    32     _relocation_set(relocation_set),
    33     _next(0) {}
    33     _next(0) {}
    34 
    34 
    35 template <bool parallel>
    35 template <bool parallel>
    36 inline bool ZRelocationSetIteratorImpl<parallel>::next(ZPage** page) {
    36 inline bool ZRelocationSetIteratorImpl<parallel>::next(ZForwarding** forwarding) {
    37   const size_t npages = _relocation_set->_npages;
    37   const size_t nforwardings = _relocation_set->_nforwardings;
    38 
    38 
    39   if (parallel) {
    39   if (parallel) {
    40     if (_next < npages) {
    40     if (_next < nforwardings) {
    41       const size_t next = Atomic::add(1u, &_next) - 1u;
    41       const size_t next = Atomic::add(1u, &_next) - 1u;
    42       if (next < npages) {
    42       if (next < nforwardings) {
    43         *page = _relocation_set->_pages[next];
    43         *forwarding = _relocation_set->_forwardings[next];
    44         return true;
    44         return true;
    45       }
    45       }
    46     }
    46     }
    47   } else {
    47   } else {
    48     if (_next < npages) {
    48     if (_next < nforwardings) {
    49       *page = _relocation_set->_pages[_next++];
    49       *forwarding = _relocation_set->_forwardings[_next++];
    50       return true;
    50       return true;
    51     }
    51     }
    52   }
    52   }
    53 
    53 
    54   return false;
    54   return false;