Skip to content
Permalink
Browse files
8253795: Implementation of JEP 391: macOS/AArch64 Port
8253816: Support macOS W^X
8253817: Support macOS Aarch64 ABI in Interpreter
8253818: Support macOS Aarch64 ABI for compiled wrappers
8253819: Implement os/cpu for macOS/AArch64
8253839: Update tests and JDK code for macOS/Aarch64
8254941: Implement Serviceability Agent for macOS/AArch64
8255776: Change build system for macOS/AArch64
8262903: [macos_aarch64] Thread::current() called on detached thread

Co-authored-by: Vladimir Kempik <vkempik@openjdk.org>
Co-authored-by: Bernhard Urban-Forster <burban@openjdk.org>
Co-authored-by: Ludovic Henry <luhenry@openjdk.org>
Co-authored-by: Monica Beckwith <mbeckwit@openjdk.org>
Reviewed-by: erikj, ihse, prr, cjplummer, stefank, gziemski, aph, mbeckwit, luhenry
  • Loading branch information
5 people committed Mar 25, 2021
1 parent b006f22 commit dbc9e4b50cdda35f5712deaf440c49f50b9edc96
Showing with 2,933 additions and 109 deletions.
  1. +10 −1 make/autoconf/build-aux/config.guess
  2. +9 −3 make/autoconf/flags.m4
  3. +8 −6 make/autoconf/jvm-features.m4
  4. +2 −2 make/common/NativeCompilation.gmk
  5. +4 −1 make/hotspot/gensrc/GensrcAdlc.gmk
  6. +2 −1 make/modules/java.desktop/lib/Awt2dLibraries.gmk
  7. +1 −1 make/modules/jdk.hotspot.agent/Lib.gmk
  8. +2 −2 src/hotspot/cpu/aarch64/globalDefinitions_aarch64.hpp
  9. +65 −17 src/hotspot/cpu/aarch64/interpreterRT_aarch64.cpp
  10. +5 −2 src/hotspot/cpu/aarch64/interpreterRT_aarch64.hpp
  11. +1 −0 src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp
  12. +27 −2 src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp
  13. +9 −0 src/hotspot/cpu/aarch64/vm_version_aarch64.hpp
  14. +3 −1 src/hotspot/os/bsd/os_bsd.cpp
  15. +9 −12 src/hotspot/os/posix/signals_posix.cpp
  16. +104 −0 src/hotspot/os_cpu/bsd_aarch64/atomic_bsd_aarch64.hpp
  17. +56 −0 src/hotspot/os_cpu/bsd_aarch64/bytes_bsd_aarch64.inline.hpp
  18. +189 −0 src/hotspot/os_cpu/bsd_aarch64/copy_bsd_aarch64.inline.hpp
  19. +240 −0 src/hotspot/os_cpu/bsd_aarch64/copy_bsd_aarch64.s
  20. +45 −0 src/hotspot/os_cpu/bsd_aarch64/globals_bsd_aarch64.hpp
  21. +45 −0 src/hotspot/os_cpu/bsd_aarch64/icache_bsd_aarch64.hpp
  22. +59 −0 src/hotspot/os_cpu/bsd_aarch64/orderAccess_bsd_aarch64.hpp
  23. +614 −0 src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp
  24. +43 −0 src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.hpp
  25. +43 −0 src/hotspot/os_cpu/bsd_aarch64/prefetch_bsd_aarch64.inline.hpp
  26. +99 −0 src/hotspot/os_cpu/bsd_aarch64/thread_bsd_aarch64.cpp
  27. +55 −0 src/hotspot/os_cpu/bsd_aarch64/thread_bsd_aarch64.hpp
  28. +55 −0 src/hotspot/os_cpu/bsd_aarch64/vmStructs_bsd_aarch64.hpp
  29. +107 −0 src/hotspot/os_cpu/bsd_aarch64/vm_version_bsd_aarch64.cpp
  30. +4 −0 src/hotspot/share/c1/c1_Runtime1.cpp
  31. +6 −1 src/hotspot/share/gc/shared/barrierSetNMethod.cpp
  32. +3 −0 src/hotspot/share/interpreter/interpreterRuntime.cpp
  33. +2 −0 src/hotspot/share/interpreter/oopMapCache.cpp
  34. +5 −4 src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
  35. +5 −0 src/hotspot/share/opto/runtime.cpp
  36. +8 −0 src/hotspot/share/prims/jni.cpp
  37. +1 −0 src/hotspot/share/prims/jniCheck.cpp
  38. +2 −0 src/hotspot/share/prims/jvmtiEnter.xsl
  39. +1 −0 src/hotspot/share/prims/jvmtiEnv.cpp
  40. +1 −0 src/hotspot/share/prims/universalNativeInvoker.cpp
  41. +4 −1 src/hotspot/share/prims/universalUpcallHandler.cpp
  42. +3 −0 src/hotspot/share/prims/unsafe.cpp
  43. +3 −2 src/hotspot/share/prims/whitebox.inline.hpp
  44. +4 −0 src/hotspot/share/runtime/deoptimization.cpp
  45. +10 −0 src/hotspot/share/runtime/interfaceSupport.inline.hpp
  46. +5 −1 src/hotspot/share/runtime/javaCalls.cpp
  47. +10 −0 src/hotspot/share/runtime/os.hpp
  48. +11 −0 src/hotspot/share/runtime/safefetch.inline.hpp
  49. +4 −0 src/hotspot/share/runtime/safepoint.cpp
  50. +10 −3 src/hotspot/share/runtime/signature.hpp
  51. +4 −0 src/hotspot/share/runtime/stubRoutines.cpp
  52. +12 −0 src/hotspot/share/runtime/thread.cpp
  53. +10 −0 src/hotspot/share/runtime/thread.hpp
  54. +22 −0 src/hotspot/share/runtime/thread.inline.hpp
  55. +49 −0 src/hotspot/share/runtime/threadWXSetters.inline.hpp
  56. +2 −0 src/hotspot/share/utilities/macros.hpp
  57. +1 −1 src/hotspot/share/utilities/nativeCallStack.cpp
  58. +3 −1 src/java.base/macosx/native/libjli/java_md_macosx.m
  59. +5 −3 src/java.security.jgss/share/native/libj2gss/gssapi.h
  60. +119 −23 src/jdk.hotspot.agent/macosx/native/libsaproc/MacosxDebuggerLocal.m
  61. +55 −1 src/jdk.hotspot.agent/macosx/native/libsaproc/libproc_impl.h
  62. +134 −1 src/jdk.hotspot.agent/macosx/native/libsaproc/ps_core.c
  63. +4 −1 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotAgent.java
  64. +11 −1 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/BsdCDebugger.java
  65. +4 −1 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/BsdThreadContextFactory.java
  66. +87 −0 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/aarch64/BsdAARCH64CFrame.java
  67. +47 −0 ...jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/aarch64/BsdAARCH64ThreadContext.java
  68. +4 −1 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java
  69. +139 −0 ...hotspot.agent/share/classes/sun/jvm/hotspot/runtime/bsd_aarch64/BsdAARCH64JavaThreadPDAccess.java
  70. +10 −3 src/utils/hsdis/Makefile
  71. +11 −2 test/hotspot/gtest/gtestMain.cpp
  72. +6 −4 test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java
  73. +42 −0 test/hotspot/jtreg/runtime/jni/codegenAttachThread/TestCodegenAttach.java
  74. +124 −0 test/hotspot/jtreg/runtime/jni/codegenAttachThread/libcodegenAttach.c
  75. +15 −3 test/hotspot/jtreg/vmTestbase/nsk/share/jdi/ArgumentHandler.java
@@ -1,6 +1,7 @@
#!/bin/sh
#
# Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2021, Azul Systems, Inc. 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
@@ -101,6 +102,14 @@ if [ "x$OUT" = x ]; then
fi
fi

# Test and fix cpu on macos-aarch64, uname -p reports arm, buildsys expects aarch64
echo $OUT | grep arm-apple-darwin > /dev/null 2> /dev/null
if test $? = 0; then
if [ `uname -m` = arm64 ]; then
OUT=aarch64`echo $OUT | sed -e 's/[^-]*//'`
fi
fi

# Test and fix cpu on Macosx when C preprocessor is not on the path
echo $OUT | grep i386-apple-darwin > /dev/null 2> /dev/null
if test $? = 0; then
@@ -125,19 +125,25 @@ AC_DEFUN([FLAGS_SETUP_MACOSX_VERSION],
[
# Additional macosx handling
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
# The expected format for <version> is either nn.n.n or nn.nn.nn. See
# /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/AvailabilityVersions.h
# MACOSX_VERSION_MIN specifies the lowest version of Macosx that the built
# binaries should be compatible with, even if compiled on a newer version
# of the OS. It currently has a hard coded value. Setting this also limits
# exposure to API changes in header files. Bumping this is likely to
# require code changes to build.
MACOSX_VERSION_MIN=10.12.0
if test "x$OPENJDK_TARGET_CPU_ARCH" = xaarch64; then
MACOSX_VERSION_MIN=11.00.00
else
MACOSX_VERSION_MIN=10.12.0
fi
MACOSX_VERSION_MIN_NODOTS=${MACOSX_VERSION_MIN//\./}
AC_SUBST(MACOSX_VERSION_MIN)
# Setting --with-macosx-version-max=<version> makes it an error to build or
# link to macosx APIs that are newer than the given OS version. The expected
# format for <version> is either nn.n.n or nn.nn.nn. See /usr/include/AvailabilityMacros.h.
# link to macosx APIs that are newer than the given OS version.
AC_ARG_WITH([macosx-version-max], [AS_HELP_STRING([--with-macosx-version-max],
[error on use of newer functionality. @<:@macosx@:>@])],
[
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2021, 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
@@ -242,7 +242,7 @@ AC_DEFUN_ONCE([JVM_FEATURES_CHECK_AOT],
elif test "x$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" = "xlinux-aarch64"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no, $OPENJDK_TARGET_CPU])
AC_MSG_RESULT([no, $OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
AVAILABLE=false
fi
@@ -264,11 +264,13 @@ AC_DEFUN_ONCE([JVM_FEATURES_CHECK_CDS],
[
JVM_FEATURES_CHECK_AVAILABILITY(cds, [
AC_MSG_CHECKING([if platform is supported by CDS])
if test "x$OPENJDK_TARGET_OS" != xaix; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no, $OPENJDK_TARGET_OS])
if test "x$OPENJDK_TARGET_OS" = xaix || \
( test "x$OPENJDK_TARGET_OS" = "xmacosx" && \
test "x$OPENJDK_TARGET_CPU" = "xaarch64" ) ; then
AC_MSG_RESULT([no, $OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
AVAILABLE=false
else
AC_MSG_RESULT([yes])
fi
])
])
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2021, 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
@@ -1177,7 +1177,7 @@ define SetupNativeCompilationBody
# This only works if the openjdk_codesign identity is present on the system. Let
# silently fail otherwise.
ifneq ($(CODESIGN), )
$(CODESIGN) -s "$(MACOSX_CODESIGN_IDENTITY)" --timestamp --options runtime \
$(CODESIGN) -f -s "$(MACOSX_CODESIGN_IDENTITY)" --timestamp --options runtime \
--entitlements $$(call GetEntitlementsFile, $$@) $$@
endif
endif
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 2021, 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
@@ -88,6 +88,9 @@ ifeq ($(call check-jvm-feature, compiler2), true)
ADLCFLAGS += -DAIX=1
else ifeq ($(call isTargetOs, macosx), true)
ADLCFLAGS += -D_ALLBSD_SOURCE=1 -D_GNU_SOURCE=1
ifeq ($(HOTSPOT_TARGET_CPU_ARCH), aarch64)
ADLCFLAGS += -DR18_RESERVED
endif
else ifeq ($(call isTargetOs, windows), true)
ifeq ($(call isTargetCpuBits, 64), true)
ADLCFLAGS += -D_WIN64=1
@@ -468,7 +468,8 @@ else
maybe-uninitialized class-memaccess
HARFBUZZ_DISABLED_WARNINGS_clang := unused-value incompatible-pointer-types \
tautological-constant-out-of-range-compare int-to-pointer-cast \
undef missing-field-initializers range-loop-analysis
undef missing-field-initializers range-loop-analysis \
deprecated-declarations c++11-narrowing
HARFBUZZ_DISABLED_WARNINGS_microsoft := 4267 4244 4090 4146 4334 4819 4101 4068 4805 4138

LIBFONTMANAGER_CFLAGS += $(HARFBUZZ_CFLAGS)
@@ -31,7 +31,7 @@ ifeq ($(call isTargetOs, linux), true)
SA_CFLAGS := -D_FILE_OFFSET_BITS=64

else ifeq ($(call isTargetOs, macosx), true)
SA_CFLAGS := -Damd64 -D_GNU_SOURCE -mno-omit-leaf-frame-pointer \
SA_CFLAGS := -D_GNU_SOURCE -mno-omit-leaf-frame-pointer \
-mstack-alignment=16 -fPIC
LIBSA_EXTRA_SRC := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent
else ifeq ($(call isTargetOs, windows), true)
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -58,7 +58,7 @@ const bool CCallingConventionRequiresIntsAsLongs = false;

#define COMPRESSED_CLASS_POINTERS_DEPENDS_ON_COMPRESSED_OOPS false

#if defined(_WIN64)
#if defined(__APPLE__) || defined(_WIN64)
#define R18_RESERVED
#define R18_RESERVED_ONLY(code) code
#define NOT_R18_RESERVED(code)
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
* Copyright (c) 2021, Azul Systems, Inc. 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
@@ -57,9 +58,14 @@ FloatRegister InterpreterRuntime::SignatureHandlerGenerator::next_fpr() {
return fnoreg;
}

int InterpreterRuntime::SignatureHandlerGenerator::next_stack_offset() {
// On macos/aarch64 native stack is packed, int/float are using only 4 bytes
// on stack. Natural alignment for types are still in place,
// for example double/long should be 8 bytes aligned.

int InterpreterRuntime::SignatureHandlerGenerator::next_stack_offset(unsigned elem_size) {
MACOS_ONLY(_stack_offset = align_up(_stack_offset, elem_size));
int ret = _stack_offset;
_stack_offset += wordSize;
_stack_offset += NOT_MACOS(wordSize) MACOS_ONLY(elem_size);
return ret;
}

@@ -71,6 +77,30 @@ InterpreterRuntime::SignatureHandlerGenerator::SignatureHandlerGenerator(
_stack_offset = 0;
}

void InterpreterRuntime::SignatureHandlerGenerator::pass_byte() {
const Address src(from(), Interpreter::local_offset_in_bytes(offset()));

Register reg = next_gpr();
if (reg != noreg) {
__ ldr(reg, src);
} else {
__ ldrb(r0, src);
__ strb(r0, Address(to(), next_stack_offset(sizeof(jbyte))));
}
}

void InterpreterRuntime::SignatureHandlerGenerator::pass_short() {
const Address src(from(), Interpreter::local_offset_in_bytes(offset()));

Register reg = next_gpr();
if (reg != noreg) {
__ ldr(reg, src);
} else {
__ ldrh(r0, src);
__ strh(r0, Address(to(), next_stack_offset(sizeof(jshort))));
}
}

void InterpreterRuntime::SignatureHandlerGenerator::pass_int() {
const Address src(from(), Interpreter::local_offset_in_bytes(offset()));

@@ -79,7 +109,7 @@ void InterpreterRuntime::SignatureHandlerGenerator::pass_int() {
__ ldr(reg, src);
} else {
__ ldrw(r0, src);
__ strw(r0, Address(to(), next_stack_offset()));
__ strw(r0, Address(to(), next_stack_offset(sizeof(jint))));
}
}

@@ -91,7 +121,7 @@ void InterpreterRuntime::SignatureHandlerGenerator::pass_long() {
__ ldr(reg, src);
} else {
__ ldr(r0, src);
__ str(r0, Address(to(), next_stack_offset()));
__ str(r0, Address(to(), next_stack_offset(sizeof(jlong))));
}
}

@@ -103,7 +133,7 @@ void InterpreterRuntime::SignatureHandlerGenerator::pass_float() {
__ ldrs(reg, src);
} else {
__ ldrw(r0, src);
__ strw(r0, Address(to(), next_stack_offset()));
__ strw(r0, Address(to(), next_stack_offset(sizeof(jfloat))));
}
}

@@ -115,7 +145,7 @@ void InterpreterRuntime::SignatureHandlerGenerator::pass_double() {
__ ldrd(reg, src);
} else {
__ ldr(r0, src);
__ str(r0, Address(to(), next_stack_offset()));
__ str(r0, Address(to(), next_stack_offset(sizeof(jdouble))));
}
}

@@ -139,7 +169,8 @@ void InterpreterRuntime::SignatureHandlerGenerator::pass_object() {
__ cbnz(temp(), L);
__ mov(r0, zr);
__ bind(L);
__ str(r0, Address(to(), next_stack_offset()));
static_assert(sizeof(jobject) == wordSize, "");
__ str(r0, Address(to(), next_stack_offset(sizeof(jobject))));
}
}

@@ -164,7 +195,7 @@ class SlowSignatureHandler
: public NativeSignatureIterator {
private:
address _from;
intptr_t* _to;
char* _to;
intptr_t* _int_args;
intptr_t* _fp_args;
intptr_t* _fp_identifiers;
@@ -199,36 +230,53 @@ class SlowSignatureHandler
return -1;
}

void pass_stack(intptr_t value) {
*_to++ = value;
template<typename T>
void pass_stack(T value) {
MACOS_ONLY(_to = align_up(_to, sizeof(value)));
*(T *)_to = value;
_to += NOT_MACOS(wordSize) MACOS_ONLY(sizeof(value));
}

virtual void pass_byte() {
jbyte value = *(jbyte*)single_slot_addr();
if (pass_gpr(value) < 0) {
pass_stack<>(value);
}
}

virtual void pass_short() {
jshort value = *(jshort*)single_slot_addr();
if (pass_gpr(value) < 0) {
pass_stack<>(value);
}
}

virtual void pass_int() {
jint value = *(jint*)single_slot_addr();
if (pass_gpr(value) < 0) {
pass_stack(value);
pass_stack<>(value);
}
}

virtual void pass_long() {
intptr_t value = *double_slot_addr();
if (pass_gpr(value) < 0) {
pass_stack(value);
pass_stack<>(value);
}
}

virtual void pass_object() {
intptr_t* addr = single_slot_addr();
intptr_t value = *addr == 0 ? NULL : (intptr_t)addr;
if (pass_gpr(value) < 0) {
pass_stack(value);
pass_stack<>(value);
}
}

virtual void pass_float() {
jint value = *(jint*)single_slot_addr();
if (pass_fpr(value) < 0) {
pass_stack(value);
pass_stack<>(value);
}
}

@@ -238,7 +286,7 @@ class SlowSignatureHandler
if (0 <= arg) {
*_fp_identifiers |= (1ull << arg); // mark as double
} else {
pass_stack(value);
pass_stack<>(value);
}
}

@@ -247,7 +295,7 @@ class SlowSignatureHandler
: NativeSignatureIterator(method)
{
_from = from;
_to = to;
_to = (char *)to;

_int_args = to - (method->is_static() ? 16 : 17);
_fp_args = to - 8;
@@ -1,6 +1,7 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
* Copyright (c) 2021, Azul Systems, Inc. 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
@@ -38,6 +39,8 @@ class SignatureHandlerGenerator: public NativeSignatureIterator {
unsigned int _num_reg_int_args;
int _stack_offset;

void pass_byte();
void pass_short();
void pass_int();
void pass_long();
void pass_float();
@@ -46,7 +49,7 @@ class SignatureHandlerGenerator: public NativeSignatureIterator {

Register next_gpr();
FloatRegister next_fpr();
int next_stack_offset();
int next_stack_offset(unsigned elem_size);

public:
// Creation
@@ -28,6 +28,7 @@

#include "asm/assembler.inline.hpp"
#include "oops/compressedOops.hpp"
#include "runtime/vm_version.hpp"
#include "utilities/powerOfTwo.hpp"

// MacroAssembler extends Assembler by frequently used macros.
Loading

1 comment on commit dbc9e4b

Please sign in to comment.