7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters

Reviewed-by: jrose, never, kvn
This commit is contained in:
Christian Thalinger 2011-05-10 00:45:03 -07:00
parent 42e49be1bc
commit fee8d7fca4
7 changed files with 95 additions and 51 deletions

View file

@ -616,9 +616,10 @@ int MethodHandleWalker::argument_count_slow() {
// -----------------------------------------------------------------------------
// MethodHandleCompiler
MethodHandleCompiler::MethodHandleCompiler(Handle root, methodHandle callee, bool is_invokedynamic, TRAPS)
MethodHandleCompiler::MethodHandleCompiler(Handle root, methodHandle callee, int invoke_count, bool is_invokedynamic, TRAPS)
: MethodHandleWalker(root, is_invokedynamic, THREAD),
_callee(callee),
_invoke_count(invoke_count),
_thread(THREAD),
_bytecode(THREAD, 50),
_constants(THREAD, 10),
@ -1182,7 +1183,7 @@ constantPoolHandle MethodHandleCompiler::get_constant_pool(TRAPS) const {
methodHandle MethodHandleCompiler::get_method_oop(TRAPS) const {
methodHandle nullHandle;
methodHandle empty;
// Create a method that holds the generated bytecode. invokedynamic
// has no receiver, normal MH calls do.
int flags_bits;
@ -1191,13 +1192,16 @@ methodHandle MethodHandleCompiler::get_method_oop(TRAPS) const {
else
flags_bits = (/*JVM_MH_INVOKE_BITS |*/ JVM_ACC_PUBLIC | JVM_ACC_FINAL | JVM_ACC_SYNTHETIC);
methodOop m_oop = oopFactory::new_method(bytecode_length(),
accessFlags_from(flags_bits),
0, 0, 0, oopDesc::IsSafeConc, CHECK_(nullHandle));
methodHandle m(THREAD, m_oop);
m_oop = NULL; // oop not GC safe
// Create a new method
methodHandle m;
{
methodOop m_oop = oopFactory::new_method(bytecode_length(),
accessFlags_from(flags_bits),
0, 0, 0, oopDesc::IsSafeConc, CHECK_(empty));
m = methodHandle(THREAD, m_oop);
}
constantPoolHandle cpool = get_constant_pool(CHECK_(nullHandle));
constantPoolHandle cpool = get_constant_pool(CHECK_(empty));
m->set_constants(cpool());
m->set_name_index(_name_index);
@ -1212,16 +1216,32 @@ methodHandle MethodHandleCompiler::get_method_oop(TRAPS) const {
typeArrayHandle exception_handlers(THREAD, Universe::the_empty_int_array());
m->set_exception_table(exception_handlers());
// Set the carry bit of the invocation counter to force inlining of
// the adapter.
// Set the invocation counter's count to the invoke count of the
// original call site.
InvocationCounter* ic = m->invocation_counter();
ic->set_carry_flag();
ic->set(InvocationCounter::wait_for_compile, _invoke_count);
// Rewrite the method and set up the constant pool cache.
objArrayOop m_array = oopFactory::new_system_objArray(1, CHECK_(nullHandle));
objArrayOop m_array = oopFactory::new_system_objArray(1, CHECK_(empty));
objArrayHandle methods(THREAD, m_array);
methods->obj_at_put(0, m());
Rewriter::rewrite(_target_klass(), cpool, methods, CHECK_(nullHandle)); // Use fake class.
Rewriter::rewrite(_target_klass(), cpool, methods, CHECK_(empty)); // Use fake class.
// Create a new MDO
{
methodDataOop mdo = oopFactory::new_methodData(m, CHECK_(empty));
assert(m->method_data() == NULL, "there should not be an MDO yet");
m->set_method_data(mdo);
// Iterate over all profile data and set the count of the counter
// data entries to the original call site counter.
for (ProfileData* pd = mdo->first_data(); mdo->is_valid(pd); pd = mdo->next_data(pd)) {
if (pd->is_CounterData()) {
CounterData* cd = pd->as_CounterData();
cd->set_count(_invoke_count);
}
}
}
#ifndef PRODUCT
if (TraceMethodHandles) {