< prev index next >
src/hotspot/share/prims/unsafe.cpp
Print this page
rev 57826 : 8237521: Memory Access API fixes for 32-bit
Reviewed-by: mcimadamore, dholmes
*** 1,7 ****
/*
! * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 358,377 ****
} UNSAFE_END
UNSAFE_ENTRY(jlong, Unsafe_AllocateMemory0(JNIEnv *env, jobject unsafe, jlong size)) {
size_t sz = (size_t)size;
! sz = align_up(sz, HeapWordSize);
void* x = os::malloc(sz, mtOther);
return addr_to_java(x);
} UNSAFE_END
UNSAFE_ENTRY(jlong, Unsafe_ReallocateMemory0(JNIEnv *env, jobject unsafe, jlong addr, jlong size)) {
void* p = addr_from_java(addr);
size_t sz = (size_t)size;
! sz = align_up(sz, HeapWordSize);
void* x = os::realloc(p, sz, mtOther);
return addr_to_java(x);
} UNSAFE_END
--- 358,379 ----
} UNSAFE_END
UNSAFE_ENTRY(jlong, Unsafe_AllocateMemory0(JNIEnv *env, jobject unsafe, jlong size)) {
size_t sz = (size_t)size;
! assert(is_aligned(sz, HeapWordSize), "sz not aligned");
!
void* x = os::malloc(sz, mtOther);
return addr_to_java(x);
} UNSAFE_END
UNSAFE_ENTRY(jlong, Unsafe_ReallocateMemory0(JNIEnv *env, jobject unsafe, jlong addr, jlong size)) {
void* p = addr_from_java(addr);
size_t sz = (size_t)size;
!
! assert(is_aligned(sz, HeapWordSize), "sz not aligned");
void* x = os::realloc(p, sz, mtOther);
return addr_to_java(x);
} UNSAFE_END
< prev index next >