[lworld] RFR: 8373608: [lworld] Remove ObjBufferAllocator
Frederic Parain
fparain at openjdk.org
Fri Dec 12 15:46:06 UTC 2025
On Fri, 12 Dec 2025 15:36:21 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
>> Please review this change to remove `ObjBufferAllocator` since the impementation now is identical to `ObjAllocator`.
>>
>> **Summary**
>> This was not the case when ObjBufferAllocator was first introduced. Back then it skipped clearing the memory and just called oopDesc::set_klass_gap(mem, 0). This is no longer the case after [JDK-8350630](https://bugs.openjdk.org/browse/JDK-8350630) in which `ObjBufferAllocator` was changed to also clear the memory. The previous optimization is likely not needed and we should streamline the code to always use `ObjAllocator`.
>>
>> **Testing**
>> * mach5 tier1-3 (ongoing)
>
> src/hotspot/share/prims/unsafe.cpp line 520:
>
>> 518: Handle vh(THREAD, v);
>> 519: InlineKlass* vk = InlineKlass::cast(v->klass());
>> 520: instanceOop new_value = vk->allocate_instance(CHECK_NULL);
>
> This changes one instance in a function named Unsafe_MakePrivateBuffer. Is that also dead code now? I don't see any Java usage of that API:
>
> $ grep -r akePrivateBuffer src/
> src/hotspot/share/prims/unsafe.cpp:UNSAFE_ENTRY(jobject, Unsafe_MakePrivateBuffer(JNIEnv *env, jobject unsafe, jobject value)) {
> src/hotspot/share/prims/unsafe.cpp: {CC "makePrivateBuffer", CC "(" OBJ ")" OBJ, FN_PTR(Unsafe_MakePrivateBuffer)},
> src/hotspot/share/classfile/vmIntrinsics.hpp: do_name(makePrivateBuffer_name,"makePrivateBuffer") \
> src/hotspot/share/classfile/vmIntrinsics.hpp: do_intrinsic(_makePrivateBuffer, jdk_internal_misc_Unsafe, makePrivateBuffer_name, object_object_signature, F_RN) \
> src/hotspot/share/classfile/vmIntrinsics.cpp: case vmIntrinsics::_makePrivateBuffer:
> src/hotspot/share/opto/doCall.cpp: if (callee->intrinsic_id() == vmIntrinsics::_makePrivateBuffer || callee->intrinsic_id() == vmIntrinsics::_finishPrivateBuffer) {
> src/hotspot/share/opto/doCall.cpp: if (!rtype->is_void() && cg->method()->intrinsic_id() != vmIntrinsicID::_makePrivateBuffer) {
> src/hotspot/share/opto/c2compiler.cpp: case vmIntrinsics::_makePrivateBuffer:
> src/hotspot/share/opto/graphKit.cpp: // language, Unsafe::makePrivateBuffer returns an Object that is checkcast-ed to the concrete
> src/hotspot/share/opto/library_call.cpp: case vmIntrinsics::_makePrivateBuffer: return inline_unsafe_make_private_buffer();
> src/hotspot/share/opto/library_call.cpp: C->record_method_not_compilable("value passed to Unsafe::makePrivateBuffer is not of a constant value type");
> src/hotspot/share/opto/library_call.cpp: C->record_method_not_compilable("value passed to Unsafe::finishPrivateBuffer must be allocated by Unsafe::makePrivateBuffer");
> src/java.base/share/classes/jdk/internal/misc/Unsafe.java: public native <V> V makePrivateBuffer(V value);
Unsafe_MakePrivateBuffer is used by the VectorAPI, which is a branch that depends on the `lworld` branch.
More details here: https://github.com/openjdk/valhalla/pull/1593
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1794#discussion_r2614678819
More information about the valhalla-dev
mailing list