RFR: 8302369: Reduce the stack size of the C1 compiler
Dean Long
dlong at openjdk.org
Wed Feb 15 00:35:48 UTC 2023
On Wed, 15 Feb 2023 00:12:58 GMT, Dean Long <dlong at openjdk.org> wrote:
>> The current fact is that C1 uses more stack space than the C2 compiler, taking method `java.lang.Object::<init>`as an example on the x86_64 platform , the stack size used is 48 bytes for C1 compiler, while only 16 bytes is used for C2 compiler.
>>
>> ========== C1-compiled nmethod =====
>> 0x00007f93311cc747: push %rbp
>> 0x00007f93311cc748: sub $0x30,%rsp // stack sizes is 48 bytes
>>
>>
>> ========== C2-compiled nmethod =======
>> pushq rbp # Save rbp
>> subq rsp, #16 # Create frame //stack sizes is 16 bytes
>>
>> After this patch, the C1 compiler will use less stack space. also taking method `java.lang.Object::<init>`as an example on the x86_64 platform , the stack size used is 16 bytes, which is the same as C2 compiler.
>>
>> ========== C1-compiled nmethod =====
>> 0x00007f80491ce647: push %rbp
>> 0x00007f80491ce648: sub $0x10,%rsp //stack sizes is 16 bytes
>
> src/hotspot/share/c1/c1_Compilation.cpp line 401:
>
>> 399: PhaseTraceTime timeit(_t_emit_lir);
>> 400:
>> 401: _frame_map = new FrameMap(method(), hir()->number_of_locks(), MAX2(4, hir()->max_stack()));
>
> I think there needs to be a minimum size (maybe 2 instead of 4?) because of code like CounterOverflowStub, RangeCheckStub, and generate_c1_load_barrier_stub() that call store_parameter() with small values (0, 1).
In order to reduce the minimum size lower than 2, C1 would need to determine (in advance?) if any stubs might be called. Maybe there is a way to calculate actual frame size required based on actual stores emitted, but that seems tricky if the prologue has already been emitted.
-------------
PR: https://git.openjdk.org/jdk/pull/12548
More information about the hotspot-compiler-dev
mailing list