Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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/os/posix/signals_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

#include "precompiled.hpp"
#include "code/codeCache.hpp"
#include "code/nmethod.hpp"
#include "code/nativeInst.hpp"
#include "code/nmethod.hpp"
#include "jvm.h"
#include "logging/log.hpp"
#include "os_posix.hpp"
Expand Down
26 changes: 16 additions & 10 deletions src/hotspot/share/code/codeBlob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ BufferBlob* BufferBlob::create(const char* name, uint buffer_size) {
assert(name != nullptr, "must provide a name");
{
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
blob = new (size) BufferBlob(name, Blob_Buffer, size);
blob = new (size) BufferBlob(name, CodeBlobKind::Blob_Buffer, size);
}
// Track memory usage statistic after releasing CodeCache_lock
MemoryService::track_code_cache_memory_usage();
Expand All @@ -286,7 +286,7 @@ BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) {
assert(name != nullptr, "must provide a name");
{
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
blob = new (size) BufferBlob(name, Blob_Buffer, cb, size);
blob = new (size) BufferBlob(name, CodeBlobKind::Blob_Buffer, cb, size);
}
// Track memory usage statistic after releasing CodeCache_lock
MemoryService::track_code_cache_memory_usage();
Expand All @@ -307,7 +307,7 @@ void BufferBlob::free(BufferBlob *blob) {
// Implementation of AdapterBlob

AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) :
BufferBlob("I2C/C2I adapters", Blob_Adapter, cb, size) {
BufferBlob("I2C/C2I adapters", CodeBlobKind::Blob_Adapter, cb, size) {
CodeCache::commit(this);
}

Expand Down Expand Up @@ -342,7 +342,7 @@ void* VtableBlob::operator new(size_t s, unsigned size) throw() {
}

VtableBlob::VtableBlob(const char* name, int size) :
BufferBlob(name, Blob_Vtable, size) {
BufferBlob(name, CodeBlobKind::Blob_Vtable, size) {
}

VtableBlob* VtableBlob::create(const char* name, int buffer_size) {
Expand Down Expand Up @@ -413,7 +413,8 @@ RuntimeStub::RuntimeStub(
OopMapSet* oop_maps,
bool caller_must_gc_arguments
)
: RuntimeBlob(name, Blob_Runtime_Stub, cb, size, sizeof(RuntimeStub), frame_complete, frame_size, oop_maps, caller_must_gc_arguments)
: RuntimeBlob(name, CodeBlobKind::Blob_Runtime_Stub, cb, size, sizeof(RuntimeStub),
frame_complete, frame_size, oop_maps, caller_must_gc_arguments)
{
}

Expand Down Expand Up @@ -469,7 +470,8 @@ DeoptimizationBlob::DeoptimizationBlob(
int unpack_with_reexecution_offset,
int frame_size
)
: SingletonBlob("DeoptimizationBlob", Blob_Deoptimization, cb, size, sizeof(DeoptimizationBlob), frame_size, oop_maps)
: SingletonBlob("DeoptimizationBlob", CodeBlobKind::Blob_Deoptimization, cb,
size, sizeof(DeoptimizationBlob), frame_size, oop_maps)
{
_unpack_offset = unpack_offset;
_unpack_with_exception = unpack_with_exception_offset;
Expand Down Expand Up @@ -518,7 +520,8 @@ UncommonTrapBlob::UncommonTrapBlob(
OopMapSet* oop_maps,
int frame_size
)
: SingletonBlob("UncommonTrapBlob", Blob_Uncommon_Trap, cb, size, sizeof(UncommonTrapBlob), frame_size, oop_maps)
: SingletonBlob("UncommonTrapBlob", CodeBlobKind::Blob_Uncommon_Trap, cb,
size, sizeof(UncommonTrapBlob), frame_size, oop_maps)
{}


Expand Down Expand Up @@ -554,7 +557,8 @@ ExceptionBlob::ExceptionBlob(
OopMapSet* oop_maps,
int frame_size
)
: SingletonBlob("ExceptionBlob", Blob_Exception, cb, size, sizeof(ExceptionBlob), frame_size, oop_maps)
: SingletonBlob("ExceptionBlob", CodeBlobKind::Blob_Exception, cb,
size, sizeof(ExceptionBlob), frame_size, oop_maps)
{}


Expand Down Expand Up @@ -589,7 +593,8 @@ SafepointBlob::SafepointBlob(
OopMapSet* oop_maps,
int frame_size
)
: SingletonBlob("SafepointBlob", Blob_Safepoint, cb, size, sizeof(SafepointBlob), frame_size, oop_maps)
: SingletonBlob("SafepointBlob", CodeBlobKind::Blob_Safepoint, cb,
size, sizeof(SafepointBlob), frame_size, oop_maps)
{}


Expand All @@ -615,7 +620,8 @@ SafepointBlob* SafepointBlob::create(
// Implementation of UpcallStub

UpcallStub::UpcallStub(const char* name, CodeBuffer* cb, int size, jobject receiver, ByteSize frame_data_offset) :
RuntimeBlob(name, Blob_Upcall, cb, size, sizeof(UpcallStub), CodeOffsets::frame_never_safe, 0 /* no frame size */,
RuntimeBlob(name, CodeBlobKind::Blob_Upcall, cb, size, sizeof(UpcallStub),
CodeOffsets::frame_never_safe, 0 /* no frame size */,
/* oop maps = */ nullptr, /* caller must gc arguments = */ false),
_receiver(receiver),
_frame_data_offset(frame_data_offset)
Expand Down
38 changes: 19 additions & 19 deletions src/hotspot/share/code/codeBlob.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ enum class CodeBlobType {
// - instruction space
// - data space

enum CodeBlobKind : u1 {
enum class CodeBlobKind : u1 {
Blob_None,
Blob_Nmethod,
Blob_Buffer,
Expand Down Expand Up @@ -155,17 +155,17 @@ class CodeBlob {
virtual void purge(bool free_code_cache_data, bool unregister_nmethod);

// Typing
bool is_nmethod() const { return _kind == Blob_Nmethod; }
bool is_buffer_blob() const { return _kind == Blob_Buffer; }
bool is_runtime_stub() const { return _kind == Blob_Runtime_Stub; }
bool is_deoptimization_stub() const { return _kind == Blob_Deoptimization; }
bool is_uncommon_trap_stub() const { return _kind == Blob_Uncommon_Trap; }
bool is_exception_stub() const { return _kind == Blob_Exception; }
bool is_safepoint_stub() const { return _kind == Blob_Safepoint; }
bool is_adapter_blob() const { return _kind == Blob_Adapter; }
bool is_vtable_blob() const { return _kind == Blob_Vtable; }
bool is_method_handles_adapter_blob() const { return _kind == Blob_MH_Adapter; }
bool is_upcall_stub() const { return _kind == Blob_Upcall; }
bool is_nmethod() const { return _kind == CodeBlobKind::Blob_Nmethod; }
bool is_buffer_blob() const { return _kind == CodeBlobKind::Blob_Buffer; }
bool is_runtime_stub() const { return _kind == CodeBlobKind::Blob_Runtime_Stub; }
bool is_deoptimization_stub() const { return _kind == CodeBlobKind::Blob_Deoptimization; }
bool is_uncommon_trap_stub() const { return _kind == CodeBlobKind::Blob_Uncommon_Trap; }
bool is_exception_stub() const { return _kind == CodeBlobKind::Blob_Exception; }
bool is_safepoint_stub() const { return _kind == CodeBlobKind::Blob_Safepoint; }
bool is_adapter_blob() const { return _kind == CodeBlobKind::Blob_Adapter; }
bool is_vtable_blob() const { return _kind == CodeBlobKind::Blob_Vtable; }
bool is_method_handles_adapter_blob() const { return _kind == CodeBlobKind::Blob_MH_Adapter; }
bool is_upcall_stub() const { return _kind == CodeBlobKind::Blob_Upcall; }

// Casting
nmethod* as_nmethod_or_null() { return is_nmethod() ? (nmethod*) this : nullptr; }
Expand Down Expand Up @@ -362,7 +362,7 @@ class VtableBlob: public BufferBlob {

class MethodHandlesAdapterBlob: public BufferBlob {
private:
MethodHandlesAdapterBlob(int size): BufferBlob("MethodHandles adapters", Blob_MH_Adapter, size) {}
MethodHandlesAdapterBlob(int size): BufferBlob("MethodHandles adapters", CodeBlobKind::Blob_MH_Adapter, size) {}

public:
// Creation
Expand Down Expand Up @@ -425,13 +425,13 @@ class SingletonBlob: public RuntimeBlob {

public:
SingletonBlob(
const char* name,
const char* name,
CodeBlobKind kind,
CodeBuffer* cb,
int size,
int header_size,
int frame_size,
OopMapSet* oop_maps
CodeBuffer* cb,
int size,
int header_size,
int frame_size,
OopMapSet* oop_maps
)
: RuntimeBlob(name, kind, cb, size, header_size, CodeOffsets::frame_never_safe, frame_size, oop_maps)
{};
Expand Down
12 changes: 3 additions & 9 deletions src/hotspot/share/code/debugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,9 @@ void DebugInfoWriteStream::write_metadata(Metadata* h) {
}

oop DebugInfoReadStream::read_oop() {
nmethod* nm = const_cast<nmethod*>(code())->as_nmethod_or_null();
oop o;
if (nm != nullptr) {
// Despite these oops being found inside nmethods that are on-stack,
// they are not kept alive by all GCs (e.g. G1 and Shenandoah).
o = nm->oop_at_phantom(read_int());
} else {
o = code()->oop_at(read_int());
}
// Despite these oops being found inside nmethods that are on-stack,
// they are not kept alive by all GCs (e.g. G1 and Shenandoah).
oop o = code()->oop_at_phantom(read_int());
assert(oopDesc::is_oop_or_null(o), "oop only");
return o;
}
Expand Down
18 changes: 9 additions & 9 deletions src/hotspot/share/code/nmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ address nmethod::oops_reloc_begin() const {
// assert(BarrierSet::barrier_set()->barrier_set_nmethod() == nullptr, "Not safe oop scan");

address low_boundary = verified_entry_point();
if (!is_in_use() && is_nmethod()) {
if (!is_in_use()) {
low_boundary += NativeJump::instruction_size;
// %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump.
// This means that the low_boundary is going to be a little too high.
Expand Down Expand Up @@ -809,8 +809,8 @@ void nmethod::run_nmethod_entry_barrier() {
// nmethods found in safepoints have gone through an entry barrier and are not armed.
// By calling this nmethod entry barrier, it plays along and acts
// like any other nmethod found on the stack of a thread (fewer surprises).
nmethod* nm = as_nmethod_or_null();
if (nm != nullptr && bs_nm->is_armed(nm)) {
nmethod* nm = this;
if (bs_nm->is_armed(nm)) {
bool alive = bs_nm->nmethod_entry_barrier(nm);
assert(alive, "should be alive");
}
Expand Down Expand Up @@ -1006,9 +1006,9 @@ const char* nmethod::compiler_name() const {

// Fill in default values for various flag fields
void nmethod::init_defaults() {
{ // avoid uninitialized fields, even for short time periods
_exception_cache = nullptr;
}
// avoid uninitialized fields, even for short time periods
_exception_cache = nullptr;

_has_unsafe_access = 0;
_has_method_handle_invokes = 0;
_has_wide_vectors = 0;
Expand Down Expand Up @@ -1211,7 +1211,7 @@ nmethod::nmethod(
ByteSize basic_lock_owner_sp_offset,
ByteSize basic_lock_sp_offset,
OopMapSet* oop_maps )
: CodeBlob("native nmethod", Blob_Nmethod, code_buffer, nmethod_size, sizeof(nmethod),
: CodeBlob("native nmethod", CodeBlobKind::Blob_Nmethod, code_buffer, nmethod_size, sizeof(nmethod),
offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false),
_deoptimization_generation(0),
_method(method),
Expand Down Expand Up @@ -1356,7 +1356,7 @@ nmethod::nmethod(
JVMCINMethodData* jvmci_data
#endif
)
: CodeBlob("nmethod", Blob_Nmethod, code_buffer, nmethod_size, sizeof(nmethod),
: CodeBlob("nmethod", CodeBlobKind::Blob_Nmethod, code_buffer, nmethod_size, sizeof(nmethod),
offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false),
_deoptimization_generation(0),
_method(method),
Expand Down Expand Up @@ -2161,7 +2161,7 @@ void nmethod::post_compiled_method_unload() {
assert(_method != nullptr, "just checking");
DTRACE_METHOD_UNLOAD_PROBE(method());

// If a JVMTI agent has enabled the nmethod Unload event then
// If a JVMTI agent has enabled the CompiledMethodUnload event then
// post the event. The Method* will not be valid when this is freed.

// Don't bother posting the unload if the load event wasn't posted.
Expand Down
19 changes: 9 additions & 10 deletions src/hotspot/share/code/nmethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,23 @@
#include "oops/metadata.hpp"
#include "oops/method.hpp"

class AbstractCompiler;
class CompiledDirectCall;
class CompiledIC;
class CompiledICData;
class CompileTask;
class DepChange;
class Dependencies;
class DirectiveSet;
class DebugInformationRecorder;
class JvmtiThreadState;
class OopIterateClosure;

class Dependencies;
class ExceptionHandlerTable;
class ImplicitExceptionTable;
class AbstractCompiler;
class xmlStream;
class CompiledDirectCall;
class JvmtiThreadState;
class MetadataClosure;
class NativeCallWrapper;
class OopIterateClosure;
class ScopeDesc;
class CompiledIC;
class MetadataClosure;
class xmlStream;

// This class is used internally by nmethods, to cache
// exception/pc/handler information.
Expand Down Expand Up @@ -902,7 +901,7 @@ class nmethod : public CodeBlob {
void decode(outputStream* st) const { decode2(st); } // just delegate here.

// printing support
void print() const override;
virtual void print() const override;
void print(outputStream* st) const;
void print_code();

Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/code/relocInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@

#include <new>

class nmethod;
class CodeBlob;
class nmethod;
class Metadata;
class NativeMovConstReg;
class nmethod;

// Types in this file:
// relocInfo
Expand Down
10 changes: 2 additions & 8 deletions src/hotspot/share/compiler/compileBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1377,8 +1377,7 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
if (osr_bci == InvocationEntryBci) {
// standard compilation
nmethod* method_code = method->code();
if (method_code != nullptr && method_code->is_nmethod()
&& (compile_reason != CompileTask::Reason_DirectivesChanged)) {
if (method_code != nullptr && (compile_reason != CompileTask::Reason_DirectivesChanged)) {
if (compilation_is_complete(method, osr_bci, comp_level)) {
return (nmethod*) method_code;
}
Expand Down Expand Up @@ -1481,12 +1480,7 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
// return requested nmethod
// We accept a higher level osr method
if (osr_bci == InvocationEntryBci) {
nmethod* code = method->code();
if (code == nullptr) {
return (nmethod*) code;
} else {
return code->as_nmethod_or_null();
}
return method->code();
}
return method->lookup_osr_nmethod_for(osr_bci, comp_level, false);
}
Expand Down
14 changes: 5 additions & 9 deletions src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class ShenandoahIsUnloadingOopClosure : public OopClosure {

class ShenandoahIsUnloadingBehaviour : public IsUnloadingBehaviour {
public:
virtual bool has_dead_oop(nmethod* method) const {
nmethod* const nm = method->as_nmethod();
virtual bool has_dead_oop(nmethod* const nm) const {
assert(ShenandoahHeap::heap()->is_concurrent_weak_root_in_progress(), "Only for this phase");
ShenandoahNMethod* data = ShenandoahNMethod::gc_data(nm);
ShenandoahReentrantLocker locker(data->lock());
Expand All @@ -91,27 +90,24 @@ class ShenandoahIsUnloadingBehaviour : public IsUnloadingBehaviour {

class ShenandoahCompiledICProtectionBehaviour : public CompiledICProtectionBehaviour {
public:
virtual bool lock(nmethod* method) {
nmethod* const nm = method->as_nmethod();
virtual bool lock(nmethod* const nm) {
ShenandoahReentrantLock* const lock = ShenandoahNMethod::lock_for_nmethod(nm);
assert(lock != nullptr, "Not yet registered?");
lock->lock();
return true;
}

virtual void unlock(nmethod* method) {
nmethod* const nm = method->as_nmethod();
virtual void unlock(nmethod* const nm) {
ShenandoahReentrantLock* const lock = ShenandoahNMethod::lock_for_nmethod(nm);
assert(lock != nullptr, "Not yet registered?");
lock->unlock();
}

virtual bool is_safe(nmethod* method) {
if (SafepointSynchronize::is_at_safepoint() || method->is_unloading()) {
virtual bool is_safe(nmethod* const nm) {
if (SafepointSynchronize::is_at_safepoint() || nm->is_unloading()) {
return true;
}

nmethod* const nm = method->as_nmethod();
ShenandoahReentrantLock* const lock = ShenandoahNMethod::lock_for_nmethod(nm);
assert(lock != nullptr, "Not yet registered?");
return lock->owned_by_self();
Expand Down
Loading