Skip to content

8362088: CompressedKlassPointers::encode should be const correct #26306

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
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
10 changes: 5 additions & 5 deletions src/hotspot/share/oops/compressedKlass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,18 @@ class CompressedKlassPointers : public AllStatic {
// Returns the highest possible narrowKlass value given the current Klass range
static narrowKlass highest_valid_narrow_klass_id() { return _highest_valid_narrow_klass_id; }

static bool is_null(Klass* v) { return v == nullptr; }
static bool is_null(narrowKlass v) { return v == 0; }
static bool is_null(const Klass* v) { return v == nullptr; }
static bool is_null(narrowKlass v) { return v == 0; }

// Versions without asserts
static inline Klass* decode_not_null_without_asserts(narrowKlass v);
static inline Klass* decode_without_asserts(narrowKlass v);
static inline Klass* decode_not_null(narrowKlass v);
static inline Klass* decode(narrowKlass v);

static inline narrowKlass encode_not_null_without_asserts(Klass* k, address narrow_base, int shift);
static inline narrowKlass encode_not_null(Klass* v);
static inline narrowKlass encode(Klass* v);
static inline narrowKlass encode_not_null_without_asserts(const Klass* k, address narrow_base, int shift);
static inline narrowKlass encode_not_null(const Klass* v);
static inline narrowKlass encode(const Klass* v);

#ifdef ASSERT
// Given an address, check that it can be encoded with the current encoding
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/oops/compressedKlass.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ inline Klass* CompressedKlassPointers::decode_not_null_without_asserts(narrowKla
return (Klass*)((uintptr_t)narrow_base_base +((uintptr_t)v << shift));
}

inline narrowKlass CompressedKlassPointers::encode_not_null_without_asserts(Klass* k, address narrow_base, int shift) {
inline narrowKlass CompressedKlassPointers::encode_not_null_without_asserts(const Klass* k, address narrow_base, int shift) {
return (narrowKlass)(pointer_delta(k, narrow_base, 1) >> shift);
}

Expand All @@ -60,7 +60,7 @@ inline Klass* CompressedKlassPointers::decode(narrowKlass v) {
return is_null(v) ? nullptr : decode_not_null(v);
}

inline narrowKlass CompressedKlassPointers::encode_not_null(Klass* v) {
inline narrowKlass CompressedKlassPointers::encode_not_null(const Klass* v) {
assert(!is_null(v), "klass value can never be zero");
DEBUG_ONLY(check_encodable(v);)
const narrowKlass nk = encode_not_null_without_asserts(v, base(), shift());
Expand All @@ -69,7 +69,7 @@ inline narrowKlass CompressedKlassPointers::encode_not_null(Klass* v) {
return nk;
}

inline narrowKlass CompressedKlassPointers::encode(Klass* v) {
inline narrowKlass CompressedKlassPointers::encode(const Klass* v) {
return is_null(v) ? (narrowKlass)0 : encode_not_null(v);
}

Expand Down