Skip to content

Commit

Permalink
Merge pull request #17021 from a7ehuo/remove-immutableField-currentTh…
Browse files Browse the repository at this point in the history
…read-0370

(v0.37.0-release) Remove setImmutableField on currentThread for JDK19 and up
  • Loading branch information
pshipton authored Mar 24, 2023
2 parents 934ce94 + c46d60a commit 8e750cf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 8 additions & 1 deletion runtime/compiler/compile/J9SymbolReferenceTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,14 @@ J9::SymbolReferenceTable::findOrCreateCurrentThreadSymbolRef()
TR_J9VMBase *fej9 = (TR_J9VMBase *)(fe());
TR::Symbol * sym = TR::RegisterMappedSymbol::createMethodMetaDataSymbol(trHeapMemory(), "CurrentThread");
sym->setDataType(TR::Address);
sym->setImmutableField();
if (fej9->isJ9VMThreadCurrentThreadImmutable())
{
sym->setImmutableField();
}
else
{
sym->setVolatile();
}
element(currentThreadSymbol) = new (trHeapMemory()) TR::SymbolReference(self(), currentThreadSymbol, sym);
element(currentThreadSymbol)->setOffset(fej9->thisThreadGetCurrentThreadOffset());
}
Expand Down
10 changes: 10 additions & 0 deletions runtime/compiler/env/VMJ9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9376,6 +9376,16 @@ TR_J9VMBase::isSnapshotModeEnabled()
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
}

bool
TR_J9VMBase::isJ9VMThreadCurrentThreadImmutable()
{
#if JAVA_SPEC_VERSION >= 19
return false;
#else
return true;
#endif /* JAVA_SPEC_VERSION >= 19 */
}

// Native method bodies
//
#if defined(TR_HOST_X86)
Expand Down
7 changes: 7 additions & 0 deletions runtime/compiler/env/VMJ9.h
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,13 @@ class TR_J9VMBase : public TR_FrontEnd
*/
bool isSnapshotModeEnabled();

/**
* \brief Answers whether or not Thread.currentThread() is immutable.
*
* \return True if Thread.currentThread() is immutable.
*/
virtual bool isJ9VMThreadCurrentThreadImmutable();

protected:

enum // _flags
Expand Down

0 comments on commit 8e750cf

Please sign in to comment.