On Wed, 18 May 2022 14:51:02 GMT, Jorn Vernee <jver...@openjdk.org> wrote:

>> 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?

I think someone might look at this and think "why aren't these bindings handled 
by `doBinding`"?

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

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

Reply via email to