RFR: 8286669: Replace MethodHandle specialization with ASM in mainline [v3]
Jorn Vernee
jvernee at openjdk.java.net
Wed May 18 14:55:00 UTC 2022
On Wed, 18 May 2022 14:21:55 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> I'm not sure if there is anything actionable here?
>>
>> I've thought in the past that it might be nice to have `GetArgument`/`SetArgument` and `GetReturnValue`/`SetReturnValue` binding operators as well, to make the inputs/outputs more explicit in the recipe. But, it doesn't seem like that would make things _much_ better...
>
> I wasn't suggesting to add more bindings. I was more suggesting to filter out the load/store from the set of bindings (since these are virtualized anyways) that are passed to `doBindings`. Then, before executing a set of bindings, (if we are in downcall mode) we load the corresponding input local var. After executing bindings (if we are in upcall mode) we store result in corresponding var.
>
> E.g. make the logic that load locals and store locals explicit in the `specialize` method, rather than have parts of it execute "in disguise" as "binding interpretation".
It's not quite that simple since a binding recipe for a single parameter can have multiple VMStores for instance if a struct is decomposed into multiple values.
It can be done by pulling the binding loops up to the `specialize` method, and have if statements for VMStore and VMLoad, like this:
for (Binding binding : callingSequence.argumentBindings(i)) {
if (binding instanceof Binding.VMStore vms && callingSequence.forDowncall()) {
emitSetOutput(vms.type());
} else if (binding instanceof Binding.VMLoad && callingSequence.forUpcall()) {
emitGetInput();
} else {
doBinding(binding);
}
}
And for returns:
for (Binding binding : callingSequence.returnBindings()) {
if (binding instanceof Binding.VMLoad vml && callingSequence.forDowncall()) {
if (!callingSequence.needsReturnBuffer()) {
emitRestoreReturnValue(vml.type());
} else {
emitReturnBufferLoad(vml);
}
} else if (binding instanceof Binding.VMStore vms && callingSequence.forUpcall()) {
if (!callingSequence.needsReturnBuffer()) {
emitSaveReturnValue(vms.type());
} else {
emitReturnBufferStore(vms);
}
} else {
doBinding(binding);
}
}
But, maybe that's better?
-------------
PR: https://git.openjdk.java.net/jdk/pull/8685
More information about the core-libs-dev
mailing list