mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-07 17:08:53 +00:00
8140659: C1: invokedynamic call patching violates JVMS-6.5.invokedynamic
Reviewed-by: roland
This commit is contained in:
parent
a82be01120
commit
7adcd9a503
@ -1748,10 +1748,6 @@ void GraphBuilder::invoke(Bytecodes::Code code) {
|
||||
const Bytecodes::Code bc_raw = stream()->cur_bc_raw();
|
||||
assert(declared_signature != NULL, "cannot be null");
|
||||
|
||||
if (!C1PatchInvokeDynamic && Bytecodes::has_optional_appendix(bc_raw) && !will_link) {
|
||||
BAILOUT("unlinked call site (C1PatchInvokeDynamic is off)");
|
||||
}
|
||||
|
||||
// we have to make sure the argument size (incl. the receiver)
|
||||
// is correct for compilation (the call would fail later during
|
||||
// linkage anyway) - was bug (gri 7/28/99)
|
||||
@ -1803,8 +1799,7 @@ void GraphBuilder::invoke(Bytecodes::Code code) {
|
||||
// Push appendix argument (MethodType, CallSite, etc.), if one.
|
||||
bool patch_for_appendix = false;
|
||||
int patching_appendix_arg = 0;
|
||||
if (C1PatchInvokeDynamic &&
|
||||
(Bytecodes::has_optional_appendix(bc_raw) && (!will_link || PatchALot))) {
|
||||
if (Bytecodes::has_optional_appendix(bc_raw) && (!will_link || PatchALot)) {
|
||||
Value arg = append(new Constant(new ObjectConstant(compilation()->env()->unloaded_ciinstance()), copy_state_before()));
|
||||
apush(arg);
|
||||
patch_for_appendix = true;
|
||||
|
||||
@ -954,20 +954,25 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
|
||||
constantPoolHandle pool(thread, caller_method->constants());
|
||||
int index = bytecode.index();
|
||||
LinkResolver::resolve_invoke(info, Handle(), pool, index, bc, CHECK);
|
||||
appendix = info.resolved_appendix();
|
||||
switch (bc) {
|
||||
case Bytecodes::_invokehandle: {
|
||||
int cache_index = ConstantPool::decode_cpcache_index(index, true);
|
||||
assert(cache_index >= 0 && cache_index < pool->cache()->length(), "unexpected cache index");
|
||||
pool->cache()->entry_at(cache_index)->set_method_handle(pool, info);
|
||||
ConstantPoolCacheEntry* cpce = pool->cache()->entry_at(cache_index);
|
||||
cpce->set_method_handle(pool, info);
|
||||
appendix = info.resolved_appendix(); // just in case somebody already resolved the entry
|
||||
break;
|
||||
}
|
||||
case Bytecodes::_invokedynamic: {
|
||||
pool->invokedynamic_cp_cache_entry_at(index)->set_dynamic_call(pool, info);
|
||||
ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(index);
|
||||
cpce->set_dynamic_call(pool, info);
|
||||
appendix = cpce->appendix_if_resolved(pool); // just in case somebody already resolved the entry
|
||||
break;
|
||||
}
|
||||
default: fatal("unexpected bytecode for load_appendix_patching_id");
|
||||
}
|
||||
assert(appendix.not_null(), "%s @ %d (%s)",
|
||||
caller_method->name_and_sig_as_C_string(), bci, Bytecodes::name(bc));
|
||||
} else {
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
|
||||
@ -341,9 +341,6 @@
|
||||
develop(bool, PrintCFGToFile, false, \
|
||||
"print control flow graph to a separate file during compilation") \
|
||||
\
|
||||
diagnostic(bool, C1PatchInvokeDynamic, true, \
|
||||
"Patch invokedynamic appendix not known at compile time") \
|
||||
\
|
||||
// Read default values for c1 globals
|
||||
|
||||
C1_FLAGS(DECLARE_DEVELOPER_FLAG, \
|
||||
|
||||
@ -2386,6 +2386,7 @@ static methodHandle unpack_method_and_appendix(Handle mname,
|
||||
oop appendix = appendix_box->obj_at(0);
|
||||
if (TraceMethodHandles) {
|
||||
#ifndef PRODUCT
|
||||
ttyLocker ttyl;
|
||||
tty->print("Linked method=" INTPTR_FORMAT ": ", p2i(m));
|
||||
m->print();
|
||||
if (appendix != NULL) { tty->print("appendix = "); appendix->print(); }
|
||||
|
||||
@ -447,6 +447,7 @@ methodHandle LinkResolver::lookup_polymorphic_method(
|
||||
assert(result->intrinsic_id() != vmIntrinsics::_invokeGeneric, "wrong place to find this");
|
||||
assert(basic_signature == result->signature(), "predict the result signature");
|
||||
if (TraceMethodHandles) {
|
||||
ttyLocker ttyl;
|
||||
tty->print("lookup_polymorphic_method => intrinsic ");
|
||||
result->print_on(tty);
|
||||
}
|
||||
@ -479,6 +480,7 @@ methodHandle LinkResolver::lookup_polymorphic_method(
|
||||
&method_type,
|
||||
CHECK_NULL);
|
||||
if (TraceMethodHandles) {
|
||||
ttyLocker ttyl;
|
||||
tty->print("lookup_polymorphic_method => (via Java) ");
|
||||
result->print_on(tty);
|
||||
tty->print(" lookup_polymorphic_method => appendix = ");
|
||||
@ -1585,10 +1587,11 @@ void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHan
|
||||
}
|
||||
|
||||
if (TraceMethodHandles) {
|
||||
ResourceMark rm(THREAD);
|
||||
tty->print_cr("resolve_invokedynamic #%d %s %s",
|
||||
ResourceMark rm(THREAD);
|
||||
tty->print_cr("resolve_invokedynamic #%d %s %s in %s",
|
||||
ConstantPool::decode_invokedynamic_index(index),
|
||||
method_name->as_C_string(), method_signature->as_C_string());
|
||||
method_name->as_C_string(), method_signature->as_C_string(),
|
||||
current_klass->name()->as_C_string());
|
||||
tty->print(" BSM info: "); bootstrap_specifier->print();
|
||||
}
|
||||
|
||||
|
||||
@ -306,6 +306,7 @@ void ConstantPoolCacheEntry::set_method_handle_common(const constantPoolHandle&
|
||||
adapter->size_of_parameters());
|
||||
|
||||
if (TraceInvokeDynamic) {
|
||||
ttyLocker ttyl;
|
||||
tty->print_cr("set_method_handle bc=%d appendix=" PTR_FORMAT "%s method_type=" PTR_FORMAT "%s method=" PTR_FORMAT " ",
|
||||
invoke_code,
|
||||
p2i(appendix()), (has_appendix ? "" : " (unused)"),
|
||||
@ -357,6 +358,7 @@ void ConstantPoolCacheEntry::set_method_handle_common(const constantPoolHandle&
|
||||
set_bytecode_1(invoke_code);
|
||||
NOT_PRODUCT(verify(tty));
|
||||
if (TraceInvokeDynamic) {
|
||||
ttyLocker ttyl;
|
||||
this->print(tty, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1200,8 +1200,10 @@ methodHandle Method::make_method_handle_intrinsic(vmIntrinsics::ID iid,
|
||||
m->set_vtable_index(Method::nonvirtual_vtable_index);
|
||||
m->link_method(m, CHECK_(empty));
|
||||
|
||||
if (TraceMethodHandles && (Verbose || WizardMode))
|
||||
if (TraceMethodHandles && (Verbose || WizardMode)) {
|
||||
ttyLocker ttyl;
|
||||
m->print_on(tty);
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
@ -202,6 +202,7 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
|
||||
assert(m_klass->verify_itable_index(vmindex), "");
|
||||
flags |= IS_METHOD | (JVM_REF_invokeInterface << REFERENCE_KIND_SHIFT);
|
||||
if (TraceInvokeDynamic) {
|
||||
ttyLocker ttyl;
|
||||
ResourceMark rm;
|
||||
tty->print_cr("memberName: invokeinterface method_holder::method: %s, itableindex: %d, access_flags:",
|
||||
Method::name_and_sig_as_C_string(m->method_holder(), m->name(), m->signature()),
|
||||
@ -242,6 +243,7 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
|
||||
m_klass = m_klass_non_interface;
|
||||
}
|
||||
if (TraceInvokeDynamic) {
|
||||
ttyLocker ttyl;
|
||||
ResourceMark rm;
|
||||
tty->print_cr("memberName: invokevirtual method_holder::method: %s, receiver: %s, vtableindex: %d, access_flags:",
|
||||
Method::name_and_sig_as_C_string(m->method_holder(), m->name(), m->signature()),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user