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

Add new Mono embedding API to consume binary runtimeconfig format #49740

Merged
merged 19 commits into from
Mar 22, 2021

Conversation

fanyang-mono
Copy link
Member

Fixes #49236

@ghost
Copy link

ghost commented Mar 17, 2021

Tagging subscribers to this area: @CoffeeFlux
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #49236

Author: fanyang-mono
Assignees: -
Labels:

area-AssemblyLoader-mono

Milestone: -

Copy link
Member

@lambdageek lambdageek left a comment

Choose a reason for hiding this comment

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

  1. Use the mono-mmap functions to open the file - it can fall back to making a copy of the data, but it doesn't have to.
  2. Use the mono_metadata_decode_blob function to get the lengths.
  3. I don't think you should parse the file right away. Just save away the MonovmRuntimeConfigArguments and the cleanup function, and parse right in mono_runtime_install_appctx_properties when we have both sets of arguments and we can create a single set of arrays to pass to managed.

src/mono/mono/mini/monovm.c Outdated Show resolved Hide resolved
src/mono/mono/mini/monovm.c Outdated Show resolved Hide resolved
src/mono/mono/mini/monovm.c Outdated Show resolved Hide resolved
src/mono/mono/mini/monovm.c Outdated Show resolved Hide resolved
src/mono/mono/mini/monovm.c Outdated Show resolved Hide resolved
src/mono/mono/mini/monovm.c Outdated Show resolved Hide resolved
src/mono/mono/mini/monovm.c Outdated Show resolved Hide resolved
Copy link
Member

@lambdageek lambdageek left a comment

Choose a reason for hiding this comment

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

Great steps in the right direction.

I'm suspicious about g_new0 not doing the right thing - I suspect it's because you're accessing the monovm_initialize keys and values after that function has already returned. Unfortunately there's no avoiding making a copy of those since the caller of monovm_initiaze might free them.

src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/mini/monovm.c Outdated Show resolved Hide resolved
src/mono/mono/mini/monovm.c Outdated Show resolved Hide resolved
src/mono/mono/mini/monovm.c Outdated Show resolved Hide resolved
Copy link
Member

@lambdageek lambdageek left a comment

Choose a reason for hiding this comment

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

Keeps getting better. But let's keep going.

I sketched out how I think _install should look. monovm_runtimeconfig_initialize can be literally a 1 liner that just stores arg, cleanup_fn and user_data to mono_runtime_register_runtimeconfig_json_properties without doing anything to them.

src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/mini/monovm.c Outdated Show resolved Hide resolved
src/mono/mono/mini/monovm.c Outdated Show resolved Hide resolved
src/mono/mono/mini/monovm.c Outdated Show resolved Hide resolved
Copy link
Member

@lambdageek lambdageek left a comment

Choose a reason for hiding this comment

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

In general LGTM. Thanks @fanyang-mono !
I'll go through one more time in a couple of hours in detail, for any minor nits.

Copy link
Member

@lambdageek lambdageek left a comment

Choose a reason for hiding this comment

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

Ok, went through in detail. Couple of minor whitespace nits, but otherwise LGTM

src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
Copy link
Member

@lewing lewing left a comment

Choose a reason for hiding this comment

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

Looks good, a couple of thoughts about simplifying things.

src/mono/mono/metadata/appdomain.c Show resolved Hide resolved
Copy link
Contributor

@CoffeeFlux CoffeeFlux left a comment

Choose a reason for hiding this comment

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

Mix of nits and comments about unneeded strlen and strcpy calls. This is called during startup, so we really need to include as few of them as possible. Getting close though! 😄

src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/appdomain.c Outdated Show resolved Hide resolved
Copy link
Contributor

@CoffeeFlux CoffeeFlux left a comment

Choose a reason for hiding this comment

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

Just one nit, but otherwise should be good to go!.

src/mono/mono/metadata/appdomain.c Show resolved Hide resolved
src/mono/mono/mini/mono-private-unstable.h Outdated Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add new Mono embedding API to consume binary runtimeconfig format
5 participants