RFR: 8302369: Reduce the stack size of the C1 compiler

SUN Guoyun duke at openjdk.org
Wed Feb 15 07:18:46 UTC 2023


On Tue, 14 Feb 2023 23:52: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/cpu/x86/c1_LIRAssembler_x86.cpp line 3028:
> 
>> 3026:   assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
>> 3027:   int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
>> 3028:   assert(offset_from_rsp_in_bytes <= frame_map()->reserved_argument_area_size(), "invalid offset");
> 
> I don't understand this change.  Doesn't the byte range go from 0 to frame_map()->reserved_argument_area_size() - 1?

It's really confusing here, I'm sure `reserved_argument_area_size` contains extra stubs for jsr292, but not sure if other stub slots (i.e. CounterOverflowStub) are included.

Your suggestion`Maybe there is a way to calculate actual frame size required based on actual stores emitted` should be correct and I'm trying to see if it works.

-------------

PR: https://git.openjdk.org/jdk/pull/12548


More information about the hotspot-compiler-dev mailing list