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
76 changes: 23 additions & 53 deletions src/hotspot/share/code/codeBlob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,82 +73,56 @@ unsigned int CodeBlob::allocation_size(CodeBuffer* cb, int header_size) {
return size;
}

#ifdef ASSERT
void CodeBlob::verify_parameters() {
assert(is_aligned(_size, oopSize), "unaligned size");
assert(is_aligned(_header_size, oopSize), "unaligned size");
assert(is_aligned(_relocation_size, oopSize), "unaligned size");
assert(_data_offset <= size(), "codeBlob is too small");
assert(code_end() == content_end(), "must be the same - see code_end()");
#ifdef COMPILER1
// probably wrong for tiered
assert(frame_size() >= -1, "must use frame size or -1 for runtime stubs");
#endif // COMPILER1
}
#endif

CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, int size, int header_size, int relocation_size,
int content_offset, int code_offset, int frame_complete_offset, int data_offset,
int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments) :
_oop_maps(oop_maps),
_name(name),
_size(size),
_header_size(header_size),
_relocation_size(relocation_size),
_content_offset(content_offset),
_code_offset(code_offset),
_frame_complete_offset(frame_complete_offset),
_data_offset(data_offset),
_frame_size(frame_size),
S390_ONLY(_ctable_offset(0) COMMA)
_kind(kind),
_caller_must_gc_arguments(caller_must_gc_arguments)
{
DEBUG_ONLY( verify_parameters(); )
}

CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size, int header_size,
int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments) :
CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size, uint16_t header_size,
int16_t frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments) :
_oop_maps(nullptr), // will be set by set_oop_maps() call
_name(name),
_size(size),
_header_size(header_size),
_relocation_size(align_up(cb->total_relocation_size(), oopSize)),
_content_offset(CodeBlob::align_code_offset(_header_size + _relocation_size)),
_content_offset(CodeBlob::align_code_offset(header_size + _relocation_size)),
_code_offset(_content_offset + cb->total_offset_of(cb->insts())),
_frame_complete_offset(frame_complete_offset),
_data_offset(_content_offset + align_up(cb->total_content_size(), oopSize)),
_frame_size(frame_size),
S390_ONLY(_ctable_offset(0) COMMA)
_header_size(header_size),
_frame_complete_offset(frame_complete_offset),
_kind(kind),
_caller_must_gc_arguments(caller_must_gc_arguments)
{
DEBUG_ONLY( verify_parameters(); )
assert(is_aligned(_size, oopSize), "unaligned size");
assert(is_aligned(header_size, oopSize), "unaligned size");
assert(is_aligned(_relocation_size, oopSize), "unaligned size");
assert(_data_offset <= _size, "codeBlob is too small: %d > %d", _data_offset, _size);
assert(code_end() == content_end(), "must be the same - see code_end()");
#ifdef COMPILER1
// probably wrong for tiered
assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
#endif // COMPILER1

set_oop_maps(oop_maps);
}

// Simple CodeBlob used for simple BufferBlob.
CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, int size, int header_size) :
CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, int size, uint16_t header_size) :
_oop_maps(nullptr),
_name(name),
_size(size),
_header_size(header_size),
_relocation_size(0),
_content_offset(CodeBlob::align_code_offset(header_size)),
_code_offset(_content_offset),
_frame_complete_offset(CodeOffsets::frame_never_safe),
_data_offset(size),
_frame_size(0),
S390_ONLY(_ctable_offset(0) COMMA)
_header_size(header_size),
_frame_complete_offset(CodeOffsets::frame_never_safe),
_kind(kind),
_caller_must_gc_arguments(false)
{
assert(is_aligned(size, oopSize), "unaligned size");
assert(is_aligned(header_size, oopSize), "unaligned size");
}

void CodeBlob::purge(bool free_code_cache_data, bool unregister_nmethod) {
void CodeBlob::purge() {
if (_oop_maps != nullptr) {
delete _oop_maps;
_oop_maps = nullptr;
Expand Down Expand Up @@ -185,8 +159,8 @@ RuntimeBlob::RuntimeBlob(
CodeBlobKind kind,
CodeBuffer* cb,
int size,
int header_size,
int frame_complete,
uint16_t header_size,
int16_t frame_complete,
int frame_size,
OopMapSet* oop_maps,
bool caller_must_gc_arguments)
Expand All @@ -198,7 +172,7 @@ RuntimeBlob::RuntimeBlob(
void RuntimeBlob::free(RuntimeBlob* blob) {
assert(blob != nullptr, "caller must check for nullptr");
ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
blob->purge(true /* free_code_cache_data */, true /* unregister_nmethod */);
blob->purge();
{
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
CodeCache::free(blob);
Expand Down Expand Up @@ -408,7 +382,7 @@ RuntimeStub::RuntimeStub(
const char* name,
CodeBuffer* cb,
int size,
int frame_complete,
int16_t frame_complete,
int frame_size,
OopMapSet* oop_maps,
bool caller_must_gc_arguments
Expand All @@ -420,7 +394,7 @@ RuntimeStub::RuntimeStub(

RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name,
CodeBuffer* cb,
int frame_complete,
int16_t frame_complete,
int frame_size,
OopMapSet* oop_maps,
bool caller_must_gc_arguments,
Expand Down Expand Up @@ -668,10 +642,6 @@ void UpcallStub::free(UpcallStub* blob) {
RuntimeBlob::free(blob);
}

void UpcallStub::preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) {
ShouldNotReachHere(); // caller should never have to gc arguments
}

//----------------------------------------------------------------------------------------------------
// Verification and printing

Expand Down
80 changes: 36 additions & 44 deletions src/hotspot/share/code/codeBlob.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ enum class CodeBlobKind : u1 {
Number_Of_Kinds
};

class UpcallStub; // for as_upcall_stub()
class RuntimeStub; // for as_runtime_stub()
class UpcallStub; // for as_upcall_stub()
class RuntimeStub; // for as_runtime_stub()
class JavaFrameAnchor; // for UpcallStub::jfa_for_frame

class CodeBlob {
Expand All @@ -101,43 +101,39 @@ class CodeBlob {

protected:
// order fields from large to small to minimize padding between fields
ImmutableOopMapSet* _oop_maps; // OopMap for this CodeBlob
ImmutableOopMapSet* _oop_maps; // OopMap for this CodeBlob
const char* _name;

int _size; // total size of CodeBlob in bytes
int _header_size; // size of header (depends on subclass)
int _relocation_size; // size of relocation
int _content_offset; // offset to where content region begins (this includes consts, insts, stubs)
int _code_offset; // offset to where instructions region begins (this includes insts, stubs)
int _frame_complete_offset; // instruction offsets in [0.._frame_complete_offset) have
// not finished setting up their frame. Beware of pc's in
// that range. There is a similar range(s) on returns
// which we don't detect.
int _data_offset; // offset to where data region begins
int _frame_size; // size of stack frame in words (NOT slots. On x64 these are 64bit words)
int _size; // total size of CodeBlob in bytes
int _relocation_size; // size of relocation (could be bigger than 64Kb)
int _content_offset; // offset to where content region begins (this includes consts, insts, stubs)
int _code_offset; // offset to where instructions region begins (this includes insts, stubs)

S390_ONLY(int _ctable_offset;)
int _data_offset; // offset to where data region begins
int _frame_size; // size of stack frame in words (NOT slots. On x64 these are 64bit words)

CodeBlobKind _kind; // Kind of this code blob
S390_ONLY(int _ctable_offset;)

bool _caller_must_gc_arguments;
uint16_t _header_size; // size of header (depends on subclass)
int16_t _frame_complete_offset; // instruction offsets in [0.._frame_complete_offset) have
// not finished setting up their frame. Beware of pc's in
// that range. There is a similar range(s) on returns
// which we don't detect.

CodeBlobKind _kind; // Kind of this code blob

bool _caller_must_gc_arguments;

#ifndef PRODUCT
AsmRemarks _asm_remarks;
DbgStrings _dbg_strings;
#endif // not PRODUCT

DEBUG_ONLY( void verify_parameters() );

CodeBlob(const char* name, CodeBlobKind kind, int size, int header_size, int relocation_size,
int content_offset, int code_offset, int data_offset, int frame_complete_offset,
int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments);
#endif

CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size, int header_size,
int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments);
CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size, uint16_t header_size,
int16_t frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments);

// Simple CodeBlob used for simple BufferBlob.
CodeBlob(const char* name, CodeBlobKind kind, int size, int header_size);
CodeBlob(const char* name, CodeBlobKind kind, int size, uint16_t header_size);

void operator delete(void* p) { }

Expand All @@ -152,7 +148,7 @@ class CodeBlob {
static unsigned int align_code_offset(int offset);

// Deletion
virtual void purge(bool free_code_cache_data, bool unregister_nmethod);
void purge();

// Typing
bool is_nmethod() const { return _kind == CodeBlobKind::Nmethod; }
Expand Down Expand Up @@ -225,7 +221,6 @@ class CodeBlob {

const ImmutableOopMap* oop_map_for_slot(int slot, address return_address) const;
const ImmutableOopMap* oop_map_for_return_address(address return_address) const;
virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) = 0;

// Frame support. Sizes are in word units.
int frame_size() const { return _frame_size; }
Expand Down Expand Up @@ -273,7 +268,7 @@ class RuntimeBlob : public CodeBlob {

// Creation
// a) simple CodeBlob
RuntimeBlob(const char* name, CodeBlobKind kind, int size, int header_size)
RuntimeBlob(const char* name, CodeBlobKind kind, int size, uint16_t header_size)
: CodeBlob(name, kind, size, header_size)
{}

Expand All @@ -285,8 +280,8 @@ class RuntimeBlob : public CodeBlob {
CodeBlobKind kind,
CodeBuffer* cb,
int size,
int header_size,
int frame_complete,
uint16_t header_size,
int16_t frame_complete,
int frame_size,
OopMapSet* oop_maps,
bool caller_must_gc_arguments = false
Expand Down Expand Up @@ -324,10 +319,9 @@ class BufferBlob: public RuntimeBlob {

static void free(BufferBlob* buf);

// GC/Verification support
void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) override { /* nothing to do */ }

// Verification support
void verify() override;

void print_on(outputStream* st) const override;
void print_value_on(outputStream* st) const override;
};
Expand Down Expand Up @@ -381,7 +375,7 @@ class RuntimeStub: public RuntimeBlob {
const char* name,
CodeBuffer* cb,
int size,
int frame_complete,
int16_t frame_complete,
int frame_size,
OopMapSet* oop_maps,
bool caller_must_gc_arguments
Expand All @@ -394,7 +388,7 @@ class RuntimeStub: public RuntimeBlob {
static RuntimeStub* new_runtime_stub(
const char* stub_name,
CodeBuffer* cb,
int frame_complete,
int16_t frame_complete,
int frame_size,
OopMapSet* oop_maps,
bool caller_must_gc_arguments,
Expand All @@ -405,10 +399,9 @@ class RuntimeStub: public RuntimeBlob {

address entry_point() const { return code_begin(); }

// GC/Verification support
void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) override { /* nothing to do */ }

// Verification support
void verify() override;

void print_on(outputStream* st) const override;
void print_value_on(outputStream* st) const override;
};
Expand All @@ -429,7 +422,7 @@ class SingletonBlob: public RuntimeBlob {
CodeBlobKind kind,
CodeBuffer* cb,
int size,
int header_size,
uint16_t header_size,
int frame_size,
OopMapSet* oop_maps
)
Expand All @@ -438,9 +431,9 @@ class SingletonBlob: public RuntimeBlob {

address entry_point() { return code_begin(); }

// GC/Verification support
void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) override { /* nothing to do */ }
// Verification support
void verify() override; // does nothing

void print_on(outputStream* st) const override;
void print_value_on(outputStream* st) const override;
};
Expand Down Expand Up @@ -632,7 +625,6 @@ class UpcallStub: public RuntimeBlob {

// GC/Verification support
void oops_do(OopClosure* f, const frame& frame);
void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) override;
void verify() override;

// Misc.
Expand Down
7 changes: 2 additions & 5 deletions src/hotspot/share/code/debugInfoRec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,11 @@ static
struct dir_stats_struct {
int chunks_queried;
int chunks_shared;
int chunks_reshared;
int chunks_elided;

void print() {
tty->print_cr("Debug Data Chunks: %d, shared %d+%d, non-SP's elided %d",
chunks_queried,
chunks_shared, chunks_reshared,
chunks_elided);
tty->print_cr("Debug Data Chunks: %d, shared %d, non-SP's elided %d",
chunks_queried, chunks_shared, chunks_elided);
}
} dir_stats;
#endif //PRODUCT
Expand Down
6 changes: 2 additions & 4 deletions src/hotspot/share/code/dependencies.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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 @@ -388,9 +388,7 @@ void Dependencies::copy_to(nmethod* nm) {
address beg = nm->dependencies_begin();
address end = nm->dependencies_end();
guarantee(end - beg >= (ptrdiff_t) size_in_bytes(), "bad sizing");
Copy::disjoint_words((HeapWord*) content_bytes(),
(HeapWord*) beg,
size_in_bytes() / sizeof(HeapWord));
(void)memcpy(beg, content_bytes(), size_in_bytes());
assert(size_in_bytes() % sizeof(HeapWord) == 0, "copy by words");
}

Expand Down
Loading