openj9 icon indicating copy to clipboard operation
openj9 copied to clipboard

Loom: GC Scan Continuation Object

Open LinHu2016 opened this issue 2 years ago • 2 comments

Identify if the Object is an instance of Continuation, if it is, scan the Java stacks in related J9vmContinuation.

- add ContinuationLink as a hiddenInstanceField of Continuation
      instance for the global linklist
- openjdk using sub class "java/lang/VirtualThread$VThreadContinuation"
 instead of "jdk/internal/vm/Continuation" for creating instance of
     Continuation.
- new HeapWalkerDelegate to handle special treatment for Continuation
Instance.
- new Scan Type GC_ObjectModel::SCAN_CONTINUATION_OBJECT
- new J9AccClassContinuation bit (0x1000000, bit in classDepthAndFlags)
for identifying Continuation Instance, reset AccClassIsContended bit
(copy from romClass->extraModifiers, but not been used at all).
- scan/special treatment the Java stack related Continuation Instance
	CompactSchemeFixupObject
	CopyForwardScheme
	GlobalCollectorDelegate
	GlobalMarkCardScrbber
	HeapWalkerDelegate
	MarkingDelegate
	MetronomeDelegate
	RealtimeMarkingScheme
	ScavengerDelegate

- ToDo List, below the items might also need some change to match
 continuation, but not directly block the loom basic features.
	HeapIteratorAPI::j9mm_iterate_object_slots()
	MM_ReferenceChainWalker::scanObject()
	MM_CompactDelegate::verifyHeap()
	MM_RealtimeAccessBarrier::validateWriteBarrier()
 	tgcHookReportInterRegionReferenceCounting()
	MM_CopyForwardScheme::verifyObject()
	MM_IncrementalGenerationalGC::verifyMarkMapClosure()
	MM_WriteOnceCompactor::verifyHeap()
	jvmtiHeap.mapEventType()
	DDR
	GCCheck
   - need to handle/avoid mount/unmount continuation during concurrent GCs

#depends on https://github.com/eclipse/omr/pull/6575, https://github.com/eclipse-openj9/openj9/pull/15434 #fix: https://github.com/eclipse-openj9/openj9/issues/15178

Signed-off-by: Lin Hu [email protected]

LinHu2016 avatar Jul 21 '22 21:07 LinHu2016

@amicic @dmitripivkine please review the changes, Thanks

LinHu2016 avatar Jul 27 '22 15:07 LinHu2016

General question: Do we need put #if JAVA_SPEC_VERSION >= 19 around most changes in GC? Can we just rely on existence of this case for Java 19 only? If it is possible it would make GC code much cleaner (despite slight grows of code and data for earlier Java versions)

dmitripivkine avatar Jul 27 '22 16:07 dmitripivkine

updating new vm api walkContinuationStackFrames for scanning java stack in j9vmContinuation. https://github.com/eclipse-openj9/openj9/pull/15678/files#diff-aa08fd4ba250064714cc602eda8db8bbaae659c38b78e47f24ff00d9a5dd6a44

LinHu2016 avatar Aug 17 '22 14:08 LinHu2016

@tajila please review vm related changes, @dsouzai please review jit releated changes, Thanks

LinHu2016 avatar Aug 22 '22 15:08 LinHu2016

@jdmpapin could you also review the JIT changes from an optimizer pov?

dsouzai avatar Aug 22 '22 18:08 dsouzai

the personal build with the latest omr master branch https://hyc-runtimes-jenkins.swg-devops.com/view/OpenJ9%20-%20Personal/job/Pipeline-Build-Test-Personal/13977/

LinHu2016 avatar Aug 23 '22 21:08 LinHu2016

The JIT changes LGTM, but we may also need to bump MINOR_NUMBER. I'm thinking of a scenario where the client has continuation classes, but the server doesn't know about them, in which case the server could e.g. think it's ok to stack allocate

jdmpapin avatar Aug 26 '22 20:08 jdmpapin

@LinHu2016 sorry, in the formatting changes I requested I meant that your code was using tabs, whereas the compiler code uses spaces. As it stands, the formatting is still incorrect in runtime/compiler/env/J9ClassEnv.cpp and runtime/compiler/env/VMJ9.cpp

dsouzai avatar Aug 30 '22 14:08 dsouzai

Jenkins test sanity all jdk11

amicic avatar Sep 01 '22 16:09 amicic

Jenkins test sanity all jdk11

amicic avatar Sep 02 '22 15:09 amicic

Jenkins compile win32 jdk8

amicic avatar Sep 02 '22 16:09 amicic

@amicic Update ScavengerDelegate.cpp, add OMR_GC_CONCURRENT_SCAVENGER precompile option for calling fixupSlot().

LinHu2016 avatar Sep 02 '22 17:09 LinHu2016

Jenkins compile win32 jdk8

amicic avatar Sep 02 '22 17:09 amicic

Jenkins compile win jdk11

amicic avatar Sep 02 '22 17:09 amicic

The last commit was minor, fixing a 32bit compile failure. So, I just re-lauched a couple of compile jobs. For sanity testing I'm relying on these that were done just before the last commit, and they were all green: https://openj9-jenkins.osuosl.org/job/PullRequest-OpenJ9/2642/

amicic avatar Sep 02 '22 19:09 amicic