[foreign] RFR 8218153: Read/Write of Value layout should honor declared endianness

Henry Jen henry.jen at oracle.com
Mon Feb 25 21:00:16 UTC 2019


Updated webrev[1] to support byte swap operators, and enforce that the NativeMethodType can only have NE layouts.

Note that, we haven’t enforce the check at the descriptor parser level, which in theory we could, but that can be next step.

Also, we didn’t enforce explicit endianness check on “accessing memory”. However, a Value::specializedLayout can be used to make sure a layout have explicit endianness by make sure NE become host endianness, which I think is what we should do whenever a contents described by the layout is outbound to leave the process.

Cheers,
Henry

[1] http://cr.openjdk.java.net/~henryjen/panama/8218153/0/webrev/


> On Feb 3, 2019, at 12:16 PM, John Rose <john.r.rose at oracle.com> wrote:
> 
> On Feb 3, 2019, at 12:04 PM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
>>>> I quite like this because it has a nice correspondence between layout API and description: in both cases there's no explicit support for NE - which is encoded always as a lack of explicit endianness info.
> 
> Well, I like it too.  Thanks for teasing out the details.
> 
> One other advantage:  The NE state can naturally be upgraded
> after the fact to BE or LE (or vm-specific PE of course).  This means
> that we have more options for layout strings produced by jextract
> or by hand:  They can be conveniently left in the NE state, and
> the BE or LE state can be pushed into the layout string from context.
> 
> This gets an effect very similar to what Henry wants, which is a
> sensible default for simple notation.  It gets this effect not by
> eagerly assigning PE to elements in a layout string (which I
> don't want) but rather allowing a chance for the context of the
> layout string to supply then needed polarity.  The polarity
> can be explicit in a central place, such as in a global argument
> sent from jextract to the binder.  For casual use with PE, the
> polarity can be quietly injected as an optional argument to the
> function which parses layouts.
> 
> The basic idea behind this, of NE, is that some layouts can
> (and should) be "endian pure" in refusing to take a side, and the
> endian-ness can be specified where it is needed, in order to
> form correct memory accesses.
> 
> Thanks, guys.
> 
> — John
> 
> 



More information about the panama-dev mailing list