RFR: 8307352: AARCH64: Improve itable_stub [v2]

Boris Ulasevich bulasevich at openjdk.org
Mon Aug 7 08:31:36 UTC 2023


On Mon, 10 Jul 2023 15:16:25 GMT, Evgeny Astigeevich <eastigeevich at openjdk.org> wrote:

>> Boris Ulasevich has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains one commit:
>> 
>>   8307352: AARCH64: Improve itable_stub
>
> src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp line 1233:
> 
>> 1231:   ldr(temp_itbl_klass, Address(recv_klass, scan_temp, Address::lsl(3)));
>> 1232:   mov(holder_offset, zr);
>> 1233:   lea(scan_temp, Address(recv_klass, scan_temp, Address::lsl(3)));
> 
> The comments to the code help little to understand the origins of the generated code.
> I understand the generated code corresponds to:
> 
> temp_itbl_klass = (itableOffsetEntry*)(recv_klass->start_of_itable())[0].interface_klass()
> 
> which is
> 
> temp_itbl_klass = *(recv_klass + Klass::vtable_start_offset() + sizeof(intptr_t)*recv_klass->_vtable_length + itableOffsetEntry::offset_offset())
> 
> 
> You store `recv_klass + Klass::vtable_start_offset() +itableOffsetEntry::offset_offset()` into `recv_klass`.
> BTW, you assume `sizeof(intptr_t) == 8` to use `Address::lsl(3)`. Should this be mentioned in comments? 
> You store `recv_klass + sizeof(intptr_t)*recv_klass->_vtable_length` into `scan_temp` to access `itable[i].interface_klass()`.
> 
> I think the code is worth adding more comments.

A simple cpp code explains things better than words. Let me put it in a way that explains data access, rather than strictly following a sequence of register manipulation:

  int vtable_start_offset = in_bytes(Klass::vtable_start_offset());
  int ioffset = in_bytes(itableOffsetEntry::interface_offset());

  ldrw(scan_temp, Address(recv_klass, Klass::vtable_length_offset()));
  add(recv_klass, recv_klass, vtable_start_offset + ioffset);
  // itableOffsetEntry[] itable = recv_klass + Klass::vtable_start_offset() + recv_klass->_vtable_len;
  // temp_itbl_klass = itable[0]._interface;
  ldr(temp_itbl_klass, Address(recv_klass, scan_temp, Address::lsl(3)));
  // scan_temp = &(itable[0]._interface)
  lea(scan_temp, Address(recv_klass, scan_temp, Address::lsl(3)));

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13792#discussion_r1285548102


More information about the hotspot-dev mailing list