Skip to content

Commit e107bcb

Browse files
lewurmluhenry
authored andcommitted
[metadata] split IL generation code into seperate compilation units. (mono/mono#7487)
* [metadata] split IL generation code into seperate compilation units. * [metadata] move ENABLE_ILGEN definition to configure * [metadata] split IL generation code into seperate compilation units. By adding callbacks for IL generating runtime code, we can link in code later into the runtime that does such for configurations which do not need IL generation initially. This is the case if you configure the runtime with `--enable-minimal=jit,interpreter`. In such configuration, the build will produce an additional library, called `libmono-ilgen`. An embedded can choose to link this library to the final binary and initialize IL generation with the following three, newly added, API calls: * `void mono_marshal_ilgen_init (void)` * `void mono_method_builder_ilgen_init (void)` * `void mono_sgen_mono_ilgen_init (void)` This change is mostly moving code around, but there are minor changes like introducing the enum `MarshalTypeCheckPositions`, so we avoid copy/paste constants accross compilation units. * [windows] add IL gen files to windows build and set ENABLE_ILGEN * [fixup!] fix windows build * [fixup!] resolve merge conflicts with class getter commits * marshal.c: mono/mono@b8da973 * sgen-mono.c: mono/mono@8ba4947 at some point I gave up to resolve merge conflicts and worked through errors/warnings by compiling with > `CFLAGS=-DENABLE_CHECKED_BUILD_PRIVATE_TYPES=1` so the result is likely a bit different * redo lost changes from mono/mono@57f3f34 * redo lost changes from mono/mono@52514ef * [fixup!] fix array marshal * [method-builder] use eglib types review comment by Ludovic, mono/mono#7375 (comment) * [marshal] remove stelem strings from header review comment by Rodrigo, mono/mono#7375 (comment) Commit migrated from mono/mono@868a402
1 parent c1a921d commit e107bcb

26 files changed

+10175
-9123
lines changed

src/mono/configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,12 @@ fi
14221422

14231423
AM_CONDITIONAL(DISABLE_INTERPRETER, test x$mono_feature_disable_interpreter = xyes)
14241424

1425+
if test "x$mono_feature_disable_interpreter" != "xyes" -o "x$mono_feature_disable_jit" != "xyes"; then
1426+
AC_DEFINE(ENABLE_ILGEN, 1, [Some VES is available at runtime])
1427+
fi
1428+
1429+
AM_CONDITIONAL(ENABLE_ILGEN, test x$mono_feature_disable_interpreter != xyes -o x$mono_feature_disable_jit != xyes)
1430+
14251431
if test "x$mono_feature_disable_simd" = "xyes"; then
14261432
AC_DEFINE(DISABLE_SIMD, 1, [Disable SIMD intrinsics related optimizations.])
14271433
AC_MSG_NOTICE([Disabled SIMD support])

src/mono/mono/metadata/Makefile.am

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,13 @@ if DISABLE_ICALL_TABLES
8585
icall_table_libraries = libmono-icall-table.la
8686
endif
8787

88+
if !ENABLE_ILGEN
89+
ilgen_libraries = libmono-ilgen.la
90+
endif
91+
8892
noinst_LTLIBRARIES = libmonoruntime-config.la $(boehm_libraries) $(sgen_libraries)
8993

90-
lib_LTLIBRARIES = $(icall_table_libraries)
94+
lib_LTLIBRARIES = $(icall_table_libraries) $(ilgen_libraries)
9195

9296
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/mono $(LIBGC_CPPFLAGS) $(GLIB_CFLAGS) $(SHARED_CFLAGS)
9397

@@ -122,6 +126,25 @@ libmono_icall_table_la_LIBADD = ../eglib/libeglib.la ../utils/libmonoutils.la ..
122126
endif
123127
endif
124128

129+
#
130+
# This library contains code to generate IL at runtime
131+
#
132+
if !ENABLE_ILGEN
133+
libmono_ilgen_la_SOURCES = \
134+
method-builder-ilgen.c \
135+
method-builder-ilgen.h \
136+
method-builder-ilgen-internals.h \
137+
marshal-ilgen.c \
138+
marshal-ilgen.h \
139+
sgen-mono-ilgen.c \
140+
sgen-mono-ilgen.h
141+
libmono_ilgen_la_CFLAGS = $(SGEN_DEFINES)
142+
libmono_ilgen_la_LDFLAGS = $(libmonoldflags)
143+
if BITCODE
144+
libmono_ilgen_la_LIBADD = ../eglib/libeglib.la ../utils/libmonoutils.la ../sgen/libmonosgen.la libmonoruntimesgen.la
145+
endif
146+
endif
147+
125148
CLEANFILES = mono-bundle.stamp
126149

127150
null_sources = \
@@ -137,6 +160,17 @@ icall_tables_sources = \
137160
icall-table.c
138161
endif
139162

163+
if ENABLE_ILGEN
164+
ilgen_sources = \
165+
method-builder-ilgen.c \
166+
method-builder-ilgen.h \
167+
method-builder-ilgen-internals.h \
168+
marshal-ilgen.c \
169+
marshal-ilgen.h \
170+
sgen-mono-ilgen.c \
171+
sgen-mono-ilgen.h
172+
endif
173+
140174
common_sources = \
141175
$(platform_sources) \
142176
appdomain.c \
@@ -204,6 +238,7 @@ common_sources = \
204238
metadata-verify.c \
205239
metadata-internals.h \
206240
method-builder.h \
241+
method-builder-internals.h \
207242
method-builder.c \
208243
mono-basic-block.c \
209244
mono-basic-block.h \
@@ -327,13 +362,14 @@ sgen_sources = \
327362
sgen-toggleref.h \
328363
sgen-stw.c \
329364
sgen-mono.c \
365+
sgen-mono.h \
330366
sgen-client-mono.h
331367

332-
libmonoruntime_la_SOURCES = $(common_sources) $(icall_tables_sources) $(gc_dependent_sources) $(null_gc_sources) $(boehm_sources)
368+
libmonoruntime_la_SOURCES = $(common_sources) $(icall_tables_sources) $(ilgen_sources) $(gc_dependent_sources) $(null_gc_sources) $(boehm_sources)
333369
libmonoruntime_la_CFLAGS = $(BOEHM_DEFINES)
334370
libmonoruntime_la_LIBADD = libmonoruntime-config.la
335371

336-
libmonoruntimesgen_la_SOURCES = $(common_sources) $(icall_tables_sources) $(gc_dependent_sources) $(sgen_sources)
372+
libmonoruntimesgen_la_SOURCES = $(common_sources) $(icall_tables_sources) $(ilgen_sources) $(gc_dependent_sources) $(sgen_sources)
337373
libmonoruntimesgen_la_CFLAGS = $(SGEN_DEFINES)
338374
libmonoruntimesgen_la_LIBADD = libmonoruntime-config.la
339375

src/mono/mono/metadata/boehm-gc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <mono/metadata/profiler-private.h>
1919
#include <mono/metadata/class-internals.h>
2020
#include <mono/metadata/method-builder.h>
21+
#include <mono/metadata/method-builder-ilgen.h>
22+
#include <mono/metadata/method-builder-ilgen-internals.h>
2123
#include <mono/metadata/opcodes.h>
2224
#include <mono/metadata/domain-internals.h>
2325
#include <mono/metadata/metadata-internals.h>

src/mono/mono/metadata/cominterop.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "mono/metadata/threads.h"
3030
#include "mono/metadata/monitor.h"
3131
#include "mono/metadata/metadata-internals.h"
32+
#include "mono/metadata/method-builder-ilgen-internals.h"
3233
#include "mono/metadata/domain-internals.h"
3334
#include "mono/metadata/gc-internals.h"
3435
#include "mono/metadata/threads-types.h"

src/mono/mono/metadata/cominterop.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define __MONO_COMINTEROP_H__
1212

1313
#include <mono/metadata/method-builder.h>
14+
#include <mono/metadata/method-builder-ilgen.h>
1415
#include <mono/metadata/marshal.h>
1516

1617
void

0 commit comments

Comments
 (0)