Limitations of the Calling Convention Optimization

Tobias Hartmann tobias.hartmann at oracle.com
Mon Oct 26 09:43:14 UTC 2020


On 23.10.20 15:07, Tobias Hartmann wrote:
> Not quite. A method always supports the "default" calling convention (all arguments/returns passed
> as pointers) but if the type of an argument/return is known to be an inline type at *method* link
> time (i.e. when the method holder is loaded by the VM), we can optimize that default calling
> convention by adding a scalarized calling convention.

The significant limitation here is that for a scalarized method, even when calling through the
"default" entry point, the method body does not support null. For example, a C2 compiled method

int foo(MyInline bar) {
  return bar.x;
}

will have the following entry points (simplified):

int foo(MyInline bar) {     <- Default entry, 'bar' is passed as pointer
  int x = bar.x;
  goto Body:
}

int foo(int x) {            <- Scalarized entry, only the integer field of bar is passed
 Body:
  return x;
}

Please let me know if things are still unclear, I'm happy to provide more details about the
implementation and its limitations.

Best regards,
Tobias



More information about the valhalla-dev mailing list