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

[Memoryprofiler] Exposing required mono API for backend migration #1206

Merged
merged 8 commits into from
Jul 29, 2019

Conversation

realek
Copy link

@realek realek commented Jul 12, 2019

This PR focuses on either exposing or adding new mono functionality in order to allow the Profiler team to fully migrate the memory profiler backend from inside the VM.
It's sister PR: https://github.cds.internal.unity3d.com/unity/il2cpp/pull/446 on the IL2Cpp repo will handle feature parity in between the two back-ends
Preview PR with embedded backends at: https://ono.unity3d.com/unity/unity/pull-request/89971/_/profiler/memory/streaming_snapshot
-> A lot of the changes are the CLang format kicking in...can't really do much about that <-

exposed/new functions as copied from the main repo branch:
Note: MonoDataFunc define is the same signature as GFunc from the mono repo

DO_API(void, mono_unity_image_set_mempool_foreach, (MonoDataFunc callback, void* userdata))
DO_API(void, mono_unity_root_domain_mempool_chunk_foreach, (MonoDataFunc callback, void* userdata))
DO_API(void, mono_unity_domain_mempool_chunk_foreach, (MonoDomain* domain, MonoDataFunc callback, void* userData))
DO_API(void, mono_unity_assembly_mempool_chunk_foreach, (MonoAssembly* assembly, MonoDataFunc callback, void* userData))
DO_API(void, mono_unity_gc_heap_foreach, (MonoDataFunc callback, void* userData))
DO_API(void, mono_unity_gc_handles_foreach_get_target, (MonoDataFunc callback, void* userData))
DO_API(uint32_t, mono_unity_object_header_size, ())
DO_API(uint32_t, mono_unity_array_object_header_size, ())
DO_API(uint32_t, mono_unity_offset_of_array_length_in_array_object_header, ())
DO_API(uint32_t, mono_unity_offset_of_array_bounds_in_array_object_header, ())
DO_API(uint32_t, mono_unity_allocation_granularity, ())
DO_API(uint32_t, mono_unity_class_get_data_size, (MonoClass* klass))
//Non alocating type get name variant, can be used with a preallocated core::string
DO_API(void, mono_unity_type_get_name_full_chunked, (MonoType* type, MonoDataFunc appendCallback, void* userData))
DO_API(MonoVTable*, mono_unity_class_try_get_vtable, (MonoDomain domain, MonoClass klass)) //current get VTable tries to create it, if it does not exist
DO_API(gboolean, mono_unity_type_is_pointer_type, (MonoType
type))
DO_API(gboolean, mono_unity_type_is_static,(MonoType
type))
DO_API(gboolean, mono_unity_class_field_is_literal, (MonoClassField field))
DO_API(void
, mono_unity_vtable_get_static_field_data, (MonoVTable* vTable))
DO_API(void, mono_unity_class_for_each, (MonoClassFunc callback, void* userData))
// used to stop/start the GC world as the alternative would require allocating a state and using the
// liveness methods already present in the codebase
DO_API(void, mono_unity_stop_gc_world, ())
DO_API(void, mono_unity_start_gc_world, ())

@realek realek changed the title Memoryprofiler exposing required mono API [Preview][Memoryprofiler] Exposing required mono API for backend migration Jul 12, 2019
@realek realek requested a review from joncham July 12, 2019 13:23
mono/metadata/class.c Outdated Show resolved Hide resolved
…n logic over all initialized classes in the VM
…l terminated chunks.

A good example for this can be using a preallocated instance of core::string as user_data for the callback which will then append onto the preallocated string
…emory blocks from the VM heap

added mono_unity_domain_mempool_chunk_foreach in order to report memory blocks inside the current domain's memory pool
added mono_unity_root_domain_mempool_chunk_foreach in order to report memory blocks inside the root domain's memory pool
added mono_unity_assembly_mempool_chunk_foreach in order to report memory blocks inside an assembly's image's memory pool
added mono_unity_class_get_data_size in order to return static field data size for a MonoClass
added mono_unity_class_get_static_field_data in order to access static fields memory for a given MonoClass
added mono_unity_class_field_is_literal in order to find out if the attributes
added mono_unity_start/stop_gc_world() in order to control the GC world state
added mono_unity_gc_heap_foreach in order to report each allocated GC heap section
added mono_unity_gchandles_foreach_get_target in order to report all gc handle targets tracked by the garbage collector
added mono_unity_object_header_size in order to report mono object header size
added mono_unity_array_object_header_size in order to report mono array object header size
added mono_unity_offset_of_array_length/bounds_in_array_object_header in order to report the offset of the length/bounds of the array within the header
added mono_unity_allocation_granularity in order to report the minimum allocation granulariy inside the vm
added mono_unity_get_name_full_chunked in order to extract a types name in chunks
added mono_unity_type_is_static in order to report if the given type is static
added mono_unity_type_is_pointer_type in order to report if the given type is a pointer type
@realek realek force-pushed the memoryprofiler/exposing_mono_API branch from 403fd74 to ebfcd51 Compare July 16, 2019 15:10
@realek realek changed the title [Preview][Memoryprofiler] Exposing required mono API for backend migration [Memoryprofiler] Exposing required mono API for backend migration Jul 16, 2019
@realek realek requested a review from joncham July 17, 2019 10:50
@realek realek self-assigned this Jul 17, 2019
mono/metadata/class.c Outdated Show resolved Hide resolved
@realek realek requested a review from joncham July 22, 2019 16:28
@realek
Copy link
Author

realek commented Jul 24, 2019

finally green wooop ! ^_^

Copy link
Member

@joncham joncham left a comment

Choose a reason for hiding this comment

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

Great work!

@realek realek merged commit 610a9ac into unity-master Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants