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

[Condy] Add support for ConstantDynamic constant pool entries #1269

Closed
11 tasks done
tajila opened this issue Feb 26, 2018 · 1 comment
Closed
11 tasks done

[Condy] Add support for ConstantDynamic constant pool entries #1269

tajila opened this issue Feb 26, 2018 · 1 comment
Labels

Comments

@tajila
Copy link
Contributor

tajila commented Feb 26, 2018

http://cr.openjdk.java.net/~dlsmith/constant-dynamic.html

The following have to be done in order

The rest can be done simultaneously


New contant pool type ‘Constant_Dynamic’ used to describe a dynamically computed constant which can be a primitive of ref. This value is produced by calling a bootstrap method. The constant is only computed once. In multithreaded scenarios, as soon as a value is computed all other subsequent ones are discarded (there is only one winner). Similarly, for recursive scenarios the deepest nested call wins.

CONSTANT_Dynamic_info {
   u1 tag;
   u2 bootstrap_method_attr_index;
   u2 name_and_type_index;
}

The ‘tag’ is the type of ConstantPool entry (17). ‘bootstrap_method_attr_index’ is the index of the bootstrap method in the bootstrap method table in the class file. ‘name_and_type_index’ index into the constant pool that must be a ‘Constant_NameAndType_info’ structure.

Resolution for ConstantDynamic is:
• Bootsrap MethodHandle is resolved (specified by symbolic reference). Exception may be thrown if failure occurs when resolving methodHandle
• Array is created of size n + 3 where n are the static args (n >= 0). Array initialized to null.
o This stage can be optimized out so long as there are no behavior changes
• First arg of array is the lookup object
• Second arg is the Name (j.l.String) in name_and_type_index
• Third arg is a Class derived from the field descriptor in name_and_type_index
• The rest of the args are the static args listed at bootstrap_method_attr_index. Exception may be thrown
• If the symbolic reference being resolved is also a static arg or references itself via other static args then a StackOverflowError is thrown
• The bootstrapMethodHandle is invoked (mh.invokeWithArguments(argsArray)). Exception/Error may be thrown
• The result from the boostrapMethodHandle is validated. For condy this converts the result to the type specified by the field descriptor in name_and_type_index

Once resolution is performed the value is cached in the constant pool. If an error/exception occurs the same failure must be thrown every time the constant pool entry is referenced. A Constant_Dynamic entry may be loaded by ldc instruction.

J9 Implementation

Goal is to reuse as much of the invokeDynamic functionality as possible. As a result some of the invokeDynmaic functionality and layout will have to be changed

@DanHeidinga DanHeidinga changed the title Add support for ConstantDynamic constant pool entries [Condy] Add support for ConstantDynamic constant pool entries Feb 27, 2018
@tajila
Copy link
Contributor Author

tajila commented Jul 11, 2019

This is complete

@tajila tajila closed this as completed Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants