Skip to content

Commit

Permalink
Add CMAKE_C_COMPILER_IS_OPENXL macro for related flags
Browse files Browse the repository at this point in the history
Add CMAKE_C_COMPILER_IS_OPENXL macro to add the compiler flags
needed by openXL17

Signed-off-by: Ishita Ray <[email protected]>
  • Loading branch information
ishitaR88 authored and midronij committed Nov 27, 2024
1 parent a3e0530 commit 2c6610f
Show file tree
Hide file tree
Showing 14 changed files with 214 additions and 161 deletions.
9 changes: 7 additions & 2 deletions runtime/cmake/platform/os/aix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@
# Override cmake default of ".a" for shared libs on aix
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")

set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-G,-brtl,-bernotok,-bnoentry,-bnolibpath")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-brtl")
if(CMAKE_C_COMPILER_IS_OPENXL)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-G,-brtl,-bernotok,-bnoentry,-bnolibpath -latomic -lperfstat -liconv")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-brtl -latomic -lperfstat -liconv")
else()
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-G,-brtl,-bernotok,-bnoentry,-bnolibpath")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-brtl")
endif()
5 changes: 3 additions & 2 deletions runtime/cmake/platform/toolcfg/gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ list(APPEND OMR_PLATFORM_CXX_COMPILE_OPTIONS -fno-threadsafe-statics)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")

# Raise an error if a shared library has any unresolved symbols.
# This flag isn't supported on OSX, but it has this behaviour by default
if(NOT OMR_OS_OSX)
# This flag isn't supported on OSX and on AIX while using openxl compiler,
# but it has this behaviour by default.
if(NOT OMR_OS_OSX AND NOT OMR_OS_AIX AND NOT CMAKE_C_COMPILER_IS_OPENXL)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,defs ${CMAKE_SHARED_LINKER_FLAGS}")
endif()

Expand Down
6 changes: 5 additions & 1 deletion runtime/compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,11 @@ elseif(OMR_OS_AIX)
-DSUPPORTS_THREAD_LOCAL
)
if(OMR_ENV_DATA64)
list(APPEND J9_SHAREDFLAGS -q64)
if(CMAKE_C_COMPILER_IS_OPENXL)
list(APPEND J9_SHAREDFLAGS -m64)
else()
list(APPEND J9_SHAREDFLAGS -q64)
endif()
if(OMR_TOOLCONFIG STREQUAL "xlc")
# Modify the arch tuning value we inherit from OMR.
list(REMOVE_ITEM TR_COMPILE_OPTIONS "-qarch=pwr7")
Expand Down
7 changes: 2 additions & 5 deletions runtime/compiler/env/J9KnownObjectTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*******************************************************************************/

#include "compile/Compilation.hpp"
#include "env/alloca_openxl.h"
#include "env/j9fieldsInfo.h"
#include "env/KnownObjectTable.hpp"
#include "env/StackMemoryRegion.hpp"
Expand Down Expand Up @@ -474,11 +475,7 @@ J9::KnownObjectTable::dumpTo(TR::FILE *file, TR::Compilation *comp)
// Collect field info and determine which objects are reachable from other objects
//
TR_BitVector reachable(endIndex, comp->trMemory(), stackAlloc, notGrowable);
#if defined(__open_xl__)
TR_VMFieldsInfo **fieldsInfoByIndex = (TR_VMFieldsInfo**)__builtin_alloca(endIndex * sizeof(TR_VMFieldsInfo*));
#else
TR_VMFieldsInfo **fieldsInfoByIndex = (TR_VMFieldsInfo**)alloca(endIndex * sizeof(TR_VMFieldsInfo*));
#endif
TR_VMFieldsInfo **fieldsInfoByIndex = (TR_VMFieldsInfo**)alloca(endIndex * sizeof(TR_VMFieldsInfo*));
for (i = 1; i < endIndex; i++)
{
uintptr_t object = self()->getPointer(i);
Expand Down
25 changes: 5 additions & 20 deletions runtime/compiler/env/VMJ9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#endif /* defined(J9VM_OPT_JITSERVER) */

#include "env/VMJ9.h"
#include "env/alloca_openxl.h"

#include <algorithm>
#include <ctype.h>
Expand Down Expand Up @@ -4581,11 +4582,7 @@ TR_J9VMBase::lookupArchetype(TR_OpaqueClassBlock *clazz, const char *name, const
// placeholder argument. findClosestArchetype will progressively truncate
// the other arguments until the best match is found.
//
#if defined(__open_xl__)
char *truncatedSignature = (char*)__builtin_alloca(strlen(signature)+2); // + 'I' + null terminator
#else
char *truncatedSignature = (char*)alloca(strlen(signature)+2); // + 'I' + null terminator
#endif
char *truncatedSignature = (char*)alloca(strlen(signature)+2); // + 'I' + null terminator
strcpy(truncatedSignature, signature);
char toInsert = 'I';
char *cur;
Expand All @@ -4608,18 +4605,10 @@ TR_J9VMBase::lookupMethodHandleThunkArchetype(uintptr_t methodHandle)
//
uintptr_t thunkableSignatureString = methodHandle_thunkableSignature((uintptr_t)methodHandle);
intptr_t thunkableSignatureLength = getStringUTF8Length(thunkableSignatureString);
#if defined(__open_xl__)
char *thunkSignature = (char*)__builtin_alloca(thunkableSignatureLength+1);
#else
char *thunkSignature = (char*)alloca(thunkableSignatureLength+1);
#endif
char *thunkSignature = (char*)alloca(thunkableSignatureLength+1);
getStringUTF8(thunkableSignatureString, thunkSignature, thunkableSignatureLength+1);

#if defined(__open_xl__)
char *archetypeSpecimenSignature = (char*)__builtin_alloca(thunkableSignatureLength+20);
#else
char *archetypeSpecimenSignature = (char*)alloca(thunkableSignatureLength+20);
#endif
char *archetypeSpecimenSignature = (char*)alloca(thunkableSignatureLength+20);
strcpy(archetypeSpecimenSignature, thunkSignature);
char *returnType = (1+strchr(archetypeSpecimenSignature, ')'));
size_t maxSize = (thunkableSignatureLength + 20) - (returnType - archetypeSpecimenSignature);
Expand Down Expand Up @@ -9857,11 +9846,7 @@ void JNICALL Java_java_lang_invoke_MutableCallSite_invalidate
return;
}

#if defined(__open_xl__)
jlong *cookies = (jlong*)__builtin_alloca(numSites * sizeof(cookies[0]));
#else
jlong *cookies = (jlong*)alloca(numSites * sizeof(cookies[0]));
#endif
jlong *cookies = (jlong*)alloca(numSites * sizeof(cookies[0]));
env->GetLongArrayRegion(cookieArrayObject, 0, numSites, cookies);
if (!env->ExceptionCheck())
{
Expand Down
25 changes: 25 additions & 0 deletions runtime/compiler/env/alloca_openxl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright IBM Corp. and others 2000
*
* 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] https://openjdk.org/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
*******************************************************************************/

#if defined(__open_xl__)
#define alloca(size) __builtin_alloca(size)
#endif /* defined(__open_xl__) */
37 changes: 7 additions & 30 deletions runtime/compiler/env/j9method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*******************************************************************************/

#include "env/j9method.h"
#include "env/alloca_openxl.h"

#include <stddef.h>
#include "bcnames.h"
Expand Down Expand Up @@ -8114,11 +8115,7 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef)
"type", "Ljava/lang/invoke/MethodType;"),
"methodDescriptor", "Ljava/lang/String;");
methodDescriptorLength = fej9->getStringUTF8Length(methodDescriptorRef);
#if defined(__open_xl__)
methodDescriptor = (char*)__builtin_alloca(methodDescriptorLength+1);
#else
methodDescriptor = (char*)alloca(methodDescriptorLength+1);
#endif
methodDescriptor = (char*)alloca(methodDescriptorLength+1);
fej9->getStringUTF8(methodDescriptorRef, methodDescriptor, methodDescriptorLength+1);
}

Expand Down Expand Up @@ -8319,11 +8316,7 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef)
"type", "Ljava/lang/invoke/MethodType;"),
"methodDescriptor", "Ljava/lang/String;");
methodDescriptorLength = fej9->getStringUTF8Length(methodDescriptorRef);
#if defined(__open_xl__)
methodDescriptor = (char*)__builtin_alloca(methodDescriptorLength+1);
#else
methodDescriptor = (char*)alloca(methodDescriptorLength+1);
#endif
methodDescriptor = (char*)alloca(methodDescriptorLength+1);
fej9->getStringUTF8(methodDescriptorRef, methodDescriptor, methodDescriptorLength+1);
}

Expand Down Expand Up @@ -8432,11 +8425,7 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef)
"type", "Ljava/lang/invoke/MethodType;"),
"methodDescriptor", "Ljava/lang/String;");
methodDescriptorLength = fej9->getStringUTF8Length(methodDescriptorRef);
#if defined(__open_xl__)
nextHandleSignature = (char*)__builtin_alloca(methodDescriptorLength+1);
#else
nextHandleSignature = (char*)alloca(methodDescriptorLength+1);
#endif
nextHandleSignature = (char*)alloca(methodDescriptorLength+1);
fej9->getStringUTF8(methodDescriptorRef, nextHandleSignature, methodDescriptorLength+1);
}

Expand Down Expand Up @@ -8917,11 +8906,7 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef)

// Construct the signature string for the array class
//
#if defined(__open_xl__)
char *arrayClassSignature = (char*)__builtin_alloca(arity + leafClassNameLength + 3); // 3 = 'L' + ';' + null terminator
#else
char *arrayClassSignature = (char*)alloca(arity + leafClassNameLength + 3); // 3 = 'L' + ';' + null terminator
#endif
char *arrayClassSignature = (char*)alloca(arity + leafClassNameLength + 3); // 3 = 'L' + ';' + null terminator
memset(arrayClassSignature, '[', arity);
if (isPrimitiveClass)
{
Expand Down Expand Up @@ -9265,11 +9250,7 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef)

uintptr_t methodDescriptorRef = fej9->getReferenceField(finallyType, "methodDescriptor", "Ljava/lang/String;");
int methodDescriptorLength = fej9->getStringUTF8Length(methodDescriptorRef);
#if defined(__open_xl__)
methodDescriptor = (char*)__builtin_alloca(methodDescriptorLength+1);
#else
methodDescriptor = (char*)alloca(methodDescriptorLength+1);
#endif
methodDescriptor = (char*)alloca(methodDescriptorLength+1);
fej9->getStringUTF8(methodDescriptorRef, methodDescriptor, methodDescriptorLength+1);
}

Expand Down Expand Up @@ -9455,11 +9436,7 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef)
"type", "Ljava/lang/invoke/MethodType;"),
"methodDescriptor", "Ljava/lang/String;");
intptr_t methodDescriptorLength = fej9->getStringUTF8Length(methodDescriptorRef);
#if defined(__open_xl__)
nextSignature = (char*)__builtin_alloca(methodDescriptorLength+1);
#else
nextSignature = (char*)alloca(methodDescriptorLength+1);
#endif
nextSignature = (char*)alloca(methodDescriptorLength+1);
fej9->getStringUTF8(methodDescriptorRef, nextSignature, methodDescriptorLength+1);
}

Expand Down
31 changes: 6 additions & 25 deletions runtime/compiler/runtime/JitRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "control/Options_inlines.hpp"
#include "control/Recompilation.hpp"
#include "control/CompilationStrategy.hpp"
#include "env/alloca_openxl.h"
#include "env/CompilerEnv.hpp"
#include "env/IO.hpp"
#include "env/J2IThunk.hpp"
Expand Down Expand Up @@ -1451,11 +1452,7 @@ static void printMethodHandleArgs(j9object_t methodHandle, void **stack, J9VMThr

uintptr_t sigObject = fej9->methodType_descriptor(fej9->methodHandle_type((uintptr_t)methodHandle));
intptr_t sigLength = fej9->getStringUTF8Length(sigObject);
#if defined(__open_xl__)
char *sig = (char*)__builtin_alloca(sigLength+1);
#else
char *sig = (char*)alloca(sigLength+1);
#endif
char *sig = (char*)alloca(sigLength+1);
fej9->getStringUTF8(sigObject, sig, sigLength+1);

if (vlogTag)
Expand Down Expand Up @@ -1583,11 +1580,7 @@ uint8_t *compileMethodHandleThunk(j9object_t methodHandle, j9object_t arg, J9VMT
uintptr_t methodType = fej9->methodHandle_type((uintptr_t)methodHandle);
uintptr_t descriptorObject = fej9->methodType_descriptor(methodType);
intptr_t descriptorLength = fej9->getStringUTF8Length(descriptorObject);
#if defined(__open_xl__)
char *descriptorNTS = (char*)__builtin_alloca(descriptorLength+1); // NTS = null-terminated string
#else
char *descriptorNTS = (char*)alloca(descriptorLength+1); // NTS = null-terminated string
#endif
char *descriptorNTS = (char*)alloca(descriptorLength+1); // NTS = null-terminated string
fej9->getStringUTF8(descriptorObject, descriptorNTS, descriptorLength+1);
TR_VerboseLog::writeLineLocked(TR_Vlog_MHD, "%p %.*s %p hash %x type %p %s", vmThread, classNameLength, className, methodHandle, hashCode, methodType, descriptorNTS);
}
Expand Down Expand Up @@ -1617,11 +1610,7 @@ uint8_t *compileMethodHandleThunk(j9object_t methodHandle, j9object_t arg, J9VMT
{
uintptr_t thunkableSignatureString = fej9->methodHandle_thunkableSignature((uintptr_t)methodHandle);
intptr_t thunkableSignatureLength = fej9->getStringUTF8Length(thunkableSignatureString);
#if defined(__open_xl__)
char *thunkSignature = (char*)__builtin_alloca(thunkableSignatureLength+1);
#else
char *thunkSignature = (char*)alloca(thunkableSignatureLength+1);
#endif
char *thunkSignature = (char*)alloca(thunkableSignatureLength+1);
fej9->getStringUTF8(thunkableSignatureString, thunkSignature, thunkableSignatureLength+1);
TR_VerboseLog::writeLineLocked(TR_Vlog_MHD, "%p Looking up archetype for class %.*s signature %s", vmThread, classNameLength, className, thunkSignature);
}
Expand Down Expand Up @@ -1714,11 +1703,7 @@ void *initialInvokeExactThunk(j9object_t methodHandle, J9VMThread *vmThread)

uintptr_t thunkableSignatureString = fej9->methodHandle_thunkableSignature((uintptr_t)methodHandle);
intptr_t thunkableSignatureLength = fej9->getStringUTF8Length(thunkableSignatureString);
#if defined(__open_xl__)
char *thunkSignature = (char*)__builtin_alloca(thunkableSignatureLength+1);
#else
char *thunkSignature = (char*)alloca(thunkableSignatureLength+1);
#endif
char *thunkSignature = (char*)alloca(thunkableSignatureLength+1);
fej9->getStringUTF8(thunkableSignatureString, thunkSignature, thunkableSignatureLength+1);

uintptr_t thunkTuple = fej9->getReferenceField((uintptr_t)methodHandle, "thunks", "Ljava/lang/invoke/ThunkTuple;");
Expand All @@ -1732,11 +1717,7 @@ void *initialInvokeExactThunk(j9object_t methodHandle, J9VMThread *vmThread)
uintptr_t methodType = fej9->methodHandle_type((uintptr_t)methodHandle);
uintptr_t descriptorObject = fej9->methodType_descriptor(methodType);
intptr_t descriptorLength = fej9->getStringUTF8Length(descriptorObject);
#if defined(__open_xl__)
char *descriptorNTS = (char*)__builtin_alloca(descriptorLength+1); // NTS = null-terminated string
#else
char *descriptorNTS = (char*)alloca(descriptorLength+1); // NTS = null-terminated string
#endif
char *descriptorNTS = (char*)alloca(descriptorLength+1); // NTS = null-terminated string
fej9->getStringUTF8(descriptorObject, descriptorNTS, descriptorLength+1);
TR_VerboseLog::writeLineLocked(TR_Vlog_MHD, "%p %.*s %p hash %x type %p %s", vmThread, classNameLength, className, methodHandle, hashCode, methodType, descriptorNTS);
TR_VerboseLog::writeLineLocked(TR_Vlog_MHD, "%p ThunkTuple %p thunkableSignature: %s", vmThread, thunkTuple, thunkSignature);
Expand Down
13 changes: 3 additions & 10 deletions runtime/compiler/runtime/SymbolValidationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <string.h>
#include "env/VMJ9.h"
#include "env/alloca_openxl.h"
#include "env/ClassLoaderTable.hpp"
#include "env/JSR292Methods.h"
#include "env/PersistentCHTable.hpp"
Expand Down Expand Up @@ -1514,20 +1515,12 @@ TR::SymbolValidationManager::validateMethodFromClassAndSignatureRecord(uint16_t
TR_OpaqueClassBlock *beholder = getClassFromID(beholderID, SymOptional);

J9UTF8 *methodNameData = J9ROMMETHOD_NAME(romMethod);
#if defined(__open_xl__)
char *methodName = (char *)__builtin_alloca(J9UTF8_LENGTH(methodNameData)+1);
#else
char *methodName = (char *)alloca(J9UTF8_LENGTH(methodNameData)+1);
#endif
char *methodName = (char *)alloca(J9UTF8_LENGTH(methodNameData)+1);
strncpy(methodName, reinterpret_cast<const char *>(J9UTF8_DATA(methodNameData)), J9UTF8_LENGTH(methodNameData));
methodName[J9UTF8_LENGTH(methodNameData)] = '\0';

J9UTF8 *methodSigData = J9ROMMETHOD_SIGNATURE(romMethod);
#if defined(__open_xl__)
char *methodSig = (char *)__builtin_alloca(J9UTF8_LENGTH(methodSigData)+1);
#else
char *methodSig = (char *)alloca(J9UTF8_LENGTH(methodSigData)+1);
#endif
char *methodSig = (char *)alloca(J9UTF8_LENGTH(methodSigData)+1);
strncpy(methodSig, reinterpret_cast<const char *>(J9UTF8_DATA(methodSigData)), J9UTF8_LENGTH(methodSigData));
methodSig[J9UTF8_LENGTH(methodSigData)] = '\0';

Expand Down
10 changes: 7 additions & 3 deletions runtime/gc_glue_java/configure_includes/configure_aix_ppc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ CONFIGURE_ARGS += 'OMR_HOST_OS=aix'
CONFIGURE_ARGS += 'OMR_HOST_ARCH=ppc'
CONFIGURE_ARGS += 'OMR_TARGET_DATASIZE=$(TEMP_TARGET_DATASIZE)'
CONFIGURE_ARGS += 'OMR_TOOLCHAIN=xlc'

CONFIGURE_ARGS+= 'GLOBAL_CFLAGS=-qstackprotect'
CONFIGURE_ARGS+= 'GLOBAL_CXXFLAGS=-qstackprotect'
ifeq ($(OMR_ENV_OPENXL),1)
CONFIGURE_ARGS += 'GLOBAL_CFLAGS=-fstack-protector'
CONFIGURE_ARGS += 'GLOBAL_CXXFLAGS=-fstack-protector'
else
CONFIGURE_ARGS += 'GLOBAL_CFLAGS=-qstackprotect'
CONFIGURE_ARGS += 'GLOBAL_CXXFLAGS=-qstackprotect'
endif
Loading

0 comments on commit 2c6610f

Please sign in to comment.