/* * Copyright (c) 1998, 2022, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
class ImmutableOopMap; class ImmutableOopMapSet; class JNIHandleBlock; class OopMapSet;
// CodeBlob Types // Used in the CodeCache to assign CodeBlobs to different CodeHeaps enumclass CodeBlobType {
MethodNonProfiled = 0, // Execution level 1 and 4 (non-profiled) nmethods (including native nmethods)
MethodProfiled = 1, // Execution level 2 and 3 (profiled) nmethods
NonNMethod = 2, // Non-nmethods like Buffers, Adapters and Runtime Stubs
All = 3, // All types (No code cache segmentation)
NumTypes = 4 // Number of CodeBlobTypes
};
// CodeBlob - superclass for all entries in the CodeCache. // // Subtypes are: // CompiledMethod : Compiled Java methods (include method that calls to native code) // nmethod : JIT Compiled Java methods // RuntimeBlob : Non-compiled method code; generated glue code // BufferBlob : Used for non-relocatable code such as interpreter, stubroutines, etc. // AdapterBlob : Used to hold C2I/I2C adapters // VtableBlob : Used for holding vtable chunks // MethodHandlesAdapterBlob : Used to hold MethodHandles adapters // RuntimeStub : Call to VM runtime methods // SingletonBlob : Super-class for all blobs that exist in only one instance // DeoptimizationBlob : Used for deoptimization // ExceptionBlob : Used for stack unrolling // SafepointBlob : Used to handle illegal instruction exceptions // UncommonTrapBlob : Used to handle uncommon traps // UpcallStub : Used for upcalls from native code // // // Layout : continuous in the CodeCache // - header // - relocation // - content space // - instruction space // - data space
class CodeBlobLayout; class UpcallStub; // for as_upcall_stub() class RuntimeStub; // for as_runtime_stub() class JavaFrameAnchor; // for UpcallStub::jfa_for_frame
class CodeBlob { friendclass VMStructs; friendclass JVMCIVMStructs; friendclass CodeCacheDumper;
protected:
// order fields from large to small to minimize padding between fields
address _code_begin;
address _code_end;
address _content_begin; // address to where content region begins (this includes consts, insts, stubs) // address _content_end - not required, for all CodeBlobs _code_end == _content_end for now
address _data_end;
address _relocation_begin;
address _relocation_end;
ImmutableOopMapSet* _oop_maps; // OopMap for this CodeBlob
constchar* _name;
S390_ONLY(int _ctable_offset;)
int _size; // total size of CodeBlob in bytes int _header_size; // size of header (depends on subclass) 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)
~CodeBlob() {
_asm_remarks.clear();
_dbg_strings.clear();
} #endif// not PRODUCT
CodeBlob(constchar* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments, bool compiled = false);
CodeBlob(constchar* name, CompilerType type, const CodeBlobLayout& layout, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments, bool compiled = false); public: // Only used by unit test.
CodeBlob() : _type(compiler_none) {}
// Returns the space needed for CodeBlob staticunsignedint allocation_size(CodeBuffer* cb, int header_size); staticunsignedint align_code_offset(int offset);
// Boundaries
address header_begin() const { return (address) this; }
relocInfo* relocation_begin() const { return (relocInfo*) _relocation_begin; };
relocInfo* relocation_end() const { return (relocInfo*) _relocation_end; }
address content_begin() const { return _content_begin; }
address content_end() const { return _code_end; } // _code_end == _content_end is true for all types of blobs for now, it is also checked in the constructor
address code_begin() const { return _code_begin; }
address code_end() const { return _code_end; }
address data_end() const { return _data_end; }
// This field holds the beginning of the const section in the old code buffer. // It is needed to fix relocations of pc-relative loads when resizing the // the constant pool or moving it.
S390_ONLY(address ctable_begin() const { return header_begin() + _ctable_offset; }) void set_ctable_begin(address ctable) { S390_ONLY(_ctable_offset = ctable - header_begin();) }
// Sizes int size() const { return _size; } int header_size() const { return _header_size; } int relocation_size() const { return (address) relocation_end() - (address) relocation_begin(); } int content_size() const { return content_end() - content_begin(); } int code_size() const { return code_end() - code_begin(); } // Only used from CodeCache::free_unused_tail() after the Interpreter blob was trimmed void adjust_size(size_t used) {
_size = (int)used;
_data_offset = (int)used;
_code_end = (address)this + used;
_data_end = (address)this + used;
}
// Frame support. Sizes are in word units. int frame_size() const { return _frame_size; } void set_frame_size(int size) { _frame_size = size; }
// Returns true, if the next frame is responsible for GC'ing oops passed as arguments bool caller_must_gc_arguments(JavaThread* thread) const { return _caller_must_gc_arguments; }
class CodeBlobLayout : public StackObj { private: int _size; int _header_size; int _relocation_size; int _content_offset; int _code_offset; int _data_offset;
address _code_begin;
address _code_end;
address _content_begin;
address _content_end;
address _data_end;
address _relocation_begin;
address _relocation_end;
class RuntimeBlob : public CodeBlob { friendclass VMStructs; public:
// Creation // a) simple CodeBlob // frame_complete is the offset from the beginning of the instructions // to where the frame setup (from stackwalk viewpoint) is complete.
RuntimeBlob(constchar* name, int header_size, int size, int frame_complete, int locs_size);
// b) full CodeBlob
RuntimeBlob( constchar* name,
CodeBuffer* cb, int header_size, int size, int frame_complete, int frame_size,
OopMapSet* oop_maps, bool caller_must_gc_arguments = false
);
class WhiteBox; //---------------------------------------------------------------------------------------------------- // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
class BufferBlob: public RuntimeBlob { friendclass VMStructs; friendclass AdapterBlob; friendclass VtableBlob; friendclass MethodHandlesAdapterBlob; friendclass UpcallStub; friendclass WhiteBox;
private: // Creation support
BufferBlob(constchar* name, int size);
BufferBlob(constchar* name, int size, CodeBuffer* cb);
// This ordinary operator delete is needed even though not used, so the // below two-argument operator delete will be treated as a placement // delete rather than an ordinary sized delete; see C++14 3.7.4.2/p2. voidoperatordelete(void* p); void* operatornew(size_t s, unsigned size) throw();
//--------------------------------------------------------------------------------------------------- class VtableBlob: public BufferBlob { private:
VtableBlob(constchar*, int);
//---------------------------------------------------------------------------------------------------- // MethodHandlesAdapterBlob: used to hold MethodHandles adapters
class MethodHandlesAdapterBlob: public BufferBlob { private:
MethodHandlesAdapterBlob(int size): BufferBlob("MethodHandles adapters", size) {}
//---------------------------------------------------------------------------------------------------- // RuntimeStub: describes stubs used by compiled code to call a (static) C++ runtime routine
class RuntimeStub: public RuntimeBlob { friendclass VMStructs; private: // Creation support
RuntimeStub( constchar* name,
CodeBuffer* cb, int size, int frame_complete, int frame_size,
OopMapSet* oop_maps, bool caller_must_gc_arguments
);
// This ordinary operator delete is needed even though not used, so the // below two-argument operator delete will be treated as a placement // delete rather than an ordinary sized delete; see C++14 3.7.4.2/p2. voidoperatordelete(void* p); void* operatornew(size_t s, unsigned size) throw();
public: // Creation static RuntimeStub* new_runtime_stub( constchar* stub_name,
CodeBuffer* cb, int frame_complete, int frame_size,
OopMapSet* oop_maps, bool caller_must_gc_arguments
);
//---------------------------------------------------------------------------------------------------- // Super-class for all blobs that exist in only one instance. Implements default behaviour.
class SingletonBlob: public RuntimeBlob { friendclass VMStructs;
protected: // This ordinary operator delete is needed even though not used, so the // below two-argument operator delete will be treated as a placement // delete rather than an ordinary sized delete; see C++14 3.7.4.2/p2. voidoperatordelete(void* p); void* operatornew(size_t s, unsigned size) throw();
public:
SingletonBlob( constchar* name,
CodeBuffer* cb, int header_size, int size, int frame_size,
OopMapSet* oop_maps
)
: RuntimeBlob(name, cb, header_size, size, CodeOffsets::frame_never_safe, frame_size, oop_maps)
{};
address entry_point() { return code_begin(); }
// GC/Verification support void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* nothing to do */ } void verify(); // does nothing void print_on(outputStream* st) const; void print_value_on(outputStream* st) const;
};
class DeoptimizationBlob: public SingletonBlob { friendclass VMStructs; friendclass JVMCIVMStructs; private: int _unpack_offset; int _unpack_with_exception; int _unpack_with_reexecution;
int _unpack_with_exception_in_tls;
#if INCLUDE_JVMCI // Offsets when JVMCI calls uncommon_trap. int _uncommon_trap_offset; int _implicit_exception_uncommon_trap_offset; #endif
// Creation support
DeoptimizationBlob(
CodeBuffer* cb, int size,
OopMapSet* oop_maps, int unpack_offset, int unpack_with_exception_offset, int unpack_with_reexecution_offset, int frame_size
);
public: // Creation static DeoptimizationBlob* create(
CodeBuffer* cb,
OopMapSet* oop_maps, int unpack_offset, int unpack_with_exception_offset, int unpack_with_reexecution_offset, int frame_size
);
// Alternate entry point for C1 where the exception and issuing pc // are in JavaThread::_exception_oop and JavaThread::_exception_pc // instead of being in registers. This is needed because C1 doesn't // model exception paths in a way that keeps these registers free so // there may be live values in those registers during deopt. void set_unpack_with_exception_in_tls_offset(int offset) {
_unpack_with_exception_in_tls = offset;
assert(code_contains(code_begin() + _unpack_with_exception_in_tls), "must be PC inside codeblob");
}
address unpack_with_exception_in_tls() const { return code_begin() + _unpack_with_exception_in_tls; }
//---------------------------------------------------------------------------------------------------- // UncommonTrapBlob (currently only used by Compiler 2)
#ifdef COMPILER2
class UncommonTrapBlob: public SingletonBlob { friendclass VMStructs; private: // Creation support
UncommonTrapBlob(
CodeBuffer* cb, int size,
OopMapSet* oop_maps, int frame_size
);
//---------------------------------------------------------------------------------------------------- // ExceptionBlob: used for exception unwinding in compiled code (currently only used by Compiler 2)
class ExceptionBlob: public SingletonBlob { friendclass VMStructs; private: // Creation support
ExceptionBlob(
CodeBuffer* cb, int size,
OopMapSet* oop_maps, int frame_size
);
//---------------------------------------------------------------------------------------------------- // SafepointBlob: handles illegal_instruction exceptions during a safepoint
class SafepointBlob: public SingletonBlob { friendclass VMStructs; private: // Creation support
SafepointBlob(
CodeBuffer* cb, int size,
OopMapSet* oop_maps, int frame_size
);
// A (Panama) upcall stub. Not used by JNI. class UpcallStub: public RuntimeBlob { friendclass UpcallLinker; private:
intptr_t _exception_handler_offset;
jobject _receiver;
ByteSize _frame_data_offset;
// This ordinary operator delete is needed even though not used, so the // below two-argument operator delete will be treated as a placement // delete rather than an ordinary sized delete; see C++14 3.7.4.2/p2. voidoperatordelete(void* p); void* operatornew(size_t s, unsigned size) throw();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.