This is the mail archive of the java@gcc.gnu.org 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]
Other format: [Raw text]

Re: values types for Java [message reformatted]


On Mon, 20 Oct 2003, Patrik Reali wrote:
> I think no additional bytecodes are needed to support value types.

Agreed.

> Such types should be marked with some additional attributes in the
> classfile.

Perhaps.  For gcj's purposes it may be sufficient to generate compatible
bytecode, and leverage struct optimizations when compiling from source.

A simple example:

struct S {
  int a,b;
}

class C {
  int x,y;
  S s;
}

might produce bytecode equivalent to:

class C {
  int x,y,s$a,s$b;
}

I can imagine something similar for method parameters.  Struct return
values are a little trickier; they could be wrapped in some other object
perhaps.

> I not sure whether designing a language with some specific compiler
> optimizations for a specific processor and calling convention in mind is a
> good thing.

That's certainly not what I intended!  The vast majority of architectures
I've dealt with have special handling for struct passing in the ABI.  (x86
is indeed the oddball here.)

Truthfully I do have sort of an architecture in mind, the virtual machine
represented by GCC's backend.  It knows how to efficiently do things like
BLKmode copies on many architectures.

> Anyway, this restriction would be formulated in the language report as
> "value types are final subclasses of Object". This restriction is often
> mentioned and could make sense (Per proposed it). This would automatically
> remove the need for virtual dispatch.

But even Object has a vtable.  I feel making value types a subclass of
Object undermines the value of this proposal, having simple, lightweight
stack-allocated structs.

You could disallow these types from having Object semantics, but that
seems awkward to me.

Jeff


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