Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,6 @@ void InterpreterMacroAssembler::get_cache_index_at_bcp(Register index,
} else if (index_size == sizeof(u4)) {
// assert(EnableInvokeDynamic, "giant index used only for JSR 292");
ldrw(index, Address(rbcp, bcp_offset));
// Check if the secondary index definition is still ~x, otherwise
// we have to change the following assembler code to calculate the
// plain index.
assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line");
eonw(index, index, zr); // convert to plain index
} else if (index_size == sizeof(u1)) {
load_unsigned_byte(index, Address(rbcp, bcp_offset));
} else {
Expand Down
5 changes: 0 additions & 5 deletions src/hotspot/cpu/arm/interp_masm_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,6 @@ void InterpreterMacroAssembler::get_index_at_bcp(Register index, int bcp_offset,
orr(index, tmp_reg, AsmOperand(index, lsl, BitsPerByte));
ldrb(tmp_reg, Address(Rbcp, bcp_offset));
orr(index, tmp_reg, AsmOperand(index, lsl, BitsPerByte));
// Check if the secondary index definition is still ~x, otherwise
// we have to change the following assembler code to calculate the
// plain index.
assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line");
mvn_32(index, index); // convert to plain index
} else if (index_size == sizeof(u1)) {
ldrb(index, Address(Rbcp, bcp_offset));
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,6 @@ void InterpreterMacroAssembler::get_cache_index_at_bcp(Register Rdst, int bcp_of
} else {
lwa(Rdst, bcp_offset, R14_bcp);
}
assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line");
nand(Rdst, Rdst, Rdst); // convert to plain index
} else if (index_size == sizeof(u1)) {
lbz(Rdst, bcp_offset, R14_bcp);
} else {
Expand Down
7 changes: 0 additions & 7 deletions src/hotspot/cpu/riscv/interp_masm_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,6 @@ void InterpreterMacroAssembler::get_cache_index_at_bcp(Register index,
}
} else if (index_size == sizeof(u4)) {
load_int_misaligned(index, Address(xbcp, bcp_offset), tmp, false);

// Check if the secondary index definition is still ~x, otherwise
// we have to change the following assembler code to calculate the
// plain index.
assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line");
xori(index, index, -1);
sign_extend(index, index, 32);
} else if (index_size == sizeof(u1)) {
load_unsigned_byte(index, Address(xbcp, bcp_offset));
} else {
Expand Down
6 changes: 0 additions & 6 deletions src/hotspot/cpu/s390/interp_masm_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,6 @@ void InterpreterMacroAssembler::get_cache_index_at_bcp(Register index, int bcp_o
} else if (index_size == sizeof(u4)) {

load_sized_value(index, param, 4, false);

// Check if the secondary index definition is still ~x, otherwise
// we have to change the following assembler code to calculate the
// plain index.
assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line");
not_(index); // Convert to plain index.
} else if (index_size == sizeof(u1)) {
z_llgc(index, param);
} else {
Expand Down
5 changes: 0 additions & 5 deletions src/hotspot/cpu/x86/interp_masm_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,6 @@ void InterpreterMacroAssembler::get_cache_index_at_bcp(Register index,
load_unsigned_short(index, Address(_bcp_register, bcp_offset));
} else if (index_size == sizeof(u4)) {
movl(index, Address(_bcp_register, bcp_offset));
// Check if the secondary index definition is still ~x, otherwise
// we have to change the following assembler code to calculate the
// plain index.
assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line");
notl(index); // convert to plain index
} else if (index_size == sizeof(u1)) {
load_unsigned_byte(index, Address(_bcp_register, bcp_offset));
} else {
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/c1/c1_Runtime1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_
break;
}
case Bytecodes::_invokedynamic: {
int indy_index = pool->decode_invokedynamic_index(index);
appendix = Handle(current, pool->cache()->set_dynamic_call(info, indy_index));
appendix = Handle(current, pool->cache()->set_dynamic_call(info, index));
break;
}
default: fatal("unexpected bytecode for load_appendix_patching_id");
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/cds/classListParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ void ClassListParser::resolve_indy_impl(Symbol* class_name_symbol, TRAPS) {
LinkResolver::resolve_invoke(info,
recv,
pool,
ConstantPool::encode_invokedynamic_index(indy_index),
indy_index,
Bytecodes::_invokedynamic, CHECK);
break;
}
Expand Down
13 changes: 5 additions & 8 deletions src/hotspot/share/ci/ciEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,10 +869,8 @@ ciMethod* ciEnv::get_method_by_index_impl(const constantPoolHandle& cpool,
// Jump through a patchable call site, which is initially a deopt routine.
// Patch the call site to the nmethod entry point of the static compiled lambda form.
// As with other two-component call sites, both values must be independently verified.
int indy_index = cpool->decode_invokedynamic_index(index);
assert (indy_index >= 0, "should be");
assert(indy_index < cpool->cache()->resolved_indy_entries_length(), "impossible");
Method* adapter = cpool->resolved_indy_entry_at(indy_index)->method();
assert(index < cpool->cache()->resolved_indy_entries_length(), "impossible");
Method* adapter = cpool->resolved_indy_entry_at(index)->method();
// Resolved if the adapter is non null.
if (adapter != nullptr) {
return get_method(adapter);
Expand Down Expand Up @@ -1499,21 +1497,20 @@ void ciEnv::record_call_site_method(Thread* thread, Method* adapter) {

// Process an invokedynamic call site and record any dynamic locations.
void ciEnv::process_invokedynamic(const constantPoolHandle &cp, int indy_index, JavaThread* thread) {
int index = cp->decode_invokedynamic_index(indy_index);
ResolvedIndyEntry* indy_info = cp->resolved_indy_entry_at(index);
ResolvedIndyEntry* indy_info = cp->resolved_indy_entry_at(indy_index);
if (indy_info->method() != nullptr) {
// process the adapter
Method* adapter = indy_info->method();
record_call_site_method(thread, adapter);
// process the appendix
oop appendix = cp->resolved_reference_from_indy(index);
oop appendix = cp->resolved_reference_from_indy(indy_index);
{
RecordLocation fp(this, "<appendix>");
record_call_site_obj(thread, appendix);
}
// process the BSM
int pool_index = indy_info->constant_pool_index();
BootstrapInfo bootstrap_specifier(cp, pool_index, index);
BootstrapInfo bootstrap_specifier(cp, pool_index, indy_index);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just change the incoming parameter name to index?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indy_index is used frequently even in functions that are only used in the context of invokedynamic. I think it helps with clarity.

oop bsm = cp->resolve_possibly_cached_constant_at(bootstrap_specifier.bsm_index(), thread);
{
RecordLocation fp(this, "<bsm>");
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/ci/ciReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ class CompileReplay : public StackObj {
int pool_index = 0;

if (bytecode.is_invokedynamic()) {
index = cp->decode_invokedynamic_index(index);
cp->cache()->set_dynamic_call(callInfo, index);

appendix = cp->resolved_reference_from_indy(index);
Expand Down
7 changes: 3 additions & 4 deletions src/hotspot/share/ci/ciStreams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ ciMethod* ciBytecodeStream::get_method(bool& will_link, ciSignature* *declared_s
bool ciBytecodeStream::has_appendix() {
VM_ENTRY_MARK;
constantPoolHandle cpool(THREAD, _method->get_Method()->constants());
return ConstantPool::has_appendix_at_if_loaded(cpool, get_method_index());
return ConstantPool::has_appendix_at_if_loaded(cpool, get_method_index(), cur_bc());
}

// ------------------------------------------------------------------
Expand All @@ -481,7 +481,7 @@ bool ciBytecodeStream::has_appendix() {
ciObject* ciBytecodeStream::get_appendix() {
VM_ENTRY_MARK;
constantPoolHandle cpool(THREAD, _method->get_Method()->constants());
oop appendix_oop = ConstantPool::appendix_at_if_loaded(cpool, get_method_index());
oop appendix_oop = ConstantPool::appendix_at_if_loaded(cpool, get_method_index(), cur_bc());
return CURRENT_ENV->get_object(appendix_oop);
}

Expand All @@ -493,7 +493,7 @@ ciObject* ciBytecodeStream::get_appendix() {
bool ciBytecodeStream::has_local_signature() {
GUARDED_VM_ENTRY(
constantPoolHandle cpool(Thread::current(), _method->get_Method()->constants());
return ConstantPool::has_local_signature_at_if_loaded(cpool, get_method_index());
return ConstantPool::has_local_signature_at_if_loaded(cpool, get_method_index(), cur_bc());
)
}

Expand Down Expand Up @@ -543,4 +543,3 @@ int ciBytecodeStream::get_method_signature_index(const constantPoolHandle& cpool
return cpool->signature_ref_index_at(name_and_type_index);
)
}

3 changes: 1 addition & 2 deletions src/hotspot/share/classfile/resolutionErrors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ class ResolutionErrorTable : AllStatic {
static const int CPCACHE_INDEX_MANGLE_VALUE = 1000000;

// This function is used to encode an invokedynamic index to differentiate it from a
// constant pool index. It assumes it is being called with a index that is less than 0
// constant pool index.
static int encode_indy_index(int index) {
assert(index < 0, "Unexpected non-negative cpCache index");
return index + CPCACHE_INDEX_MANGLE_VALUE;
}
};
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/interpreter/abstractInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ bool AbstractInterpreter::is_not_reached(const methodHandle& method, int bci) {
switch (code) {
case Bytecodes::_invokedynamic: {
assert(invoke_bc.has_index_u4(code), "sanity");
int method_index = cpool->decode_invokedynamic_index(invoke_bc.get_index_u4(code));
int method_index = invoke_bc.get_index_u4(code);
return cpool->resolved_indy_entry_at(method_index)->is_resolved();
}
case Bytecodes::_invokevirtual: // fall-through
Expand Down Expand Up @@ -394,8 +394,7 @@ address AbstractInterpreter::deopt_continue_after_entry(Method* method, address
// (NOT needed for the old calling convention)
if (!is_top_frame) {
int index = Bytes::get_native_u4(bcp+1);
int indy_index = method->constants()->decode_invokedynamic_index(index);
method->constants()->resolved_indy_entry_at(indy_index)->set_num_parameters(callee_parameters);
method->constants()->resolved_indy_entry_at(index)->set_num_parameters(callee_parameters);
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/interpreter/bootstrapInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool BootstrapInfo::resolve_previously_linked_invokedynamic(CallInfo& result, TR
Exceptions::wrap_dynamic_exception(/* is_indy */ true, CHECK_false);
return true;
} else if (indy_entry->resolution_failed()) {
int encoded_index = ResolutionErrorTable::encode_indy_index(ConstantPool::encode_invokedynamic_index(_indy_index));
int encoded_index = ResolutionErrorTable::encode_indy_index(_indy_index);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an improvement, from two levels of encoding to only one!

ConstantPool::throw_resolution_error(_pool, encoded_index, CHECK_false); // Doesn't necessarily need to be resolved yet
return true;
} else {
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/interpreter/bootstrapInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class BootstrapInfo : public StackObj {
// derived accessors
InstanceKlass* caller() const { return _pool->pool_holder(); }
oop caller_mirror() const { return caller()->java_mirror(); }
int decode_indy_index() const { return ConstantPool::decode_invokedynamic_index(_indy_index); }
int bsms_attr_index() const { return _pool->bootstrap_methods_attribute_index(_bss_index); }
int bsm_index() const { return _pool->bootstrap_method_ref_index_at(_bss_index); }
//int argc() is eagerly cached in _argc
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/interpreter/bytecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ int Bytecode_member_ref::pool_index() const {
ResolvedIndyEntry* Bytecode_member_ref::resolved_indy_entry() const {
int index = this->index();
assert(invoke_code() == Bytecodes::_invokedynamic, "should not call this");
return cpcache()->resolved_indy_entry_at(ConstantPool::decode_invokedynamic_index(index));
return cpcache()->resolved_indy_entry_at(index);
}

ResolvedMethodEntry* Bytecode_member_ref::resolved_method_entry() const {
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/interpreter/bytecodeTracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,7 @@ void BytecodePrinter::print_attributes(int bci, outputStream* st) {
int indy_index;
int cp_index;
if (is_linked()) {
int i = get_native_index_u4();
indy_index = ConstantPool::decode_invokedynamic_index(i);
indy_index = get_native_index_u4();
cp_index = constants()->resolved_indy_entry_at(indy_index)->constant_pool_index();
} else {
indy_index = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/interpreter/interpreterRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ void InterpreterRuntime::resolve_invokedynamic(JavaThread* current) {
index, bytecode, CHECK);
} // end JvmtiHideSingleStepping

pool->cache()->set_dynamic_call(info, pool->decode_invokedynamic_index(index));
pool->cache()->set_dynamic_call(info, index);
}

// This function is the interface to the assembly code. It returns the resolved
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/interpreter/linkResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1779,11 +1779,10 @@ void LinkResolver::resolve_handle_call(CallInfo& result,
}

void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int indy_index, TRAPS) {
int index = pool->decode_invokedynamic_index(indy_index);
int pool_index = pool->resolved_indy_entry_at(index)->constant_pool_index();
int pool_index = pool->resolved_indy_entry_at(indy_index)->constant_pool_index();

// Resolve the bootstrap specifier (BSM + optional arguments).
BootstrapInfo bootstrap_specifier(pool, pool_index, index);
BootstrapInfo bootstrap_specifier(pool, pool_index, indy_index);

// Check if CallSite has been bound already or failed already, and short circuit:
{
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/interpreter/rewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,14 @@ void Rewriter::rewrite_invokedynamic(address bcp, int offset, bool reverse) {
// must have a five-byte instruction format. (Of course, other JVM
// implementations can use the bytes for other purposes.)
// Note: We use native_u4 format exclusively for 4-byte indexes.
Bytes::put_native_u4(p, ConstantPool::encode_invokedynamic_index(_invokedynamic_index));
Bytes::put_native_u4(p, (u2)_invokedynamic_index);
_invokedynamic_index++;

// Collect invokedynamic information before creating ResolvedInvokeDynamicInfo array
_initialized_indy_entries.push(ResolvedIndyEntry((u2)resolved_index, (u2)cp_index));
} else {
// Should do nothing since we are not patching this bytecode
int cache_index = ConstantPool::decode_invokedynamic_index(
Bytes::get_native_u4(p));
int cache_index = Bytes::get_native_u4(p);
int cp_index = _initialized_indy_entries.at(cache_index).constant_pool_index();
assert(_pool->tag_at(cp_index).is_invoke_dynamic(), "wrong index");
// zero out 4 bytes
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
}

CASE(_invokedynamic): {
u4 index = cp->constant_pool()->decode_invokedynamic_index(Bytes::get_native_u4(pc+1)); // index is originally negative
u4 index = Bytes::get_native_u4(pc+1);
ResolvedIndyEntry* indy_info = cp->resolved_indy_entry_at(index);
if (!indy_info->is_resolved()) {
CALL_VM(InterpreterRuntime::resolve_from_cache(THREAD, (Bytecodes::Code)opcode),
Expand Down
Loading