8136421: JEP 243: Java-Level JVM Compiler Interface

Reviewed-by: ihse, alanb, roland, coleenp, iveresov, kvn, kbarrett
This commit is contained in:
Christian Thalinger 2015-10-08 12:49:30 -10:00
parent f5b4bb46f5
commit 16526e000e
505 changed files with 50394 additions and 915 deletions

View file

@ -413,13 +413,39 @@ void ReceiverTypeData::clean_weak_klass_links(BoolObjectClosure* is_alive_cl) {
}
}
#if INCLUDE_JVMCI
void VirtualCallData::clean_weak_klass_links(BoolObjectClosure* is_alive_cl) {
ReceiverTypeData::clean_weak_klass_links(is_alive_cl);
for (uint row = 0; row < method_row_limit(); row++) {
Method* p = method(row);
if (p != NULL && !p->method_holder()->is_loader_alive(is_alive_cl)) {
clear_method_row(row);
}
}
}
void VirtualCallData::clean_weak_method_links() {
ReceiverTypeData::clean_weak_method_links();
for (uint row = 0; row < method_row_limit(); row++) {
Method* p = method(row);
if (p != NULL && !p->on_stack()) {
clear_method_row(row);
}
}
}
#endif // INCLUDE_JVMCI
void ReceiverTypeData::print_receiver_data_on(outputStream* st) const {
uint row;
int entries = 0;
for (row = 0; row < row_limit(); row++) {
if (receiver(row) != NULL) entries++;
}
#if INCLUDE_JVMCI
st->print_cr("count(%u) nonprofiled_count(%u) entries(%u)", count(), nonprofiled_count(), entries);
#else
st->print_cr("count(%u) entries(%u)", count(), entries);
#endif
int total = count();
for (row = 0; row < row_limit(); row++) {
if (receiver(row) != NULL) {
@ -438,9 +464,36 @@ void ReceiverTypeData::print_data_on(outputStream* st, const char* extra) const
print_shared(st, "ReceiverTypeData", extra);
print_receiver_data_on(st);
}
#if INCLUDE_JVMCI
void VirtualCallData::print_method_data_on(outputStream* st) const {
uint row;
int entries = 0;
for (row = 0; row < method_row_limit(); row++) {
if (method(row) != NULL) entries++;
}
tab(st);
st->print_cr("method_entries(%u)", entries);
int total = count();
for (row = 0; row < method_row_limit(); row++) {
if (method(row) != NULL) {
total += method_count(row);
}
}
for (row = 0; row < method_row_limit(); row++) {
if (method(row) != NULL) {
tab(st);
method(row)->print_value_on(st);
st->print_cr("(%u %4.2f)", method_count(row), (float) method_count(row) / (float) total);
}
}
}
#endif // INCLUDE_JVMCI
void VirtualCallData::print_data_on(outputStream* st, const char* extra) const {
print_shared(st, "VirtualCallData", extra);
print_receiver_data_on(st);
print_method_data_on(st);
}
// ==================================================================
@ -665,7 +718,7 @@ MethodData* MethodData::allocate(ClassLoaderData* loader_data, methodHandle meth
}
int MethodData::bytecode_cell_count(Bytecodes::Code code) {
#if defined(COMPILER1) && !defined(COMPILER2)
#if defined(COMPILER1) && !(defined(COMPILER2) || INCLUDE_JVMCI)
return no_profile_data;
#else
switch (code) {
@ -797,6 +850,26 @@ bool MethodData::is_speculative_trap_bytecode(Bytecodes::Code code) {
}
int MethodData::compute_extra_data_count(int data_size, int empty_bc_count, bool needs_speculative_traps) {
#if INCLUDE_JVMCI
if (ProfileTraps) {
// Assume that up to 30% of the possibly trapping BCIs with no MDP will need to allocate one.
int extra_data_count = MIN2(empty_bc_count, MAX2(4, (empty_bc_count * 30) / 100));
// Make sure we have a minimum number of extra data slots to
// allocate SpeculativeTrapData entries. We would want to have one
// entry per compilation that inlines this method and for which
// some type speculation assumption fails. So the room we need for
// the SpeculativeTrapData entries doesn't directly depend on the
// size of the method. Because it's hard to estimate, we reserve
// space for an arbitrary number of entries.
int spec_data_count = (needs_speculative_traps ? SpecTrapLimitExtraEntries : 0) *
(SpeculativeTrapData::static_cell_count() + DataLayout::header_size_in_cells());
return MAX2(extra_data_count, spec_data_count);
} else {
return 0;
}
#else // INCLUDE_JVMCI
if (ProfileTraps) {
// Assume that up to 3% of BCIs with no MDP will need to allocate one.
int extra_data_count = (uint)(empty_bc_count * 3) / 128 + 1;
@ -822,6 +895,7 @@ int MethodData::compute_extra_data_count(int data_size, int empty_bc_count, bool
} else {
return 0;
}
#endif // INCLUDE_JVMCI
}
// Compute the size of the MethodData* necessary to store
@ -835,7 +909,7 @@ int MethodData::compute_allocation_size_in_bytes(methodHandle method) {
while ((c = stream.next()) >= 0) {
int size_in_bytes = compute_data_size(&stream);
data_size += size_in_bytes;
if (size_in_bytes == 0) empty_bc_count += 1;
if (size_in_bytes == 0 JVMCI_ONLY(&& Bytecodes::can_trap(c))) empty_bc_count += 1;
needs_speculative_traps = needs_speculative_traps || is_speculative_trap_bytecode(c);
}
int object_size = in_bytes(data_offset()) + data_size;
@ -869,7 +943,7 @@ int MethodData::compute_allocation_size_in_words(methodHandle method) {
// the segment in bytes.
int MethodData::initialize_data(BytecodeStream* stream,
int data_index) {
#if defined(COMPILER1) && !defined(COMPILER2)
#if defined(COMPILER1) && !(defined(COMPILER2) || INCLUDE_JVMCI)
return 0;
#else
int cell_count = -1;
@ -1060,10 +1134,14 @@ void MethodData::post_initialize(BytecodeStream* stream) {
MethodData::MethodData(methodHandle method, int size, TRAPS)
: _extra_data_lock(Monitor::leaf, "MDO extra data lock"),
_parameters_type_data_di(parameters_uninitialized) {
No_Safepoint_Verifier no_safepoint; // init function atomic wrt GC
ResourceMark rm;
// Set the method back-pointer.
_method = method();
initialize();
}
void MethodData::initialize() {
No_Safepoint_Verifier no_safepoint; // init function atomic wrt GC
ResourceMark rm;
init();
set_creation_mileage(mileage_of(method()));
@ -1073,13 +1151,13 @@ MethodData::MethodData(methodHandle method, int size, TRAPS)
int data_size = 0;
int empty_bc_count = 0; // number of bytecodes lacking data
_data[0] = 0; // apparently not set below.
BytecodeStream stream(method);
BytecodeStream stream(method());
Bytecodes::Code c;
bool needs_speculative_traps = false;
while ((c = stream.next()) >= 0) {
int size_in_bytes = initialize_data(&stream, data_size);
data_size += size_in_bytes;
if (size_in_bytes == 0) empty_bc_count += 1;
if (size_in_bytes == 0 JVMCI_ONLY(&& Bytecodes::can_trap(c))) empty_bc_count += 1;
needs_speculative_traps = needs_speculative_traps || is_speculative_trap_bytecode(c);
}
_data_size = data_size;
@ -1097,7 +1175,7 @@ MethodData::MethodData(methodHandle method, int size, TRAPS)
// the code for traps cells works.
DataLayout *dp = data_layout_at(data_size + extra_size);
int arg_size = method->size_of_parameters();
int arg_size = method()->size_of_parameters();
dp->initialize(DataLayout::arg_info_data_tag, 0, arg_size+1);
int arg_data_size = DataLayout::compute_size_in_bytes(arg_size+1);
@ -1126,6 +1204,7 @@ MethodData::MethodData(methodHandle method, int size, TRAPS)
post_initialize(&stream);
assert(object_size == compute_allocation_size_in_bytes(methodHandle(_method)), "MethodData: computed size != initialized size");
set_size(object_size);
}
@ -1146,6 +1225,10 @@ void MethodData::init() {
_num_blocks = 0;
_would_profile = unknown;
#if INCLUDE_JVMCI
_jvmci_ir_size = 0;
#endif
#if INCLUDE_RTM_OPT
_rtm_state = NoRTM; // No RTM lock eliding by default
if (UseRTMLocking &&