Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8304265: Implementation of Foreign Function and Memory API (Third Preview) #13079

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
71bd224
Generate delta
minborg Mar 17, 2023
bc1a2ee
Remove Panama-specific content
minborg Mar 17, 2023
8929b54
Remove extra line
minborg Mar 17, 2023
bb2f443
Update after first round of comments
minborg Mar 20, 2023
d68a9d2
Update src/java.base/share/classes/java/lang/foreign/AddressLayout.java
minborg Mar 21, 2023
7a78948
Update src/java.base/share/classes/java/lang/foreign/SymbolLookup.java
minborg Mar 21, 2023
a71518c
Remove MemoryInspection classes
minborg Mar 21, 2023
4626a54
Improve Linker javadocs
minborg Mar 21, 2023
21ef060
Add example for Option::captureStateLayout
minborg Mar 21, 2023
f203800
Fix typo -> shared arena
minborg Mar 22, 2023
192050d
Fix formating and modifier order
minborg Mar 22, 2023
45febe9
Disalow padding layouts of size zero
minborg Mar 22, 2023
6df28a7
Improve javadocs for Linker::captureStateLayout
minborg Mar 22, 2023
4ea68de
Apply RISCV port patch
minborg Mar 28, 2023
c972658
Add snippet to Linker.Option.captureStateLayout()
minborg Mar 28, 2023
fc5b5de
Make checking method handle zero case
minborg Mar 28, 2023
37aaf3b
Fix typos in Arena
minborg Mar 28, 2023
7bac48d
Update Linker.downcallHandle() javadoc
minborg Mar 28, 2023
c4e7714
Use @return
minborg Mar 28, 2023
cba8260
Add bug number
minborg Mar 28, 2023
3dab13d
Make fallbacklinker.c consistent with downcallLinker.cpp
minborg Mar 28, 2023
bc29c6f
Merge with master
minborg Mar 28, 2023
e7471d0
Update copyright years
minborg Mar 28, 2023
24bea62
Fix copyrigth year issues
minborg Mar 28, 2023
0f3895f
fix ULE when intializing LibFallback
JornVernee Mar 28, 2023
54e49e0
Remove unused method and declare class final
minborg Mar 29, 2023
846eaf3
Merge pull request #1 from JornVernee/Fix_ULE
minborg Mar 29, 2023
c787a28
Cleanup finality
minborg Mar 29, 2023
a0d84f5
Update src/java.base/share/classes/java/lang/foreign/MemorySegment.java
minborg Mar 30, 2023
928ad35
Update src/java.base/share/classes/java/lang/foreign/MemorySegment.java
minborg Mar 30, 2023
3a4d9f6
Update JEP number and name
minborg Apr 5, 2023
183d351
Improve code snipet
minborg Apr 5, 2023
0ee65ac
Merge master
minborg Apr 5, 2023
adab1b8
8305087: MemoryLayout API checks should be more eager
minborg Apr 6, 2023
c199944
8305369: Issues in zero-length memory segment javadoc section
minborg Apr 6, 2023
d3ea0a3
account for missing mincore on WSL in TestByteBuffer
JornVernee Apr 11, 2023
5de9087
Merge branch 'master' into PR_21_V2
minborg Apr 12, 2023
6164abe
Merge pull request #2 from JornVernee/WSL_BB
minborg Apr 12, 2023
6e99eab
rename has_port
JornVernee Apr 12, 2023
91f43d1
Merge pull request #3 from JornVernee/IsForeignLinkerSupported
minborg Apr 13, 2023
213cc16
Update test/jdk/java/foreign/TestByteBuffer.java
minborg Apr 19, 2023
ba04f5c
Merge branch 'master' into PR_21_V2
minborg Apr 19, 2023
fbd3520
8306668: Some foreign tests fail on x86
minborg Apr 26, 2023
b18d44c
Update src/java.base/share/classes/java/lang/foreign/Linker.java
minborg Apr 26, 2023
cdbfc0e
Update test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadStor…
minborg Apr 26, 2023
228d4c6
Update test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadStor…
minborg Apr 26, 2023
8393218
Use pattern maching in for-loop
minborg Apr 26, 2023
0365fcf
Merge branch 'master' into PR_21_V2
minborg Apr 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions make/autoconf/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ JDKOPT_SETUP_UNDEFINED_BEHAVIOR_SANITIZER
# LeakSanitizer
JDKOPT_SETUP_LEAK_SANITIZER

# Fallback linker
# This needs to go before 'LIB_DETERMINE_DEPENDENCIES'
JDKOPT_SETUP_FALLBACK_LINKER

###############################################################################
#
# Check dependencies for external and internal libraries.
Expand Down
19 changes: 19 additions & 0 deletions make/autoconf/jdk-options.m4
Original file line number Diff line number Diff line change
Expand Up @@ -903,3 +903,22 @@ AC_DEFUN([JDKOPT_SETUP_MACOSX_SIGNING],
AC_SUBST(MACOSX_CODESIGN_MODE)
fi
])

################################################################################
#
# fallback linker
#
AC_DEFUN_ONCE([JDKOPT_SETUP_FALLBACK_LINKER],
[
FALLBACK_LINKER_DEFAULT=false

if HOTSPOT_CHECK_JVM_VARIANT(zero); then
FALLBACK_LINKER_DEFAULT=true
fi

UTIL_ARG_ENABLE(NAME: fallback-linker, DEFAULT: $FALLBACK_LINKER_DEFAULT,
RESULT: ENABLE_FALLBACK_LINKER,
DESC: [enable libffi-based fallback implementation of java.lang.foreign.Linker],
CHECKING_MSG: [if fallback linker enabled])
AC_SUBST(ENABLE_FALLBACK_LINKER)
])
2 changes: 1 addition & 1 deletion make/autoconf/libraries.m4
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ AC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES],
fi

# Check if ffi is needed
if HOTSPOT_CHECK_JVM_VARIANT(zero); then
if HOTSPOT_CHECK_JVM_VARIANT(zero) || test "x$ENABLE_FALLBACK_LINKER" = "xtrue"; then
NEEDS_LIB_FFI=true
else
NEEDS_LIB_FFI=false
Expand Down
3 changes: 3 additions & 0 deletions make/autoconf/spec.gmk.in
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ TEST_JOBS?=@TEST_JOBS@
DEFAULT_MAKE_TARGET:=@DEFAULT_MAKE_TARGET@
DEFAULT_LOG:=@DEFAULT_LOG@

# Fallback linker
ENABLE_FALLBACK_LINKER:=@ENABLE_FALLBACK_LINKER@

FREETYPE_TO_USE:=@FREETYPE_TO_USE@
FREETYPE_LIBS:=@FREETYPE_LIBS@
FREETYPE_CFLAGS:=@FREETYPE_CFLAGS@
Expand Down
46 changes: 44 additions & 2 deletions make/conf/jib-profiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,12 @@ var getJibProfilesProfiles = function (input, common, data) {
"linux-x64-zero": {
target_os: "linux",
target_cpu: "x64",
dependencies: ["devkit", "gtest"],
dependencies: ["devkit", "gtest", "libffi"],
configure_args: concat(common.configure_args_64bit, [
"--with-zlib=system",
"--with-jvm-variants=zero",
"--enable-libffi-bundling"
"--with-libffi=" + input.get("libffi", "home_path"),
"--enable-libffi-bundling",
])
},

Expand Down Expand Up @@ -744,6 +745,40 @@ var getJibProfilesProfiles = function (input, common, data) {
common.debug_profile_artifacts(artifactData[name]));
});

// Define artifact just for linux-x64-zero, which is the only one we test on
["linux-x64"].forEach(function (name) {
var o = artifactData[name]
var pf = o.platform
var jdk_subdir = (o.jdk_subdir != null ? o.jdk_subdir : "jdk-" + data.version);
var jdk_suffix = (o.jdk_suffix != null ? o.jdk_suffix : "tar.gz");
var zeroName = name + "-zero";
profiles[zeroName].artifacts = {
jdk: {
local: "bundles/\\(jdk.*bin." + jdk_suffix + "\\)",
remote: [
"bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-zero." + jdk_suffix,
],
subdir: jdk_subdir,
exploded: "images/jdk",
},
test: {
local: "bundles/\\(jdk.*bin-tests.tar.gz\\)",
remote: [
"bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-zero-tests.tar.gz",
],
exploded: "images/test"
},
jdk_symbols: {
local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)",
remote: [
"bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-zero-symbols.tar.gz",
],
subdir: jdk_subdir,
exploded: "images/jdk"
},
};
});

buildJdkDep = input.build_os + "-" + input.build_cpu + ".jdk";
docsProfiles = {
"docs": {
Expand Down Expand Up @@ -1234,6 +1269,13 @@ var getJibProfilesDependencies = function (input, common) {
ext: "tar.gz",
revision: "1.13.0+1.0"
},

libffi: {
organization: common.organization,
module: "libffi-" + input.build_platform,
ext: "tar.gz",
revision: "3.4.2+1.0"
},
};

return dependencies;
Expand Down
3 changes: 2 additions & 1 deletion make/data/hotspot-symbols/symbols-shared
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2016, 2023, 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
Expand Down Expand Up @@ -30,5 +30,6 @@ jio_vsnprintf
JNI_CreateJavaVM
JNI_GetCreatedJavaVMs
JNI_GetDefaultJavaVMInitArgs
JVM_IsForeignLinkerSupported
JVM_FindClassFromBootLoader
JVM_InitAgentProperties
111 changes: 111 additions & 0 deletions make/devkit/createLibffiBundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/bin/bash
#
# Copyright (c) 2023, 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. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# 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.
#

# This script generates a libffi bundle. On linux by building it from source
# using a devkit, which should match the devkit used to build the JDK.
#
# Set MAKE_ARGS to add parameters to make. Ex:
#
# $ MAKE_ARGS=-j32 bash createLibffiBundle.sh
#
# The script tries to behave well on multiple invocations, only performing steps
# not already done. To redo a step, manually delete the target files from that
# step.
#
# Note that the libtool and texinfo packages are needed to build libffi
# $ sudo apt install libtool texinfo

LIBFFI_VERSION=3.4.2

BUNDLE_NAME=libffi-$LIBFFI_VERSION.tar.gz

SCRIPT_FILE="$(basename $0)"
SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
OUTPUT_DIR="${SCRIPT_DIR}/../../build/libffi"
SRC_DIR="$OUTPUT_DIR/src"
DOWNLOAD_DIR="$OUTPUT_DIR/download"
INSTALL_DIR="$OUTPUT_DIR/install"
IMAGE_DIR="$OUTPUT_DIR/image"

USAGE="$0 <devkit dir>"

if [ "$1" = "" ]; then
echo $USAGE
exit 1
fi
DEVKIT_DIR="$1"

# Download source distros
mkdir -p $DOWNLOAD_DIR
cd $DOWNLOAD_DIR
SOURCE_TAR=v$LIBFFI_VERSION.tar.gz
if [ ! -f $SOURCE_TAR ]; then
wget https://github.com/libffi/libffi/archive/refs/tags/v$LIBFFI_VERSION.tar.gz
fi

# Unpack src
mkdir -p $SRC_DIR
cd $SRC_DIR
LIBFFI_DIRNAME=libffi-$LIBFFI_VERSION
LIBFFI_DIR=$SRC_DIR/$LIBFFI_DIRNAME
if [ ! -d $LIBFFI_DIRNAME ]; then
echo "Unpacking $SOURCE_TAR"
tar xf $DOWNLOAD_DIR/$SOURCE_TAR
fi

# Build
cd $LIBFFI_DIR
if [ ! -e $LIBFFI_DIR/configure ]; then
bash ./autogen.sh
fi
bash ./configure --prefix=$INSTALL_DIR CC=$DEVKIT_DIR/bin/gcc CXX=$DEVKIT_DIR/bin/g++

# Run with nice to keep system usable during build.
nice make $MAKE_ARGS install

mkdir -p $IMAGE_DIR
# Extract what we need into an image
if [ ! -e $IMAGE_DIR/lib/libffi.so ]; then
echo "Copying libffi.so* to image"
mkdir -p $IMAGE_DIR/lib
cp -a $INSTALL_DIR/lib64/libffi.so* $IMAGE_DIR/lib/
fi
if [ ! -e $IMAGE_DIR/include/ ]; then
echo "Copying include to image"
mkdir -p $IMAGE_DIR/include
cp -a $INSTALL_DIR/include/. $IMAGE_DIR/include/
fi
if [ ! -e $IMAGE_DIR/$SCRIPT_FILE ]; then
echo "Copying this script to image"
cp -a $SCRIPT_DIR/$SCRIPT_FILE $IMAGE_DIR/
fi

# Create bundle
if [ ! -e $OUTPUT_DIR/$BUNDLE_NAME ]; then
echo "Creating $OUTPUT_DIR/$BUNDLE_NAME"
cd $IMAGE_DIR
tar zcf $OUTPUT_DIR/$BUNDLE_NAME *
fi
17 changes: 16 additions & 1 deletion make/modules/java.base/Lib.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2023, 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
Expand Down Expand Up @@ -215,3 +215,18 @@ $(eval $(call SetupJdkLibrary, BUILD_SYSLOOKUPLIB, \
))

TARGETS += $(BUILD_SYSLOOKUPLIB)

################################################################################
# Create fallback linker lib

ifeq ($(ENABLE_FALLBACK_LINKER), true)
$(eval $(call SetupJdkLibrary, BUILD_LIBFALLBACKLINKER, \
NAME := fallbackLinker, \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBFFI_CFLAGS), \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS := $(LIBFFI_LIBS), \
))

TARGETS += $(BUILD_LIBFALLBACKLINKER)
endif
Loading