1 /*
 2  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
 3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  *
 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
 7  * published by the Free Software Foundation.
 8  *
 9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHSTACKCHUNKGCDATA_INLINE_HPP
25 #define SHARE_GC_SHENANDOAH_SHENANDOAHSTACKCHUNKGCDATA_INLINE_HPP
26 
27 #include "gc/shenandoah/shenandoahStackChunkGCData.hpp"
28 
29 #include "oops/instanceStackChunkKlass.inline.hpp"
30 #include "oops/stackChunkOop.inline.hpp"
31 
32 inline ShenandoahStackChunkGCData* ShenandoahStackChunkGCData::data(stackChunkOop chunk) {
33 #ifdef ASSERT
34   size_t data_size = sizeof(ShenandoahStackChunkGCData);
35   size_t avail_size = InstanceStackChunkKlass::gc_data_size(chunk->stack_size()) * HeapWordSize;
36   assert(data_size <= avail_size, "Data of size %zu must fit in %zu space", data_size, avail_size);
37 #endif
38   return reinterpret_cast<ShenandoahStackChunkGCData*>(chunk->gc_data());
39 }
40 
41 inline void ShenandoahStackChunkGCData::initialize(stackChunkOop chunk) {
42   data(chunk)->_epoch = _epoch_id_counter.load_relaxed();
43 }
44 
45 inline bool ShenandoahStackChunkGCData::is_different_epoch(stackChunkOop chunk) {
46   return data(chunk)->_epoch != _epoch_id_counter.load_relaxed();
47 }
48 
49 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHSTACKCHUNKGCDATA_INLINE_HPP