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
25 #ifndef SHARE_VM_MEMORY_THREADLOCALALLOCBUFFER_INLINE_HPP
26 #define SHARE_VM_MEMORY_THREADLOCALALLOCBUFFER_INLINE_HPP
27
28 #include "gc_interface/collectedHeap.hpp"
29 #include "memory/threadLocalAllocBuffer.hpp"
30 #include "runtime/atomic.hpp"
31 #include "runtime/thread.hpp"
32 #include "utilities/copy.hpp"
33
34 inline HeapWord* ThreadLocalAllocBuffer::allocate(size_t size) {
35 invariants();
36 HeapWord* obj = top();
37 if (pointer_delta(end(), obj) >= size) {
38 // successful thread-local allocation
39 #ifdef ASSERT
40 // Skip mangling the space corresponding to the object header to
41 // ensure that the returned space is not considered parsable by
42 // any concurrent GC thread.
43 size_t hdr_size = oopDesc::header_size();
44 Copy::fill_to_words(obj + hdr_size, size - hdr_size, badHeapWordVal);
45 #endif // ASSERT
46 // This addition is safe because we know that top is
47 // at least size below end, so the add can't wrap.
48 set_top(obj + size);
49
50 invariants();
|
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
25 #ifndef SHARE_VM_MEMORY_THREADLOCALALLOCBUFFER_INLINE_HPP
26 #define SHARE_VM_MEMORY_THREADLOCALALLOCBUFFER_INLINE_HPP
27
28 #include "gc_interface/collectedHeap.hpp"
29 #include "memory/threadLocalAllocBuffer.hpp"
30 #include "runtime/thread.hpp"
31 #include "utilities/copy.hpp"
32
33 inline HeapWord* ThreadLocalAllocBuffer::allocate(size_t size) {
34 invariants();
35 HeapWord* obj = top();
36 if (pointer_delta(end(), obj) >= size) {
37 // successful thread-local allocation
38 #ifdef ASSERT
39 // Skip mangling the space corresponding to the object header to
40 // ensure that the returned space is not considered parsable by
41 // any concurrent GC thread.
42 size_t hdr_size = oopDesc::header_size();
43 Copy::fill_to_words(obj + hdr_size, size - hdr_size, badHeapWordVal);
44 #endif // ASSERT
45 // This addition is safe because we know that top is
46 // at least size below end, so the add can't wrap.
47 set_top(obj + size);
48
49 invariants();
|