From 5590ab87871fabacaa31e13054fea1fd9d123ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sat, 11 Jul 2020 14:17:04 +0100 Subject: [PATCH] java: add aarch64 support to JamVM in icedtea-7. --- dev-java/icedtea/Manifest | 6 +- .../icedtea/files/additional_patches.patch | 13 + .../files/jamvm-1.6.0-aarch64-support.patch | 632 ++++++++++++++++++ .../files/jamvm-1.6.0-opcode-guard.patch | 35 + .../files/wrong_checksum_workaround.patch | 11 - dev-java/icedtea/icedtea-7.2.6.9.ebuild | 13 +- 6 files changed, 692 insertions(+), 18 deletions(-) create mode 100644 dev-java/icedtea/files/additional_patches.patch create mode 100644 dev-java/icedtea/files/jamvm-1.6.0-aarch64-support.patch create mode 100644 dev-java/icedtea/files/jamvm-1.6.0-opcode-guard.patch delete mode 100644 dev-java/icedtea/files/wrong_checksum_workaround.patch diff --git a/dev-java/icedtea/Manifest b/dev-java/icedtea/Manifest index 108079c..b93be87 100644 --- a/dev-java/icedtea/Manifest +++ b/dev-java/icedtea/Manifest @@ -1,6 +1,8 @@ +AUX additional_patches.patch 447 BLAKE2B d952037e1d422b05d2a937820e3496dedcfee0b4fae1ede7004f25a5c64466a4eea92ab67a9329371a543f64db85eb19f9cb926b905a8592435f8bfdf57193c4 SHA512 51e86eabd715fe9c0702c46c46dcccbebe822487e3c1226027776ec68a038676f4ed43681922808bebc6cdb0baccd5268bf967e47bd76325d30b2c03b27f03c1 AUX generate-cacerts.pl 11051 BLAKE2B e6d54319153735bd4b445581dfbd2b78e2e27a19f3b8a78d2fe6912efa207d133fa550652295648bc0bd1370956f71374d4b42de71776fa253f44d4e9dff2527 SHA512 22d1be675362c09ed61af4dc3ece14cab81e9514937d588ff5d324e61b7eba7d3dd99b26bc5ec0953365de56d099f708b2afdb13cca37bc4ff07fd8ce31fbe97 AUX icedtea.env.sh 1130 BLAKE2B 8ffd3a9c558b9abb9df723efc531496537d7883d676c145411d9a4f02ecd6826c5edec9451ced8187224a9c24b408e6cbad3dc11ebcbe2f69a38b0966cb691c7 SHA512 79c279338cc2790df91c92d8d9b97c007f1a030374066dfacbbb2f9aac754eafba9197b748adcb9fe6fbff16bd998b6536298443028df281d1b12d3b348da66f -AUX wrong_checksum_workaround.patch 410 BLAKE2B aa95776418643cb8df154f4986f6304ed6ba210747440af20709ed58e2f54c014a2224932c0b561090bcb460475d8074cd80b2774e1e2f47a7fd58e049413f57 SHA512 7ed0971240f613c37b957cb4cb797e4949e1114d4989c707ad8ddd670d03f33bd1164f57e662ff7da90caa87f7e02809f581c309e7f4eb62b0c4e04fa04f83a4 +AUX jamvm-1.6.0-aarch64-support.patch 23347 BLAKE2B b80462ea9d8ceb54f8039d1a2c6e161a45eceabcd5e27993dec602605397d70754bcc4c70fcc6be197f17a7d1383d6d91ae57c01063dbc55c61537f50fb71de6 SHA512 aa602103865d64dc0d53d8d46002888b99afb7b92e95f39dacd36a2d3b937006f7816826efc418d0e3b9e7b3eec5b0b01a1642e37875635577c0c5653418596c +AUX jamvm-1.6.0-opcode-guard.patch 1416 BLAKE2B 4e866f4dde142d591d3dce89f10589fd3fbd290b1429ad83ba4ba4d4dfcb91d7e9da4ea7797859337690e24a8f1ebcf39eaa5aad085d03233306db02147f18cb SHA512 396d18eaad17bc76d8316bfc8fa2553e081389deade1ce0cd72f082226a91dbd70ec983636d324243be0a502ae9e0dd91d40952f13bf77c991601e61385af728 DIST icedtea-2.6-corba-737fd3fbf139.tar.bz2 1073197 BLAKE2B af7a9a9c91511ba63835e2930e71ad442c45215f66043c6d05c636b8f3ab2803c4a0afb8ebf099b1f707ccb4850a9c4a2ecd78d7434f7c0b6ec38d1f56ba65b9 SHA512 77e81659d3314172c2b80fb1441d268edc52e0ec0bd25f9a9596e3c7a545f0694a11cc2298952d72c85965529b344493d1f2c2187cf4d38749278018fc85a6b8 DIST icedtea-2.6-hotspot-9fc0d63c2a74.tar.bz2 8195300 BLAKE2B d56487ac634367d50c605e9b782d51a5950c89a588b6b98863378e4727056c5af201e0c15d9006d608e6dade79a8a239fe33fb3fd519035dc62c2597579f1a45 SHA512 9bd3b2fea69c9e7c27ad9e157a44a20c113acc41bb0c830f18395df61d919dea1cd6bb69f9849ca449be25a9244ccc7bf05a51b3c64521362b0d765bfd59fb32 DIST icedtea-2.6-jaxp-aa1c302a99fb.tar.bz2 2733907 BLAKE2B 29afc8449c8c7c2f58266f18ab798b3ed31b426e39671a9ceef64425fafb064476fb22f677474fb18da42a601540da37447cbab9f55ae6af4e664b768a1f34aa SHA512 c1dd1b00d4f232ee8e3f365caa8502069bcf7cbda28e0900891ad9e63905a9bdeed00ae6e661148f181949494aae9bed6e2b0422711f24b2413c0bf484c08522 @@ -24,4 +26,4 @@ DIST icedtea-cacao-c182f119eaad.tar.gz 4485353 BLAKE2B 5c1faa3cbbfea62f819562a01 DIST icedtea-cacao-c182f119eaad.tar.xz 3056520 BLAKE2B 6b1be66ce19f491d49f1591babcd8c088e8e327f828dca3f30b8f8b04c132140f8b9f487ef6d91aed212aebab2c7c3052d79fa3f2d76d3832341d94d48e77089 SHA512 22e8a031db5f93f82b276b310c175f1e926e48d64e1e50bebe51138e0f66391cd005501491a959d31663f338f27a29ec984ac29f77078f59472856e4d08edef7 DIST icedtea-jamvm-ec18fb9e49e62dce16c5094ef1527eed619463aa.tar.gz 317187 BLAKE2B 1ca581a02be4cf5c09162687bbc90ec01b58b4910d866d11512cf17a1caff181fdc69e42f7498b2df9deb875ddc6efc6bc2888428f411da94bbc2313ddf5a2c9 SHA512 a31348481e1c02747f5bb9db333f855c45a1555aa187ee35de5ef553a10a8a47dfcc1beb1e69502046c1758438b91958a328e0a0015812c153221f67734a70a6 EBUILD icedtea-3.7.0.ebuild 13476 BLAKE2B 83ff27f01a25038abf19cbfe5b13d495fe1845e112d6fa916f3192664779ae5bcef95b6b3d0fe189cf5c5baa24dae6ab901b9c50ee99f6679a4a1b6ffd6d4720 SHA512 beacbf9b65aba5ca2a624f1d3a68245feee9331b694e3a0f6993eacfdae78332174702bed0933809d97e8d5ee2ed2a1007e31f5e246720d2baa3ad0e47dc4619 -EBUILD icedtea-7.2.6.9.ebuild 11347 BLAKE2B 310f665a893b602d2ac126aff288258aba3b9e6701e6e5d132727c6b1a306e3e1344c354f99a8e132653140abf2846c9c0d5ef0550adac8f5437ccbb7a82a5d7 SHA512 0992b17c63b9903d42d0cfb0e373ab05bb19504b0be23ed383e1bf3941cea08e9fe63e0554e1a166fe40fd66226aa617895ac0647f0b5989b6b7fc3048e866a6 +EBUILD icedtea-7.2.6.9.ebuild 11399 BLAKE2B 900e633728ab3e802d6230926e860eb99bb98e285af7b50ddd316c31ad8b8bace62871513dcf0b7a4eafebb209ea831776172bf5c902e8d03d38a0885e5df080 SHA512 1418e3319be53299bb9aef32744b1759e4271d1b98eb4c4f663fd7cdff56f0d28db926486b4abb6013faf5526b3354d4835e94603d2dd17cf959e8829fc878f4 diff --git a/dev-java/icedtea/files/additional_patches.patch b/dev-java/icedtea/files/additional_patches.patch new file mode 100644 index 0000000..bb5e690 --- /dev/null +++ b/dev-java/icedtea/files/additional_patches.patch @@ -0,0 +1,13 @@ +--- a/Makefile.am 2020-07-11 13:44:32.099191644 +0100 ++++ b/Makefile.am 2020-07-11 13:45:23.436056479 +0100 +@@ -408,7 +408,9 @@ + patches/jamvm/pr2172-tempdir.patch \ + patches/jamvm/noexecstack.patch \ + patches/jamvm/pr2665.patch \ +- patches/jamvm/pr3134-unsafe_methods.patch ++ patches/jamvm/pr3134-unsafe_methods.patch \ ++ patches/jamvm/jamvm-1.6.0-aarch64-support.patch \ ++ patches/jamvm/jamvm-1.6.0-opcode-guard.patch + endif + + if ENABLE_NSS diff --git a/dev-java/icedtea/files/jamvm-1.6.0-aarch64-support.patch b/dev-java/icedtea/files/jamvm-1.6.0-aarch64-support.patch new file mode 100644 index 0000000..2bf13e8 --- /dev/null +++ b/dev-java/icedtea/files/jamvm-1.6.0-aarch64-support.patch @@ -0,0 +1,632 @@ +From a44154f7a18496cc3e5fc0b1b2ea69523ebc623a Mon Sep 17 00:00:00 2001 +From: Simon South +Date: Mon, 1 Jun 2020 07:09:34 -0400 +Subject: [PATCH] Add support for aarch64 on GNU/Linux + +--- + AUTHORS | 1 + + README | 2 +- + configure.ac | 7 +- + src/arch/Makefile.am | 2 +- + src/arch/aarch64.h | 147 +++++++++++++++++++++ + src/jam.c | 3 +- + src/os/linux/Makefile.am | 2 +- + src/os/linux/aarch64/Makefile.am | 28 ++++ + src/os/linux/aarch64/callNative.S | 212 ++++++++++++++++++++++++++++++ + src/os/linux/aarch64/dll_md.c | 59 +++++++++ + src/os/linux/aarch64/init.c | 51 +++++++ + 11 files changed, 508 insertions(+), 6 deletions(-) + create mode 100644 src/arch/aarch64.h + create mode 100644 src/os/linux/aarch64/Makefile.am + create mode 100644 src/os/linux/aarch64/callNative.S + create mode 100644 src/os/linux/aarch64/dll_md.c + create mode 100644 src/os/linux/aarch64/init.c + +diff --git a/AUTHORS b/AUTHORS +index e1334fe..6fd0eeb 100644 +--- jamvm/jamvm/AUTHORS ++++ jamvm/jamvm/AUTHORS +@@ -1,1 +1,2 @@ + Robert Lougher ++Simon South +diff --git a/configure.ac b/configure.ac +index 138b7e6..e7051d7 100644 +--- jamvm/jamvm/configure.ac ++++ jamvm/jamvm/configure.ac +@@ -46,6 +46,7 @@ x86_64-*-freebsd*) host_os=bsd libdl_needed=no ;; + arm*-*-linux*) host_cpu=arm host_os=linux interp_cflags=-marm ;; + arm*-*-openbsd*) host_cpu=arm host_os=bsd libdl_needed=no ;; + arm*-*-freebsd*) host_cpu=arm host_os=bsd libdl_needed=no ;; ++aarch64*-*-linux*) host_cpu=aarch64 host_os=linux ;; + powerpc*-*-linux*) host_cpu=powerpc host_os=linux ;; + powerpc*-*-openbsd*) host_cpu=powerpc host_os=bsd libdl_needed=no ;; + powerpc*-*-freebsd*) host_cpu=powerpc host_os=bsd libdl_needed=no ;; +@@ -155,10 +156,11 @@ AC_ARG_ENABLE(runtime-reloc-checks, + + AC_ARG_ENABLE(int-inlining, + [AS_HELP_STRING(--enable-int-inlining,enable inline threaded version of the interpreter +- (by default enabled on x86_64, i386, powerpc, mips and arm, ++ (by default enabled on x86_64, i386, powerpc, mips, arm and aarch64, + disabled otherwise))],, + [if test "$host_cpu" = x86_64 -o "$host_cpu" = i386 -o "$host_cpu" = x86 -o \ +- "$host_cpu" = powerpc -o "$host_cpu" = arm -o "$host_cpu" = mips; then ++ "$host_cpu" = powerpc -o "$host_cpu" = arm -o "$host_cpu" = mips -o \ ++ "$host_cpu" = aarch64; then + enable_int_inlining=yes + else + enable_int_inlining=no +@@ -407,6 +409,7 @@ AC_CONFIG_FILES( + src/os/linux/x86_64/Makefile \ + src/os/linux/parisc/Makefile \ + src/os/linux/mips/Makefile \ ++ src/os/linux/aarch64/Makefile \ + src/os/darwin/i386/Makefile \ + src/os/darwin/arm/Makefile \ + src/os/darwin/powerpc/Makefile \ +diff --git a/src/arch/Makefile.am b/src/arch/Makefile.am +index 7580a1b..4e2a4f9 100644 +--- jamvm/jamvm/src/arch/Makefile.am ++++ jamvm/jamvm/src/arch/Makefile.am +@@ -19,4 +19,4 @@ + ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ## + +-EXTRA_DIST = powerpc.h arm.h i386.h x86_64.h parisc.h mips.h sparc.h ++EXTRA_DIST = powerpc.h arm.h i386.h x86_64.h parisc.h mips.h sparc.h aarch64.h +diff --git a/src/arch/aarch64.h b/src/arch/aarch64.h +new file mode 100644 +index 0000000..1912e79 +--- /dev/null ++++ jamvm/jamvm/src/arch/aarch64.h +@@ -0,0 +1,147 @@ ++/* ++ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 ++ * Robert Lougher . ++ * Copyright (C) 2020 Simon South . ++ * ++ * This file is part of JamVM. ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2, ++ * or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ */ ++ ++#include ++ ++#define OS_ARCH "aarch64" ++ ++#define HANDLER_TABLE_T static const void ++#define DOUBLE_1_BITS 0x3ff0000000000000LL ++ ++#define READ_DBL(v,p,l) v = ((u8)p[0]<<56)|((u8)p[1]<<48)|((u8)p[2]<<40) \ ++ |((u8)p[3]<<32)|((u8)p[4]<<24)|((u8)p[5]<<16) \ ++ |((u8)p[6]<<8)|(u8)p[7]; p+=8 ++ ++/* Needed for i386 -- empty here */ ++#define FPU_HACK ++ ++#define COMPARE_AND_SWAP_64(addr, old_val, new_val) \ ++({ \ ++ int result, read_val; \ ++ __asm__ __volatile__ (" \ ++ 1: ldaxr %2, %1; \ ++ cmp %2, %3; \ ++ b.ne 2f; \ ++ stlxr %w0, %4, %1; \ ++ cmp %w0, wzr; \ ++ b.ne 1b; \ ++ 2: cset %w0, eq;" \ ++ : "=&r" (result), "+Q" (*addr), "=&r" (read_val) \ ++ : "r" (old_val), "r" (new_val) \ ++ : "cc"); \ ++ result; \ ++}) ++ ++#define COMPARE_AND_SWAP_32(addr, old_val, new_val) \ ++({ \ ++ int result, read_val; \ ++ __asm__ __volatile__ (" \ ++ 1: ldaxr %w2, %1; \ ++ cmp %w2, %w3; \ ++ b.ne 2f; \ ++ stlxr %w0, %w4, %1; \ ++ cmp %w0, wzr; \ ++ b.ne 1b; \ ++ 2: cset %w0, eq;" \ ++ : "=&r" (result), "+Q" (*addr), "=&r" (read_val) \ ++ : "r" (old_val), "r" (new_val) \ ++ : "cc"); \ ++ result; \ ++}) ++ ++#define COMPARE_AND_SWAP(addr, old_val, new_val) \ ++ COMPARE_AND_SWAP_64(addr, old_val, new_val) ++ ++#define LOCKWORD_READ(addr) \ ++({ \ ++ uintptr_t result; \ ++ __asm__ __volatile__ (" \ ++ ldar %0, %1;" \ ++ : "=r" (result) \ ++ : "Q" (*addr) \ ++ : "cc"); \ ++ result; \ ++}) ++ ++#define LOCKWORD_WRITE(addr, value) \ ++({ \ ++ __asm__ __volatile__ (" \ ++ stlr %1, %0;" \ ++ : "=Q" (*addr) \ ++ : "r" (value) \ ++ : "cc"); \ ++}) ++ ++#define LOCKWORD_COMPARE_AND_SWAP(addr, old_val, new_val) \ ++ COMPARE_AND_SWAP_64(addr, old_val, new_val) ++ ++#define FLUSH_CACHE(addr, length) \ ++{ \ ++ uintptr_t start = (uintptr_t) (addr); \ ++ uintptr_t end = start + length; \ ++ uintptr_t i; \ ++ \ ++ for(i = start & aarch64_data_cache_line_mask; \ ++ i < end; \ ++ i += aarch64_data_cache_line_len) \ ++ __asm__ ("dc cvau, %0" :: "r" (i)); \ ++ \ ++ __asm__ ("dsb ish"); \ ++ \ ++ for(i = start & aarch64_instruction_cache_line_mask; \ ++ i < end; \ ++ i += aarch64_instruction_cache_line_len) \ ++ __asm__ ("ic ivau, %0" :: "r" (i)); \ ++ \ ++ __asm__ ("dsb ish; isb"); \ ++} ++ ++#define GEN_REL_JMP(target_addr, patch_addr, patch_size) \ ++({ \ ++ int patched = FALSE; \ ++ \ ++ if(patch_size >= 4) { \ ++ /* Guard against the pointer difference being \ ++ larger than the signed range */ \ ++ long long offset = (uintptr_t)(target_addr) - \ ++ (uintptr_t)(patch_addr); \ ++ \ ++ if(offset >= -1<<28 && offset < 1<<28) { \ ++ *(uint32_t*)(patch_addr) = offset>>2 & 0x03ffffff \ ++ | 0x14000000; \ ++ patched = TRUE; \ ++ } \ ++ } \ ++ patched; \ ++}) ++ ++#define MBARRIER() __asm__ ("dmb ish" ::: "memory") ++#define RMBARRIER() __asm__ ("dmb ishld" ::: "memory") ++#define WMBARRIER() __asm__ ("dmb ishst" ::: "memory") ++#define JMM_LOCK_MBARRIER() __asm__ ("dmb ish" ::: "memory") ++#define JMM_UNLOCK_MBARRIER() JMM_LOCK_MBARRIER() ++ ++/* Defined in src/os/linux/aarch64/init.c */ ++extern unsigned char aarch64_data_cache_line_len; ++extern uintptr_t aarch64_data_cache_line_mask; ++extern unsigned char aarch64_instruction_cache_line_len; ++extern uintptr_t aarch64_instruction_cache_line_mask; +diff --git a/src/jam.c b/src/jam.c +index 052f84a..c97524a 100644 +--- jamvm/jamvm/src/jam.c ++++ jamvm/jamvm/src/jam.c +@@ -98,7 +98,8 @@ void showUsage(char *name) { + void showVersionAndCopyright() { + printf("java version \"%s\"\n", JAVA_COMPAT_VERSION); + printf("JamVM version %s\n", VERSION); +- printf("Copyright (C) 2003-2013 Robert Lougher \n\n"); ++ printf("Copyright (C) 2003-2013 Robert Lougher \n"); ++ printf("Portions Copyright (C) 2020 Simon South \n\n"); + printf("This program is free software; you can redistribute it and/or\n"); + printf("modify it under the terms of the GNU General Public License\n"); + printf("as published by the Free Software Foundation; either version 2,\n"); +diff --git a/src/os/linux/Makefile.am b/src/os/linux/Makefile.am +index 542094e..83e7dfe 100644 +--- jamvm/jamvm/src/os/linux/Makefile.am ++++ jamvm/jamvm/src/os/linux/Makefile.am +@@ -20,7 +20,7 @@ + ## + + SUBDIRS = @arch@ +-DIST_SUBDIRS = powerpc arm i386 x86_64 parisc mips ++DIST_SUBDIRS = powerpc arm i386 x86_64 parisc mips aarch64 + + noinst_LTLIBRARIES = libos.la + libos_la_SOURCES = os.c +diff --git a/src/os/linux/aarch64/Makefile.am b/src/os/linux/aarch64/Makefile.am +new file mode 100644 +index 0000000..0e5134f +--- /dev/null ++++ jamvm/jamvm/src/os/linux/aarch64/Makefile.am +@@ -0,0 +1,28 @@ ++## ++## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012 ++## Robert Lougher . ++## ++## File added by Simon South . ++## ++## This file is part of JamVM. ++## ++## This program is free software; you can redistribute it and/or ++## modify it under the terms of the GNU General Public License ++## as published by the Free Software Foundation; either version 2, ++## or (at your option) any later version. ++## ++## This program is distributed in the hope that it will be useful, ++## but WITHOUT ANY WARRANTY; without even the implied warranty of ++## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++## GNU General Public License for more details. ++## ++## You should have received a copy of the GNU General Public License ++## along with this program; if not, write to the Free Software ++## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++## ++ ++noinst_LTLIBRARIES = libnative.la ++libnative_la_SOURCES = init.c dll_md.c callNative.S ++ ++AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src ++AM_CCASFLAGS = -I$(top_builddir)/src +diff --git a/src/os/linux/aarch64/callNative.S b/src/os/linux/aarch64/callNative.S +new file mode 100644 +index 0000000..e067c4f +--- /dev/null ++++ jamvm/jamvm/src/os/linux/aarch64/callNative.S +@@ -0,0 +1,212 @@ ++/* ++ * Copyright (C) 2008, 2009, 2011, 2012 Robert Lougher . ++ * Copyright (C) 2020 Simon South . ++ * ++ * This file is part of JamVM. ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2, ++ * or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ */ ++ ++#include "config.h" ++ ++#ifndef USE_FFI ++ .text ++ .arch armv8-a ++ .align 2 ++ .global callJNIMethod ++ .type callJNIMethod,function ++ ++/* ++ * Arguments passed in: ++ * ++ * x0 JNIEnv ++ * x1 class or NULL ++ * x2 sig ++ * w3 extra arg ++ * x4 ostack ++ * x5 function pntr ++ * w6 args count ++ */ ++ ++/* Register usage: ++ * ++ * x20 ostack ++ * x19 sig pntr ++ * x16 function pntr ++ * x15 ostack pntr ++ * x14 args pntr ++ * x13 float/double handler ++ * x12 int/long handler ++ * w11 fp regs remaining ++ * w10 int regs remaining ++ * x9 scratch ++ * x2-x7 outgoing int args ++ * x1 outgoing class or this pntr ++ * x0 outgoing JNIEnv (as passed in) ++ * ++ * d0 - d7 outgoing float args ++ */ ++ ++callJNIMethod: ++ stp x29, x30, [sp, #-32]! ++ mov x29, sp ++ stp x19, x20, [x29, #16] ++ ++ sub sp, sp, w3 /* allocate room for stacked args */ ++ mov x14, sp ++ ++ mov x20, x4 /* preserve ostack */ ++ add x19, x2, #1 /* init sig pntr -- skipping '(' */ ++ ++ mov x16, x5 /* save function pntr */ ++ mov x15, x20 /* init ostack pntr */ ++ ++ adr x13, fp_reg_handlers-8 ++ adr x12, int_reg_handlers-8 ++ ++ mov w11, #8 /* fp regs remaining */ ++ mov w10, #6 /* int regs remaining */ ++ ++ cbnz x1, scan_sig /* is method non-static? */ ++ ldr x1, [x15], #8 /* yes, load x1 with "this" */ ++ ++scan_sig: ++ ldrb w9, [x19], #1 /* get next sig char */ ++ ++ cmp w9, #41 /* ')' */ ++ b.eq done ++ ++ cmp w9, #74 /* 'J' */ ++ b.eq long ++ ++ cmp w9, #70 /* 'F' */ ++ b.eq float ++ ++ cmp w9, #68 /* 'D' */ ++ b.eq double ++ ++skip_brackets: ++ cmp w9, #91 /* '[' */ ++ b.ne 1f ++ ldrb w9, [x19], #1 ++ b skip_brackets ++1: ++ cmp w9, #76 /* 'L' */ ++ b.ne int ++ ++skip_ref: ++ ldrb w9, [x19], #1 ++ cmp w9, #59 /* ';' */ ++ b.ne skip_ref ++ ++int: ++ ldr x9, [x15], #8 ++ cbz w10, stack_push ++ ++load_int_reg: ++ sub w10, w10, #1 ++ add x12, x12, #8 ++ br x12 ++ ++int_reg_handlers: ++ mov x2, x9 ++ b scan_sig ++ mov x3, x9 ++ b scan_sig ++ mov x4, x9 ++ b scan_sig ++ mov x5, x9 ++ b scan_sig ++ mov x6, x9 ++ b scan_sig ++ mov x7, x9 ++ b scan_sig ++ ++long: ++ ldr x9, [x15], #16 ++ cbz w10, stack_push ++ b load_int_reg ++ ++float: ++ ldr w9, [x15], #8 ++ cbz w11, stack_push ++ b load_fp_reg ++ ++double: ++ ldr x9, [x15], #16 ++ cbz w11, stack_push ++ ++load_fp_reg: ++ sub w11, w11, #1 ++ add x13, x13, #8 ++ br x13 ++ ++fp_reg_handlers: ++ fmov d0, x9 ++ b scan_sig ++ fmov d1, x9 ++ b scan_sig ++ fmov d2, x9 ++ b scan_sig ++ fmov d3, x9 ++ b scan_sig ++ fmov d4, x9 ++ b scan_sig ++ fmov d5, x9 ++ b scan_sig ++ fmov d6, x9 ++ b scan_sig ++ fmov d7, x9 ++ b scan_sig ++ ++stack_push: ++ str x9, [x14], #8 ++ b scan_sig ++ ++done: ++ /* Call the function */ ++ blr x16 ++ ++ mov sp, x29 /* Pop argument area */ ++ ++ ldrb w9, [x19] /* Return type */ ++ ++ cmp w9, #86 /* 'V' */ ++ b.eq return ++ ++ cmp w9, #68 /* 'D' */ ++ b.ne 2f ++ str d0, [x20], #16 ++ b return ++2: ++ cmp w9, #70 /* 'F' */ ++ b.ne 3f ++ str s0, [x20], #8 ++ b return ++3: ++ cmp w9, #74 /* 'J' */ ++ b.ne 4f ++ str x0, [x20], #16 ++ b return ++4: ++ str x0, [x20], #8 ++ ++return: ++ mov x0, x20 /* return ostack */ ++ ++ ldp x19, x20, [x29, #16] ++ ldp x29, x30, [sp], #32 ++ ret ++#endif +diff --git a/src/os/linux/aarch64/dll_md.c b/src/os/linux/aarch64/dll_md.c +new file mode 100644 +index 0000000..189f8a8 +--- /dev/null ++++ jamvm/jamvm/src/os/linux/aarch64/dll_md.c +@@ -0,0 +1,59 @@ ++/* ++ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011 ++ * Robert Lougher . ++ * Copyright (C) 2020 Simon South . ++ * ++ * This file is part of JamVM. ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2, ++ * or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ */ ++ ++#include "jam.h" ++ ++#ifndef USE_FFI ++ ++int nativeExtraArg(MethodBlock *mb) { ++ char *sig = mb->type; ++ int stack_args = 0; ++ int int_args = 6; ++ int fp_args = 8; ++ ++ while(*++sig != ')') ++ switch(*sig) { ++ case 'F': ++ case 'D': ++ if(fp_args == 0) ++ stack_args += 8; ++ else ++ fp_args--; ++ ++ default: ++ if(int_args == 0) ++ stack_args += 8; ++ else ++ int_args--; ++ ++ if(*sig == '[') ++ while(*++sig == '['); ++ if(*sig == 'L') ++ while(*++sig != ';'); ++ break; ++ } ++ ++ /* Ensure the stack remains 16 byte aligned. */ ++ return (stack_args + 15) & ~15; ++} ++ ++#endif +diff --git a/src/os/linux/aarch64/init.c b/src/os/linux/aarch64/init.c +new file mode 100644 +index 0000000..b21dc55 +--- /dev/null ++++ jamvm/jamvm/src/os/linux/aarch64/init.c +@@ -0,0 +1,51 @@ ++/* ++ * Copyright (C) 2003, 2004, 2005, 2006, 2007 ++ * Robert Lougher . ++ * Copyright (C) 2020 Simon South . ++ * ++ * This file is part of JamVM. ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2, ++ * or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ */ ++ ++#include "arch/aarch64.h" ++ ++/* Length in bytes of the smallest line in the host system's data cache */ ++unsigned char aarch64_data_cache_line_len; ++ ++/* Mask used to align a virtual address to a line in the data cache */ ++uintptr_t aarch64_data_cache_line_mask; ++ ++/* Length in bytes of the smallest line in the host system's instruction ++ cache */ ++unsigned char aarch64_instruction_cache_line_len; ++ ++/* Mask used to align a virtual address to a line in the instruction cache */ ++uintptr_t aarch64_instruction_cache_line_mask; ++ ++void initialisePlatform() { ++ unsigned int cache_type; ++ ++ /* Extract information from the cache-type register, which describes aspects ++ of the host's cache configuration */ ++ __asm__ ("mrs %0, ctr_el0" : "=r" (cache_type)); ++ ++ aarch64_data_cache_line_len = 4 << ((cache_type >> 16) & 0x0f); ++ aarch64_data_cache_line_mask = ~(aarch64_data_cache_line_len - 1); ++ ++ aarch64_instruction_cache_line_len = 4 << (cache_type & 0x0f); ++ aarch64_instruction_cache_line_mask = ++ ~(aarch64_instruction_cache_line_len - 1); ++} +-- +2.26.2 + diff --git a/dev-java/icedtea/files/jamvm-1.6.0-opcode-guard.patch b/dev-java/icedtea/files/jamvm-1.6.0-opcode-guard.patch new file mode 100644 index 0000000..3618a94 --- /dev/null +++ b/dev-java/icedtea/files/jamvm-1.6.0-opcode-guard.patch @@ -0,0 +1,35 @@ +From ca11b53896365c948426974cb90e8f71c70d123b Mon Sep 17 00:00:00 2001 +From: Simon South +Date: Sun, 31 May 2020 20:36:43 -0400 +Subject: [PATCH] Guard floating-point opcodes with explicit memory barrier + +--- + src/interp/engine/interp-inlining.h | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/src/interp/engine/interp-inlining.h b/src/interp/engine/interp-inlining.h +index 3339b0e..4ee5c5a 100644 +--- jamvm/jamvm/src/interp/engine/interp-inlining.h ++++ jamvm/jamvm/src/interp/engine/interp-inlining.h +@@ -78,8 +78,17 @@ + 4.3, we need to insert a label, and ensure its address + is taken (to stop it being optimised out). However, + this reduces performance on PowerPC by approx 1 - 2%. ++ ++ With gcc 5 and newer an asm statement with a "memory" ++ clobber argument explicitly sets a memory barrier for the ++ compiler, preventing it from reordering memory accesses ++ in a way that breaks decaching. + */ +-#if (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3) ++#if (__GNUC__ > 4) ++#define DEF_GUARD_TABLE(level) /* none */ ++#define GUARD(opcode, level) __asm__("" ::: "memory"); ++#define GUARD_TBLS /* none */ ++#elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3) + #define DEF_GUARD_TABLE(level) DEF_HANDLER_TABLE(level, GUARD) + #define GUARD(opcode, level) label(opcode, level, GUARD) + #define GUARD_TBLS , HNDLR_TBLS(GUARD) +-- +2.26.2 + diff --git a/dev-java/icedtea/files/wrong_checksum_workaround.patch b/dev-java/icedtea/files/wrong_checksum_workaround.patch deleted file mode 100644 index 3299892..0000000 --- a/dev-java/icedtea/files/wrong_checksum_workaround.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/openjdk/hotspot/src/share/vm/memory/dump.cpp 2019-11-30 18:24:36.750323337 +0000 -+++ b/openjdk/hotspot/src/share/vm/memory/dump.cpp 2019-11-30 18:24:51.150696251 +0000 -@@ -1553,7 +1553,7 @@ - if (computed_jsum != file_jsum) { - tty->cr(); - tty->print_cr("Preload failed: checksum of class list was incorrect."); -- exit(1); -+ // exit(1); - } - - tty->print_cr("done. "); diff --git a/dev-java/icedtea/icedtea-7.2.6.9.ebuild b/dev-java/icedtea/icedtea-7.2.6.9.ebuild index 2934c05..a6933cb 100644 --- a/dev-java/icedtea/icedtea-7.2.6.9.ebuild +++ b/dev-java/icedtea/icedtea-7.2.6.9.ebuild @@ -3,14 +3,10 @@ # $Id$ # Build written by Andrew John Hughes (gnu_andrew@member.fsf.org) -# ********************************************************* -# * IF YOU CHANGE THIS EBUILD, CHANGE ICEDTEA-6.* AS WELL * -# ********************************************************* - EAPI="6" SLOT="7" -inherit check-reqs gnome2-utils java-pkg-2 java-vm-2 multiprocessing pax-utils prefix versionator virtualx +inherit autotools check-reqs eutils gnome2-utils java-pkg-2 java-vm-2 multiprocessing pax-utils prefix versionator virtualx ICEDTEA_VER=$(get_version_component_range 2-4) ICEDTEA_BRANCH=$(get_version_component_range 2-3) @@ -171,6 +167,13 @@ pkg_setup() { src_unpack() { unpack ${SRC_PKG} + + cp "${FILESDIR}/jamvm-1.6.0-aarch64-support.patch" "${S}/patches/jamvm" + cp "${FILESDIR}/jamvm-1.6.0-opcode-guard.patch" "${S}/patches/jamvm" + + cd "${S}" + eapply "${FILESDIR}/additional_patches.patch" + eautoreconf } src_configure() {