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

Reviewed-by: shade, coleenp
This commit is contained in:
Roman Kennke 2021-07-27 16:37:31 +00:00
parent fc80a6b493
commit ea49691f1d
4 changed files with 4 additions and 5 deletions

View File

@ -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) {

View File

@ -131,7 +131,7 @@ private:
}
public:
inline int object_size();
inline int object_size(const TypeArrayKlass* tk) const;
};
#endif // SHARE_OOPS_TYPEARRAYOOP_HPP

View File

@ -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());
}

View File

@ -302,7 +302,7 @@ JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len
if ((len > 0) && (result != NULL) &&
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.