RFR: 8308031: Linkers should promote variadic arguments [v8]

Jorn Vernee jvernee at openjdk.org
Tue Jun 6 15:17:26 UTC 2023


> In C, arguments smaller than `int` are promoted to (`unsigned`) `int`, and `float` is promoted to `double`, when being passed as variadic argument (see e.g. https://en.cppreference.com/w/c/language/conversion#Default_argument_promotions). This patch adds the automatic argument promotion for variadic arguments, to align the implementation with the C specification.
> 
> The fallback linker is also updated to use to correct function to link variadic calls (not doing this turned out not to be a problem so far, but it is problematic for instance on Mac/AArch64 when using the fallback linker). Adding the restriction on layouts for all linkers is also partly motivated by the fallback linker rejecting such unsupported variadic layouts already.
> 
> I've added a small paragraph to the Linker javadoc as well that explains this.
> 
> TestVarArgs needed to be updated in order to account for the difference in the promoted `float` values.
> 
> Testing:
> - local testing on Windows/x64
> - local testing on Linux/x64 using the fallback linker
> - tier1-3 + jdk-tier5
> - manual test run on mac/aarch64 with the fallback linker to verify the correctness of the fallback linker changes.

Jorn Vernee has updated the pull request incrementally with two additional commits since the last revision:

 - Improve javadoc, align implementation
 - Revert "automatically apply variadic promotions"
   
   This reverts commit 38d759d615b79b0c508bdf2231699c0aea0ad94f.

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/14225/files
  - new: https://git.openjdk.org/jdk/pull/14225/files/3ec04fa6..ca56fade

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=14225&range=07
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14225&range=06-07

  Stats: 202 lines in 7 files changed: 70 ins; 116 del; 16 mod
  Patch: https://git.openjdk.org/jdk/pull/14225.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14225/head:pull/14225

PR: https://git.openjdk.org/jdk/pull/14225


More information about the core-libs-dev mailing list