For kicks and giggles I ported the Linux sparc support over to OpenBSD. Seems to work fairly well and passes most of the teir1 test cases. I'm somewhate hampered by egdb crashing when trying to debug the jvm while running (core files work fine though).
The method used to port Linux sparc support over is better documented in my commit messages here: https://github.com/bsdkurt/openjdk-jdk8u/commits/bsd_sparc Index: java.port.mk =================================================================== RCS file: /cvs/ports/devel/jdk/java.port.mk,v retrieving revision 1.39 diff -u -p -u -r1.39 java.port.mk --- java.port.mk 19 May 2021 01:39:00 -0000 1.39 +++ java.port.mk 6 Jul 2021 20:24:52 -0000 @@ -28,7 +28,11 @@ MODJAVA_VER?= ERRORS+="Fatal: MODJAVA_VER must be one of 1.8, 11 or 16 with an optional + suffix." .endif -ONLY_FOR_ARCHS?= i386 amd64 aarch64 +.if ${MODJAVA_VER} == "1.8" + ONLY_FOR_ARCHS?= i386 amd64 aarch64 sparc64 +.else + ONLY_FOR_ARCHS?= i386 amd64 aarch64 +.endif .if ${MODJAVA_VER:S/+//} == "1.8" JAVA_HOME= ${LOCALBASE}/jdk-1.8.0 Index: 1.8/Makefile =================================================================== RCS file: /cvs/ports/devel/jdk/1.8/Makefile,v retrieving revision 1.60 diff -u -p -u -r1.60 Makefile --- 1.8/Makefile 18 Jun 2021 19:37:52 -0000 1.60 +++ 1.8/Makefile 6 Jul 2021 20:24:52 -0000 @@ -1,6 +1,6 @@ # $OpenBSD: Makefile,v 1.60 2021/06/18 19:37:52 kurt Exp $ -ONLY_FOR_ARCHS= i386 amd64 aarch64 +ONLY_FOR_ARCHS= i386 amd64 aarch64 sparc64 USE_WXNEEDED= Yes DPB_PROPERTIES= parallel @@ -13,7 +13,7 @@ V= ${BASE_VER}.${UPDATE_VER}.${BUILD_VE PKGNAME= jdk-${V} PKGSTEM= jdk-${BASE_VER} EPOCH= 0 -REVISION= 0 +REVISION= 1 DIST_SUBDIR= jdk DISTNAME= jdk8u${UPDATE_VER}-${BUILD_VER}.${BSD_PORT_REL} @@ -45,9 +45,10 @@ APACHE_ANT= apache-ant-1.9.7-bin.tar.gz SUPDISTFILES+= openjdk-jdk8u-bootjdk-i386-${BOOTJDK_DATE}.tar.gz:1 \ openjdk-jdk8u-bootjdk-amd64-${BOOTJDK_DATE}.tar.gz:1 \ openjdk-jdk8u-bootjdk-aarch64-${BOOTJDK_DATE}.tar.gz:1 \ + openjdk-jdk8u-bootjdk-sparc64-${BOOTJDK_DATE}.tar.gz:1 \ ${APACHE_ANT}:2 -COMPILER= base-clang ports-gcc base-gcc +COMPILER= base-clang base-gcc .include <bsd.port.arch.mk> @@ -61,7 +62,8 @@ BUILD_DEPENDS+= jdk->=1.8.0.00v0,<1.9v0: BOOT_JDK= ${LOCALBASE}/jdk-1.8.0 .else BOOT_JDK_DIST= openjdk-jdk8u-bootjdk-${MACHINE_ARCH}-${BOOTJDK_DATE}.tar.gz -. if (${MACHINE_ARCH}==amd64) || (${MACHINE_ARCH}==i386) || (${MACHINE_ARCH}==aarch64) +. if (${MACHINE_ARCH}==amd64) || (${MACHINE_ARCH}==i386) || \ + (${MACHINE_ARCH}==aarch64) || (${MACHINE_ARCH}==sparc64) DISTFILES+= ${BOOT_JDK_DIST}:1 . endif DISTFILES+= ${APACHE_ANT}:2 @@ -113,18 +115,21 @@ MAKE_ENV+= DEFAULT_LIBPATH="/usr/lib:${X COMPILER_WARNINGS_FATAL=false .if ${PROPERTIES:Mclang} -MAKE_ENV+= USE_CLANG=true +CONFIGURE_ARGS+=--with-toolchain-type=clang +.else +CONFIGURE_ARGS+=--with-toolchain-type=gcc .endif JDKHOME= jdk-1.8.0 -SUBST_VARS= JDKHOME - -JVMARCH= ${MACHINE_ARCH:S/i386/x86/:S/amd64/x86_64/} +JVMARCH= ${MACHINE_ARCH:S/i386/x86/:S/amd64/x86_64/:S/sparc64/sparcv9/} +LIBARCH= ${MACHINE_ARCH:S/sparc64/sparcv9/} BUILDDIR= ${WRKDIST}/build/bsd-${JVMARCH}-normal-server-release/images JDKIMAGEDIR= ${BUILDDIR}/j2sdk-image WRKTMP= ${WRKDIR}/tmp +SUBST_VARS= JDKHOME LIBARCH + post-extract: chmod +x ${WRKDIST}/configure @@ -151,10 +156,10 @@ build-bootjdk: build ${_PBUILD} rm -rf demo sample @cd ${WRKTMP}/bootjdk && \ ${_PBUILD} rm bin/appletviewer bin/policytool jre/bin/policytool - @cd ${WRKTMP}/bootjdk/jre/lib/${MACHINE_ARCH} && \ + @cd ${WRKTMP}/bootjdk/jre/lib/${LIBARCH} && \ ${_PBUILD} rm libnpt.so libinstrument.so libsplashscreen.so \ libjsound.so libawt_xawt.so - @LD_LIBRARY_PATH="${WRKTMP}/bootjdk/jre/lib/${MACHINE_ARCH}:${WRKTMP}/bootjdk/jre/lib/${MACHINE_ARCH}/server" \ + @LD_LIBRARY_PATH="${WRKTMP}/bootjdk/jre/lib/${LIBARCH}:${WRKTMP}/bootjdk/jre/lib/${LIBARCH}/server" \ find ${WRKTMP}/bootjdk -type f -exec ldd {} + 2>/dev/null | \ grep rlib | cut -d"/" -f 2-20 | sort -u | grep -v "\.so$$" | \ xargs -I % ${_PBUILD} cp /% ${WRKTMP}/bootjdk-libs Index: 1.8/distinfo =================================================================== RCS file: /cvs/ports/devel/jdk/1.8/distinfo,v retrieving revision 1.27 diff -u -p -u -r1.27 distinfo --- 1.8/distinfo 18 Jun 2021 19:37:52 -0000 1.27 +++ 1.8/distinfo 6 Jul 2021 20:24:52 -0000 @@ -3,8 +3,10 @@ SHA256 (jdk/jdk8u292-b10.2.tar.gz) = p6G SHA256 (jdk/openjdk-jdk8u-bootjdk-aarch64-20210615.tar.gz) = dcHgGHTdP2tOgUhTrrHxkCsOrnM+lnmqITDpygG8CgM= SHA256 (jdk/openjdk-jdk8u-bootjdk-amd64-20210615.tar.gz) = PNX1evUzIBaoq/FQSWdS0w8DdrhUrxeCO8LrQeq8gr4= SHA256 (jdk/openjdk-jdk8u-bootjdk-i386-20210615.tar.gz) = Ssb52Qm1oThmjf1e3Nz4UCnACdQHa4WTm08eFTQiZuE= +SHA256 (jdk/openjdk-jdk8u-bootjdk-sparc64-20210615.tar.gz) = wmY4+ZGdyrBKNcVGe4N2XOKMwzkN2qK/Z319brEbLqc= SIZE (jdk/apache-ant-1.9.7-bin.tar.gz) = 5601575 SIZE (jdk/jdk8u292-b10.2.tar.gz) = 88568471 SIZE (jdk/openjdk-jdk8u-bootjdk-aarch64-20210615.tar.gz) = 103452168 SIZE (jdk/openjdk-jdk8u-bootjdk-amd64-20210615.tar.gz) = 104795359 SIZE (jdk/openjdk-jdk8u-bootjdk-i386-20210615.tar.gz) = 103017578 +SIZE (jdk/openjdk-jdk8u-bootjdk-sparc64-20210615.tar.gz) = 103616215 Index: 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_debugger_bsd_sparc_BsdSPARCCFrame_java =================================================================== RCS file: 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_debugger_bsd_sparc_BsdSPARCCFrame_java diff -N 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_debugger_bsd_sparc_BsdSPARCCFrame_java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_debugger_bsd_sparc_BsdSPARCCFrame_java 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,89 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/sparc/BsdSPARCCFrame.java +--- hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/sparc/BsdSPARCCFrame.java.orig ++++ hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/sparc/BsdSPARCCFrame.java +@@ -0,0 +1,81 @@ ++/* ++ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++package sun.jvm.hotspot.debugger.bsd.sparc; ++ ++import sun.jvm.hotspot.debugger.*; ++import sun.jvm.hotspot.debugger.sparc.*; ++import sun.jvm.hotspot.debugger.bsd.*; ++import sun.jvm.hotspot.debugger.cdbg.*; ++import sun.jvm.hotspot.debugger.cdbg.basic.*; ++ ++final public class BsdSPARCCFrame extends BasicCFrame { ++ // package/class internals only ++ ++ public BsdSPARCCFrame(BsdDebugger dbg, Address sp, Address pc, int address_size) { ++ super(dbg.getCDebugger()); ++ this.sp = sp; ++ this.pc = pc; ++ this.dbg = dbg; ++ this.address_size=address_size; ++ if (address_size==8) SPARC_STACK_BIAS = 0x7ff; ++ else SPARC_STACK_BIAS = 0x0; ++ } ++ ++ // override base class impl to avoid ELF parsing ++ public ClosestSymbol closestSymbolToPC() { ++ // try native lookup in debugger. ++ return dbg.lookup(dbg.getAddressValue(pc())); ++ } ++ ++ public Address pc() { ++ return pc; ++ } ++ ++ public Address localVariableBase() { ++ return sp; ++ } ++ ++ public CFrame sender(ThreadProxy thread) { ++ if (sp == null) { ++ return null; ++ } ++ ++ Address nextSP = sp.getAddressAt( SPARCThreadContext.R_SP * address_size + SPARC_STACK_BIAS); ++ if (nextSP == null) { ++ return null; ++ } ++ Address nextPC = sp.getAddressAt(SPARCThreadContext.R_O7 * address_size + SPARC_STACK_BIAS); ++ if (nextPC == null) { ++ return null; ++ } ++ return new BsdSPARCCFrame(dbg, nextSP, nextPC,address_size); ++ } ++ ++ public static int SPARC_STACK_BIAS; ++ private static int address_size; ++ private Address pc; ++ private Address sp; ++ private BsdDebugger dbg; ++} Index: 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_debugger_bsd_sparc_BsdSPARCThreadContext_java =================================================================== RCS file: 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_debugger_bsd_sparc_BsdSPARCThreadContext_java diff -N 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_debugger_bsd_sparc_BsdSPARCThreadContext_java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_debugger_bsd_sparc_BsdSPARCThreadContext_java 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,54 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/sparc/BsdSPARCThreadContext.java +--- hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/sparc/BsdSPARCThreadContext.java.orig ++++ hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/sparc/BsdSPARCThreadContext.java +@@ -0,0 +1,46 @@ ++/* ++ * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++package sun.jvm.hotspot.debugger.bsd.sparc; ++ ++import sun.jvm.hotspot.debugger.*; ++import sun.jvm.hotspot.debugger.sparc.*; ++import sun.jvm.hotspot.debugger.bsd.*; ++ ++public class BsdSPARCThreadContext extends SPARCThreadContext { ++ private BsdDebugger debugger; ++ ++ public BsdSPARCThreadContext(BsdDebugger debugger) { ++ super(); ++ this.debugger = debugger; ++ } ++ ++ public void setRegisterAsAddress(int index, Address value) { ++ setRegister(index, debugger.getAddressValue(value)); ++ } ++ ++ public Address getRegisterAsAddress(int index) { ++ return debugger.newAddress(getRegister(index)); ++ } ++} Index: 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_runtime_Threads_java =================================================================== RCS file: 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_runtime_Threads_java diff -N 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_runtime_Threads_java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_runtime_Threads_java 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,24 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java +--- hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java.orig ++++ hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java +@@ -40,6 +40,7 @@ import sun.jvm.hotspot.runtime.bsd_x86.BsdX86JavaThrea + import sun.jvm.hotspot.runtime.bsd_aarch64.BsdAARCH64JavaThreadPDAccess; + import sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess; + import sun.jvm.hotspot.runtime.bsd_ppc64.BsdPPC64JavaThreadPDAccess; ++import sun.jvm.hotspot.runtime.bsd_sparc.BsdSPARCJavaThreadPDAccess; + import sun.jvm.hotspot.utilities.*; + + public class Threads { +@@ -112,6 +113,8 @@ public class Threads { + access = new BsdAARCH64JavaThreadPDAccess(); + } else if (cpu.equals("ppc64")) { + access = new BsdPPC64JavaThreadPDAccess(); ++ } else if (cpu.equals("sparc")) { ++ access = new BsdSPARCJavaThreadPDAccess(); + } + } else if (os.equals("darwin")) { + if (cpu.equals("amd64") || cpu.equals("x86_64")) { Index: 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_runtime_bsd_sparc_BsdSPARCJavaThreadPDAccess_java =================================================================== RCS file: 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_runtime_bsd_sparc_BsdSPARCJavaThreadPDAccess_java diff -N 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_runtime_bsd_sparc_BsdSPARCJavaThreadPDAccess_java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_runtime_bsd_sparc_BsdSPARCJavaThreadPDAccess_java 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,173 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_sparc/BsdSPARCJavaThreadPDAccess.java +--- hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_sparc/BsdSPARCJavaThreadPDAccess.java.orig ++++ hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_sparc/BsdSPARCJavaThreadPDAccess.java +@@ -0,0 +1,165 @@ ++/* ++ * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++package sun.jvm.hotspot.runtime.bsd_sparc; ++ ++import java.io.*; ++import java.util.*; ++import sun.jvm.hotspot.debugger.*; ++import sun.jvm.hotspot.debugger.sparc.*; ++import sun.jvm.hotspot.runtime.*; ++import sun.jvm.hotspot.runtime.sparc.*; ++import sun.jvm.hotspot.types.*; ++import sun.jvm.hotspot.utilities.*; ++ ++public class BsdSPARCJavaThreadPDAccess implements JavaThreadPDAccess { ++ private static AddressField baseOfStackPointerField; ++ private static AddressField postJavaStateField; ++ private static AddressField osThreadField; ++ private static int isPC; ++ private static int hasFlushed; ++ ++ // Field from OSThread ++ private static CIntegerField osThreadThreadIDField; ++ ++ static { ++ VM.registerVMInitializedObserver(new Observer() { ++ public void update(Observable o, Object data) { ++ initialize(VM.getVM().getTypeDataBase()); ++ } ++ }); ++ } ++ ++ private static synchronized void initialize(TypeDataBase db) { ++ Type type = db.lookupType("JavaThread"); ++ Type anchorType = db.lookupType("JavaFrameAnchor"); ++ ++ osThreadField = type.getAddressField("_osthread"); ++ hasFlushed = db.lookupIntConstant("JavaFrameAnchor::flushed").intValue(); ++ ++ type = db.lookupType("OSThread"); ++ osThreadThreadIDField = type.getCIntegerField("_thread_id"); ++ } ++ ++ public Address getLastJavaFP(Address addr) { ++ return null; ++ ++ } ++ ++ public Address getLastJavaPC(Address addr) { ++ return null; ++ } ++ ++ public Address getBaseOfStackPointer(Address addr) { ++ return baseOfStackPointerField.getValue(addr); ++ } ++ ++ public Frame getLastFramePD(JavaThread thread, Address addr) { ++ ++ // This assert doesn't work in the debugging case for threads ++ // which are running Java code and which haven't re-entered the ++ // runtime (e.g., through a Method.invoke() or otherwise). They ++ // haven't yet "decached" their last Java stack pointer to the ++ // thread. ++ ++ // if (Assert.ASSERTS_ENABLED) { ++ // Assert.that(hasLastJavaFrame(), "must have last_Java_sp() when suspended"); ++ // // FIXME: add assertion about flushing register windows for runtime system ++ // // (not appropriate for debugging system, though, unless at safepoin t) ++ // } ++ ++ // FIXME: I don't think this is necessary, but might be useful ++ // while debugging ++ if (thread.getLastJavaSP() == null) { ++ return null; ++ } ++ ++ // sparc does a lazy window flush. The _flags field of the JavaFrameAnchor ++ // encodes whether the windows have flushed. Whenever the windows have flushed ++ // there will be a last_Java_pc. ++ // In a relective system we'd have to do something to force the thread to flush ++ // its windows and give us the pc (or the younger_sp so we can find it ourselves) ++ // In a debugger situation (process or core) the flush should have happened and ++ // so if we don't have the younger sp we can find it ++ // ++ if (thread.getLastJavaPC() != null) { ++ return new SPARCFrame(SPARCFrame.biasSP(thread.getLastJavaSP()), thread.getLastJavaPC()); ++ } else { ++ Frame top = getCurrentFrameGuess(thread, addr); ++ return new SPARCFrame(SPARCFrame.biasSP(thread.getLastJavaSP()), ++ SPARCFrame.biasSP(SPARCFrame.findYoungerSP(top.getSP(), thread.getLastJavaSP())), ++ false); ++ } ++ ++ ++ } ++ ++ public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) { ++ return new SPARCRegisterMap(thread, updateMap); ++ } ++ ++ public Frame getCurrentFrameGuess(JavaThread thread, Address addr) { ++ ThreadProxy t = getThreadProxy(addr); ++ SPARCThreadContext context = (SPARCThreadContext) t.getContext(); ++ // For now, let's see what happens if we do a similar thing to ++ // what the runtime code does. I suspect this may cause us to lose ++ // the top frame from the stack. ++ Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP); ++ Address pc = context.getRegisterAsAddress(SPARCThreadContext.R_PC); ++ ++ if ((sp == null) || (pc == null)) { ++ // Problems (have not hit this case so far, but would be bad to continue if we did) ++ return null; ++ } ++ ++ return new SPARCFrame(sp, pc); ++ } ++ ++ ++ public void printThreadIDOn(Address addr, PrintStream tty) { ++ tty.print(getThreadProxy(addr)); ++ } ++ ++ public Address getLastSP(Address addr) { ++ ThreadProxy t = getThreadProxy(addr); ++ SPARCThreadContext context = (SPARCThreadContext) t.getContext(); ++ return SPARCFrame.unBiasSP(context.getRegisterAsAddress(SPARCThreadContext.R_SP)); ++ } ++ ++ public void printInfoOn(Address threadAddr, PrintStream tty) { ++ } ++ ++ public ThreadProxy getThreadProxy(Address addr) { ++ // Fetch the OSThread (for now and for simplicity, not making a ++ // separate "OSThread" class in this package) ++ Address osThreadAddr = osThreadField.getValue(addr); ++ // Get the address of the thread ID from the OSThread ++ Address tidAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset()); ++ ++ JVMDebugger debugger = VM.getVM().getDebugger(); ++ return debugger.getThreadForIdentifierAddress(tidAddr); ++ } ++ ++ ++} Index: 1.8/patches/patch-hotspot_make_bsd_makefiles_buildtree_make =================================================================== RCS file: 1.8/patches/patch-hotspot_make_bsd_makefiles_buildtree_make diff -N 1.8/patches/patch-hotspot_make_bsd_makefiles_buildtree_make --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_make_bsd_makefiles_buildtree_make 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,15 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/make/bsd/makefiles/buildtree.make +--- hotspot/make/bsd/makefiles/buildtree.make.orig ++++ hotspot/make/bsd/makefiles/buildtree.make +@@ -203,6 +203,7 @@ LP64_SETTING/64 = LP64 = 1 + DATA_MODE/i486 = 32 + DATA_MODE/amd64 = 64 + DATA_MODE/aarch64 = 64 ++DATA_MODE/sparcv9 = 64 + + DATA_MODE = $(DATA_MODE/$(BUILDARCH)) + Index: 1.8/patches/patch-hotspot_make_bsd_makefiles_defs_make =================================================================== RCS file: 1.8/patches/patch-hotspot_make_bsd_makefiles_defs_make diff -N 1.8/patches/patch-hotspot_make_bsd_makefiles_defs_make --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_make_bsd_makefiles_defs_make 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,31 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/make/bsd/makefiles/defs.make +--- hotspot/make/bsd/makefiles/defs.make.orig ++++ hotspot/make/bsd/makefiles/defs.make +@@ -66,7 +66,7 @@ ifeq ($(ARCH), ia64) + endif + + # sparc +-ifeq ($(ARCH), sparc64) ++ifneq (,$(findstring $(ARCH), sparc)) + ifeq ($(ARCH_DATA_MODEL), 64) + ARCH_DATA_MODEL = 64 + MAKE_ARGS += LP64=1 +@@ -388,12 +388,14 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) + ifeq ($(ZIP_DEBUGINFO_FILES),1) + ADD_SA_BINARIES/aarch64 += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.diz + ADD_SA_BINARIES/ppc += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.diz ++ ADD_SA_BINARIES/sparc += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.diz + else + ifeq ($(OS_VENDOR), Darwin) + ADD_SA_BINARIES/ppc += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX).dSYM + else + ADD_SA_BINARIES/aarch64 += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo + ADD_SA_BINARIES/ppc += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo ++ ADD_SA_BINARIES/sparc += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo + endif + endif + endif Index: 1.8/patches/patch-hotspot_make_bsd_makefiles_gcc_make =================================================================== RCS file: 1.8/patches/patch-hotspot_make_bsd_makefiles_gcc_make diff -N 1.8/patches/patch-hotspot_make_bsd_makefiles_gcc_make --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_make_bsd_makefiles_gcc_make 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,16 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/make/bsd/makefiles/gcc.make +--- hotspot/make/bsd/makefiles/gcc.make.orig ++++ hotspot/make/bsd/makefiles/gcc.make +@@ -286,6 +286,8 @@ ifeq ($(USE_CLANG), true) + WARNINGS_ARE_ERRORS += -Wno-undefined-bool-conversion -Wno-expansion-to-defined + WARNINGS_ARE_ERRORS += -Wno-undefined-var-template + endif ++else ++ WARNINGS_ARE_ERRORS += -Wno-format + endif + + WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2 Index: 1.8/patches/patch-hotspot_make_bsd_makefiles_sparcv9_make =================================================================== RCS file: 1.8/patches/patch-hotspot_make_bsd_makefiles_sparcv9_make diff -N 1.8/patches/patch-hotspot_make_bsd_makefiles_sparcv9_make --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_make_bsd_makefiles_sparcv9_make 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,24 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/make/bsd/makefiles/sparcv9.make +--- hotspot/make/bsd/makefiles/sparcv9.make.orig ++++ hotspot/make/bsd/makefiles/sparcv9.make +@@ -21,7 +21,16 @@ + # questions. + # + ++OS_VENDOR = $(shell uname -s) ++ ++ifeq ($(OS_VENDOR), OpenBSD) ++SYSDEFS+= -DSTACKGHOST ++endif ++ + # gcc 4.0 miscompiles this code in -m64 + OPT_CFLAGS/macro.o = -O0 ++ ++# Avoid ICE with gcc 4.2.1 ++OPT_CFLAGS/mulnode.o = -O0 + + CFLAGS += -D_LP64=1 Index: 1.8/patches/patch-hotspot_src_cpu_sparc_vm_frame_sparc_cpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_cpu_sparc_vm_frame_sparc_cpp diff -N 1.8/patches/patch-hotspot_src_cpu_sparc_vm_frame_sparc_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_cpu_sparc_vm_frame_sparc_cpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,73 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/cpu/sparc/vm/frame_sparc.cpp +--- hotspot/src/cpu/sparc/vm/frame_sparc.cpp.orig ++++ hotspot/src/cpu/sparc/vm/frame_sparc.cpp +@@ -174,6 +174,14 @@ void RegisterMap::shift_individual_registers() { + check_location_valid(); + } + ++address frame::sender_pc() const { ++#ifdef STACKGHOST ++ return (address)((intptr_t)(*I7_addr() + pc_return_offset) ^ sg_cookie()); ++#else ++ return (*I7_addr() + pc_return_offset); ++#endif ++} ++ + bool frame::safe_for_sender(JavaThread *thread) { + + address _SP = (address) sp(); +@@ -243,7 +251,12 @@ bool frame::safe_for_sender(JavaThread *thread) { + intptr_t* _SENDER_SP = sender_sp(); // sender is actually just _FP + bool adjusted_stack = is_interpreted_frame(); + ++#ifdef STACKGHOST ++ address sender_pc = (address)younger_sp[I7->sp_offset_in_saved_window()]; ++ sender_pc = (address)((intptr_t)sender_pc ^ sg_cookie()) + pc_return_offset; ++#else + address sender_pc = (address)younger_sp[I7->sp_offset_in_saved_window()] + pc_return_offset; ++#endif + + + // We must always be able to find a recognizable pc +@@ -378,7 +391,12 @@ frame::frame(intptr_t* sp, intptr_t* younger_sp, bool + _pc = NULL; + _cb = NULL; + } else { ++#ifdef STACKGHOST ++ _pc = (address)younger_sp[I7->sp_offset_in_saved_window()]; ++ _pc = (address)((intptr_t)_pc ^ sg_cookie()) + pc_return_offset; ++#else + _pc = (address)younger_sp[I7->sp_offset_in_saved_window()] + pc_return_offset; ++#endif + assert( (intptr_t*)younger_sp[FP->sp_offset_in_saved_window()] == (intptr_t*)((intptr_t)sp - STACK_BIAS), "younger_sp must be valid"); + // Any frame we ever build should always "safe" therefore we should not have to call + // find_blob_unsafe +@@ -545,7 +563,11 @@ void frame::patch_pc(Thread* thread, address pc) { + tty->print_cr("patch_pc at address 0x%x [0x%x -> 0x%x] ", O7_addr(), _pc, pc); + } + _cb = CodeCache::find_blob(pc); ++#ifdef STACKGHOST ++ *O7_addr() = (address)((uintptr_t)(pc - pc_return_offset) ^ sg_cookie()); ++#else + *O7_addr() = pc - pc_return_offset; ++#endif + _cb = CodeCache::find_blob(_pc); + address original_pc = nmethod::get_deopt_original_pc(this); + if (original_pc != NULL) { +@@ -691,7 +713,12 @@ void JavaFrameAnchor::capture_last_Java_pc(intptr_t* s + // Really this should never fail otherwise VM call must have non-standard + // frame linkage (bad) or stack is not properly flushed (worse). + guarantee(_post_Java_sp != NULL, "bad stack!"); ++#ifdef STACKGHOST ++ _last_Java_pc = (address) _post_Java_sp[ I7->sp_offset_in_saved_window()]; ++ _last_Java_pc = (address)((intptr_t)_last_Java_pc ^ sg_cookie()) + frame::pc_return_offset; ++#else + _last_Java_pc = (address) _post_Java_sp[ I7->sp_offset_in_saved_window()] + frame::pc_return_offset; ++#endif + + } + set_window_flushed(); Index: 1.8/patches/patch-hotspot_src_cpu_sparc_vm_frame_sparc_inline_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_cpu_sparc_vm_frame_sparc_inline_hpp diff -N 1.8/patches/patch-hotspot_src_cpu_sparc_vm_frame_sparc_inline_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_cpu_sparc_vm_frame_sparc_inline_hpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,16 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp +--- hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp.orig ++++ hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp +@@ -74,8 +74,6 @@ inline intptr_t* frame::unextended_sp() const { return + + // return address: + +-inline address frame::sender_pc() const { return *I7_addr() + pc_return_offset; } +- + inline address* frame::I7_addr() const { return (address*) &sp()[ I7->sp_offset_in_saved_window()]; } + inline address* frame::I0_addr() const { return (address*) &sp()[ I0->sp_offset_in_saved_window()]; } + Index: 1.8/patches/patch-hotspot_src_cpu_sparc_vm_register_sparc_cpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_cpu_sparc_vm_register_sparc_cpp diff -N 1.8/patches/patch-hotspot_src_cpu_sparc_vm_register_sparc_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_cpu_sparc_vm_register_sparc_cpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,36 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/cpu/sparc/vm/register_sparc.cpp +--- hotspot/src/cpu/sparc/vm/register_sparc.cpp.orig ++++ hotspot/src/cpu/sparc/vm/register_sparc.cpp +@@ -25,6 +25,28 @@ + #include "precompiled.hpp" + #include "register_sparc.hpp" + ++#ifdef STACKGHOST ++uintptr_t get_stackghost_cookie() { ++ uintptr_t cookie; ++ ++ __asm volatile( ++ "add %%i7, %%g0, %%g4\n" ++ "save %%sp, -176, %%sp\n" ++ "flushw\n" ++ "restore\n" ++ "ldx [%%sp + 2047 + 0x78], %%g5\n" ++ "xor %%g4, %%g5, %0\n" ++ : "=r" (cookie) : : "%g4", "%g5"); ++ ++ return cookie; ++} ++ ++uintptr_t sg_cookie() { ++ static uintptr_t cookie = get_stackghost_cookie(); ++ return cookie; ++} ++#endif ++ + const int ConcreteRegisterImpl::max_gpr = RegisterImpl::number_of_registers << 1; + const int ConcreteRegisterImpl::max_fpr = ConcreteRegisterImpl::max_gpr + FloatRegisterImpl::number_of_registers; + Index: 1.8/patches/patch-hotspot_src_cpu_sparc_vm_register_sparc_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_cpu_sparc_vm_register_sparc_hpp diff -N 1.8/patches/patch-hotspot_src_cpu_sparc_vm_register_sparc_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_cpu_sparc_vm_register_sparc_hpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,18 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/cpu/sparc/vm/register_sparc.hpp +--- hotspot/src/cpu/sparc/vm/register_sparc.hpp.orig ++++ hotspot/src/cpu/sparc/vm/register_sparc.hpp +@@ -28,6 +28,10 @@ + #include "asm/register.hpp" + #include "vm_version_sparc.hpp" + ++#ifdef STACKGHOST ++uintptr_t sg_cookie(); ++#endif ++ + // forward declaration + class Address; + class VMRegImpl; Index: 1.8/patches/patch-hotspot_src_cpu_sparc_vm_sharedRuntime_sparc_cpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_cpu_sparc_vm_sharedRuntime_sparc_cpp diff -N 1.8/patches/patch-hotspot_src_cpu_sparc_vm_sharedRuntime_sparc_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_cpu_sparc_vm_sharedRuntime_sparc_cpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,21 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp +--- hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp.orig ++++ hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp +@@ -2490,7 +2490,13 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroA + // QQQ I think that non-v9 (like we care) we don't need these saves + // either as the flush traps and the current window goes too. + __ st_ptr(FP, SP, FP->sp_offset_in_saved_window()*wordSize + STACK_BIAS); ++#ifdef STACKGHOST ++ __ set(sg_cookie(), G3_scratch); ++ __ xor3(G3_scratch, I7, G3_scratch); ++ __ st_ptr(G3_scratch, SP, I7->sp_offset_in_saved_window()*wordSize + STACK_BIAS); ++#else + __ st_ptr(I7, SP, I7->sp_offset_in_saved_window()*wordSize + STACK_BIAS); ++#endif + } + + // get JNIEnv* which is first argument to native Index: 1.8/patches/patch-hotspot_src_cpu_sparc_vm_vm_version_ext_sparc_cpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_cpu_sparc_vm_vm_version_ext_sparc_cpp diff -N 1.8/patches/patch-hotspot_src_cpu_sparc_vm_vm_version_ext_sparc_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_cpu_sparc_vm_vm_version_ext_sparc_cpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,16 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/cpu/sparc/vm/vm_version_ext_sparc.cpp +--- hotspot/src/cpu/sparc/vm/vm_version_ext_sparc.cpp.orig ++++ hotspot/src/cpu/sparc/vm/vm_version_ext_sparc.cpp +@@ -147,7 +147,7 @@ bool VM_Version_Ext::initialize_cpu_information(void) + kstat_close(kc); + return true; + } +-#elif defined(LINUX) ++#else + // get cpu information. + bool VM_Version_Ext::initialize_cpu_information(void) { + // Not yet implemented. Index: 1.8/patches/patch-hotspot_src_os_bsd_vm_os_perf_bsd_cpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_bsd_vm_os_perf_bsd_cpp diff -N 1.8/patches/patch-hotspot_src_os_bsd_vm_os_perf_bsd_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_bsd_vm_os_perf_bsd_cpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,17 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os/bsd/vm/os_perf_bsd.cpp +--- hotspot/src/os/bsd/vm/os_perf_bsd.cpp.orig ++++ hotspot/src/os/bsd/vm/os_perf_bsd.cpp +@@ -39,6 +39,9 @@ + #ifdef TARGET_ARCH_ppc + # include "vm_version_ext_ppc.hpp" + #endif ++#ifdef TARGET_ARCH_sparc ++# include "vm_version_ext_sparc.hpp" ++#endif + + #ifdef __APPLE__ + #import <libproc.h> Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_atomic_bsd_sparc_inline_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_atomic_bsd_sparc_inline_hpp diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_atomic_bsd_sparc_inline_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_atomic_bsd_sparc_inline_hpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,224 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/atomic_bsd_sparc.inline.hpp +--- hotspot/src/os_cpu/bsd_sparc/vm/atomic_bsd_sparc.inline.hpp.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/atomic_bsd_sparc.inline.hpp +@@ -0,0 +1,216 @@ ++/* ++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++#ifndef OS_CPU_BSD_SPARC_VM_ATOMIC_BSD_SPARC_INLINE_HPP ++#define OS_CPU_BSD_SPARC_VM_ATOMIC_BSD_SPARC_INLINE_HPP ++ ++#include "runtime/atomic.hpp" ++#include "runtime/os.hpp" ++#include "vm_version_sparc.hpp" ++ ++// Implementation of class atomic ++ ++inline void Atomic::store (jbyte store_value, jbyte* dest) { *dest = store_value; } ++inline void Atomic::store (jshort store_value, jshort* dest) { *dest = store_value; } ++inline void Atomic::store (jint store_value, jint* dest) { *dest = store_value; } ++inline void Atomic::store (jlong store_value, jlong* dest) { *dest = store_value; } ++inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) { *dest = store_value; } ++inline void Atomic::store_ptr(void* store_value, void* dest) { *(void**)dest = store_value; } ++ ++inline void Atomic::store (jbyte store_value, volatile jbyte* dest) { *dest = store_value; } ++inline void Atomic::store (jshort store_value, volatile jshort* dest) { *dest = store_value; } ++inline void Atomic::store (jint store_value, volatile jint* dest) { *dest = store_value; } ++inline void Atomic::store (jlong store_value, volatile jlong* dest) { *dest = store_value; } ++inline void Atomic::store_ptr(intptr_t store_value, volatile intptr_t* dest) { *dest = store_value; } ++inline void Atomic::store_ptr(void* store_value, volatile void* dest) { *(void* volatile *)dest = store_value; } ++ ++inline void Atomic::inc (volatile jint* dest) { (void)add (1, dest); } ++inline void Atomic::inc_ptr(volatile intptr_t* dest) { (void)add_ptr(1, dest); } ++inline void Atomic::inc_ptr(volatile void* dest) { (void)add_ptr(1, dest); } ++ ++inline void Atomic::dec (volatile jint* dest) { (void)add (-1, dest); } ++inline void Atomic::dec_ptr(volatile intptr_t* dest) { (void)add_ptr(-1, dest); } ++inline void Atomic::dec_ptr(volatile void* dest) { (void)add_ptr(-1, dest); } ++ ++inline jlong Atomic::load(volatile jlong* src) { return *src; } ++ ++inline jint Atomic::add (jint add_value, volatile jint* dest) { ++ intptr_t rv; ++ __asm__ volatile( ++ "1: \n\t" ++ " ld [%2], %%o2\n\t" ++ " add %1, %%o2, %%o3\n\t" ++ " cas [%2], %%o2, %%o3\n\t" ++ " cmp %%o2, %%o3\n\t" ++ " bne 1b\n\t" ++ " nop\n\t" ++ " add %1, %%o2, %0\n\t" ++ : "=r" (rv) ++ : "r" (add_value), "r" (dest) ++ : "memory", "o2", "o3"); ++ return rv; ++} ++ ++inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) { ++ intptr_t rv; ++#ifdef _LP64 ++ __asm__ volatile( ++ "1: \n\t" ++ " ldx [%2], %%o2\n\t" ++ " add %1, %%o2, %%o3\n\t" ++ " casx [%2], %%o2, %%o3\n\t" ++ " cmp %%o2, %%o3\n\t" ++ " bne %%xcc, 1b\n\t" ++ " nop\n\t" ++ " add %1, %%o2, %0\n\t" ++ : "=r" (rv) ++ : "r" (add_value), "r" (dest) ++ : "memory", "o2", "o3"); ++#else ++ __asm__ volatile( ++ "1: \n\t" ++ " ld [%2], %%o2\n\t" ++ " add %1, %%o2, %%o3\n\t" ++ " cas [%2], %%o2, %%o3\n\t" ++ " cmp %%o2, %%o3\n\t" ++ " bne 1b\n\t" ++ " nop\n\t" ++ " add %1, %%o2, %0\n\t" ++ : "=r" (rv) ++ : "r" (add_value), "r" (dest) ++ : "memory", "o2", "o3"); ++#endif // _LP64 ++ return rv; ++} ++ ++inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) { ++ return (void*)add_ptr((intptr_t)add_value, (volatile intptr_t*)dest); ++} ++ ++ ++inline jint Atomic::xchg (jint exchange_value, volatile jint* dest) { ++ intptr_t rv = exchange_value; ++ __asm__ volatile( ++ " swap [%2],%1\n\t" ++ : "=r" (rv) ++ : "0" (exchange_value) /* we use same register as for return value */, "r" (dest) ++ : "memory"); ++ return rv; ++} ++ ++inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) { ++ intptr_t rv = exchange_value; ++#ifdef _LP64 ++ __asm__ volatile( ++ "1:\n\t" ++ " mov %1, %%o3\n\t" ++ " ldx [%2], %%o2\n\t" ++ " casx [%2], %%o2, %%o3\n\t" ++ " cmp %%o2, %%o3\n\t" ++ " bne %%xcc, 1b\n\t" ++ " nop\n\t" ++ " mov %%o2, %0\n\t" ++ : "=r" (rv) ++ : "r" (exchange_value), "r" (dest) ++ : "memory", "o2", "o3"); ++#else ++ __asm__ volatile( ++ "swap [%2],%1\n\t" ++ : "=r" (rv) ++ : "0" (exchange_value) /* we use same register as for return value */, "r" (dest) ++ : "memory"); ++#endif // _LP64 ++ return rv; ++} ++ ++inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) { ++ return (void*)xchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest); ++} ++ ++ ++inline jint Atomic::cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value) { ++ jint rv; ++ __asm__ volatile( ++ " cas [%2], %3, %0" ++ : "=r" (rv) ++ : "0" (exchange_value), "r" (dest), "r" (compare_value) ++ : "memory"); ++ return rv; ++} ++ ++inline jlong Atomic::cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value) { ++#ifdef _LP64 ++ jlong rv; ++ __asm__ volatile( ++ " casx [%2], %3, %0" ++ : "=r" (rv) ++ : "0" (exchange_value), "r" (dest), "r" (compare_value) ++ : "memory"); ++ return rv; ++#else ++ volatile jlong_accessor evl, cvl, rv; ++ evl.long_value = exchange_value; ++ cvl.long_value = compare_value; ++ ++ __asm__ volatile( ++ " sllx %2, 32, %2\n\t" ++ " srl %3, 0, %3\n\t" ++ " or %2, %3, %2\n\t" ++ " sllx %5, 32, %5\n\t" ++ " srl %6, 0, %6\n\t" ++ " or %5, %6, %5\n\t" ++ " casx [%4], %5, %2\n\t" ++ " srl %2, 0, %1\n\t" ++ " srlx %2, 32, %0\n\t" ++ : "=r" (rv.words[0]), "=r" (rv.words[1]) ++ : "r" (evl.words[0]), "r" (evl.words[1]), "r" (dest), "r" (cvl.words[0]), "r" (cvl.words[1]) ++ : "memory"); ++ ++ return rv.long_value; ++#endif ++} ++ ++inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value) { ++ intptr_t rv; ++#ifdef _LP64 ++ __asm__ volatile( ++ " casx [%2], %3, %0" ++ : "=r" (rv) ++ : "0" (exchange_value), "r" (dest), "r" (compare_value) ++ : "memory"); ++#else ++ __asm__ volatile( ++ " cas [%2], %3, %0" ++ : "=r" (rv) ++ : "0" (exchange_value), "r" (dest), "r" (compare_value) ++ : "memory"); ++#endif // _LP64 ++ return rv; ++} ++ ++inline void* Atomic::cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value) { ++ return (void*)cmpxchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest, (intptr_t)compare_value); ++} ++ ++#endif // OS_CPU_BSD_SPARC_VM_ATOMIC_BSD_SPARC_INLINE_HPP Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_bsd_sparc_ad =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_bsd_sparc_ad diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_bsd_sparc_ad --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_bsd_sparc_ad 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,35 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/bsd_sparc.ad +--- hotspot/src/os_cpu/bsd_sparc/vm/bsd_sparc.ad.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/bsd_sparc.ad +@@ -0,0 +1,27 @@ ++// ++// Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. ++// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++// ++// This code is free software; you can redistribute it and/or modify it ++// under the terms of the GNU General Public License version 2 only, as ++// published by the Free Software Foundation. ++// ++// This code 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 ++// version 2 for more details (a copy is included in the LICENSE file that ++// accompanied this code). ++// ++// You should have received a copy of the GNU General Public License version ++// 2 along with this work; if not, write to the Free Software Foundation, ++// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++// ++// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++// or visit www.oracle.com if you need additional information or have any ++// questions. ++// ++ ++// ++// ++ ++// SPARC Bsd Architecture Description File Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_bsd_sparc_s =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_bsd_sparc_s diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_bsd_sparc_s --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_bsd_sparc_s 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,77 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/bsd_sparc.s +--- hotspot/src/os_cpu/bsd_sparc/vm/bsd_sparc.s.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/bsd_sparc.s +@@ -0,0 +1,69 @@ ++# ++# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. ++# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++# ++# This code is free software; you can redistribute it and/or modify it ++# under the terms of the GNU General Public License version 2 only, as ++# published by the Free Software Foundation. ++# ++# This code 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 ++# version 2 for more details (a copy is included in the LICENSE file that ++# accompanied this code). ++# ++# You should have received a copy of the GNU General Public License version ++# 2 along with this work; if not, write to the Free Software Foundation, ++# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++# ++# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++# or visit www.oracle.com if you need additional information or have any ++# questions. ++# ++ ++ # Possibilities: ++ # -- membar ++ # -- CAS (SP + BIAS, G0, G0) ++ # -- wr %g0, %asi ++ ++ .globl SpinPause ++ .type SpinPause,@function ++ .align 32 ++SpinPause: ++ retl ++ mov %g0, %o0 ++ ++ .globl _Copy_conjoint_jlongs_atomic ++ .type _Copy_conjoint_jlongs_atomic,@function ++_Copy_conjoint_jlongs_atomic: ++ cmp %o0, %o1 ++ bleu 4f ++ sll %o2, 3, %o4 ++ ba 2f ++ 1: ++ subcc %o4, 8, %o4 ++ std %o2, [%o1] ++ add %o0, 8, %o0 ++ add %o1, 8, %o1 ++ 2: ++ bge,a 1b ++ ldd [%o0], %o2 ++ ba 5f ++ nop ++ 3: ++ std %o2, [%o1+%o4] ++ 4: ++ subcc %o4, 8, %o4 ++ bge,a 3b ++ ldd [%o0+%o4], %o2 ++ 5: ++ retl ++ nop ++ ++ ++ .globl _flush_reg_windows ++ .align 32 ++ _flush_reg_windows: ++ ta 0x03 ++ retl ++ mov %fp, %o0 Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_globals_bsd_sparc_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_globals_bsd_sparc_hpp diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_globals_bsd_sparc_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_globals_bsd_sparc_hpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,47 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/globals_bsd_sparc.hpp +--- hotspot/src/os_cpu/bsd_sparc/vm/globals_bsd_sparc.hpp.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/globals_bsd_sparc.hpp +@@ -0,0 +1,39 @@ ++/* ++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++#ifndef OS_CPU_BSD_SPARC_VM_GLOBALS_BSD_SPARC_HPP ++#define OS_CPU_BSD_SPARC_VM_GLOBALS_BSD_SPARC_HPP ++ ++// ++// Sets the default values for platform dependent flags used by the ++// runtime system. (see globals.hpp) ++// ++ ++define_pd_global(uintx, JVMInvokeMethodSlack, 12288); ++define_pd_global(intx, CompilerThreadStackSize, 0); ++ ++// Used on 64 bit platforms for UseCompressedOops base address ++define_pd_global(uintx, HeapBaseMinAddress, CONST64(4)*G); ++ ++#endif // OS_CPU_BSD_SPARC_VM_GLOBALS_BSD_SPARC_HPP Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_orderAccess_bsd_sparc_inline_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_orderAccess_bsd_sparc_inline_hpp diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_orderAccess_bsd_sparc_inline_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_orderAccess_bsd_sparc_inline_hpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,118 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/orderAccess_bsd_sparc.inline.hpp +--- hotspot/src/os_cpu/bsd_sparc/vm/orderAccess_bsd_sparc.inline.hpp.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/orderAccess_bsd_sparc.inline.hpp +@@ -0,0 +1,110 @@ ++/* ++ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++#ifndef OS_CPU_BSD_SPARC_VM_ORDERACCESS_BSD_SPARC_INLINE_HPP ++#define OS_CPU_BSD_SPARC_VM_ORDERACCESS_BSD_SPARC_INLINE_HPP ++ ++#include "runtime/orderAccess.hpp" ++#include "vm_version_sparc.hpp" ++ ++// Implementation of class OrderAccess. ++ ++// Assume TSO. ++ ++inline void OrderAccess::loadload() { acquire(); } ++inline void OrderAccess::storestore() { release(); } ++inline void OrderAccess::loadstore() { acquire(); } ++inline void OrderAccess::storeload() { fence(); } ++ ++inline void OrderAccess::acquire() { ++ __asm__ volatile ("nop" : : :); ++} ++ ++inline void OrderAccess::release() { ++ jint* local_dummy = (jint*)&local_dummy; ++ __asm__ volatile("stw %%g0, [%0]" : : "r" (local_dummy) : "memory"); ++} ++ ++inline void OrderAccess::fence() { ++ __asm__ volatile ("membar #StoreLoad" : : :); ++} ++ ++inline jbyte OrderAccess::load_acquire(volatile jbyte* p) { return *p; } ++inline jshort OrderAccess::load_acquire(volatile jshort* p) { return *p; } ++inline jint OrderAccess::load_acquire(volatile jint* p) { return *p; } ++inline jlong OrderAccess::load_acquire(volatile jlong* p) { return *p; } ++inline jubyte OrderAccess::load_acquire(volatile jubyte* p) { return *p; } ++inline jushort OrderAccess::load_acquire(volatile jushort* p) { return *p; } ++inline juint OrderAccess::load_acquire(volatile juint* p) { return *p; } ++inline julong OrderAccess::load_acquire(volatile julong* p) { return *p; } ++inline jfloat OrderAccess::load_acquire(volatile jfloat* p) { return *p; } ++inline jdouble OrderAccess::load_acquire(volatile jdouble* p) { return *p; } ++ ++inline intptr_t OrderAccess::load_ptr_acquire(volatile intptr_t* p) { return *p; } ++inline void* OrderAccess::load_ptr_acquire(volatile void* p) { return *(void* volatile *)p; } ++inline void* OrderAccess::load_ptr_acquire(const volatile void* p) { return *(void* const volatile *)p; } ++ ++inline void OrderAccess::release_store(volatile jbyte* p, jbyte v) { *p = v; } ++inline void OrderAccess::release_store(volatile jshort* p, jshort v) { *p = v; } ++inline void OrderAccess::release_store(volatile jint* p, jint v) { *p = v; } ++inline void OrderAccess::release_store(volatile jlong* p, jlong v) { *p = v; } ++inline void OrderAccess::release_store(volatile jubyte* p, jubyte v) { *p = v; } ++inline void OrderAccess::release_store(volatile jushort* p, jushort v) { *p = v; } ++inline void OrderAccess::release_store(volatile juint* p, juint v) { *p = v; } ++inline void OrderAccess::release_store(volatile julong* p, julong v) { *p = v; } ++inline void OrderAccess::release_store(volatile jfloat* p, jfloat v) { *p = v; } ++inline void OrderAccess::release_store(volatile jdouble* p, jdouble v) { *p = v; } ++ ++inline void OrderAccess::release_store_ptr(volatile intptr_t* p, intptr_t v) { *p = v; } ++inline void OrderAccess::release_store_ptr(volatile void* p, void* v) { *(void* volatile *)p = v; } ++ ++inline void OrderAccess::store_fence(jbyte* p, jbyte v) { *p = v; fence(); } ++inline void OrderAccess::store_fence(jshort* p, jshort v) { *p = v; fence(); } ++inline void OrderAccess::store_fence(jint* p, jint v) { *p = v; fence(); } ++inline void OrderAccess::store_fence(jlong* p, jlong v) { *p = v; fence(); } ++inline void OrderAccess::store_fence(jubyte* p, jubyte v) { *p = v; fence(); } ++inline void OrderAccess::store_fence(jushort* p, jushort v) { *p = v; fence(); } ++inline void OrderAccess::store_fence(juint* p, juint v) { *p = v; fence(); } ++inline void OrderAccess::store_fence(julong* p, julong v) { *p = v; fence(); } ++inline void OrderAccess::store_fence(jfloat* p, jfloat v) { *p = v; fence(); } ++inline void OrderAccess::store_fence(jdouble* p, jdouble v) { *p = v; fence(); } ++ ++inline void OrderAccess::store_ptr_fence(intptr_t* p, intptr_t v) { *p = v; fence(); } ++inline void OrderAccess::store_ptr_fence(void** p, void* v) { *p = v; fence(); } ++ ++inline void OrderAccess::release_store_fence(volatile jbyte* p, jbyte v) { *p = v; fence(); } ++inline void OrderAccess::release_store_fence(volatile jshort* p, jshort v) { *p = v; fence(); } ++inline void OrderAccess::release_store_fence(volatile jint* p, jint v) { *p = v; fence(); } ++inline void OrderAccess::release_store_fence(volatile jlong* p, jlong v) { *p = v; fence(); } ++inline void OrderAccess::release_store_fence(volatile jubyte* p, jubyte v) { *p = v; fence(); } ++inline void OrderAccess::release_store_fence(volatile jushort* p, jushort v) { *p = v; fence(); } ++inline void OrderAccess::release_store_fence(volatile juint* p, juint v) { *p = v; fence(); } ++inline void OrderAccess::release_store_fence(volatile julong* p, julong v) { *p = v; fence(); } ++inline void OrderAccess::release_store_fence(volatile jfloat* p, jfloat v) { *p = v; fence(); } ++inline void OrderAccess::release_store_fence(volatile jdouble* p, jdouble v) { *p = v; fence(); } ++ ++inline void OrderAccess::release_store_ptr_fence(volatile intptr_t* p, intptr_t v) { *p = v; fence(); } ++inline void OrderAccess::release_store_ptr_fence(volatile void* p, void* v) { *(void* volatile *)p = v; fence(); } ++ ++#endif // OS_CPU_BSD_SPARC_VM_ORDERACCESS_BSD_SPARC_INLINE_HPP Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_os_bsd_sparc_cpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_os_bsd_sparc_cpp diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_os_bsd_sparc_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_os_bsd_sparc_cpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,762 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/os_bsd_sparc.cpp +--- hotspot/src/os_cpu/bsd_sparc/vm/os_bsd_sparc.cpp.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/os_bsd_sparc.cpp +@@ -0,0 +1,754 @@ ++/* ++ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++// no precompiled headers ++#include "asm/macroAssembler.hpp" ++#include "classfile/classLoader.hpp" ++#include "classfile/systemDictionary.hpp" ++#include "classfile/vmSymbols.hpp" ++#include "code/icBuffer.hpp" ++#include "code/vtableStubs.hpp" ++#include "interpreter/interpreter.hpp" ++#include "jvm_bsd.h" ++#include "memory/allocation.inline.hpp" ++#include "mutex_bsd.inline.hpp" ++#include "nativeInst_sparc.hpp" ++#include "os_share_bsd.hpp" ++#include "prims/jniFastGetField.hpp" ++#include "prims/jvm.h" ++#include "prims/jvm_misc.hpp" ++#include "runtime/arguments.hpp" ++#include "runtime/extendedPC.hpp" ++#include "runtime/frame.inline.hpp" ++#include "runtime/interfaceSupport.hpp" ++#include "runtime/java.hpp" ++#include "runtime/javaCalls.hpp" ++#include "runtime/mutexLocker.hpp" ++#include "runtime/osThread.hpp" ++#include "runtime/sharedRuntime.hpp" ++#include "runtime/stubRoutines.hpp" ++#include "runtime/thread.inline.hpp" ++#include "runtime/timer.hpp" ++#include "utilities/events.hpp" ++#include "utilities/vmError.hpp" ++ ++// put OS-includes here ++# include <pthread.h> ++# include <pthread_np.h> ++ ++// Bsd/Sparc has rather obscure naming of registers in sigcontext ++// different between 32 and 64 bits ++#ifdef _LP64 ++#define SIG_PC(x) ((x)->sc_pc) ++#define SIG_NPC(x) ((x)->sc_npc) ++#define SIG_REGS(x) ((intptr_t*)((x)->sc_sp + STACK_BIAS)) ++#else ++#define SIG_PC(x) ((x)->sc_pc) ++#define SIG_NPC(x) ((x)->sc_npc) ++#define SIG_REGS(x) ((intptr_t*)((x)->sc_sp + STACK_BIAS)) ++#endif ++ ++// those are to reference registers in sigcontext ++enum { ++ CON_G0 = 0, ++ CON_G1, ++ CON_G2, ++ CON_G3, ++ CON_G4, ++ CON_G5, ++ CON_G6, ++ CON_G7, ++ CON_O0, ++ CON_O1, ++ CON_O2, ++ CON_O3, ++ CON_O4, ++ CON_O5, ++ CON_O6, ++ CON_O7, ++}; ++ ++static inline void set_cont_address(sigcontext* ctx, address addr) { ++ SIG_PC(ctx) = (intptr_t)addr; ++ SIG_NPC(ctx) = (intptr_t)(addr+4); ++} ++ ++// For Forte Analyzer AsyncGetCallTrace profiling support - thread is ++// currently interrupted by SIGPROF. ++// os::Solaris::fetch_frame_from_ucontext() tries to skip nested ++// signal frames. Currently we don't do that on Bsd, so it's the ++// same as os::fetch_frame_from_context(). ++ExtendedPC os::Bsd::fetch_frame_from_ucontext(Thread* thread, ++ ucontext_t* uc, ++ intptr_t** ret_sp, ++ intptr_t** ret_fp) { ++ assert(thread != NULL, "just checking"); ++ assert(ret_sp != NULL, "just checking"); ++ assert(ret_fp != NULL, "just checking"); ++ ++ return os::fetch_frame_from_context(uc, ret_sp, ret_fp); ++} ++ ++ExtendedPC os::fetch_frame_from_context(void* ucVoid, ++ intptr_t** ret_sp, ++ intptr_t** ret_fp) { ++ ucontext_t* uc = (ucontext_t*) ucVoid; ++ ExtendedPC epc; ++ ++ if (uc != NULL) { ++ epc = ExtendedPC(os::Bsd::ucontext_get_pc(uc)); ++ if (ret_sp) { ++ *ret_sp = os::Bsd::ucontext_get_sp(uc); ++ } ++ if (ret_fp) { ++ *ret_fp = (intptr_t*)NULL; ++ } ++ } else { ++ // construct empty ExtendedPC for return value checking ++ epc = ExtendedPC(NULL); ++ if (ret_sp) { ++ *ret_sp = (intptr_t*) NULL; ++ } ++ if (ret_fp) { ++ *ret_fp = (intptr_t*) NULL; ++ } ++ } ++ ++ return epc; ++} ++ ++frame os::fetch_frame_from_context(void* ucVoid) { ++ intptr_t* sp; ++ ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, NULL); ++ return frame(sp, frame::unpatchable, epc.pc()); ++} ++ ++frame os::get_sender_for_C_frame(frame* fr) { ++ return frame(fr->sender_sp(), frame::unpatchable, fr->sender_pc()); ++} ++ ++frame os::current_frame() { ++ intptr_t* sp = StubRoutines::Sparc::flush_callers_register_windows_func()(); ++ frame myframe(sp, frame::unpatchable, ++ CAST_FROM_FN_PTR(address, os::current_frame)); ++ if (os::is_first_C_frame(&myframe)) { ++ // stack is not walkable ++ return frame(NULL, frame::unpatchable, NULL); ++ } else { ++ return os::get_sender_for_C_frame(&myframe); ++ } ++} ++ ++address os::current_stack_pointer() { ++ register void *sp __asm__ ("sp"); ++ return (address)sp; ++} ++ ++static void current_stack_region(address* bottom, size_t* size) { ++#if defined(__OpenBSD__) ++ stack_t ss; ++ int rslt = pthread_stackseg_np(pthread_self(), &ss); ++ ++ if (rslt != 0) ++ fatal(err_msg("pthread_stackseg_np failed with err = %d", rslt)); ++ ++ *bottom = (address)((char *)ss.ss_sp - ss.ss_size); ++ *size = ss.ss_size; ++#else ++ pthread_attr_t attr; ++ ++ int rslt = pthread_attr_init(&attr); ++ ++ // JVM needs to know exact stack location, abort if it fails ++ if (rslt != 0) ++ fatal(err_msg("pthread_attr_init failed with err = %d", rslt)); ++ ++ rslt = pthread_attr_get_np(pthread_self(), &attr); ++ ++ if (rslt != 0) ++ fatal(err_msg("pthread_attr_get_np failed with err = %d", rslt)); ++ ++ if (pthread_attr_getstackaddr(&attr, (void **)bottom) != 0 || ++ pthread_attr_getstacksize(&attr, size) != 0) { ++ fatal("Can not locate current stack attributes!"); ++ } ++ ++ pthread_attr_destroy(&attr); ++#endif ++ assert(os::current_stack_pointer() >= *bottom && ++ os::current_stack_pointer() < *bottom + *size, "just checking"); ++} ++ ++address os::current_stack_base() { ++ address bottom; ++ size_t size; ++ current_stack_region(&bottom, &size); ++ return bottom + size; ++} ++ ++size_t os::current_stack_size() { ++ // stack size includes normal stack and HotSpot guard pages ++ address bottom; ++ size_t size; ++ current_stack_region(&bottom, &size); ++ return size; ++} ++ ++char* os::non_memory_address_word() { ++ // Must never look like an address returned by reserve_memory, ++ // even in its subfields (as defined by the CPU immediate fields, ++ // if the CPU splits constants across multiple instructions). ++ // On SPARC, 0 != %hi(any real address), because there is no ++ // allocation in the first 1Kb of the virtual address space. ++ return (char*) 0; ++} ++ ++void os::initialize_thread(Thread* thr) {} ++ ++void os::print_context(outputStream *st, void *context) { ++ if (context == NULL) return; ++ ++ ucontext_t* uc = (ucontext_t*)context; ++ sigcontext* sc = (sigcontext*)context; ++ st->print_cr("Registers:"); ++ ++ st->print_cr(" G1=" INTPTR_FORMAT " G2=" INTPTR_FORMAT ++ " G3=" INTPTR_FORMAT " G4=" INTPTR_FORMAT, ++ SIG_REGS(sc)[CON_G1], ++ SIG_REGS(sc)[CON_G2], ++ SIG_REGS(sc)[CON_G3], ++ SIG_REGS(sc)[CON_G4]); ++ st->print_cr(" G5=" INTPTR_FORMAT " G6=" INTPTR_FORMAT ++ " G7=" INTPTR_FORMAT, ++ SIG_REGS(sc)[CON_G5], ++ SIG_REGS(sc)[CON_G6], ++ SIG_REGS(sc)[CON_G7]); ++ st->print_cr(" O0=" INTPTR_FORMAT " O1=" INTPTR_FORMAT ++ " O2=" INTPTR_FORMAT " O3=" INTPTR_FORMAT, ++ SIG_REGS(sc)[CON_O0], ++ SIG_REGS(sc)[CON_O1], ++ SIG_REGS(sc)[CON_O2], ++ SIG_REGS(sc)[CON_O3]); ++ st->print_cr(" O4=" INTPTR_FORMAT " O5=" INTPTR_FORMAT ++ " O6=" INTPTR_FORMAT " O7=" INTPTR_FORMAT, ++ SIG_REGS(sc)[CON_O4], ++ SIG_REGS(sc)[CON_O5], ++ SIG_REGS(sc)[CON_O6], ++#ifdef STACKGHOST ++ SIG_REGS(sc)[CON_O7]^sg_cookie()); ++#else ++ SIG_REGS(sc)[CON_O7]); ++#endif ++ ++ intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc); ++ st->print_cr(" L0=" INTPTR_FORMAT " L1=" INTPTR_FORMAT ++ " L2=" INTPTR_FORMAT " L3=" INTPTR_FORMAT, ++ sp[L0->sp_offset_in_saved_window()], ++ sp[L1->sp_offset_in_saved_window()], ++ sp[L2->sp_offset_in_saved_window()], ++ sp[L3->sp_offset_in_saved_window()]); ++ st->print_cr(" L4=" INTPTR_FORMAT " L5=" INTPTR_FORMAT ++ " L6=" INTPTR_FORMAT " L7=" INTPTR_FORMAT, ++ sp[L4->sp_offset_in_saved_window()], ++ sp[L5->sp_offset_in_saved_window()], ++ sp[L6->sp_offset_in_saved_window()], ++ sp[L7->sp_offset_in_saved_window()]); ++ st->print_cr(" I0=" INTPTR_FORMAT " I1=" INTPTR_FORMAT ++ " I2=" INTPTR_FORMAT " I3=" INTPTR_FORMAT, ++ sp[I0->sp_offset_in_saved_window()], ++ sp[I1->sp_offset_in_saved_window()], ++ sp[I2->sp_offset_in_saved_window()], ++ sp[I3->sp_offset_in_saved_window()]); ++ st->print_cr(" I4=" INTPTR_FORMAT " I5=" INTPTR_FORMAT ++ " I6=" INTPTR_FORMAT " I7=" INTPTR_FORMAT, ++ sp[I4->sp_offset_in_saved_window()], ++ sp[I5->sp_offset_in_saved_window()], ++ sp[I6->sp_offset_in_saved_window()], ++ sp[I7->sp_offset_in_saved_window()]); ++ ++ st->print_cr(" PC=" INTPTR_FORMAT " nPC=" INTPTR_FORMAT, ++ SIG_PC(sc), ++ SIG_NPC(sc)); ++ st->cr(); ++ st->cr(); ++ ++ st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); ++ print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t)); ++ st->cr(); ++ ++ // Note: it may be unsafe to inspect memory near pc. For example, pc may ++ // point to garbage if entry point in an nmethod is corrupted. Leave ++ // this at the end, and hope for the best. ++ address pc = os::Bsd::ucontext_get_pc(uc); ++ st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc); ++ print_hex_dump(st, pc - 32, pc + 32, sizeof(char)); ++} ++ ++ ++void os::print_register_info(outputStream *st, void *context) { ++ if (context == NULL) return; ++ ++ ucontext_t *uc = (ucontext_t*)context; ++ sigcontext* sc = (sigcontext*)context; ++ intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc); ++ ++ st->print_cr("Register to memory mapping:"); ++ st->cr(); ++ ++ // this is only for the "general purpose" registers ++ st->print("G1="); print_location(st, SIG_REGS(sc)[CON_G1]); ++ st->print("G2="); print_location(st, SIG_REGS(sc)[CON_G2]); ++ st->print("G3="); print_location(st, SIG_REGS(sc)[CON_G3]); ++ st->print("G4="); print_location(st, SIG_REGS(sc)[CON_G4]); ++ st->print("G5="); print_location(st, SIG_REGS(sc)[CON_G5]); ++ st->print("G6="); print_location(st, SIG_REGS(sc)[CON_G6]); ++ st->print("G7="); print_location(st, SIG_REGS(sc)[CON_G7]); ++ st->cr(); ++ ++ st->print("O0="); print_location(st, SIG_REGS(sc)[CON_O0]); ++ st->print("O1="); print_location(st, SIG_REGS(sc)[CON_O1]); ++ st->print("O2="); print_location(st, SIG_REGS(sc)[CON_O2]); ++ st->print("O3="); print_location(st, SIG_REGS(sc)[CON_O3]); ++ st->print("O4="); print_location(st, SIG_REGS(sc)[CON_O4]); ++ st->print("O5="); print_location(st, SIG_REGS(sc)[CON_O5]); ++ st->print("O6="); print_location(st, SIG_REGS(sc)[CON_O6]); ++#ifdef STACKGHOST ++ st->print("O7="); print_location(st, SIG_REGS(sc)[CON_O7]^sg_cookie()); ++#else ++ st->print("O7="); print_location(st, SIG_REGS(sc)[CON_O7]); ++#endif ++ st->cr(); ++ ++ st->print("L0="); print_location(st, sp[L0->sp_offset_in_saved_window()]); ++ st->print("L1="); print_location(st, sp[L1->sp_offset_in_saved_window()]); ++ st->print("L2="); print_location(st, sp[L2->sp_offset_in_saved_window()]); ++ st->print("L3="); print_location(st, sp[L3->sp_offset_in_saved_window()]); ++ st->print("L4="); print_location(st, sp[L4->sp_offset_in_saved_window()]); ++ st->print("L5="); print_location(st, sp[L5->sp_offset_in_saved_window()]); ++ st->print("L6="); print_location(st, sp[L6->sp_offset_in_saved_window()]); ++ st->print("L7="); print_location(st, sp[L7->sp_offset_in_saved_window()]); ++ st->cr(); ++ ++ st->print("I0="); print_location(st, sp[I0->sp_offset_in_saved_window()]); ++ st->print("I1="); print_location(st, sp[I1->sp_offset_in_saved_window()]); ++ st->print("I2="); print_location(st, sp[I2->sp_offset_in_saved_window()]); ++ st->print("I3="); print_location(st, sp[I3->sp_offset_in_saved_window()]); ++ st->print("I4="); print_location(st, sp[I4->sp_offset_in_saved_window()]); ++ st->print("I5="); print_location(st, sp[I5->sp_offset_in_saved_window()]); ++ st->print("I6="); print_location(st, sp[I6->sp_offset_in_saved_window()]); ++ st->print("I7="); print_location(st, sp[I7->sp_offset_in_saved_window()]); ++ st->cr(); ++} ++ ++ ++address os::Bsd::ucontext_get_pc(ucontext_t* uc) { ++ return (address) SIG_PC((sigcontext*)uc); ++} ++ ++intptr_t* os::Bsd::ucontext_get_sp(ucontext_t *uc) { ++ return (intptr_t*)(uc->sc_sp + STACK_BIAS); ++} ++ ++// not used on Sparc ++intptr_t* os::Bsd::ucontext_get_fp(ucontext_t *uc) { ++ ShouldNotReachHere(); ++ return NULL; ++} ++ ++// Utility functions ++ ++inline static bool checkPrefetch(sigcontext* uc, address pc) { ++ if (StubRoutines::is_safefetch_fault(pc)) { ++ set_cont_address(uc, address(StubRoutines::continuation_for_safefetch_fault(pc))); ++ return true; ++ } ++ return false; ++} ++ ++inline static bool checkOverflow(sigcontext* uc, ++ address pc, ++ address addr, ++ JavaThread* thread, ++ address* stub) { ++ // check if fault address is within thread stack ++ if (addr < thread->stack_base() && ++ addr >= thread->stack_base() - thread->stack_size()) { ++ // stack overflow ++ if (thread->in_stack_yellow_zone(addr)) { ++ thread->disable_stack_yellow_zone(); ++ if (thread->thread_state() == _thread_in_Java) { ++ // Throw a stack overflow exception. Guard pages will be reenabled ++ // while unwinding the stack. ++ *stub = ++ SharedRuntime::continuation_for_implicit_exception(thread, ++ pc, ++ SharedRuntime::STACK_OVERFLOW); ++ } else { ++ // Thread was in the vm or native code. Return and try to finish. ++ return true; ++ } ++ } else if (thread->in_stack_red_zone(addr)) { ++ // Fatal red zone violation. Disable the guard pages and fall through ++ // to handle_unexpected_exception way down below. ++ thread->disable_stack_red_zone(); ++ tty->print_raw_cr("An irrecoverable stack overflow has occurred."); ++ ++ // This is a likely cause, but hard to verify. Let's just print ++ // it as a hint. ++ tty->print_raw_cr("Please check if any of your loaded .so files has " ++ "enabled executable stack (see man page execstack(8))"); ++ } ++ } ++ return false; ++} ++ ++inline static bool checkPollingPage(address pc, address fault, address* stub) { ++ if (fault == os::get_polling_page()) { ++ *stub = SharedRuntime::get_poll_stub(pc); ++ return true; ++ } ++ return false; ++} ++ ++inline static bool checkByteBuffer(address pc, address* stub) { ++ // BugId 4454115: A read from a MappedByteBuffer can fault ++ // here if the underlying file has been truncated. ++ // Do not crash the VM in such a case. ++ CodeBlob* cb = CodeCache::find_blob_unsafe(pc); ++ nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL; ++ if (nm != NULL && nm->has_unsafe_access()) { ++ *stub = StubRoutines::handler_for_unsafe_access(); ++ return true; ++ } ++ return false; ++} ++ ++inline static bool checkVerifyOops(address pc, address fault, address* stub) { ++ if (pc >= MacroAssembler::_verify_oop_implicit_branch[0] ++ && pc < MacroAssembler::_verify_oop_implicit_branch[1] ) { ++ *stub = MacroAssembler::_verify_oop_implicit_branch[2]; ++ warning("fixed up memory fault in +VerifyOops at address " ++ INTPTR_FORMAT, fault); ++ return true; ++ } ++ return false; ++} ++ ++inline static bool checkFPFault(address pc, int code, ++ JavaThread* thread, address* stub) { ++ if (code == FPE_INTDIV || code == FPE_FLTDIV) { ++ *stub = ++ SharedRuntime:: ++ continuation_for_implicit_exception(thread, ++ pc, ++ SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO); ++ return true; ++ } ++ return false; ++} ++ ++inline static bool checkNullPointer(address pc, intptr_t fault, ++ JavaThread* thread, address* stub) { ++ if (!MacroAssembler::needs_explicit_null_check(fault)) { ++ // Determination of interpreter/vtable stub/compiled code null ++ // exception ++ *stub = ++ SharedRuntime:: ++ continuation_for_implicit_exception(thread, pc, ++ SharedRuntime::IMPLICIT_NULL); ++ return true; ++ } ++ return false; ++} ++ ++inline static bool checkFastJNIAccess(address pc, address* stub) { ++ address addr = JNI_FastGetField::find_slowcase_pc(pc); ++ if (addr != (address)-1) { ++ *stub = addr; ++ return true; ++ } ++ return false; ++} ++ ++inline static bool checkSerializePage(JavaThread* thread, address addr) { ++ return os::is_memory_serialize_page(thread, addr); ++} ++ ++inline static bool checkZombie(sigcontext* uc, address* pc, address* stub) { ++ if (nativeInstruction_at(*pc)->is_zombie()) { ++ // zombie method (ld [%g0],%o7 instruction) ++ *stub = SharedRuntime::get_handle_wrong_method_stub(); ++ ++ // At the stub it needs to look like a call from the caller of this ++ // method (not a call from the segv site). ++#ifdef STACKGHOST ++ *pc = (address)(SIG_REGS(uc)[CON_O7]^sg_cookie()); ++#else ++ *pc = (address)SIG_REGS(uc)[CON_O7]; ++#endif ++ return true; ++ } ++ return false; ++} ++ ++inline static bool checkICMiss(sigcontext* uc, address* pc, address* stub) { ++#ifdef COMPILER2 ++ if (nativeInstruction_at(*pc)->is_ic_miss_trap()) { ++#ifdef ASSERT ++#ifdef TIERED ++ CodeBlob* cb = CodeCache::find_blob_unsafe(*pc); ++ assert(cb->is_compiled_by_c2(), "Wrong compiler"); ++#endif // TIERED ++#endif // ASSERT ++ // Inline cache missed and user trap "Tne G0+ST_RESERVED_FOR_USER_0+2" taken. ++ *stub = SharedRuntime::get_ic_miss_stub(); ++ // At the stub it needs to look like a call from the caller of this ++ // method (not a call from the segv site). ++#ifdef STACKGHOST ++ *pc = (address)(SIG_REGS(uc)[CON_O7]^sg_cookie()); ++#else ++ *pc = (address)SIG_REGS(uc)[CON_O7]; ++#endif ++ return true; ++ return true; ++ } ++#endif // COMPILER2 ++ return false; ++} ++ ++extern "C" JNIEXPORT int ++JVM_handle_bsd_signal(int sig, ++ siginfo_t* info, ++ void* ucVoid, ++ int abort_if_unrecognized) { ++ // in fact this isn't ucontext_t* at all, but struct sigcontext* ++ // but Bsd porting layer uses ucontext_t, so to minimize code change ++ // we cast as needed ++ ucontext_t* ucFake = (ucontext_t*) ucVoid; ++ sigcontext* uc = (sigcontext*)ucVoid; ++ ++ Thread* t = ThreadLocalStorage::get_thread_slow(); ++ ++ // Must do this before SignalHandlerMark, if crash protection installed we will longjmp away ++ // (no destructors can be run) ++ os::ThreadCrashProtection::check_crash_protection(sig, t); ++ ++ SignalHandlerMark shm(t); ++ ++ // Note: it's not uncommon that JNI code uses signal/sigset to install ++ // then restore certain signal handler (e.g. to temporarily block SIGPIPE, ++ // or have a SIGILL handler when detecting CPU type). When that happens, ++ // JVM_handle_bsd_signal() might be invoked with junk info/ucVoid. To ++ // avoid unnecessary crash when libjsig is not preloaded, try handle signals ++ // that do not require siginfo/ucontext first. ++ ++ if (sig == SIGPIPE || sig == SIGXFSZ) { ++ // allow chained handler to go first ++ if (os::Bsd::chained_handler(sig, info, ucVoid)) { ++ return true; ++ } else { ++ if (PrintMiscellaneous && (WizardMode || Verbose)) { ++ char buf[64]; ++ warning("Ignoring %s - see bugs 4229104 or 646499219", ++ os::exception_name(sig, buf, sizeof(buf))); ++ } ++ return true; ++ } ++ } ++ ++ JavaThread* thread = NULL; ++ VMThread* vmthread = NULL; ++ if (os::Bsd::signal_handlers_are_installed) { ++ if (t != NULL ){ ++ if(t->is_Java_thread()) { ++ thread = (JavaThread*)t; ++ } ++ else if(t->is_VM_thread()){ ++ vmthread = (VMThread *)t; ++ } ++ } ++ } ++ ++ // decide if this trap can be handled by a stub ++ address stub = NULL; ++ address pc = NULL; ++ address npc = NULL; ++ ++ //%note os_trap_1 ++ if (info != NULL && uc != NULL && thread != NULL) { ++ pc = address(SIG_PC(uc)); ++ npc = address(SIG_NPC(uc)); ++ ++ // Check to see if we caught the safepoint code in the ++ // process of write protecting the memory serialization page. ++ // It write enables the page immediately after protecting it ++ // so we can just return to retry the write. ++ if ((sig == SIGSEGV) && checkSerializePage(thread, (address)info->si_addr)) { ++ // Block current thread until the memory serialize page permission restored. ++ os::block_on_serialize_page_trap(); ++ return 1; ++ } ++ ++ if (checkPrefetch(uc, pc)) { ++ return 1; ++ } ++ ++ // Handle ALL stack overflow variations here ++ if (sig == SIGSEGV) { ++ if (checkOverflow(uc, pc, (address)info->si_addr, thread, &stub)) { ++ return 1; ++ } ++ } ++ ++ if (sig == SIGBUS && ++ thread->thread_state() == _thread_in_vm && ++ thread->doing_unsafe_access()) { ++ stub = StubRoutines::handler_for_unsafe_access(); ++ } ++ ++ if (thread->thread_state() == _thread_in_Java) { ++ do { ++ // Java thread running in Java code => find exception handler if any ++ // a fault inside compiled code, the interpreter, or a stub ++ ++ if ((sig == SIGSEGV) && checkPollingPage(pc, (address)info->si_addr, &stub)) { ++ break; ++ } ++ ++ if ((sig == SIGBUS) && checkByteBuffer(pc, &stub)) { ++ break; ++ } ++ ++ if ((sig == SIGSEGV || sig == SIGBUS) && ++ checkVerifyOops(pc, (address)info->si_addr, &stub)) { ++ break; ++ } ++ ++ if ((sig == SIGSEGV) && checkZombie(uc, &pc, &stub)) { ++ break; ++ } ++ ++ if ((sig == SIGILL) && checkICMiss(uc, &pc, &stub)) { ++ break; ++ } ++ ++ if ((sig == SIGFPE) && checkFPFault(pc, info->si_code, thread, &stub)) { ++ break; ++ } ++ ++ if ((sig == SIGSEGV) && ++ checkNullPointer(pc, (intptr_t)info->si_addr, thread, &stub)) { ++ break; ++ } ++ } while (0); ++ ++ // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in ++ // and the heap gets shrunk before the field access. ++ if ((sig == SIGSEGV) || (sig == SIGBUS)) { ++ checkFastJNIAccess(pc, &stub); ++ } ++ } ++ ++ if (stub != NULL) { ++ // save all thread context in case we need to restore it ++ thread->set_saved_exception_pc(pc); ++ thread->set_saved_exception_npc(npc); ++ set_cont_address(uc, stub); ++ return true; ++ } ++ } ++ ++ // signal-chaining ++ if (os::Bsd::chained_handler(sig, info, ucVoid)) { ++ return true; ++ } ++ ++ if (!abort_if_unrecognized) { ++ // caller wants another chance, so give it to him ++ return false; ++ } ++ ++ if (pc == NULL && uc != NULL) { ++ pc = os::Bsd::ucontext_get_pc((ucontext_t*)uc); ++ } ++ ++ // unmask current signal ++ sigset_t newset; ++ sigemptyset(&newset); ++ sigaddset(&newset, sig); ++ sigprocmask(SIG_UNBLOCK, &newset, NULL); ++ ++ VMError err(t, sig, pc, info, ucVoid); ++ err.report_and_die(); ++ ++ ShouldNotReachHere(); ++} ++ ++void os::Bsd::init_thread_fpu_state(void) { ++ // Nothing to do ++} ++ ++bool os::is_allocatable(size_t bytes) { ++#ifdef _LP64 ++ return true; ++#else ++ if (bytes < 2 * G) { ++ return true; ++ } ++ ++ char* addr = reserve_memory(bytes, NULL); ++ ++ if (addr != NULL) { ++ release_memory(addr, bytes); ++ } ++ ++ return addr != NULL; ++#endif // _LP64 ++} ++ ++/////////////////////////////////////////////////////////////////////////////// ++// thread stack ++ ++size_t os::Bsd::min_stack_allowed = 128 * K; ++ ++// pthread on Ubuntu is always in floating stack mode ++bool os::Bsd::supports_variable_stack_size() { return false; } ++ ++// return default stack size for thr_type ++size_t os::Bsd::default_stack_size(os::ThreadType thr_type) { ++ // default stack size (compiler thread needs larger stack) ++ size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); ++ return s; ++} ++ ++size_t os::Bsd::default_guard_size(os::ThreadType thr_type) { ++ // Creating guard page is very expensive. Java thread has HotSpot ++ // guard page, only enable glibc guard page for non-Java threads. ++ return (thr_type == java_thread ? 0 : page_size()); ++} ++ ++#ifndef PRODUCT ++void os::verify_stack_alignment() { ++} ++#endif Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_os_bsd_sparc_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_os_bsd_sparc_hpp diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_os_bsd_sparc_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_os_bsd_sparc_hpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,57 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/os_bsd_sparc.hpp +--- hotspot/src/os_cpu/bsd_sparc/vm/os_bsd_sparc.hpp.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/os_bsd_sparc.hpp +@@ -0,0 +1,49 @@ ++/* ++ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++#ifndef OS_CPU_BSD_SPARC_VM_OS_BSD_SPARC_HPP ++#define OS_CPU_BSD_SPARC_VM_OS_BSD_SPARC_HPP ++ ++ // ++ // NOTE: we are back in class os here, not Bsd ++ // ++ static jint (*atomic_xchg_func) (jint, volatile jint*); ++ static jint (*atomic_cmpxchg_func) (jint, volatile jint*, jint); ++ static jlong (*atomic_cmpxchg_long_func)(jlong, volatile jlong*, jlong); ++ static jint (*atomic_add_func) (jint, volatile jint*); ++ ++ static jint atomic_xchg_bootstrap (jint, volatile jint*); ++ static jint atomic_cmpxchg_bootstrap (jint, volatile jint*, jint); ++ static jlong atomic_cmpxchg_long_bootstrap(jlong, volatile jlong*, jlong); ++ static jint atomic_add_bootstrap (jint, volatile jint*); ++ ++ static void setup_fpu() {} ++ ++ static bool is_allocatable(size_t bytes); ++ ++ // Used to register dynamic code cache area with the OS ++ // Note: Currently only used in 64 bit Windows implementations ++ static bool register_code_area(char *low, char *high) { return true; } ++ ++#endif // OS_CPU_BSD_SPARC_VM_OS_BSD_SPARC_HPP Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_prefetch_bsd_sparc_inline_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_prefetch_bsd_sparc_inline_hpp diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_prefetch_bsd_sparc_inline_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_prefetch_bsd_sparc_inline_hpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,55 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/prefetch_bsd_sparc.inline.hpp +--- hotspot/src/os_cpu/bsd_sparc/vm/prefetch_bsd_sparc.inline.hpp.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/prefetch_bsd_sparc.inline.hpp +@@ -0,0 +1,47 @@ ++/* ++ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++#ifndef OS_CPU_BSD_SPARC_VM_PREFETCH_BSD_SPARC_INLINE_HPP ++#define OS_CPU_BSD_SPARC_VM_PREFETCH_BSD_SPARC_INLINE_HPP ++ ++#include "runtime/prefetch.hpp" ++ ++#if defined(COMPILER2) || defined(_LP64) ++ ++inline void Prefetch::read(void *loc, intx interval) { ++ __asm__ volatile("prefetch [%0+%1], 0" : : "r" (loc), "r" (interval) : "memory" ); ++} ++ ++inline void Prefetch::write(void *loc, intx interval) { ++ __asm__ volatile("prefetch [%0+%1], 2" : : "r" (loc), "r" (interval) : "memory" ); ++} ++ ++#else ++ ++inline void Prefetch::read (void *loc, intx interval) {} ++inline void Prefetch::write(void *loc, intx interval) {} ++ ++#endif ++ ++#endif // OS_CPU_BSD_SPARC_VM_PREFETCH_BSD_SPARC_INLINE_HPP Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_threadLS_bsd_sparc_cpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_threadLS_bsd_sparc_cpp diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_threadLS_bsd_sparc_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_threadLS_bsd_sparc_cpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,46 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/threadLS_bsd_sparc.cpp +--- hotspot/src/os_cpu/bsd_sparc/vm/threadLS_bsd_sparc.cpp.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/threadLS_bsd_sparc.cpp +@@ -0,0 +1,38 @@ ++/* ++ * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++#include "precompiled.hpp" ++#include "runtime/thread.inline.hpp" ++#include "runtime/threadLocalStorage.hpp" ++ ++void ThreadLocalStorage::generate_code_for_get_thread() { ++} ++ ++void ThreadLocalStorage::pd_init() { ++ // Nothing to do ++} ++ ++void ThreadLocalStorage::pd_set_thread(Thread* thread) { ++ os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread); ++} Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_threadLS_bsd_sparc_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_threadLS_bsd_sparc_hpp diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_threadLS_bsd_sparc_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_threadLS_bsd_sparc_hpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,41 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/threadLS_bsd_sparc.hpp +--- hotspot/src/os_cpu/bsd_sparc/vm/threadLS_bsd_sparc.hpp.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/threadLS_bsd_sparc.hpp +@@ -0,0 +1,33 @@ ++/* ++ * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++#ifndef OS_CPU_BSD_SPARC_VM_THREADLS_BSD_SPARC_HPP ++#define OS_CPU_BSD_SPARC_VM_THREADLS_BSD_SPARC_HPP ++ ++public: ++ static Thread* thread() { ++ return (Thread*) os::thread_local_storage_at(thread_index()); ++ } ++ ++#endif // OS_CPU_BSD_SPARC_VM_THREADLS_BSD_SPARC_HPP Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_cpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_cpp diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_cpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,231 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.cpp +--- hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.cpp.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.cpp +@@ -0,0 +1,223 @@ ++/* ++ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++#include "precompiled.hpp" ++#include "runtime/frame.inline.hpp" ++#include "runtime/thread.inline.hpp" ++ ++// For Forte Analyzer AsyncGetCallTrace profiling support - thread is ++// currently interrupted by SIGPROF ++bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr, ++ void* ucontext, ++ bool isInJava) { ++ assert(Thread::current() == this, "caller must be current thread"); ++ assert(this->is_Java_thread(), "must be JavaThread"); ++ ++ JavaThread* jt = (JavaThread *)this; ++ ++ if (!isInJava) { ++ // make_walkable flushes register windows and grabs last_Java_pc ++ // which can not be done if the ucontext sp matches last_Java_sp ++ // stack walking utilities assume last_Java_pc set if marked flushed ++ jt->frame_anchor()->make_walkable(jt); ++ } ++ ++ // If we have a walkable last_Java_frame, then we should use it ++ // even if isInJava == true. It should be more reliable than ++ // ucontext info. ++ if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) { ++ *fr_addr = jt->pd_last_frame(); ++ return true; ++ } ++ ++ ucontext_t* uc = (ucontext_t*) ucontext; ++ ++ // At this point, we don't have a walkable last_Java_frame, so ++ // we try to glean some information out of the ucontext. ++ intptr_t* ret_sp; ++ ExtendedPC addr = ++ os::fetch_frame_from_context(uc, &ret_sp, ++ NULL /* ret_fp only used on X86 */); ++ if (addr.pc() == NULL || ret_sp == NULL) { ++ // ucontext wasn't useful ++ return false; ++ } ++ ++ // we were running Java code when SIGPROF came in ++ if (isInJava) { ++ // If we have a last_Java_sp, then the SIGPROF signal caught us ++ // right when we were transitioning from _thread_in_Java to a new ++ // JavaThreadState. We use last_Java_sp instead of the sp from ++ // the ucontext since it should be more reliable. ++ if (jt->has_last_Java_frame()) { ++ ret_sp = jt->last_Java_sp(); ++ } ++ // Implied else: we don't have a last_Java_sp so we use what we ++ // got from the ucontext. ++ ++ frame ret_frame(ret_sp, frame::unpatchable, addr.pc()); ++ if (!ret_frame.safe_for_sender(jt)) { ++ // nothing else to try if the frame isn't good ++ return false; ++ } ++ *fr_addr = ret_frame; ++ return true; ++ } ++ ++ // At this point, we know we weren't running Java code. We might ++ // have a last_Java_sp, but we don't have a walkable frame. ++ // However, we might still be able to construct something useful ++ // if the thread was running native code. ++ if (jt->has_last_Java_frame()) { ++ assert(!jt->frame_anchor()->walkable(), "case covered above"); ++ ++ if (jt->thread_state() == _thread_in_native) { ++ frame ret_frame(jt->last_Java_sp(), frame::unpatchable, addr.pc()); ++ if (!ret_frame.safe_for_sender(jt)) { ++ // nothing else to try if the frame isn't good ++ return false; ++ } ++ *fr_addr = ret_frame; ++ return true; ++ } ++ } ++ ++ // nothing else to try ++ return false; ++} ++ ++bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, bool isInJava) { ++ // get ucontext somehow ++ return pd_get_top_frame(fr_addr, ucontext, isInJava, false); ++} ++ ++bool JavaThread::pd_get_top_frame(frame* fr_addr, ++ void* ucontext, bool isInJava, bool makeWalkable) { ++ assert(this->is_Java_thread(), "must be JavaThread"); ++ ++ JavaThread* jt = (JavaThread *)this; ++ ++ if (!isInJava && makeWalkable) { ++ // make_walkable flushes register windows and grabs last_Java_pc ++ // which can not be done if the ucontext sp matches last_Java_sp ++ // stack walking utilities assume last_Java_pc set if marked flushed ++ jt->frame_anchor()->make_walkable(jt); ++ } ++ ++ // If we have a walkable last_Java_frame, then we should use it ++ // even if isInJava == true. It should be more reliable than ++ // ucontext info. ++ if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) { ++ *fr_addr = jt->pd_last_frame(); ++ return true; ++ } ++ ++ ucontext_t* uc = (ucontext_t*) ucontext; ++ ++ // At this point, we don't have a walkable last_Java_frame, so ++ // we try to glean some information out of the ucontext. ++ intptr_t* ret_sp; ++ ExtendedPC addr = os::Bsd::fetch_frame_from_ucontext(this, uc, ++ &ret_sp, NULL /* ret_fp only used on Solaris X86 */); ++ if (addr.pc() == NULL || ret_sp == NULL) { ++ // ucontext wasn't useful ++ return false; ++ } ++ ++ frame ret_frame(ret_sp, frame::unpatchable, addr.pc()); ++ ++ // we were running Java code when SIGPROF came in ++ if (isInJava) { ++ ++ ++ // If the frame we got is safe then it is most certainly valid ++ if (ret_frame.safe_for_sender(jt)) { ++ *fr_addr = ret_frame; ++ return true; ++ } ++ ++ // If it isn't safe then we can try several things to try and get ++ // a good starting point. ++ // ++ // On sparc the frames are almost certainly walkable in the sense ++ // of sp/fp linkages. However because of recycling of windows if ++ // a piece of code does multiple save's where the initial save creates ++ // a real frame with a return pc and the succeeding save's are used to ++ // simply get free registers and have no real pc then the pc linkage on these ++ // "inner" temporary frames will be bogus. ++ // Since there is in general only a nesting level like ++ // this one deep in general we'll try and unwind such an "inner" frame ++ // here ourselves and see if it makes sense ++ ++ frame unwind_frame(ret_frame.fp(), frame::unpatchable, addr.pc()); ++ ++ if (unwind_frame.safe_for_sender(jt)) { ++ *fr_addr = unwind_frame; ++ return true; ++ } ++ ++ // Well that didn't work. Most likely we're toast on this tick ++ // The previous code would try this. I think it is dubious in light ++ // of changes to safe_for_sender and the unwind trick above but ++ // if it gets us a safe frame who wants to argue. ++ ++ // If we have a last_Java_sp, then the SIGPROF signal caught us ++ // right when we were transitioning from _thread_in_Java to a new ++ // JavaThreadState. We use last_Java_sp instead of the sp from ++ // the ucontext since it should be more reliable. ++ ++ if (jt->has_last_Java_frame()) { ++ ret_sp = jt->last_Java_sp(); ++ frame ret_frame2(ret_sp, frame::unpatchable, addr.pc()); ++ if (ret_frame2.safe_for_sender(jt)) { ++ *fr_addr = ret_frame2; ++ return true; ++ } ++ } ++ ++ // This is the best we can do. We will only be able to decode the top frame ++ ++ *fr_addr = ret_frame; ++ return true; ++ } ++ ++ // At this point, we know we weren't running Java code. We might ++ // have a last_Java_sp, but we don't have a walkable frame. ++ // However, we might still be able to construct something useful ++ // if the thread was running native code. ++ if (jt->has_last_Java_frame()) { ++ assert(!jt->frame_anchor()->walkable(), "case covered above"); ++ ++ frame ret_frame(jt->last_Java_sp(), frame::unpatchable, addr.pc()); ++ *fr_addr = ret_frame; ++ return true; ++ } ++ ++ // nothing else to try but what we found initially ++ ++ *fr_addr = ret_frame; ++ return true; ++} ++void JavaThread::cache_global_variables() { } ++ Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_cpp.orig =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_cpp.orig diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_cpp.orig --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_cpp.orig 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,119 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.cpp +--- hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.cpp.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.cpp +@@ -0,0 +1,111 @@ ++/* ++ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++#include "precompiled.hpp" ++#include "runtime/frame.inline.hpp" ++#include "runtime/thread.inline.hpp" ++ ++// For Forte Analyzer AsyncGetCallTrace profiling support - thread is ++// currently interrupted by SIGPROF ++bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr, ++ void* ucontext, ++ bool isInJava) { ++ assert(Thread::current() == this, "caller must be current thread"); ++ assert(this->is_Java_thread(), "must be JavaThread"); ++ ++ JavaThread* jt = (JavaThread *)this; ++ ++ if (!isInJava) { ++ // make_walkable flushes register windows and grabs last_Java_pc ++ // which can not be done if the ucontext sp matches last_Java_sp ++ // stack walking utilities assume last_Java_pc set if marked flushed ++ jt->frame_anchor()->make_walkable(jt); ++ } ++ ++ // If we have a walkable last_Java_frame, then we should use it ++ // even if isInJava == true. It should be more reliable than ++ // ucontext info. ++ if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) { ++ *fr_addr = jt->pd_last_frame(); ++ return true; ++ } ++ ++ ucontext_t* uc = (ucontext_t*) ucontext; ++ ++ // At this point, we don't have a walkable last_Java_frame, so ++ // we try to glean some information out of the ucontext. ++ intptr_t* ret_sp; ++ ExtendedPC addr = ++ os::fetch_frame_from_context(uc, &ret_sp, ++ NULL /* ret_fp only used on X86 */); ++ if (addr.pc() == NULL || ret_sp == NULL) { ++ // ucontext wasn't useful ++ return false; ++ } ++ ++ // we were running Java code when SIGPROF came in ++ if (isInJava) { ++ // If we have a last_Java_sp, then the SIGPROF signal caught us ++ // right when we were transitioning from _thread_in_Java to a new ++ // JavaThreadState. We use last_Java_sp instead of the sp from ++ // the ucontext since it should be more reliable. ++ if (jt->has_last_Java_frame()) { ++ ret_sp = jt->last_Java_sp(); ++ } ++ // Implied else: we don't have a last_Java_sp so we use what we ++ // got from the ucontext. ++ ++ frame ret_frame(ret_sp, frame::unpatchable, addr.pc()); ++ if (!ret_frame.safe_for_sender(jt)) { ++ // nothing else to try if the frame isn't good ++ return false; ++ } ++ *fr_addr = ret_frame; ++ return true; ++ } ++ ++ // At this point, we know we weren't running Java code. We might ++ // have a last_Java_sp, but we don't have a walkable frame. ++ // However, we might still be able to construct something useful ++ // if the thread was running native code. ++ if (jt->has_last_Java_frame()) { ++ assert(!jt->frame_anchor()->walkable(), "case covered above"); ++ ++ if (jt->thread_state() == _thread_in_native) { ++ frame ret_frame(jt->last_Java_sp(), frame::unpatchable, addr.pc()); ++ if (!ret_frame.safe_for_sender(jt)) { ++ // nothing else to try if the frame isn't good ++ return false; ++ } ++ *fr_addr = ret_frame; ++ return true; ++ } ++ } ++ ++ // nothing else to try ++ return false; ++} ++ ++void JavaThread::cache_global_variables() { } ++ Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_hpp diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_hpp 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,116 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.hpp +--- hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.hpp.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.hpp +@@ -0,0 +1,108 @@ ++/* ++ * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++#ifndef OS_CPU_BSD_SPARC_VM_THREAD_BSD_SPARC_HPP ++#define OS_CPU_BSD_SPARC_VM_THREAD_BSD_SPARC_HPP ++ ++private: ++ ++ void pd_initialize() { ++ _anchor.clear(); ++ _base_of_stack_pointer = NULL; ++ } ++ ++ frame pd_last_frame() { ++ assert(has_last_Java_frame(), "must have last_Java_sp() when suspended"); ++ assert(_anchor.walkable(), "thread has not dumped its register windows yet"); ++ ++ assert(_anchor.last_Java_pc() != NULL, "Ack no pc!"); ++ return frame(last_Java_sp(), frame::unpatchable, _anchor.last_Java_pc()); ++ } ++ ++ // Sometimes the trap handler needs to record both PC and NPC. ++ // This is a SPARC-specific companion to Thread::set_saved_exception_pc. ++ address _saved_exception_npc; ++ ++ // In polling_page_safepoint_handler_blob(s) we have to tail call other ++ // blobs without blowing any registers. A tail call requires some ++ // register to jump with and we can't blow any registers, so it must ++ // be restored in the delay slot. 'restore' cannot be used as it ++ // will chop the heads off of 64-bit %o registers in the 32-bit ++ // build. Instead we reload the registers using G2_thread and this ++ // location. Must be 64bits in the 32-bit LION build. ++ jdouble _o_reg_temps[6]; ++ ++ // a stack pointer older than any java frame stack pointer. It is ++ // used to validate stack pointers in frame::next_younger_sp (it ++ // provides the upper bound in the range check). This is necessary ++ // on Solaris/SPARC since the ucontext passed to a signal handler is ++ // sometimes corrupt and we need a way to check the extracted sp. ++ intptr_t* _base_of_stack_pointer; ++ ++public: ++ ++ static int o_reg_temps_offset_in_bytes() { return offset_of(JavaThread, _o_reg_temps); } ++ ++#ifndef _LP64 ++ address o_reg_temps(int i) { return (address)&_o_reg_temps[i]; } ++#endif ++ ++ static int saved_exception_npc_offset_in_bytes() { return offset_of(JavaThread,_saved_exception_npc); } ++ ++ address saved_exception_npc() { return _saved_exception_npc; } ++ void set_saved_exception_npc(address a) { _saved_exception_npc = a; } ++ ++ ++public: ++ ++ intptr_t* base_of_stack_pointer() { return _base_of_stack_pointer; } ++ ++ void set_base_of_stack_pointer(intptr_t* base_sp) { ++ _base_of_stack_pointer = base_sp; ++ } ++ ++ void record_base_of_stack_pointer() { ++ intptr_t *sp = (intptr_t *)(((intptr_t)StubRoutines::Sparc::flush_callers_register_windows_func()())); ++ intptr_t *ysp; ++ while((ysp = (intptr_t*)sp[FP->sp_offset_in_saved_window()]) != NULL) { ++ sp = (intptr_t *)((intptr_t)ysp + STACK_BIAS); ++ } ++ _base_of_stack_pointer = sp; ++ } ++ ++ bool pd_get_top_frame_for_signal_handler(frame* fr_addr, void* ucontext, ++ bool isInJava); ++ ++ bool pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, bool isInJava); ++private: ++ bool pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava, bool makeWalkable); ++public: ++ ++ // These routines are only used on cpu architectures that ++ // have separate register stacks (Itanium). ++ static bool register_stack_overflow() { return false; } ++ static void enable_register_stack_guard() {} ++ static void disable_register_stack_guard() {} ++ ++#endif // OS_CPU_BSD_SPARC_VM_THREAD_BSD_SPARC_HPP Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_hpp.orig =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_hpp.orig diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_hpp.orig --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_thread_bsd_sparc_hpp.orig 6 Jul 2021 20:24:52 -0000 @@ -0,0 +1,111 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.hpp +--- hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.hpp.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.hpp +@@ -0,0 +1,103 @@ ++/* ++ * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++#ifndef OS_CPU_BSD_SPARC_VM_THREAD_BSD_SPARC_HPP ++#define OS_CPU_BSD_SPARC_VM_THREAD_BSD_SPARC_HPP ++ ++private: ++ ++ void pd_initialize() { ++ _anchor.clear(); ++ _base_of_stack_pointer = NULL; ++ } ++ ++ frame pd_last_frame() { ++ assert(has_last_Java_frame(), "must have last_Java_sp() when suspended"); ++ assert(_anchor.walkable(), "thread has not dumped its register windows yet"); ++ ++ assert(_anchor.last_Java_pc() != NULL, "Ack no pc!"); ++ return frame(last_Java_sp(), frame::unpatchable, _anchor.last_Java_pc()); ++ } ++ ++ // Sometimes the trap handler needs to record both PC and NPC. ++ // This is a SPARC-specific companion to Thread::set_saved_exception_pc. ++ address _saved_exception_npc; ++ ++ // In polling_page_safepoint_handler_blob(s) we have to tail call other ++ // blobs without blowing any registers. A tail call requires some ++ // register to jump with and we can't blow any registers, so it must ++ // be restored in the delay slot. 'restore' cannot be used as it ++ // will chop the heads off of 64-bit %o registers in the 32-bit ++ // build. Instead we reload the registers using G2_thread and this ++ // location. Must be 64bits in the 32-bit LION build. ++ jdouble _o_reg_temps[6]; ++ ++ // a stack pointer older than any java frame stack pointer. It is ++ // used to validate stack pointers in frame::next_younger_sp (it ++ // provides the upper bound in the range check). This is necessary ++ // on Solaris/SPARC since the ucontext passed to a signal handler is ++ // sometimes corrupt and we need a way to check the extracted sp. ++ intptr_t* _base_of_stack_pointer; ++ ++public: ++ ++ static int o_reg_temps_offset_in_bytes() { return offset_of(JavaThread, _o_reg_temps); } ++ ++#ifndef _LP64 ++ address o_reg_temps(int i) { return (address)&_o_reg_temps[i]; } ++#endif ++ ++ static int saved_exception_npc_offset_in_bytes() { return offset_of(JavaThread,_saved_exception_npc); } ++ ++ address saved_exception_npc() { return _saved_exception_npc; } ++ void set_saved_exception_npc(address a) { _saved_exception_npc = a; } ++ ++ ++public: ++ ++ intptr_t* base_of_stack_pointer() { return _base_of_stack_pointer; } ++ ++ void set_base_of_stack_pointer(intptr_t* base_sp) { ++ _base_of_stack_pointer = base_sp; ++ } ++ ++ void record_base_of_stack_pointer() { ++ intptr_t *sp = (intptr_t *)(((intptr_t)StubRoutines::Sparc::flush_callers_register_windows_func()())); ++ intptr_t *ysp; ++ while((ysp = (intptr_t*)sp[FP->sp_offset_in_saved_window()]) != NULL) { ++ sp = (intptr_t *)((intptr_t)ysp + STACK_BIAS); ++ } ++ _base_of_stack_pointer = sp; ++ } ++ ++ bool pd_get_top_frame_for_signal_handler(frame* fr_addr, void* ucontext, ++ bool isInJava); ++ ++ // These routines are only used on cpu architectures that ++ // have separate register stacks (Itanium). ++ static bool register_stack_overflow() { return false; } ++ static void enable_register_stack_guard() {} ++ static void disable_register_stack_guard() {} ++ ++#endif // OS_CPU_BSD_SPARC_VM_THREAD_BSD_SPARC_HPP Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_vmStructs_bsd_sparc_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_vmStructs_bsd_sparc_hpp diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_vmStructs_bsd_sparc_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_vmStructs_bsd_sparc_hpp 6 Jul 2021 20:24:53 -0000 @@ -0,0 +1,71 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/vmStructs_bsd_sparc.hpp +--- hotspot/src/os_cpu/bsd_sparc/vm/vmStructs_bsd_sparc.hpp.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/vmStructs_bsd_sparc.hpp +@@ -0,0 +1,63 @@ ++/* ++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++#ifndef OS_CPU_BSD_SPARC_VM_VMSTRUCTS_BSD_SPARC_HPP ++#define OS_CPU_BSD_SPARC_VM_VMSTRUCTS_BSD_SPARC_HPP ++ ++// These are the OS and CPU-specific fields, types and integer ++// constants required by the Serviceability Agent. This file is ++// referenced by vmStructs.cpp. ++ ++#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ ++ \ ++ /******************************/ \ ++ /* Threads (NOTE: incomplete) */ \ ++ /******************************/ \ ++ \ ++ nonstatic_field(JavaThread, _base_of_stack_pointer, intptr_t*) \ ++ nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ ++ nonstatic_field(OSThread, _pthread_id, pthread_t) ++ ++ ++#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ ++ \ ++ /**********************/ \ ++ /* POSIX Thread IDs */ \ ++ /**********************/ \ ++ \ ++ declare_integer_type(OSThread::thread_id_t) \ ++ declare_unsigned_integer_type(pthread_t) ++ ++ ++#define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) \ ++ \ ++ /************************/ \ ++ /* JavaThread constants */ \ ++ /************************/ \ ++ \ ++ declare_constant(JavaFrameAnchor::flushed) ++ ++#define VM_LONG_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) ++ ++#endif // OS_CPU_BSD_SPARC_VM_VMSTRUCTS_BSD_SPARC_HPP Index: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_vm_version_bsd_sparc_cpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_vm_version_bsd_sparc_cpp diff -N 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_vm_version_bsd_sparc_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_os_cpu_bsd_sparc_vm_vm_version_bsd_sparc_cpp 6 Jul 2021 20:24:53 -0000 @@ -0,0 +1,91 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/os_cpu/bsd_sparc/vm/vm_version_bsd_sparc.cpp +--- hotspot/src/os_cpu/bsd_sparc/vm/vm_version_bsd_sparc.cpp.orig ++++ hotspot/src/os_cpu/bsd_sparc/vm/vm_version_bsd_sparc.cpp +@@ -0,0 +1,83 @@ ++/* ++ * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code 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 ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++#include "precompiled.hpp" ++#include "runtime/os.hpp" ++#include "vm_version_sparc.hpp" ++ ++static bool cpuinfo_field_contains(const char* field, const char* value) { ++ char line[1024]; ++ bool rv = false; ++ ++ FILE* fp = fopen("/proc/cpuinfo", "r"); ++ if (fp == NULL) { ++ return rv; ++ } ++ ++ while (fgets(line, sizeof(line), fp) != NULL) { ++ assert(strlen(line) < sizeof(line) - 1, "buffer line[1024] is too small."); ++ if (strncmp(line, field, strlen(field)) == 0) { ++ if (strstr(line, value) != NULL) { ++ rv = true; ++ } ++ break; ++ } ++ } ++ ++ fclose(fp); ++ return rv; ++} ++ ++static bool detect_niagara() { ++ return cpuinfo_field_contains("cpu", "Niagara"); ++} ++ ++static bool detect_M_family() { ++ return cpuinfo_field_contains("cpu", "SPARC-M"); ++} ++ ++static bool detect_blkinit() { ++ return cpuinfo_field_contains("cpucaps", "blkinit"); ++} ++ ++int VM_Version::platform_features(int features) { ++ // Default to generic v9 ++ features = generic_v9_m; ++ ++ if (detect_niagara()) { ++ NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Detected Bsd on Niagara");) ++ features = niagara1_m | T_family_m; ++ } ++ ++ if (detect_M_family()) { ++ NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Detected Bsd on M family");) ++ features = sun4v_m | generic_v9_m | M_family_m | T_family_m; ++ } ++ ++ if (detect_blkinit()) { ++ features |= blk_init_instructions_m; ++ } ++ ++ return features; ++} Index: 1.8/patches/patch-hotspot_src_share_vm_runtime_atomic_inline_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_share_vm_runtime_atomic_inline_hpp diff -N 1.8/patches/patch-hotspot_src_share_vm_runtime_atomic_inline_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_share_vm_runtime_atomic_inline_hpp 6 Jul 2021 20:24:53 -0000 @@ -0,0 +1,17 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/share/vm/runtime/atomic.inline.hpp +--- hotspot/src/share/vm/runtime/atomic.inline.hpp.orig ++++ hotspot/src/share/vm/runtime/atomic.inline.hpp +@@ -72,6 +72,9 @@ + #ifdef TARGET_OS_ARCH_bsd_ppc + # include "atomic_bsd_ppc.inline.hpp" + #endif ++#ifdef TARGET_OS_ARCH_bsd_sparc ++# include "atomic_bsd_sparc.inline.hpp" ++#endif + #ifdef TARGET_OS_ARCH_bsd_x86 + # include "atomic_bsd_x86.inline.hpp" + #endif Index: 1.8/patches/patch-hotspot_src_share_vm_runtime_globals_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_share_vm_runtime_globals_hpp diff -N 1.8/patches/patch-hotspot_src_share_vm_runtime_globals_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_share_vm_runtime_globals_hpp 6 Jul 2021 20:24:53 -0000 @@ -0,0 +1,17 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/share/vm/runtime/globals.hpp +--- hotspot/src/share/vm/runtime/globals.hpp.orig ++++ hotspot/src/share/vm/runtime/globals.hpp +@@ -106,6 +106,9 @@ + #ifdef TARGET_OS_ARCH_bsd_ppc + # include "globals_bsd_ppc.hpp" + #endif ++#ifdef TARGET_OS_ARCH_bsd_sparc ++# include "globals_bsd_sparc.hpp" ++#endif + #ifdef TARGET_OS_ARCH_bsd_x86 + # include "globals_bsd_x86.hpp" + #endif Index: 1.8/patches/patch-hotspot_src_share_vm_runtime_orderAccess_inline_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_share_vm_runtime_orderAccess_inline_hpp diff -N 1.8/patches/patch-hotspot_src_share_vm_runtime_orderAccess_inline_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_share_vm_runtime_orderAccess_inline_hpp 6 Jul 2021 20:24:53 -0000 @@ -0,0 +1,17 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/share/vm/runtime/orderAccess.inline.hpp +--- hotspot/src/share/vm/runtime/orderAccess.inline.hpp.orig ++++ hotspot/src/share/vm/runtime/orderAccess.inline.hpp +@@ -73,6 +73,9 @@ + #ifdef TARGET_OS_ARCH_bsd_ppc + # include "orderAccess_bsd_ppc.inline.hpp" + #endif ++#ifdef TARGET_OS_ARCH_bsd_sparc ++# include "orderAccess_bsd_sparc.inline.hpp" ++#endif + #ifdef TARGET_OS_ARCH_bsd_x86 + # include "orderAccess_bsd_x86.inline.hpp" + #endif Index: 1.8/patches/patch-hotspot_src_share_vm_runtime_os_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_share_vm_runtime_os_hpp diff -N 1.8/patches/patch-hotspot_src_share_vm_runtime_os_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_share_vm_runtime_os_hpp 6 Jul 2021 20:24:53 -0000 @@ -0,0 +1,17 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/share/vm/runtime/os.hpp +--- hotspot/src/share/vm/runtime/os.hpp.orig ++++ hotspot/src/share/vm/runtime/os.hpp +@@ -890,6 +890,9 @@ class os: AllStatic { + #ifdef TARGET_OS_ARCH_bsd_ppc + # include "os_bsd_ppc.hpp" + #endif ++#ifdef TARGET_OS_ARCH_bsd_sparc ++# include "os_bsd_sparc.hpp" ++#endif + #ifdef TARGET_OS_ARCH_bsd_x86 + # include "os_bsd_x86.hpp" + #endif Index: 1.8/patches/patch-hotspot_src_share_vm_runtime_prefetch_inline_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_share_vm_runtime_prefetch_inline_hpp diff -N 1.8/patches/patch-hotspot_src_share_vm_runtime_prefetch_inline_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_share_vm_runtime_prefetch_inline_hpp 6 Jul 2021 20:24:53 -0000 @@ -0,0 +1,17 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/share/vm/runtime/prefetch.inline.hpp +--- hotspot/src/share/vm/runtime/prefetch.inline.hpp.orig ++++ hotspot/src/share/vm/runtime/prefetch.inline.hpp +@@ -72,6 +72,9 @@ + #ifdef TARGET_OS_ARCH_bsd_ppc + # include "prefetch_bsd_ppc.inline.hpp" + #endif ++#ifdef TARGET_OS_ARCH_bsd_sparc ++# include "prefetch_bsd_sparc.inline.hpp" ++#endif + #ifdef TARGET_OS_ARCH_bsd_x86 + # include "prefetch_bsd_x86.inline.hpp" + #endif Index: 1.8/patches/patch-hotspot_src_share_vm_runtime_threadLocalStorage_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_share_vm_runtime_threadLocalStorage_hpp diff -N 1.8/patches/patch-hotspot_src_share_vm_runtime_threadLocalStorage_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_share_vm_runtime_threadLocalStorage_hpp 6 Jul 2021 20:24:53 -0000 @@ -0,0 +1,17 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/share/vm/runtime/threadLocalStorage.hpp +--- hotspot/src/share/vm/runtime/threadLocalStorage.hpp.orig ++++ hotspot/src/share/vm/runtime/threadLocalStorage.hpp +@@ -84,6 +84,9 @@ class ThreadLocalStorage : AllStatic { + #ifdef TARGET_OS_ARCH_bsd_ppc + # include "threadLS_bsd_ppc.hpp" + #endif ++#ifdef TARGET_OS_ARCH_bsd_sparc ++# include "threadLS_bsd_sparc.hpp" ++#endif + #ifdef TARGET_OS_ARCH_bsd_x86 + # include "threadLS_bsd_x86.hpp" + #endif Index: 1.8/patches/patch-hotspot_src_share_vm_runtime_thread_hpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_share_vm_runtime_thread_hpp diff -N 1.8/patches/patch-hotspot_src_share_vm_runtime_thread_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_share_vm_runtime_thread_hpp 6 Jul 2021 20:24:53 -0000 @@ -0,0 +1,17 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/share/vm/runtime/thread.hpp +--- hotspot/src/share/vm/runtime/thread.hpp.orig ++++ hotspot/src/share/vm/runtime/thread.hpp +@@ -1734,6 +1734,9 @@ class JavaThread: public Thread { (public) + #ifdef TARGET_OS_ARCH_bsd_ppc + # include "thread_bsd_ppc.hpp" + #endif ++#ifdef TARGET_OS_ARCH_bsd_sparc ++# include "thread_bsd_sparc.hpp" ++#endif + #ifdef TARGET_OS_ARCH_bsd_x86 + # include "thread_bsd_x86.hpp" + #endif Index: 1.8/patches/patch-hotspot_src_share_vm_runtime_vmStructs_cpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_share_vm_runtime_vmStructs_cpp diff -N 1.8/patches/patch-hotspot_src_share_vm_runtime_vmStructs_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_share_vm_runtime_vmStructs_cpp 6 Jul 2021 20:24:53 -0000 @@ -0,0 +1,17 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/share/vm/runtime/vmStructs.cpp +--- hotspot/src/share/vm/runtime/vmStructs.cpp.orig ++++ hotspot/src/share/vm/runtime/vmStructs.cpp +@@ -158,6 +158,9 @@ + #ifdef TARGET_OS_ARCH_bsd_ppc + # include "vmStructs_bsd_ppc.hpp" + #endif ++#ifdef TARGET_OS_ARCH_bsd_sparc ++# include "vmStructs_bsd_sparc.hpp" ++#endif + #ifdef TARGET_OS_ARCH_bsd_x86 + # include "vmStructs_bsd_x86.hpp" + #endif Index: 1.8/patches/patch-hotspot_src_share_vm_utilities_globalDefinitions_cpp =================================================================== RCS file: 1.8/patches/patch-hotspot_src_share_vm_utilities_globalDefinitions_cpp diff -N 1.8/patches/patch-hotspot_src_share_vm_utilities_globalDefinitions_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 1.8/patches/patch-hotspot_src_share_vm_utilities_globalDefinitions_cpp 6 Jul 2021 20:24:53 -0000 @@ -0,0 +1,20 @@ +$OpenBSD$ + +Add sparc64 support + +Index: hotspot/src/share/vm/utilities/globalDefinitions.cpp +--- hotspot/src/share/vm/utilities/globalDefinitions.cpp.orig ++++ hotspot/src/share/vm/utilities/globalDefinitions.cpp +@@ -390,10 +390,10 @@ void GlobalDefinitions::test_globals() { + assert(strcmp(expected, actual) == 0, "Test failed"); + + void GlobalDefinitions::test_proper_unit() { +- EXPECT_EQ(0u, byte_size_in_proper_unit(0u)); ++ EXPECT_EQ(0ul, byte_size_in_proper_unit(0ul)); + EXPECT_STREQ("B", proper_unit_for_byte_size(0u)); + +- EXPECT_EQ(1u, byte_size_in_proper_unit(1u)); ++ EXPECT_EQ(1ul, byte_size_in_proper_unit(1ul)); + EXPECT_STREQ("B", proper_unit_for_byte_size(1u)); + + EXPECT_EQ(1023u, byte_size_in_proper_unit(K - 1)); Index: 1.8/pkg/PLIST =================================================================== RCS file: /cvs/ports/devel/jdk/1.8/pkg/PLIST,v retrieving revision 1.4 diff -u -p -u -r1.4 PLIST --- 1.8/pkg/PLIST 20 Nov 2020 20:48:15 -0000 1.4 +++ 1.8/pkg/PLIST 6 Jul 2021 20:24:53 -0000 @@ -438,48 +438,6 @@ ${JDKHOME}/jre/bin/ @bin ${JDKHOME}/jre/bin/tnameserv @bin ${JDKHOME}/jre/bin/unpack200 ${JDKHOME}/jre/lib/ -${JDKHOME}/jre/lib/${MACHINE_ARCH}/ -@bin ${JDKHOME}/jre/lib/${MACHINE_ARCH}/jexec -${JDKHOME}/jre/lib/${MACHINE_ARCH}/jli/ -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/jli/libjli.so -@bin ${JDKHOME}/jre/lib/${MACHINE_ARCH}/jspawnhelper -${JDKHOME}/jre/lib/${MACHINE_ARCH}/jvm.cfg -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libattach.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libawt.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libawt_headless.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libawt_xawt.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libdt_socket.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libfontmanager.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libhprof.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libinstrument.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libj2gss.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libj2pcsc.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libj2pkcs11.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libjaas_unix.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libjava.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libjava_crw_demo.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libjawt.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libjdwp.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libjpeg.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libjsdt.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libjsig.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libjsound.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/liblcms.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libmanagement.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libmlib_image.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libnet.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libnio.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libnpt.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libsaproc.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libsplashscreen.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libsunec.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libunpack.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libverify.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libzip.so -${JDKHOME}/jre/lib/${MACHINE_ARCH}/server/ -${JDKHOME}/jre/lib/${MACHINE_ARCH}/server/Xusage.txt -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/server/libjsig.so -@so ${JDKHOME}/jre/lib/${MACHINE_ARCH}/server/libjvm.so ${JDKHOME}/jre/lib/applet/ ${JDKHOME}/jre/lib/calendars.properties ${JDKHOME}/jre/lib/charsets.jar @@ -550,19 +508,61 @@ ${JDKHOME}/jre/lib/security/policy/unlim ${JDKHOME}/jre/lib/security/policy/unlimited/US_export_policy.jar ${JDKHOME}/jre/lib/security/policy/unlimited/local_policy.jar ${JDKHOME}/jre/lib/sound.properties +${JDKHOME}/jre/lib/${LIBARCH}/ +@bin ${JDKHOME}/jre/lib/${LIBARCH}/jexec +${JDKHOME}/jre/lib/${LIBARCH}/jli/ +@so ${JDKHOME}/jre/lib/${LIBARCH}/jli/libjli.so +@bin ${JDKHOME}/jre/lib/${LIBARCH}/jspawnhelper +${JDKHOME}/jre/lib/${LIBARCH}/jvm.cfg +@so ${JDKHOME}/jre/lib/${LIBARCH}/libattach.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libawt.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libawt_headless.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libawt_xawt.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libdt_socket.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libfontmanager.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libhprof.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libinstrument.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libj2gss.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libj2pcsc.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libj2pkcs11.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libjaas_unix.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libjava.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libjava_crw_demo.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libjawt.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libjdwp.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libjpeg.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libjsdt.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libjsig.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libjsound.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/liblcms.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libmanagement.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libmlib_image.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libnet.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libnio.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libnpt.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libsaproc.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libsplashscreen.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libsunec.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libunpack.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libverify.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/libzip.so +${JDKHOME}/jre/lib/${LIBARCH}/server/ +${JDKHOME}/jre/lib/${LIBARCH}/server/Xusage.txt +@so ${JDKHOME}/jre/lib/${LIBARCH}/server/libjsig.so +@so ${JDKHOME}/jre/lib/${LIBARCH}/server/libjvm.so ${JDKHOME}/jre/lib/tzdb.dat ${JDKHOME}/lib/ -${JDKHOME}/lib/${MACHINE_ARCH}/ -@bin ${JDKHOME}/lib/${MACHINE_ARCH}/jexec -${JDKHOME}/lib/${MACHINE_ARCH}/jli/ -@so ${JDKHOME}/lib/${MACHINE_ARCH}/jli/libjli.so -@so ${JDKHOME}/lib/${MACHINE_ARCH}/libjawt.so ${JDKHOME}/lib/ct.sym ${JDKHOME}/lib/dt.jar ${JDKHOME}/lib/ir.idl ${JDKHOME}/lib/jconsole.jar ${JDKHOME}/lib/orb.idl ${JDKHOME}/lib/sa-jdi.jar +${JDKHOME}/lib/${LIBARCH}/ +@bin ${JDKHOME}/lib/${LIBARCH}/jexec +${JDKHOME}/lib/${LIBARCH}/jli/ +@so ${JDKHOME}/lib/${LIBARCH}/jli/libjli.so +@so ${JDKHOME}/lib/${LIBARCH}/libjawt.so ${JDKHOME}/lib/tools.jar @mandir ${JDKHOME}/man/ ${JDKHOME}/man/man1/
