Skip to content

Commit

Permalink
Factor out cloned_vtable_offs().
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealMDoerr committed Jun 15, 2024
1 parent d46dd8f commit ad77e8a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/hotspot/share/cds/cppVtables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@
class CppVtableInfo {
intptr_t _vtable_size;
intptr_t _cloned_vtable[1]; // Pseudo flexible array member.
static size_t cloned_vtable_offs() { return offset_of(CppVtableInfo, _cloned_vtable); }
public:
static int num_slots(int vtable_size) {
return 1 + vtable_size; // Need to add the space occupied by _vtable_size;
}
int vtable_size() { return int(uintx(_vtable_size)); }
void set_vtable_size(int n) { _vtable_size = intptr_t(n); }
// Using _cloned_vtable[i] for i > 0 causes undefined behavior. We use address calculation instead.
intptr_t* cloned_vtable() { return (intptr_t*)((char*)this + offset_of(CppVtableInfo, _cloned_vtable)); }
intptr_t* cloned_vtable() { return (intptr_t*)((char*)this + cloned_vtable_offs()); }
void zero() { memset(cloned_vtable(), 0, sizeof(intptr_t) * vtable_size()); }
// Returns the address of the next CppVtableInfo that can be placed immediately after this CppVtableInfo
static size_t byte_size(int vtable_size) {
CppVtableInfo i;
return pointer_delta(&i.cloned_vtable()[vtable_size], &i, sizeof(u1));
return cloned_vtable_offs() + (sizeof(intptr_t) * vtable_size);
}
};

Expand Down

0 comments on commit ad77e8a

Please sign in to comment.