[foreign] RFR: Debug code for UniversalUpcallHandler

Jorn Vernee jbvernee at xs4all.nl
Tue Dec 18 00:16:25 UTC 2018


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