Skip to content

8270794: Avoid loading Klass* twice in TypeArrayKlass::oop_size() #1527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/typeArrayKlass.cpp
Original file line number Diff line number Diff line change
@@ -230,7 +230,7 @@ Klass* TypeArrayKlass::array_klass_or_null() {
int TypeArrayKlass::oop_size(oop obj) const {
assert(obj->is_typeArray(),"must be a type array");
typeArrayOop t = typeArrayOop(obj);
return t->object_size();
return t->object_size(this);
}

void TypeArrayKlass::initialize(TRAPS) {
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/typeArrayOop.hpp
Original file line number Diff line number Diff line change
@@ -131,7 +131,7 @@ class typeArrayOopDesc : public arrayOopDesc {
}

public:
inline int object_size();
inline int object_size(const TypeArrayKlass* tk) const;
};

#endif // SHARE_OOPS_TYPEARRAYOOP_HPP
3 changes: 1 addition & 2 deletions src/hotspot/share/oops/typeArrayOop.inline.hpp
Original file line number Diff line number Diff line change
@@ -31,8 +31,7 @@
#include "oops/oop.inline.hpp"
#include "oops/arrayOop.hpp"

int typeArrayOopDesc::object_size() {
TypeArrayKlass* tk = TypeArrayKlass::cast(klass());
int typeArrayOopDesc::object_size(const TypeArrayKlass* tk) const {
return object_size(tk->layout_helper(), length());
}

2 changes: 1 addition & 1 deletion src/hotspot/share/opto/runtime.cpp
Original file line number Diff line number Diff line change
@@ -302,7 +302,7 @@ JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len
if ((len > 0) && (result != nullptr) &&
is_deoptimized_caller_frame(current)) {
// Zero array here if the caller is deoptimized.
int size = ((typeArrayOop)result)->object_size();
int size = TypeArrayKlass::cast(array_type)->oop_size(result);
BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
const size_t hs = arrayOopDesc::header_size(elem_type);
// Align to next 8 bytes to avoid trashing arrays's length.