Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConstantDynamic: Building ROM and RAM Classes #1271

Closed
tajila opened this issue Feb 26, 2018 · 4 comments · Fixed by #1426
Closed

ConstantDynamic: Building ROM and RAM Classes #1271

tajila opened this issue Feb 26, 2018 · 4 comments · Fixed by #1426

Comments

@tajila
Copy link
Contributor

tajila commented Feb 26, 2018

Marking CPEntries

Marking which CP entries are used by ldc will have to be updated to account for Condy entries.

computeConstantMapAndSizes will also have to be updated to include Condy CP entries.

Add new CP entry type

Add new CP description types to BCT_J9DescriptionCPType and J9DescriptionBits (j9nonbuilder.h) for Condy. This will be used to detect the CP type in the bytecode interpreter during ldc (ldc_2 and ldc2_w) bytecodes.

Update ConstantPoolWriter (RomClassWriter.cpp) to add visitCondyType. This will write out CP entries for Condy in the romConstantPool. The first CP entry slot is a SRP to the NameAndSignature. The second slot is the bootstrap Method index or’ed with the J9DescriptionCPType.

Slot1: SRP to NAS
Slot2: Index of BSM (shifted up by 4) | Cptype

This matches the RomStringRef type

typedef struct J9ROMStringRef {
	J9SRP utf8Data;
	U_32 cpType;
} J9ROMStringRef;

The first 4bits of second slot in the romCPEntry must contain the cpType. This is checked by the ldc bytecode to determine what type of resolution to perform for the cp entry.

Update constantPoolDo in ConstantPoolMap for the new cp entry.

RamClass layout

The ramConstantPool entry for Condy is:
Slot1: (j9object_t) Constant
Slot2: (j9object_t) exception

This is done to match existing RamStringRefs. By convention the first slot is NULL checked to see if the ref requires resolution. For this reason the Condy constant must be the first slot.

typedef struct J9RAMStringRef {
	j9object_t stringObject;
	UDATA unused;
} J9RAMStringRef;
@DanHeidinga
Copy link
Member

Add new CP description types to BCT_J9DescriptionCPType and J9DescriptionBits (j9nonbuilder.h) for Indy and Condy.

As you pointed out on the whiteboard, moving Indy CP entries back into the constantpool will increase the romclass size slightly in the common case of invokedynamics not sharing cp entries.

This design can do the Condy side and leave the Indy representation as is.

@DanHeidinga
Copy link
Member

The layout of the ROM / RAM cp entries must match the layout of Constant_Class / Constant_String entries due to the resolution check in the ldc bytecode. It treats all ldc-able constants as having a common shape and null-checks the first(?) slot as a resolve check. After that it differentiates by type.

@tajila
Copy link
Contributor Author

tajila commented Feb 27, 2018

As you pointed out on the whiteboard, moving Indy CP entries back into the constantpool will increase the romclass size slightly in the common case of invokedynamics not sharing cp entries.

I wasn't sure if we reached a consensus yesterday. I have updated the design to exclude InvokeDynamic.

The layout of the ROM / RAM cp entries must match the layout of Constant_Class / Constant_String entries due to the resolution check ...

Yes, they currently match. I've added the existing String CPentries to the design for comparison

@DanHeidinga
Copy link
Member

@fengxue-IS Are you looking at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants