<div dir="auto">I found this sentence on the apidoc now:</div><div dir="auto"><br></div><div dir="auto"><div><span style="color:rgb(71,71,71);font-family:'dejavu serif','georgia','times new roman','times',serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration:none;display:inline!important;float:none">Moreover, if the function descriptor's return layout is a group layout, the resulting downcall method handle accepts an additional leading parameter of type </span><a href="https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/foreign/SegmentAllocator.html" style="text-decoration:none;font-family:'dejavu serif','georgia','times new roman','times',serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><code style="padding-top:4px;margin-top:8px;line-height:1.4em">SegmentAllocator</code></a><span style="color:rgb(71,71,71);font-family:'dejavu serif','georgia','times new roman','times',serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration:none;display:inline!important;float:none">, which is used by the linker runtime to allocate the memory region associated with the struct returned by the downcall method handle.</span></div><br clear="all"><div dir="auto"><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><font face="arial, sans-serif">Best,</font></div><div><font face="arial, sans-serif">tison.</font></div></div></div></div></div></div></div></div></div></div></div><div><br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">tison <<a href="mailto:wander4096@gmail.com">wander4096@gmail.com</a>>于2024年4月6日 周六17:13写道:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Hi,</div><div dir="auto"><br></div><div dir="auto">This seems undocumented. As in [1], the native method signature is: FunctionDescriptor.of(either, ValueLayout.ADDRESS).</div><div dir="auto"><br></div><div dir="auto">And below when invoke the method handle, it requires: handle.invoke(arena, arena.allocateFrom("name")</div><div dir="auto"><br></div><div dir="auto">Where comes this extra param?</div><div dir="auto"><br clear="all"><div dir="auto"><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><font face="arial, sans-serif" style="font-family:arial,sans-serif;color:rgb(0,0,0)">Best,</font></div><div><font face="arial, sans-serif" style="font-family:arial,sans-serif;color:rgb(0,0,0)">tison.</font></div><div dir="auto"><font face="arial, sans-serif" style="font-family:arial,sans-serif;color:rgb(0,0,0)"><br></font></div><div dir="auto"><font face="arial, sans-serif" style="font-family:arial,sans-serif;color:rgb(0,0,0)">[1] <div dir="auto" style="font-family:arial,sans-serif"><a href="https://x.com/tisonkuncz/status/1776518595499217094?s=46&t=rCbLrJSBayvO_CKE6XmYKQ" style="font-family:arial,sans-serif" target="_blank">https://x.com/tisonkuncz/status/1776518595499217094</a></div></font></div></div></div></div></div></div></div></div></div></div></div>
</blockquote></div></div>