Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/hotspot/share/memory/oopFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,9 @@ typeArrayOop oopFactory::new_typeArray_nozero(BasicType type, int length, TRAPS)
return klass->allocate_common(length, false, THREAD);
}


objArrayOop oopFactory::new_objArray(Klass* klass, int length, TRAPS) {
if (klass->is_array_klass()) {
return ArrayKlass::cast(klass)->allocate_arrayArray(1, length, THREAD);
} else {
return InstanceKlass::cast(klass)->allocate_objArray(1, length, THREAD);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this has symmetry in the mainline, except both of these functions do the same thing as ObjArrayKlass.allocate_instance do. The goal is to hide allocate_instance and only make this class a friend, and not InstanceKlass. This isn't the case in the current repository but it is in the valhalla repo and I want them to be the same at this level.

So this isolates the CollectedHeap::array_allocate call to less places now.

ArrayKlass* ak = klass->array_klass(CHECK_NULL);
return ObjArrayKlass::cast(ak)->allocate_instance(length, THREAD);
}

objArrayHandle oopFactory::new_objArray_handle(Klass* klass, int length, TRAPS) {
Expand Down
10 changes: 0 additions & 10 deletions src/hotspot/share/oops/arrayKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,6 @@ GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots,
return nullptr;
}

objArrayOop ArrayKlass::allocate_arrayArray(int n, int length, TRAPS) {
check_array_allocation_length(length, arrayOopDesc::max_array_length(T_ARRAY), CHECK_NULL);
size_t size = objArrayOopDesc::object_size(length);
ArrayKlass* ak = array_klass(n + dimension(), CHECK_NULL);
objArrayOop o = (objArrayOop)Universe::heap()->array_allocate(ak, size, length,
/* do_zero */ true, CHECK_NULL);
// initialization to null not necessary, area already cleared
return o;
}

// JVMTI support

jint ArrayKlass::jvmti_class_status() const {
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/oops/arrayKlass.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, 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
Expand Down Expand Up @@ -87,7 +87,6 @@ class ArrayKlass: public Klass {
// Sizes points to the first dimension of the array, subsequent dimensions
// are always in higher memory. The callers of these set that up.
virtual oop multi_allocate(int rank, jint* sizes, TRAPS);
objArrayOop allocate_arrayArray(int n, int length, TRAPS);

// find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined
Klass* find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
Expand Down
9 changes: 0 additions & 9 deletions src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,15 +1561,6 @@ bool InstanceKlass::is_same_or_direct_interface(Klass *k) const {
return false;
}

objArrayOop InstanceKlass::allocate_objArray(int n, int length, TRAPS) {
check_array_allocation_length(length, arrayOopDesc::max_array_length(T_OBJECT), CHECK_NULL);
size_t size = objArrayOopDesc::object_size(length);
ArrayKlass* ak = array_klass(n, CHECK_NULL);
objArrayOop o = (objArrayOop)Universe::heap()->array_allocate(ak, size, length,
/* do_zero */ true, CHECK_NULL);
return o;
}

instanceOop InstanceKlass::register_finalizer(instanceOop i, TRAPS) {
if (TraceFinalizerRegistration) {
tty->print("Registered ");
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/oops/instanceKlass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,6 @@ class InstanceKlass: public Klass {
// additional member function to return a handle
instanceHandle allocate_instance_handle(TRAPS);

objArrayOop allocate_objArray(int n, int length, TRAPS);
// Helper function
static instanceOop register_finalizer(instanceOop i, TRAPS);

Expand Down
7 changes: 3 additions & 4 deletions src/hotspot/share/oops/objArrayKlass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ class ObjArrayKlass : public ArrayKlass {
// Instance variables
Klass* element_klass() const { return _element_klass; }
void set_element_klass(Klass* k) { _element_klass = k; }
Klass** element_klass_addr() { return &_element_klass; }

// Compiler/Interpreter offset
static ByteSize element_klass_offset() { return byte_offset_of(ObjArrayKlass, _element_klass); }

Klass* bottom_klass() const { return _bottom_klass; }
void set_bottom_klass(Klass* k) { _bottom_klass = k; }
Expand All @@ -73,9 +75,6 @@ class ObjArrayKlass : public ArrayKlass {
ModuleEntry* module() const;
PackageEntry* package() const;

// Compiler/Interpreter offset
static ByteSize element_klass_offset() { return byte_offset_of(ObjArrayKlass, _element_klass); }

// Dispatched operation
bool can_be_primary_super_slow() const;
GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,
Expand Down