[foreign] RFR: Debug code for UniversalUpcallHandler

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Dec 18 11:41:04 UTC 2018


Sorry I was distracted by some of the output in your email - which was 
effectively the output of CalingSequence::asString :-)

Looks good
Maurizio



On 18/12/2018 00:45, Jorn Vernee wrote:
> They are pretty similar, but CallingSequence::asString doesn't 
> actually print out the values of the arguments, it's more of a "which 
> argument goes where" type of deal.
>
> UpcallContext actually holds the values of the arguments, so in the 
> case of UpcallContext::asString we dump the actual value of the 
> arguments.
>
> Does that make sense?
>
> Jorn
>
> Maurizio Cimadamore schreef op 2018-12-18 01:35:
>> Question: why is UniversalUpcallHandler::asString duplicating the
>> CallSequence::asString code (instead of delegating to it)?
>>
>> Maurizio
>>
>> On 18/12/2018 00:16, Jorn Vernee wrote:
>>> Hi,
>>>
>>> I have one more piece of debugging code from my Windows porting 
>>> experience that I thought might be useful to have.
>>>
>>> This adds to the debugging code already in UniversalUpcallHandler to 
>>> also output the incoming and outgoing UpcallContext and Java 
>>> arguments/returns. e.g. this is for a qsort comparator call:
>>>
>>> ```
>>> === UpcallHandler.invoke ===
>>> CallingSequence: {
>>>   returnsInMemory: false
>>>   Classes:
>>>     STACK_ARGUMENT_SLOT
>>>     VECTOR_ARGUMENT_REGISTER
>>>     INTEGER_ARGUMENT_REGISTER
>>>       Storage { INTEGER_ARGUMENT_REGISTER[0] (size=8) } : arg0 @ 0x0
>>>       Storage { INTEGER_ARGUMENT_REGISTER[1] (size=8) } : arg1 @ 0x0
>>>     VECTOR_RETURN_REGISTER
>>>     INTEGER_RETURN_REGISTER
>>>       Storage { INTEGER_RETURN_REGISTER[0] (size=8) } : __retval @ 0x0
>>>     X87_RETURN_REGISTER
>>> }
>>>
>>> UpcallContext:
>>>   STACK_ARGUMENT_SLOT
>>>   VECTOR_ARGUMENT_REGISTER
>>>   INTEGER_ARGUMENT_REGISTER
>>>     b0 4f 57 cb a0 02 00 00
>>>     c4 4f 57 cb a0 02 00 00
>>>   VECTOR_RETURN_REGISTER
>>>   INTEGER_RETURN_REGISTER
>>>     73 9e 21 af a0 02 00 00
>>>   X87_RETURN_REGISTER
>>>
>>> Java arguments:
>>>   [{ BoundedPointer type: 
>>> jdk.internal.foreign.memory.LayoutTypeImpl at 61064425 region: { 
>>> BoundedMemoryRegion base=null, min=0x0 length=0x7fffffffffffffff 
>>> mode=READ_WRITE } offset=0x2a0cb574fb0 }, { BoundedPointer type: 
>>> jdk.internal.foreign.memory.LayoutTypeImpl at 61064425 region: { 
>>> BoundedMemoryRegion base=null, min=0x0 length=0x7fffffffffffffff 
>>> mode=READ_WRITE } offset=0x2a0cb574fc4 }]
>>>
>>> Java return:
>>>   1
>>>
>>> Returning:
>>>   UpcallContext:
>>>     STACK_ARGUMENT_SLOT
>>>     VECTOR_ARGUMENT_REGISTER
>>>     INTEGER_ARGUMENT_REGISTER
>>>       b0 4f 57 cb a0 02 00 00
>>>       c4 4f 57 cb a0 02 00 00
>>>     VECTOR_RETURN_REGISTER
>>>     INTEGER_RETURN_REGISTER
>>>       01 00 00 00 a0 02 00 00
>>>     X87_RETURN_REGISTER
>>> ```
>>>
>>> This behaviour is guarded by the 
>>> '-Djdk.internal.foreign.UpcallHandler.DEBUG=true' flag.
>>>
>>> Webrev: 
>>> http://cr.openjdk.java.net/~jvernee/panama/webrevs/univupcalldebug/webrev.03/
>>>
>>> Let me know what you think!
>>>
>>> Thanks,
>>> Jorn
>>>
>>> P.S. is it OK that I'm not making JIRA tickets for these?


More information about the panama-dev mailing list