Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loom: GC Scan Continuation Object #15603

Merged
merged 1 commit into from
Sep 2, 2022

Conversation

LinHu2016
Copy link
Contributor

@LinHu2016 LinHu2016 commented Jul 21, 2022

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 eclipse/omr#6575, #15434, #15678
#fix: #15178

Signed-off-by: Lin Hu linhu@ca.ibm.com

@LinHu2016 LinHu2016 force-pushed the GC_SCAN_Continuation_Loom branch 3 times, most recently from dc2a5af to faebda8 Compare July 23, 2022 03:30
@LinHu2016
Copy link
Contributor Author

@amicic @dmitripivkine please review the changes, Thanks

case GC_ObjectModel::SCAN_CONTINUATION_OBJECT:
returnCode = iterateMixedObjectSlots(javaVM, objectPtr, object, flags, func, userData);
break;
#endif /* JAVA_SPEC_VERSION >= 19 */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we plan to have extra or different logic here? If not, you can add this case to group above:
....
case GC_ObjectModel::SCAN_CLASSLOADER_OBJECT:
case GC_ObjectModel::SCAN_REFERENCE_MIXED_OBJECT:
#if JAVA_SPEC_VERSION >= 19
case GC_ObjectModel::SCAN_CONTINUATION_OBJECT:
#endif /* JAVA_SPEC_VERSION >= 19 */
....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I leave it separate here, because I am not very clear if we need any different logic for continuation in this case, keep a room to update in future.

@dmitripivkine
Copy link
Contributor

dmitripivkine commented Jul 27, 2022

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)

case GC_ObjectModel::SCAN_CONTINUATION_OBJECT:
scanMixedObject(objectPtr);
break;
#endif /* JAVA_SPEC_VERSION >= 19 */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this case be separate or can it be joined to the group above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same reason as above for keeping the separated code.

@LinHu2016 LinHu2016 force-pushed the GC_SCAN_Continuation_Loom branch 7 times, most recently from 3fb509a to fe627a9 Compare August 3, 2022 20:15
@dmitripivkine dmitripivkine added comp:gc project:loom Used to track Project Loom related work labels Aug 4, 2022
@LinHu2016 LinHu2016 force-pushed the GC_SCAN_Continuation_Loom branch 2 times, most recently from d873db9 to c9b5e0c Compare August 4, 2022 16:52
@LinHu2016 LinHu2016 force-pushed the GC_SCAN_Continuation_Loom branch 2 times, most recently from f20dd73 to 07da4a5 Compare August 17, 2022 14:22
@LinHu2016
Copy link
Contributor Author

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

@LinHu2016 LinHu2016 force-pushed the GC_SCAN_Continuation_Loom branch 2 times, most recently from 9a25d9e to 2af6bac Compare August 26, 2022 01:08
@jdmpapin
Copy link
Contributor

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

Copy link
Contributor

@jdmpapin jdmpapin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, but I'd like @dsouzai to give his opinion about the protocol version

Copy link
Contributor

@dsouzai dsouzai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the MINOR_NUMBER should be bumped since this includes frontend API changes.

Also there's some formatting issues that remain.

@@ -87,7 +87,8 @@ J9::ClassEnv::isClassSpecialForStackAllocation(TR_OpaqueClassBlock * clazz)
const UDATA mask = (J9AccClassReferenceWeak |
J9AccClassReferenceSoft |
J9AccClassFinalizeNeeded |
J9AccClassOwnableSynchronizer);
J9AccClassOwnableSynchronizer |
J9AccClassContinuation );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is using tabs instead of spaces.

Comment on lines 6503 to 6504
J9Class* j9class = TR::Compiler->cls.convertClassOffsetToClassPtr(clazz);
return ((J9CLASS_FLAGS(j9class) & J9AccClassContinuation) != 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting; tabs used instead of spaces.

@LinHu2016 LinHu2016 force-pushed the GC_SCAN_Continuation_Loom branch 2 times, most recently from 121cb31 to 9182142 Compare August 30, 2022 14:33
@dsouzai
Copy link
Contributor

dsouzai commented Aug 30, 2022

@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

@amicic
Copy link
Contributor

amicic commented Sep 1, 2022

Jenkins test sanity all jdk11

Copy link
Contributor

@dmitripivkine dmitripivkine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two cosmetic changes left:

  • remove check for Java 19 in MM_GlobalMarkingScheme::scanClassObject() or explain why it required
  • revert Copyrights date update in MemorySubSpaceTarok.cpp, file has not been changed
    Except this looks good to me

@amicic
Copy link
Contributor

amicic commented Sep 2, 2022

Jenkins test sanity all jdk11

@amicic
Copy link
Contributor

amicic commented Sep 2, 2022

Jenkins compile win32 jdk8

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

Signed-off-by: Lin Hu <linhu@ca.ibm.com>
@LinHu2016
Copy link
Contributor Author

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

@amicic
Copy link
Contributor

amicic commented Sep 2, 2022

Jenkins compile win32 jdk8

@amicic
Copy link
Contributor

amicic commented Sep 2, 2022

Jenkins compile win jdk11

@amicic
Copy link
Contributor

amicic commented Sep 2, 2022

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 amicic merged commit 00f03c2 into eclipse-openj9:master Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:gc comp:jit comp:vm project:loom Used to track Project Loom related work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loom: GC Contiuation Scan type
7 participants