[mono] Introduce MonoMemoryManager to hold memory previously owned by the domain...
authorRyan Lucia <rylucia@microsoft.com>
Tue, 15 Sep 2020 01:55:45 +0000 (21:55 -0400)
committerGitHub <noreply@github.com>
Tue, 15 Sep 2020 01:55:45 +0000 (21:55 -0400)
commit2143e5488ec82a417eea36de90e817db035081a5
treea64b43a27612fc495181cf29378e68d8496be0d7
parent53f4fe4550e5f7c424f8c83fd2b43830d17ed499
[mono] Introduce MonoMemoryManager to hold memory previously owned by the domain (#41754)

* Introduce MonoMemoryManager

* Move things out of the domain

* Update callers

This does *not* handle cases where we call mono_domain_alloc and friends, just direct access to domain->mp etc. As of this, everything is allocated from the default ALC on netcore and the domain on legacy.

* Update locks in domain_alloc functions

* Take correct lock around mp

* Introduce memory manager allocation helpers

* Shorten mono_domain_default_memory_manager

* Add memory_manager alloc nolock variants

* Fix locking

* More use of nolock functions

* Add trailing newline to monovm.h

This is obviously unrelated, but it was causing issues with my sed commands

* mono_memory_manager -> mono_mem_manager

Bit shorter at least, but I can cut it down further if deemed necessary

* Add to msvc build

* Fix mono/mono build

* Fix test failure

Oops

* Remove erroneous returns

* Store domain in memory manager, take domain lock

* Build fixes

* Remove comment

* Free memory manager during domain unload

* C++ fix

* Don't double free

* Remove designated initializer

MSVC C++ fails it seems :(
19 files changed:
src/mono/mono/metadata/Makefile.am
src/mono/mono/metadata/appdomain.c
src/mono/mono/metadata/assembly-load-context.c
src/mono/mono/metadata/assembly.c
src/mono/mono/metadata/domain-internals.h
src/mono/mono/metadata/domain.c
src/mono/mono/metadata/loader-internals.h
src/mono/mono/metadata/memory-manager.c [new file with mode: 0644]
src/mono/mono/metadata/object.c
src/mono/mono/metadata/reflection-cache.h
src/mono/mono/metadata/reflection.c
src/mono/mono/metadata/sre.c
src/mono/mono/mini/interp/interp.c
src/mono/mono/mini/interp/transform.c
src/mono/mono/mini/method-to-ir.c
src/mono/mono/mini/mini-runtime.c
src/mono/mono/mini/monovm.h
src/mono/msvc/libmonoruntime-common.targets
src/mono/msvc/libmonoruntime-common.targets.filters