RFR: 8302369: Reduce the stack size of the C1 compiler
SUN Guoyun
duke at openjdk.org
Wed Feb 15 06:56:11 UTC 2023
On Wed, 15 Feb 2023 00:29:38 GMT, Dean Long <dlong at openjdk.org> wrote:
>> 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.
<pre><code class="cpp">
// src/hotspot/share/c1/c1_FrameMap.cpp
// bool FrameMap::finalize_frame(int nof_slots) {
191 _framesize = align_up(in_bytes(sp_offset_for_monitor_base(0)) +
192 _num_monitors * (int)sizeof(BasicObjectLock) +
193 (int)sizeof(intptr_t) + // offset of deopt orig pc
194 frame_pad_in_bytes,
195 StackAlignmentInBytes) / 4;
</code></pre>
Here the value of ` (int)sizeof(intptr_t)` is 8 and the value of `StackAlignmentInBytes` is 16, so the minimum stack size of a method is guaranteed to be 16, which should ensure that CounterOverflowStub (or other stub) needs two slots(0, 1).
But I don't understand what the addition of `(int)sizeof(intptr_t)` does here and what does `// offset of deopt orig pc` mean, do you know?
-------------
PR: https://git.openjdk.org/jdk/pull/12548
More information about the hotspot-compiler-dev
mailing list