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

CMake enablement for libjvm31 shim library #13365

Merged
merged 2 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 23 additions & 0 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,26 @@ add_custom_ascii_command(OUTPUT "${J9VM_INCLUDE_DIR}/jvmti.h"
WORKING_DIRECTORY "${J9VM_INCLUDE_DIR}"
)

# Generate zOS 31/64-bit interoperability compatible jni.h and copy other dependent headers.
if(J9VM_ZOS_3164_INTEROPERABILITY)
set(J9VM_INCLUDE31_DIR "${CMAKE_CURRENT_BINARY_DIR}/include31")
file(MAKE_DIRECTORY "${J9VM_INCLUDE31_DIR}")
file(INSTALL "${CMAKE_CURRENT_SOURCE_DIR}/include/jni_convert.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/jniport.h"
DESTINATION "${J9VM_INCLUDE31_DIR}")

add_custom_ascii_command(OUTPUT "${J9VM_INCLUDE31_DIR}/jni.h"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/jni.h.m4"
COMMAND m4 -D "J9_ZOS_3164_INTEROPERABILITY=1" -D "JAVA_SPEC_VERSION=${JAVA_SPEC_VERSION}" "${CMAKE_CURRENT_SOURCE_DIR}/include/jni.h.m4" ${ASCII_TO_NATIVE} > "jni.h"
VERBATIM
WORKING_DIRECTORY "${J9VM_INCLUDE31_DIR}"
)

add_custom_target(j9vm31_m4gen
DEPENDS
"${J9VM_INCLUDE31_DIR}/jni.h"
)
endif()

# Note we do this here rather than in the redirector directory to work around
# issues in cmake. If we did it there each target which consumed generated.c would need
# its own rule to create it, which leads race conditions when building in parallel.
Expand Down Expand Up @@ -487,6 +507,9 @@ endif()
if(J9VM_MODULE_J9VM)
add_subdirectory(j9vm)
endif()
if(J9VM_ZOS_3164_INTEROPERABILITY)
add_subdirectory(j9vm31)
endif()
# NOTE this is not conditional in the UMA module.xml
add_subdirectory(jcl)
if(J9VM_MODULE_JEXTRACTNATIVES)
Expand Down
2 changes: 2 additions & 0 deletions runtime/cmake/caches/zos_390-64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ set(J9VM_JIT_TRANSACTION_DIAGNOSTIC_THREAD_BLOCK ON CACHE BOOL "")
set(J9VM_PORT_RUNTIME_INSTRUMENTATION ON CACHE BOOL "")
set(J9VM_THR_ASYNC_NAME_UPDATE OFF CACHE BOOL "")

set(J9VM_ZOS_3164_INTEROPERABILITY ON CACHE BOOL "")

include("${CMAKE_CURRENT_LIST_DIR}/common.cmake")
83 changes: 83 additions & 0 deletions runtime/j9vm31/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
################################################################################
# Copyright (c) 2021, 2021 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
# distribution and is available at https://www.eclipse.org/legal/epl-2.0/
# or the Apache License, Version 2.0 which accompanies this distribution and
# is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# This Source Code may also be made available under the following
# Secondary Licenses when the conditions for such availability set
# forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
# General Public License, version 2 with the GNU Classpath
# Exception [1] and GNU General Public License, version 2 with the
# OpenJDK Assembly Exception [2].
#
# [1] https://www.gnu.org/software/classpath/license.html
# [2] http://openjdk.java.net/legal/assembly-exception.html
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
################################################################################

set(OMR_ENHANCED_WARNINGS OFF)

# libjvm31 is a standalone 31-bit shim library in what is otherwise a 64-bit build.
add_library(jvm31 SHARED
j9cel4ro64.c
j9vm31floatstubs.s
jnicgen.cpp
jnicsup.cpp
jnifield.cpp
jniinv.cpp
jnimisc.cpp
jnireflect.cpp
)

# Note: These include directories need to be declared ahead of the removals of compile flags
# below, otherwise, the directories will not be added.
target_include_directories(jvm31
PRIVATE
# Use the include31 with the generated header artifacts.
${CMAKE_CURRENT_BINARY_DIR}/../include31
# Explicitly include OMR's include directories, instead of linking to INTERFACE, to ensure
# we don't pick up other 64-bit linking dependencies.
${omr_SOURCE_DIR}/include_core
${CMAKE_CURRENT_BINARY_DIR}/../omr
)
add_dependencies(jvm31 j9vm31_m4gen)

include(exports.cmake)

# Need to remove XPLINK and 64-bit compile and link options, as libjvm31 needs to be a 31-bit Standard Linkage library.

# Flags to be removed when compiling.
set(compile_flags_to_remove
"\"-Wc,xplink\""
"-Wc,lp64"
"\"-Wa,SYSPARM(BIT64)\""
"-DJ9ZOS39064"
"-qxplink=noback"
)

foreach(flag IN LISTS compile_flags_to_remove)
omr_remove_flags(CMAKE_C_FLAGS "${flag}")
omr_remove_flags(CMAKE_CXX_FLAGS "${flag}")
omr_remove_flags(CMAKE_ASM_FLAGS "${flag}")
endforeach()

# Flags to be removed when linking.
set(link_flags_to_remove
"-Wl,xplink"
"-Wl,lp64"
)

foreach(flag IN LISTS link_flags_to_remove)
omr_remove_flags(CMAKE_SHARED_LINKER_FLAGS "${flag}")
endforeach()

install(
TARGETS jvm31
LIBRARY DESTINATION ${j9vm_SOURCE_DIR}
RUNTIME DESTINATION ${j9vm_SOURCE_DIR}
)
265 changes: 265 additions & 0 deletions runtime/j9vm31/exports.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
################################################################################
# Copyright (c) 2021, 2021 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
# distribution and is available at https://www.eclipse.org/legal/epl-2.0/
# or the Apache License, Version 2.0 which accompanies this distribution and
# is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# This Source Code may also be made available under the following
# Secondary Licenses when the conditions for such availability set
# forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
# General Public License, version 2 with the GNU Classpath
# Exception [1] and GNU General Public License, version 2 with the
# OpenJDK Assembly Exception [2].
#
# [1] https://www.gnu.org/software/classpath/license.html
# [2] http://openjdk.java.net/legal/assembly-exception.html
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
################################################################################

omr_add_exports(jvm31
JNI_CreateJavaVM
JNI_GetCreatedJavaVMs
JNI_GetDefaultJavaVMInitArgs
DestroyJavaVM
AttachCurrentThread
keithc-ca marked this conversation as resolved.
Show resolved Hide resolved
DetachCurrentThread
GetEnv
AttachCurrentThreadAsDaemon
GetVersion
DefineClass
FindClass
FromReflectedMethod
FromReflectedField
ToReflectedMethod
GetSuperclass
IsAssignableFrom
ToReflectedField
Throw
ThrowNew
ExceptionOccurred
ExceptionDescribe
ExceptionClear
FatalError
PushLocalFrame
PopLocalFrame
NewGlobalRef
DeleteGlobalRef
DeleteLocalRef
IsSameObject
NewLocalRef
EnsureLocalCapacity
AllocObject
NewObject
NewObjectV
NewObjectA
GetObjectClass
IsInstanceOf
GetMethodID
CallObjectMethod
CallObjectMethodV
CallObjectMethodA
CallBooleanMethod
CallBooleanMethodV
CallBooleanMethodA
CallByteMethod
CallByteMethodV
CallByteMethodA
CallCharMethod
CallCharMethodV
CallCharMethodA
CallShortMethod
CallShortMethodV
CallShortMethodA
CallIntMethod
CallIntMethodV
CallIntMethodA
CallLongMethod
CallLongMethodV
CallLongMethodA
CallFloatMethod
CallFloatMethodV
CallFloatMethodA
CallDoubleMethod
CallDoubleMethodV
CallDoubleMethodA
CallVoidMethod
CallVoidMethodV
CallVoidMethodA
CallNonvirtualObjectMethod
CallNonvirtualObjectMethodV
CallNonvirtualObjectMethodA
CallNonvirtualBooleanMethod
CallNonvirtualBooleanMethodV
CallNonvirtualBooleanMethodA
CallNonvirtualByteMethod
CallNonvirtualByteMethodV
CallNonvirtualByteMethodA
CallNonvirtualCharMethod
CallNonvirtualCharMethodV
CallNonvirtualCharMethodA
CallNonvirtualShortMethod
CallNonvirtualShortMethodV
CallNonvirtualShortMethodA
CallNonvirtualIntMethod
CallNonvirtualIntMethodV
CallNonvirtualIntMethodA
CallNonvirtualLongMethod
CallNonvirtualLongMethodV
CallNonvirtualLongMethodA
CallNonvirtualFloatMethod
CallNonvirtualFloatMethodV
CallNonvirtualFloatMethodA
CallNonvirtualDoubleMethod
CallNonvirtualDoubleMethodV
CallNonvirtualDoubleMethodA
CallNonvirtualVoidMethod
CallNonvirtualVoidMethodV
CallNonvirtualVoidMethodA
GetFieldID
GetObjectField
GetBooleanField
GetByteField
GetCharField
GetShortField
GetIntField
GetLongField
GetFloatField
GetDoubleField
SetObjectField
SetBooleanField
SetByteField
SetCharField
SetShortField
SetIntField
SetLongField
SetFloatField
SetDoubleField
GetStaticMethodID
CallStaticObjectMethod
CallStaticObjectMethodV
CallStaticObjectMethodA
CallStaticBooleanMethod
CallStaticBooleanMethodV
CallStaticBooleanMethodA
CallStaticByteMethod
CallStaticByteMethodV
CallStaticByteMethodA
CallStaticCharMethod
CallStaticCharMethodV
CallStaticCharMethodA
CallStaticShortMethod
CallStaticShortMethodV
CallStaticShortMethodA
CallStaticIntMethod
CallStaticIntMethodV
CallStaticIntMethodA
CallStaticLongMethod
CallStaticLongMethodV
CallStaticLongMethodA
CallStaticFloatMethod
CallStaticFloatMethodV
CallStaticFloatMethodA
CallStaticDoubleMethod
CallStaticDoubleMethodV
CallStaticDoubleMethodA
CallStaticVoidMethod
CallStaticVoidMethodV
CallStaticVoidMethodA
GetStaticFieldID
GetStaticObjectField
GetStaticBooleanField
GetStaticByteField
GetStaticCharField
GetStaticShortField
GetStaticIntField
GetStaticLongField
GetStaticFloatField
GetStaticDoubleField
SetStaticObjectField
SetStaticBooleanField
SetStaticByteField
SetStaticCharField
SetStaticShortField
SetStaticIntField
SetStaticLongField
SetStaticFloatField
SetStaticDoubleField
NewString
GetStringLength
GetStringChars
ReleaseStringChars
NewStringUTF
GetStringUTFLength
GetStringUTFChars
ReleaseStringUTFChars
GetArrayLength
NewObjectArray
GetObjectArrayElement
SetObjectArrayElement
NewBooleanArray
NewByteArray
NewCharArray
NewShortArray
NewIntArray
NewLongArray
NewFloatArray
NewDoubleArray
GetBooleanArrayElements
GetByteArrayElements
GetCharArrayElements
GetShortArrayElements
GetIntArrayElements
GetLongArrayElements
GetFloatArrayElements
GetDoubleArrayElements
ReleaseBooleanArrayElements
ReleaseByteArrayElements
ReleaseCharArrayElements
ReleaseShortArrayElements
ReleaseIntArrayElements
ReleaseLongArrayElements
ReleaseFloatArrayElements
ReleaseDoubleArrayElements
GetBooleanArrayRegion
GetByteArrayRegion
GetCharArrayRegion
GetShortArrayRegion
GetIntArrayRegion
GetLongArrayRegion
GetFloatArrayRegion
GetDoubleArrayRegion
SetBooleanArrayRegion
SetByteArrayRegion
SetCharArrayRegion
SetShortArrayRegion
SetIntArrayRegion
SetLongArrayRegion
SetFloatArrayRegion
SetDoubleArrayRegion
RegisterNatives
UnregisterNatives
MonitorEnter
MonitorExit
GetJavaVM
GetStringRegion
GetStringUTFRegion
GetPrimitiveArrayCritical
ReleasePrimitiveArrayCritical
GetStringCritical
ReleaseStringCritical
NewWeakGlobalRef
DeleteWeakGlobalRef
ExceptionCheck
NewDirectByteBuffer
GetDirectBufferAddress
GetDirectBufferCapacity
GetObjectRefType
)

if(NOT JAVA_SPEC_VERSION LESS 11)
omr_add_exports(jvm31 GetModule)
endif()
Loading