values types for Java [message reformatted]

Jeff Sturm jsturm@one-point.com
Tue Oct 21 22:39:00 GMT 2003


On 2003年10月20日, 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


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /