Details
Description
(This is an alternative proposal than JDK-8026297).
When a CDS-archived class is loaded, the following 4 fields are unconditionally modified for every Method in this class:
Method::_i2i_entry
Method::_from_interpreted_entry
Method::_from_compiled_entry
Method::_adapter
This causes a lot of copy-on-write on the Methods. If we can avoid these modifications, more data in the "RW" section of the CDS archive can be shared across processes.
The proposal is to change the first 3 fields into trampoline calls. E.g.,
Method::_i2i_entry points to a function F at a fixed location inside the CDS archive's "MC" section. In turn, F contains an unconditional branch to the real destination of the i2i entry.
For the 4th field, the proposal is
union {
AdapterHandlerEntry* _adapter;
AdapterHandlerEntry** _adapter_trampoline;
};
AdapterHandlerEntry* adapter() {
if (is_shared()) {
return *_adapter_trampoline;
} else {
return _adapter;
}
}
_adapter_trampoline points to a fixed location A inside the CDS archive's "MD" section. In turn, A points to the real location of the AdapterHandlerEntry.
When the class is loaded, the contents of F and A will be modified, but the contents of the Method no longer need to be modified.
With this change, Method::_adapter can be moved to ConstMethod, since it never changes for archived Methods.
We can also move Method::i2i_entry to ConstMethod. However, I am not sure about the performance impact, so this will be done in a separate RFE (JDK-8145234).
When a CDS-archived class is loaded, the following 4 fields are unconditionally modified for every Method in this class:
Method::_i2i_entry
Method::_from_interpreted_entry
Method::_from_compiled_entry
Method::_adapter
This causes a lot of copy-on-write on the Methods. If we can avoid these modifications, more data in the "RW" section of the CDS archive can be shared across processes.
The proposal is to change the first 3 fields into trampoline calls. E.g.,
Method::_i2i_entry points to a function F at a fixed location inside the CDS archive's "MC" section. In turn, F contains an unconditional branch to the real destination of the i2i entry.
For the 4th field, the proposal is
union {
AdapterHandlerEntry* _adapter;
AdapterHandlerEntry** _adapter_trampoline;
};
AdapterHandlerEntry* adapter() {
if (is_shared()) {
return *_adapter_trampoline;
} else {
return _adapter;
}
}
_adapter_trampoline points to a fixed location A inside the CDS archive's "MD" section. In turn, A points to the real location of the AdapterHandlerEntry.
When the class is loaded, the contents of F and A will be modified, but the contents of the Method no longer need to be modified.
With this change, Method::_adapter can be moved to ConstMethod, since it never changes for archived Methods.
We can also move Method::i2i_entry to ConstMethod. However, I am not sure about the performance impact, so this will be done in a separate RFE (
Attachments
Issue Links
- relates to
-
JDK-8150663 JavaThread::pd_get_top_frame_for_profiling may fail if the PC is at arbitrary locations
- Closed
-
JDK-8145234 Move Method::_i2i_entry to ConstMethod
- Closed
-
JDK-8169711 CDS does not patch entry trampoline if intrinsic method is disabled
- Resolved
-
JDK-8026297 Generate AdapterHandlerEntry during CDS dump
- Open
-
JDK-8263002 Remove CDS MiscCode region
- Resolved