plab.inline.hpp revision 11857:d0fbf661cc16
1256949Sganbold/*
2266337Sian * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
3256949Sganbold * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4256949Sganbold *
5256949Sganbold * This code is free software; you can redistribute it and/or modify it
6256949Sganbold * under the terms of the GNU General Public License version 2 only, as
7256949Sganbold * published by the Free Software Foundation.
8256949Sganbold *
9256949Sganbold * This code is distributed in the hope that it will be useful, but WITHOUT
10256949Sganbold * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11256949Sganbold * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12256949Sganbold * version 2 for more details (a copy is included in the LICENSE file that
13256949Sganbold * accompanied this code).
14256949Sganbold *
15256949Sganbold * You should have received a copy of the GNU General Public License version
16256949Sganbold * 2 along with this work; if not, write to the Free Software Foundation,
17256949Sganbold * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18256949Sganbold *
19256949Sganbold * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20256949Sganbold * or visit www.oracle.com if you need additional information or have any
21256949Sganbold * questions.
22256949Sganbold *
23256949Sganbold */
24256949Sganbold
25256949Sganbold#ifndef SHARE_VM_GC_SHARED_PLAB_INLINE_HPP
26256949Sganbold#define SHARE_VM_GC_SHARED_PLAB_INLINE_HPP
27256949Sganbold
28256949Sganbold#include "gc/shared/collectedHeap.inline.hpp"
29256949Sganbold#include "gc/shared/plab.hpp"
30256949Sganbold#include "memory/allocation.inline.hpp"
31256949Sganbold#include "runtime/atomic.hpp"
32256949Sganbold
33256949Sganboldinline HeapWord* PLAB::allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes) {
34256949Sganbold  HeapWord* res = CollectedHeap::align_allocation_or_fail(_top, _end, alignment_in_bytes);
35256949Sganbold  if (res == NULL) {
36256949Sganbold    return NULL;
37256949Sganbold  }
38256949Sganbold
39256949Sganbold  // Set _top so that allocate(), which expects _top to be correctly set,
40256949Sganbold  // can be used below.
41256949Sganbold  _top = res;
42256949Sganbold  return allocate(word_sz);
43256949Sganbold}
44256949Sganbold
45256949Sganboldvoid PLABStats::add_allocated(size_t v) {
46256949Sganbold  Atomic::add_ptr(v, &_allocated);
47256949Sganbold}
48256949Sganbold
49256949Sganboldvoid PLABStats::add_unused(size_t v) {
50256949Sganbold  Atomic::add_ptr(v, &_unused);
51256949Sganbold}
52256949Sganbold
53256949Sganboldvoid PLABStats::add_wasted(size_t v) {
54256949Sganbold  Atomic::add_ptr(v, &_wasted);
55256949Sganbold}
56256949Sganbold
57256949Sganboldvoid PLABStats::add_undo_wasted(size_t v) {
58256949Sganbold  Atomic::add_ptr(v, &_undo_wasted);
59256949Sganbold}
60256949Sganbold
61256949Sganbold#endif // SHARE_VM_GC_SHARED_PLAB_INLINE_HPP
62256949Sganbold