RFR: 8286669: Replace MethodHandle specialization with ASM in mainline [v3]
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Wed May 18 15:36:57 UTC 2022
On Wed, 18 May 2022 15:05:26 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> 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?
>
> I think someone might look at this and think "why aren't these bindings handled by `doBinding`"?
Let's leave it as is for the time being. I guess what I'm trying to get at is to try and make the code more explicit - but that is hard, given the constraints.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8685
More information about the core-libs-dev
mailing list