Skip to content

Commit

Permalink
Disable invalid offsetof warning in runtime, ras, control
Browse files Browse the repository at this point in the history
In order to allow OMR_WARNINGS_AS_ERRORS to be enabled across the
JIT, disable -Winvalid-offsetof on gcc and clang builds while work
is done to refactor relevant classes to be standard-layout type
so offsetof can be used

Signed-off-by: Dylan Tuttle <jdylantuttle@gmail.com>
  • Loading branch information
dylanjtuttle committed Jun 11, 2024
1 parent 775a2c2 commit d0811d4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
15 changes: 15 additions & 0 deletions runtime/compiler/control/J9Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,22 @@
#include "j9jitnls.h"
#endif

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
#endif

#define SET_OPTION_BIT(x) TR::Options::setBit, offsetof(OMR::Options,_options[(x)&TR_OWM]), ((x)&~TR_OWM)

#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic pop
#endif

//Default code cache total max memory percentage set to 25% of physical RAM for low memory systems
#define CODECACHE_DEFAULT_MAXRAMPERCENTAGE 25
// For use with TPROF only, disable JVMPI hooks even if -Xrun is specified.
Expand Down
13 changes: 13 additions & 0 deletions runtime/compiler/ras/kca_offsets_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,22 @@ J9::Options::kcaOffsets(const char *option, void *, TR::OptionTable *entry)
fprintf( file, "#define OSTHREAD_TID (%" OMR_PRIuSIZE ")\n", offsetof(J9AbstractThread,tid) );

fprintf( file, "#define J9JITSTACKATLAS_MAPBYTES (%" OMR_PRIuSIZE ")\n", offsetof(J9JITStackAtlas,numberOfMapBytes) );

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
#endif
fprintf( file, "#define BODYINFO_HOTNESS (%" OMR_PRIuSIZE ")\n", offsetof(TR_PersistentJittedBodyInfo,_hotness) );
fprintf( file, "#define PERSISTENTINFO_CHTABLE (%" OMR_PRIuSIZE ")\n", offsetof(TR::PersistentInfo,_persistentCHTable) );
fprintf( file, "#define PERSISTENTCLASS_VISITED (%" OMR_PRIuSIZE ")\n", offsetof(TR_PersistentClassInfo,_visitedStatus) );
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic pop
#endif

fprintf( file, "#define ELS_OLDELS (%" OMR_PRIuSIZE ")\n", offsetof(J9VMEntryLocalStorage,oldEntryLocalStorage) );
fprintf( file, "#define ELS_I2JSTATE (%" OMR_PRIuSIZE ")\n", offsetof(J9VMEntryLocalStorage,i2jState) );
Expand Down
26 changes: 26 additions & 0 deletions runtime/compiler/runtime/J9ValueProfiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,21 @@ class TR_HashTableProfilerInfo : public TR_AbstractHashTableProfilerInfo
TR_AbstractHashTableProfilerInfo(bci, bits, hash, kind)
{}

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
#endif
size_t getLockOffset() { return offsetof(TR_HashTableProfilerInfo<T>, _metaData.otherIndex); }
size_t getHashOffset() { return offsetof(TR_HashTableProfilerInfo<T>, _hashConfig); }
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic pop
#endif

TR::DataType getDataType() { return sizeof(T) <= 4 ? TR::Int32 : TR::Int64; }

/**
Expand Down Expand Up @@ -404,8 +417,21 @@ class TR_EmbeddedHashTable : public TR_HashTableProfilerInfo<T>
}

bool resetLowFreqKeys();

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
#endif
size_t getKeysOffset() { return offsetof(this_t, _keys); }
size_t getFreqOffset() { return offsetof(this_t, _freqs); }
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic pop
#endif

protected:
typedef TR_EmbeddedHashTable<T, bits> this_t;
Expand Down

0 comments on commit d0811d4

Please sign in to comment.