This is the mail archive of the mailing list for the Java project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Alpha vs. new ABI

Jeff Sturm wrote:
> Looks like C++ and the runtime are basically working both for static and
> dynamically allocated arrays.  But the Java expression `i[n]' seems to get the
> array offset wrong.  And compiling from bytecode yields yet another variation:

I think I understand what is happening.  Please let me know if I'm off track.

The element offset is computed in build_java_arrayaccess accordingly:

  arith = fold (build (PLUS_EXPR, int_type_node,
               java_array_data_offset (array),
               fold (build (MULT_EXPR, int_type_node,
                    index, size_in_bytes(type)))));

and java_array_data_offset searches for the `data' member.  If successful, it
returns the offset of data, else the size of the entire array header:

  tree data_fld = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (array_type)));

  if (data_fld == NULL_TREE)
    return size_in_bytes (array_type);
    return byte_position (data_fld);

I'm finding that data_fld == NULL_TREE _each_ time this method is called.  This
looks very wrong to me... the size of array_type is always a multiple of its
largest member, which is _not_ necessarily the same as the offset of its last
member, due to padding.

Back in build_java_array_type (where we started), I'm finding the `length'
argument is frequently -1, so arfld is not initialized (why?) and
build_java_arrayaccess runs amok.

Jeff Sturm

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]