Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [omr-dev] Symbol refs, shadow refs and aliasing

Hi Younes,

Many thanks for the detailed reply.

On 5 July 2018 at 16:38, Younes Manton <younes.m@xxxxxxxxx> wrote:
>
>
> On Wed, Jul 4, 2018 at 6:13 PM Dibyendu Majumdar <mobile@xxxxxxxxxxxxxxx>
> wrote:
>>
>> Is there an alternative way to create a local value that is bigger
>> than a primitive? I am using OMR as JIT for C backend - so there can
>> be local vars that are structs, unions or arrays. I saw that in
>> JitBuilder a byte array type is used to represent structs / locals -
>> which made sense to me - i.e. a C struct is just a region of memory
>> that in interpreted in a certain way. What would be the alternative
>> way to represent such local values?
>
>
> Unfortunately not as aggregates are not really fully represented in the OMR
> IL. JitBuilder treats them as a local array of bytes (and that was done as a
> first attempt for a project that needed to represent aggregates similarly to
> C/C++), and there's the TR::Aggregate data type that was used for similar
> things back when this code was closed source, but there isn't much support
> beyond that that lets you use them as first class data types like
> primitives.
>

That's okay; as long as I can represent them as byte arrays.

> How to best represent aggregates is still very much an open question, e.g.
> does the node represent the 'value' or address of the aggregate, how do you
> square that with OMR IL's need to pass values between basic blocks via
> memory (prior to the optimizer forming EBBs and commoning across them),

I am not sure I understand this problem. I was under the impression
that in any case values cannot be passed from one block to another? In
my case all access is via member load/store - and I don't allow
aggregate assignment; so it seems to work.

> how
> do you distinguish between passing/returning an aggregate by value v.s.
> passing/returning it's address, how do you copy it by value, how do you
> represent passing/returning across function calls, how do you represent the
> differing ABI constraints across platforms, how do you access its members

I don't support aggregate assignment or passing aggregates by value
... much like original K&R C - so not an issue for me. But I realize
it is a problem if someone wants to implement this.

> (do you overload the indirect ops we already have, invent new ones, use
> direct accesses) and so on and so forth. You can probably get by some of
> these issues by doing the dirty work yourself and generating code specific
> to your combination of language/IL generator/environment, but you're in
> here-be-dragons territory for the most part.
>

Currently I am doing something like this:

ptr = base + offsetof(member)
cast ptr to right type

This is fine for me because the front-end I use also thinks of member
access in this way.

I guess that as long as I know that local aggregates will not exhibit
great performance that is fine - that it at least works is great
because this is so fundamental to C like languages.
Isn't there a plan to support value types in Java? Presumably when
that happens some work will need to be done to optimize these
scenarios?

Thanks and Regards
Dibyendu


Back to the top