8148945: JDK-8148481: Devirtualize Klass::vtable breaks Zero build
Summary: Use Klass::method_at_vtable() instead of InstanceClass::start_of_vtable()[index]
Reviewed-by: mgerdin, coleenp
--- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp Wed Feb 03 11:33:33 2016 +0100
+++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp Wed Feb 03 12:19:03 2016 +0100
@@ -2502,10 +2502,10 @@
// Same comments as invokevirtual apply here.
oop rcvr = STACK_OBJECT(-parms);
VERIFY_OOP(rcvr);
- InstanceKlass* rcvrKlass = (InstanceKlass*)rcvr->klass();
- callee = (Method*) rcvrKlass->start_of_vtable()[ cache->f2_as_index()];
+ Klass* rcvrKlass = rcvr->klass();
+ callee = (Method*) rcvrKlass->method_at_vtable(cache->f2_as_index());
// Profile 'special case of invokeinterface' virtual call.
- BI_PROFILE_UPDATE_VIRTUALCALL(rcvr->klass());
+ BI_PROFILE_UPDATE_VIRTUALCALL(rcvrKlass);
}
istate->set_callee(callee);
istate->set_callee_entry_point(callee->from_interpreted_entry());
@@ -2594,7 +2594,7 @@
// but this works
oop rcvr = STACK_OBJECT(-parms);
VERIFY_OOP(rcvr);
- InstanceKlass* rcvrKlass = (InstanceKlass*)rcvr->klass();
+ Klass* rcvrKlass = rcvr->klass();
/*
Executing this code in java.lang.String:
public String(char value[]) {
@@ -2611,9 +2611,9 @@
However it seems to have a vtable in the right location. Huh?
Because vtables have the same offset for ArrayKlass and InstanceKlass.
*/
- callee = (Method*) rcvrKlass->start_of_vtable()[ cache->f2_as_index()];
+ callee = (Method*) rcvrKlass->method_at_vtable(cache->f2_as_index());
// Profile virtual call.
- BI_PROFILE_UPDATE_VIRTUALCALL(rcvr->klass());
+ BI_PROFILE_UPDATE_VIRTUALCALL(rcvrKlass);
}
} else {
if ((Bytecodes::Code)opcode == Bytecodes::_invokespecial) {