Tuesday, July 06, 2021

devel/jdk/1.8 add sparc64 support

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);
++

No comments:

Post a Comment