6655646: dynamic languages need dynamically linked call sites

Invokedynamic instruction (JSR 292 RI)

Reviewed-by: twisti, never
This commit is contained in:
John R Rose 2009-04-21 23:21:04 -07:00
parent fd05c28901
commit 34c1d72421
65 changed files with 1457 additions and 264 deletions

View file

@ -29,8 +29,18 @@
// Implememtation of ConstantPoolCacheEntry
void ConstantPoolCacheEntry::set_initial_state(int index) {
assert(0 <= index && index < 0x10000, "sanity check");
if (constantPoolCacheOopDesc::is_secondary_index(index)) {
// Hack: The rewriter is trying to say that this entry itself
// will be a secondary entry.
int main_index = constantPoolCacheOopDesc::decode_secondary_index(index);
assert(0 <= main_index && main_index < 0x10000, "sanity check");
_indices = (main_index << 16);
assert(main_entry_index() == main_index, "");
return;
}
assert(0 < index && index < 0x10000, "sanity check");
_indices = index;
assert(constant_pool_index() == index, "");
}
@ -136,6 +146,7 @@ void ConstantPoolCacheEntry::set_method(Bytecodes::Code invoke_code,
int byte_no = -1;
bool needs_vfinal_flag = false;
switch (invoke_code) {
case Bytecodes::_invokedynamic:
case Bytecodes::_invokevirtual:
case Bytecodes::_invokeinterface: {
if (method->can_be_statically_bound()) {
@ -211,6 +222,23 @@ void ConstantPoolCacheEntry::set_interface_call(methodHandle method, int index)
}
void ConstantPoolCacheEntry::set_dynamic_call(Handle call_site, int extra_data) {
methodOop method = (methodOop) sun_dyn_CallSiteImpl::vmmethod(call_site());
assert(method->is_method(), "must be initialized properly");
int param_size = method->size_of_parameters();
assert(param_size > 1, "method argument size must include MH.this & initial dynamic receiver");
param_size -= 1; // do not count MH.this; it is not stacked for invokedynamic
if (Atomic::cmpxchg_ptr(call_site(), &_f1, NULL) == NULL) {
// racing threads might be trying to install their own favorites
set_f1(call_site());
}
set_f2(extra_data);
set_flags(as_flags(as_TosState(method->result_type()), method->is_final_method(), false, false, false, true) | param_size);
// do not do set_bytecode on a secondary CP cache entry
//set_bytecode_1(Bytecodes::_invokedynamic);
}
class LocalOopClosure: public OopClosure {
private:
void (*_f)(oop*);
@ -392,7 +420,11 @@ void ConstantPoolCacheEntry::print(outputStream* st, int index) const {
// print separator
if (index == 0) tty->print_cr(" -------------");
// print entry
tty->print_cr("%3d (%08x) [%02x|%02x|%5d]", index, this, bytecode_2(), bytecode_1(), constant_pool_index());
tty->print_cr("%3d (%08x) ", index, this);
if (is_secondary_entry())
tty->print_cr("[%5d|secondary]", main_entry_index());
else
tty->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), constant_pool_index());
tty->print_cr(" [ %08x]", (address)(oop)_f1);
tty->print_cr(" [ %08x]", _f2);
tty->print_cr(" [ %08x]", _flags);