mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8136421: JEP 243: Java-Level JVM Compiler Interface
Reviewed-by: ihse, alanb, roland, coleenp, iveresov, kvn, kbarrett
This commit is contained in:
parent
f5b4bb46f5
commit
16526e000e
505 changed files with 50394 additions and 915 deletions
|
@ -39,6 +39,9 @@
|
|||
#ifdef COMPILER2
|
||||
#include "opto/optoreg.hpp"
|
||||
#endif
|
||||
#ifdef SPARC
|
||||
#include "vmreg_sparc.inline.hpp"
|
||||
#endif
|
||||
|
||||
// OopMapStream
|
||||
|
||||
|
@ -272,10 +275,15 @@ static DoNothingClosure do_nothing;
|
|||
static void add_derived_oop(oop* base, oop* derived) {
|
||||
#ifndef TIERED
|
||||
COMPILER1_PRESENT(ShouldNotReachHere();)
|
||||
#if INCLUDE_JVMCI
|
||||
if (UseJVMCICompiler) {
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
#endif
|
||||
#endif // TIERED
|
||||
#ifdef COMPILER2
|
||||
#if defined(COMPILER2) || INCLUDE_JVMCI
|
||||
DerivedPointerTable::add(derived, base);
|
||||
#endif // COMPILER2
|
||||
#endif // COMPILER2 || INCLUDE_JVMCI
|
||||
}
|
||||
|
||||
|
||||
|
@ -284,7 +292,7 @@ static void trace_codeblob_maps(const frame *fr, const RegisterMap *reg_map) {
|
|||
// Print oopmap and regmap
|
||||
tty->print_cr("------ ");
|
||||
CodeBlob* cb = fr->cb();
|
||||
ImmutableOopMapSet* maps = cb->oop_maps();
|
||||
const ImmutableOopMapSet* maps = cb->oop_maps();
|
||||
const ImmutableOopMap* map = cb->oop_map_for_return_address(fr->pc());
|
||||
map->print();
|
||||
if( cb->is_nmethod() ) {
|
||||
|
@ -321,7 +329,7 @@ void OopMapSet::all_do(const frame *fr, const RegisterMap *reg_map,
|
|||
|
||||
NOT_PRODUCT(if (TraceCodeBlobStacks) trace_codeblob_maps(fr, reg_map);)
|
||||
|
||||
ImmutableOopMapSet* maps = cb->oop_maps();
|
||||
const ImmutableOopMapSet* maps = cb->oop_maps();
|
||||
const ImmutableOopMap* map = cb->oop_map_for_return_address(fr->pc());
|
||||
assert(map != NULL, "no ptr map found");
|
||||
|
||||
|
@ -333,6 +341,11 @@ void OopMapSet::all_do(const frame *fr, const RegisterMap *reg_map,
|
|||
if (!oms.is_done()) {
|
||||
#ifndef TIERED
|
||||
COMPILER1_PRESENT(ShouldNotReachHere();)
|
||||
#if INCLUDE_JVMCI
|
||||
if (UseJVMCICompiler) {
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
#endif
|
||||
#endif // !TIERED
|
||||
// Protect the operation on the derived pointers. This
|
||||
// protects the addition of derived pointers to the shared
|
||||
|
@ -448,7 +461,7 @@ void OopMapSet::update_register_map(const frame *fr, RegisterMap *reg_map) {
|
|||
|
||||
// Check that runtime stubs save all callee-saved registers
|
||||
#ifdef COMPILER2
|
||||
assert(cb->is_compiled_by_c1() || !cb->is_runtime_stub() ||
|
||||
assert(cb->is_compiled_by_c1() || cb->is_compiled_by_jvmci() || !cb->is_runtime_stub() ||
|
||||
(nof_callee >= SAVED_ON_ENTRY_REG_COUNT || nof_callee >= C_SAVED_ON_ENTRY_REG_COUNT),
|
||||
"must save all");
|
||||
#endif // COMPILER2
|
||||
|
@ -462,13 +475,18 @@ void OopMapSet::update_register_map(const frame *fr, RegisterMap *reg_map) {
|
|||
bool ImmutableOopMap::has_derived_pointer() const {
|
||||
#ifndef TIERED
|
||||
COMPILER1_PRESENT(return false);
|
||||
#if INCLUDE_JVMCI
|
||||
if (UseJVMCICompiler) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#endif // !TIERED
|
||||
#ifdef COMPILER2
|
||||
OopMapStream oms((OopMap*)this,OopMapValue::derived_oop_value);
|
||||
#if defined(COMPILER2) || INCLUDE_JVMCI
|
||||
OopMapStream oms(this,OopMapValue::derived_oop_value);
|
||||
return oms.is_done();
|
||||
#else
|
||||
return false;
|
||||
#endif // COMPILER2
|
||||
#endif // COMPILER2 || INCLUDE_JVMCI
|
||||
}
|
||||
|
||||
#endif //PRODUCT
|
||||
|
@ -601,74 +619,9 @@ int ImmutableOopMap::nr_of_bytes() const {
|
|||
}
|
||||
#endif
|
||||
|
||||
class ImmutableOopMapBuilder {
|
||||
private:
|
||||
class Mapping;
|
||||
|
||||
private:
|
||||
const OopMapSet* _set;
|
||||
const OopMap* _empty;
|
||||
const OopMap* _last;
|
||||
int _empty_offset;
|
||||
int _last_offset;
|
||||
int _offset;
|
||||
Mapping* _mapping;
|
||||
ImmutableOopMapSet* _new_set;
|
||||
|
||||
/* Used for bookkeeping when building ImmutableOopMaps */
|
||||
class Mapping : public ResourceObj {
|
||||
public:
|
||||
enum kind_t { OOPMAP_UNKNOWN = 0, OOPMAP_NEW = 1, OOPMAP_EMPTY = 2, OOPMAP_DUPLICATE = 3 };
|
||||
|
||||
kind_t _kind;
|
||||
int _offset;
|
||||
int _size;
|
||||
const OopMap* _map;
|
||||
const OopMap* _other;
|
||||
|
||||
Mapping() : _kind(OOPMAP_UNKNOWN), _offset(-1), _size(-1), _map(NULL) {}
|
||||
|
||||
void set(kind_t kind, int offset, int size, const OopMap* map = 0, const OopMap* other = 0) {
|
||||
_kind = kind;
|
||||
_offset = offset;
|
||||
_size = size;
|
||||
_map = map;
|
||||
_other = other;
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
ImmutableOopMapBuilder(const OopMapSet* set) : _set(set), _new_set(NULL), _empty(NULL), _last(NULL), _empty_offset(-1), _last_offset(-1), _offset(0) {
|
||||
_mapping = NEW_RESOURCE_ARRAY(Mapping, _set->size());
|
||||
}
|
||||
|
||||
int heap_size();
|
||||
ImmutableOopMapSet* build();
|
||||
private:
|
||||
bool is_empty(const OopMap* map) const {
|
||||
return map->count() == 0;
|
||||
}
|
||||
|
||||
bool is_last_duplicate(const OopMap* map) {
|
||||
if (_last != NULL && _last->count() > 0 && _last->equals(map)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef ASSERT
|
||||
void verify(address buffer, int size, const ImmutableOopMapSet* set);
|
||||
#endif
|
||||
|
||||
bool has_empty() const {
|
||||
return _empty_offset != -1;
|
||||
}
|
||||
|
||||
int size_for(const OopMap* map) const;
|
||||
void fill_pair(ImmutableOopMapPair* pair, const OopMap* map, int offset, const ImmutableOopMapSet* set);
|
||||
int fill_map(ImmutableOopMapPair* pair, const OopMap* map, int offset, const ImmutableOopMapSet* set);
|
||||
void fill(ImmutableOopMapSet* set, int size);
|
||||
};
|
||||
ImmutableOopMapBuilder::ImmutableOopMapBuilder(const OopMapSet* set) : _set(set), _new_set(NULL), _empty(NULL), _last(NULL), _empty_offset(-1), _last_offset(-1), _offset(0), _required(-1) {
|
||||
_mapping = NEW_RESOURCE_ARRAY(Mapping, _set->size());
|
||||
}
|
||||
|
||||
int ImmutableOopMapBuilder::size_for(const OopMap* map) const {
|
||||
return align_size_up(sizeof(ImmutableOopMap) + map->data_size(), 8);
|
||||
|
@ -713,6 +666,7 @@ int ImmutableOopMapBuilder::heap_size() {
|
|||
|
||||
int total = base + pairs + _offset;
|
||||
DEBUG_ONLY(total += 8);
|
||||
_required = total;
|
||||
return total;
|
||||
}
|
||||
|
||||
|
@ -764,21 +718,25 @@ void ImmutableOopMapBuilder::verify(address buffer, int size, const ImmutableOop
|
|||
}
|
||||
#endif
|
||||
|
||||
ImmutableOopMapSet* ImmutableOopMapBuilder::build() {
|
||||
int required = heap_size();
|
||||
ImmutableOopMapSet* ImmutableOopMapBuilder::generate_into(address buffer) {
|
||||
DEBUG_ONLY(memset(&buffer[_required-8], 0xff, 8));
|
||||
|
||||
// We need to allocate a chunk big enough to hold the ImmutableOopMapSet and all of its ImmutableOopMaps
|
||||
address buffer = (address) NEW_C_HEAP_ARRAY(unsigned char, required, mtCode);
|
||||
DEBUG_ONLY(memset(&buffer[required-8], 0xff, 8));
|
||||
_new_set = new (buffer) ImmutableOopMapSet(_set, _required);
|
||||
fill(_new_set, _required);
|
||||
|
||||
_new_set = new (buffer) ImmutableOopMapSet(_set, required);
|
||||
fill(_new_set, required);
|
||||
|
||||
DEBUG_ONLY(verify(buffer, required, _new_set));
|
||||
DEBUG_ONLY(verify(buffer, _required, _new_set));
|
||||
|
||||
return _new_set;
|
||||
}
|
||||
|
||||
ImmutableOopMapSet* ImmutableOopMapBuilder::build() {
|
||||
_required = heap_size();
|
||||
|
||||
// We need to allocate a chunk big enough to hold the ImmutableOopMapSet and all of its ImmutableOopMaps
|
||||
address buffer = (address) NEW_C_HEAP_ARRAY(unsigned char, _required, mtCode);
|
||||
return generate_into(buffer);
|
||||
}
|
||||
|
||||
ImmutableOopMapSet* ImmutableOopMapSet::build_from(const OopMapSet* oopmap_set) {
|
||||
ResourceMark mark;
|
||||
ImmutableOopMapBuilder builder(oopmap_set);
|
||||
|
@ -788,7 +746,7 @@ ImmutableOopMapSet* ImmutableOopMapSet::build_from(const OopMapSet* oopmap_set)
|
|||
|
||||
//------------------------------DerivedPointerTable---------------------------
|
||||
|
||||
#ifdef COMPILER2
|
||||
#if defined(COMPILER2) || INCLUDE_JVMCI
|
||||
|
||||
class DerivedPointerEntry : public CHeapObj<mtCompiler> {
|
||||
private:
|
||||
|
@ -881,4 +839,4 @@ void DerivedPointerTable::update_pointers() {
|
|||
_active = false;
|
||||
}
|
||||
|
||||
#endif // COMPILER2
|
||||
#endif // COMPILER2 || INCLUDE_JVMCI
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue