Skip to content

Commit

Permalink
Merge pull request #18313 from dylanjtuttle/disableOffsetOf
Browse files Browse the repository at this point in the history
Disable -Winvalid-offsetof in J9Options, kca_offsets_generator, J9ValueProfiler
  • Loading branch information
pshipton authored Sep 20, 2024
2 parents 94dfa06 + d0811d4 commit c8520fe
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 c8520fe

Please sign in to comment.