-
Enhancement
-
Resolution: Fixed
-
P3
-
9
-
b33
There are many cases in InterpreterRuntime that look like this:
IRT_ENTRY(void, InterpreterRuntime::resolve_ldc(JavaThread* thread, Bytecodes::Code bytecode)) {
...
methodHandle m (thread, method(thread));
Bytecode_loadconstant ldc(m, bci(thread));
Where method(thread) and bci(thread) each would issue a call to thread->last_frame():
static frame last_frame(JavaThread *thread) { return thread->last_frame(); }
static Method* method(JavaThread *thread) { return last_frame(thread).interpreter_frame_method(); }
static address bcp(JavaThread *thread) { return last_frame(thread).interpreter_frame_bcp(); }
However, JavaThread::last_frame() is expensive. E.g., the x86 version would search for a code blob in the code cache.
---
The proposed enhancement is to call thread->last_frame() only once and reuse it:
frame last_frame = thread->last_frame();
methodHandle m (thread, method(last_frame));
Bytecode_loadconstant ldc(m, bci(last_frame));
Preliminary benchmarking shows significant VM start-up improvement:
java -version:
no CDS = 80.35 ms -> 79.14ms (-1.5%)
w/ CDS = 53.89ms -> 52.62ms (-2.36%)
clojure sample app:
no CDS = 1442.46ms -> 1436.11ms (-0.44%)
w/ CDS = 695.78ms -> 679.52ms (-2.34%)
IRT_ENTRY(void, InterpreterRuntime::resolve_ldc(JavaThread* thread, Bytecodes::Code bytecode)) {
...
methodHandle m (thread, method(thread));
Bytecode_loadconstant ldc(m, bci(thread));
Where method(thread) and bci(thread) each would issue a call to thread->last_frame():
static frame last_frame(JavaThread *thread) { return thread->last_frame(); }
static Method* method(JavaThread *thread) { return last_frame(thread).interpreter_frame_method(); }
static address bcp(JavaThread *thread) { return last_frame(thread).interpreter_frame_bcp(); }
However, JavaThread::last_frame() is expensive. E.g., the x86 version would search for a code blob in the code cache.
---
The proposed enhancement is to call thread->last_frame() only once and reuse it:
frame last_frame = thread->last_frame();
methodHandle m (thread, method(last_frame));
Bytecode_loadconstant ldc(m, bci(last_frame));
Preliminary benchmarking shows significant VM start-up improvement:
java -version:
no CDS = 80.35 ms -> 79.14ms (-1.5%)
w/ CDS = 53.89ms -> 52.62ms (-2.36%)
clojure sample app:
no CDS = 1442.46ms -> 1436.11ms (-0.44%)
w/ CDS = 695.78ms -> 679.52ms (-2.34%)
- clones
-
JDK-8179305 Avoid repeated calls to JavaThread::last_frame in InterpreterRuntime
-
- Closed
-