What's in a CONSTANT_Class?

Dan Smith daniel.smith at oracle.com
Fri Jun 9 15:43:08 UTC 2017

> On Jun 8, 2017, at 8:44 PM, John Rose <john.r.rose at oracle.com> wrote:
> The void quasi-type should be lumped into PrimitiveType, for the sake
> of ldc (void.class).

I see the appeal, though it also, unfortunately, expands the set of "primitive types" and means we have to restrict that set at the use sites:

CONSTANT_ArrayType_info {
  u1 tag; // 21
  u2 component_index; // PrimitiveType **but not void**, ClassType, ArrayType, or SpeciesType

CONSTANT_SpeciesType_info {
   u1 tag; //22
   u1 mode_code; // 'L'=76 or 12, 'Q'=81 or 13
   u2 class_index; // Class
   u2 enclosing_index; // ClassType or SpeciesType
   u2 typearg_count;
   u2 typeargs[typearg_count]; // PrimitiveType **but not void**, ClassType, ArrayType, or SpeciesType

CONSTANT_MethodDescriptor_info {
  u1 tag; // 23
  u2 parameter_count;
  u2 parameter_descriptors[parameter_count]; // PrimitiveType **but not void**, ClassType, ArrayType, or SpeciesType
  u2 return_descriptor; // PrimitiveType, ClassType, ArrayType, SpeciesType, or 0 (void)

CONSTANT_FieldDescriptor_info { // is this wrapper useful?
   u1 tag; // 24
   u2 type_index; // PrimitiveType **but not void**, ClassType, ArrayType, or SpeciesType

- Any non-void type (CONSTANT_Class, CONSTANT_ArrayType, CONSTANT_ClassType, CONSTANT_SpeciesType, or CONSTANT_PrimitiveType **that isn't void**):

- Any type or void (CONSTANT_Class, CONSTANT_ArrayType, CONSTANT_ClassType, CONSTANT_SpeciesType, or CONSTANT_PrimitiveType):

I prefer the discipline of making 'void' a separate entity (CONSTANT_Void?) that we don't necessarily call a "type", although not sure that carries its weight.

> Note that very small integer constants
> (which would correspond to PT sub-tags) are *not* usually
> stored in the CP; they are loaded with short instructions
> like "bipush", not "ldc".

Yes, and that works fine for instructions (see also newarray). The new requirement here is for another constant pool entry to need to talk about one of these very small things, and in a polymorphic way (e.g., the component type of an array may be a primitive or some other type).


More information about the valhalla-spec-experts mailing list