On Fri, 18 Mar 2022 22:12:10 GMT, liach <d...@openjdk.java.net> wrote:

>> Change `CallSite` to a sealed class, as `CallSite` is an abstract class 
>> which does not allow direct subclassing by users per its documentation. 
>> Since I don't have a JBS account, I posted the content for the CSR in a 
>> GitHub Gist at https://gist.github.com/150d5aa7f8b13a4deddf95969ad39d73 and 
>> wish someone can submit a CSR for me.
>
> liach has updated the pull request incrementally with one additional commit 
> since the last revision:
> 
>   Remove homemade callsite from test

Hmm, I think the purpose of this test is just to fill up the class constant 
pool with random garbage and to ensure it runs, and using either type of indy 
doesn't seem to make big differences.

Moreover, these tests [need to be 
reworked](https://github.com/openjdk/jdk/blob/d8893fad23d1ee6841336b96c34599643edb81ce/test/hotspot/jtreg/vmTestbase/README.md),
 but I don't think I am suited for such a rework for this test.

--------------------------

If we do tweak the test, a subclass of `ConstantCallSite` would work too:

public class CustomCallSite extends ConstantCallSite {
    public CustomCallSite(MethodHandles.Lookup lookup, String callName, 
MethodType mtype, MethodHandle handle) {
        super(handle);
    }
}

And we write bytecode that makes an indy using this ctor as bootstrap method 
and additionally pass a `Handle` with `fullClassName`, `TARGET_METHOD_NAME`, 
`TARGET_METHOD_SIGNATURE`.

https://github.com/openjdk/jdk/blob/d8893fad23d1ee6841336b96c34599643edb81ce/test/hotspot/jtreg/vmTestbase/vm/mlvm/cp/share/GenManyIndyCorrectBootstrap.java#L107-L109

Becomes

mw.visitInvokeDynamicInsn(TARGET_METHOD_NAME,
                TARGET_METHOD_SIGNATURE,
                bsm,
                customCallSite ? new Object[] {TARGET_HANDLE} : new Object[0]);


The problem with this approach is:
1. Where should I put this `CustomCallSite` class? The bootstrap is only a 
class generator as opposed to a runtime, and this class probably shouldn't be 
put into the patches for `java.lang`. (In fact, the patches on asm should be 
replaced by patches on a shaded standalone asm library to reduce compile time 
for tests, too)
    - Should I generate it in the `generateBytecodes` method instead?
2. The approach of using a indy + a MethodHandle constant would use an extra 
constant, wonder if it hurts the goal of filling up the constant pool without 
exceeding the limit.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7840

Reply via email to