From 5f0bb98eca8993d1f72f196d3ea15c1b7d094362 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 28 Mar 2023 11:15:39 -0400 Subject: [PATCH 01/23] Use dn_vector_t instead of GArray in one place in Mono Set up the infrastructure to consume shared container types from src/mono/{metadata,mini}. Replace one use of GArray with dn_vector_t --- src/mono/mono/CMakeLists.txt | 2 ++ src/mono/mono/metadata/CMakeLists.txt | 16 +++++++++++++++- src/mono/mono/metadata/custom-attrs.c | 21 +++++++++++++-------- src/mono/mono/mini/CMakeLists.txt | 2 +- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/mono/mono/CMakeLists.txt b/src/mono/mono/CMakeLists.txt index c59470996f5825..75815d178ee343 100644 --- a/src/mono/mono/CMakeLists.txt +++ b/src/mono/mono/CMakeLists.txt @@ -1,5 +1,7 @@ project(mono) +set(SHARED_CONTAINERS_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/containers/") + set(subdirs eglib utils diff --git a/src/mono/mono/metadata/CMakeLists.txt b/src/mono/mono/metadata/CMakeLists.txt index abddf1a58a5d92..a7a9460304bfd8 100644 --- a/src/mono/mono/metadata/CMakeLists.txt +++ b/src/mono/mono/metadata/CMakeLists.txt @@ -1,5 +1,19 @@ project(metadata C) +include (${SHARED_CONTAINERS_SOURCE_PATH}containers.cmake) + +set(shared_container_sources "") + +list(APPEND shared_container_sources + ${SHARED_CONTAINER_SOURCES} + ${SHARED_CONTAINER_HEADERS} +) + +addprefix(shared_container_sources ${SHARED_CONTAINERS_SOURCE_PATH} "${shared_container_sources}") + +add_library(shared_container_objects OBJECT ${shared_container_sources}) +target_include_directories(shared_container_objects PUBLIC ${SHARED_CONTAINERS_SOURCE_PATH}) + # # This library contains the icall tables if the runtime was configured with DISABLE_ICALL_TABLES # @@ -203,7 +217,7 @@ target_compile_definitions(metadata_objects PRIVATE ${metadata_compile_definitio target_link_libraries(metadata_objects PRIVATE monoapi eglib_api utils_objects) # note: metadata_objects is an object library, so this doesn't force linking with sgen, # it just adds the relevant include directories - which we need even with Boehm -target_link_libraries(metadata_objects PRIVATE sgen_objects) +target_link_libraries(metadata_objects PRIVATE sgen_objects shared_container_objects) target_compile_definitions(metadata_objects PRIVATE -DMONO_DLL_EXPORT) target_include_directories(metadata_objects PRIVATE ${PROJECT_BINARY_DIR}/../.. ${PROJECT_SOURCE_DIR}/../.. diff --git a/src/mono/mono/metadata/custom-attrs.c b/src/mono/mono/metadata/custom-attrs.c index 566c3512202b15..eb27ccd9eb967c 100644 --- a/src/mono/mono/metadata/custom-attrs.c +++ b/src/mono/mono/metadata/custom-attrs.c @@ -13,6 +13,7 @@ * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #include +#include #include "mono/metadata/assembly.h" #include "mono/metadata/class-init.h" #include "mono/metadata/class-internals.h" @@ -1880,6 +1881,7 @@ mono_custom_attrs_from_index (MonoImage *image, guint32 idx) mono_error_cleanup (error); return result; } + /** * mono_custom_attrs_from_index_checked: * \returns NULL if no attributes are found. On error returns NULL and sets \p error. @@ -1891,7 +1893,7 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig guint32 cols [MONO_CUSTOM_ATTR_SIZE]; MonoTableInfo *ca; MonoCustomAttrInfo *ainfo; - GArray *attr_array; + dn_vector_t *attr_array; const char *data; MonoCustomAttrEntry* attr; @@ -1904,7 +1906,10 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig return NULL; i --; // initial size chosen arbitrarily, but default is 16 which is rather small - attr_array = g_array_sized_new (TRUE, TRUE, sizeof (guint32), 128); + dn_vector_custom_alloc_params_t vec_params = {0,}; + vec_params.capacity = 128; + vec_params.attributes = DN_VECTOR_ATTRIBUTE_MEMORY_INIT; + attr_array = dn_vector_custom_alloc_t (&vec_params, uint32_t); while (!mono_metadata_table_bounds_check (image, MONO_TABLE_CUSTOMATTRIBUTE, i + 1)) { if (mono_metadata_decode_row_col (ca, i, MONO_CUSTOM_ATTR_PARENT) != idx) { if (G_LIKELY (!image->has_updates)) { @@ -1916,19 +1921,19 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig continue; } } - attr_array = g_array_append_val (attr_array, i); + dn_vector_push_back (attr_array, i); ++i; } - len = attr_array->len; + len = dn_vector_size (attr_array); if (!len) { - g_array_free (attr_array, TRUE); + dn_vector_free (attr_array); return NULL; } ainfo = (MonoCustomAttrInfo *)g_malloc0 (MONO_SIZEOF_CUSTOM_ATTR_INFO + sizeof (MonoCustomAttrEntry) * len); ainfo->num_attrs = len; ainfo->image = image; for (i = 0; i < len; ++i) { - mono_metadata_decode_row (ca, g_array_index (attr_array, guint32, i), cols, MONO_CUSTOM_ATTR_SIZE); + mono_metadata_decode_row (ca, *dn_vector_index_t (attr_array, uint32_t, i), cols, MONO_CUSTOM_ATTR_SIZE); mtoken = cols [MONO_CUSTOM_ATTR_TYPE] >> MONO_CUSTOM_ATTR_TYPE_BITS; switch (cols [MONO_CUSTOM_ATTR_TYPE] & MONO_CUSTOM_ATTR_TYPE_MASK) { case MONO_CUSTOM_ATTR_TYPE_METHODDEF: @@ -1949,7 +1954,7 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig mono_error_cleanup (error); error_init (error); } else { - g_array_free (attr_array, TRUE); + dn_vector_free (attr_array); g_free (ainfo); return NULL; } @@ -1959,7 +1964,7 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig attr->data_size = mono_metadata_decode_value (data, &data); attr->data = (guchar*)data; } - g_array_free (attr_array, TRUE); + dn_vector_free (attr_array); return ainfo; } diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 8419317adc58c3..3c14c803db02ae 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -354,7 +354,7 @@ set(monosgen-sources "${icu_shim_sources};${mini_sources};${ZLIB_SOURCES}") add_library(monosgen-objects OBJECT "${monosgen-sources}") target_link_libraries (monosgen-objects PRIVATE monoapi eglib_api utils_objects sgen_objects metadata_objects) -add_library(monosgen-static STATIC $ $ $ $ $) +add_library(monosgen-static STATIC $ $ $ $ $ $) set_target_properties(monosgen-static PROPERTIES OUTPUT_NAME ${MONO_LIB_NAME}) if(DISABLE_COMPONENTS OR AOT_COMPONENTS) From a9912494f0a5cac7ab911b53cda68046a2beda68 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 28 Mar 2023 12:14:56 -0400 Subject: [PATCH 02/23] include shared containers in mono shared lib, too --- src/mono/mono/mini/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 3c14c803db02ae..843b64f63f6a66 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -353,7 +353,7 @@ endif() set(monosgen-sources "${icu_shim_sources};${mini_sources};${ZLIB_SOURCES}") add_library(monosgen-objects OBJECT "${monosgen-sources}") -target_link_libraries (monosgen-objects PRIVATE monoapi eglib_api utils_objects sgen_objects metadata_objects) +target_link_libraries (monosgen-objects PRIVATE monoapi eglib_api utils_objects sgen_objects metadata_objects shared_container_objects) add_library(monosgen-static STATIC $ $ $ $ $ $) set_target_properties(monosgen-static PROPERTIES OUTPUT_NAME ${MONO_LIB_NAME}) @@ -378,7 +378,7 @@ if(NOT DISABLE_SHARED_LIBS) target_link_libraries(monosgen-shared PRIVATE ucontext) endif(CLR_CMAKE_HOST_ALPINE_LINUX AND TARGET_S390X) set_target_properties(monosgen-shared PROPERTIES OUTPUT_NAME ${MONO_SHARED_LIB_NAME}) - target_link_libraries(monosgen-shared PRIVATE monoapi eglib_objects utils_objects sgen_objects metadata_objects) + target_link_libraries(monosgen-shared PRIVATE monoapi eglib_objects utils_objects sgen_objects metadata_objects shared_container_objects) target_include_directories (monosgen-shared PRIVATE monoapi) if(TARGET_WIN32) # on Windows the import library for the shared mono library will have the same name as the static library, From 87f5d5064e7a2db84a2a9b37425832b807499bce Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 28 Mar 2023 12:29:03 -0400 Subject: [PATCH 03/23] convert mono_seq_point_init_next to use dn_vector_t --- src/mono/mono/metadata/seq-points-data.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/mono/mono/metadata/seq-points-data.c b/src/mono/mono/metadata/seq-points-data.c index b5e50eea056852..5680dde50ef38c 100644 --- a/src/mono/mono/metadata/seq-points-data.c +++ b/src/mono/mono/metadata/seq-points-data.c @@ -9,6 +9,7 @@ */ #include "seq-points-data.h" +#include typedef struct { guint8 *data; @@ -274,24 +275,27 @@ mono_seq_point_init_next (MonoSeqPointInfo* info, SeqPoint sp, SeqPoint* next) int i; guint8* ptr; SeqPointIterator it; - GArray* seq_points = g_array_new (FALSE, TRUE, sizeof (SeqPoint)); + dn_vector_t seq_points = {0,}; + + dn_vector_init_t (&seq_points, SeqPoint); + SeqPointInfoInflated info_inflated = seq_point_info_inflate (info); g_assert (info_inflated.has_debug_data); mono_seq_point_iterator_init (&it, info); while (mono_seq_point_iterator_next (&it)) - g_array_append_vals (seq_points, &it.seq_point, 1); + dn_vector_push_back (&seq_points, it.seq_point); ptr = info_inflated.data + sp.next_offset; for (i = 0; i < sp.next_len; i++) { int next_index; next_index = decode_var_int (ptr, &ptr); - g_assert (next_index < seq_points->len); - memcpy (&next[i], seq_points->data + next_index * sizeof (SeqPoint), sizeof (SeqPoint)); + g_assert (next_index < dn_vector_size (&seq_points)); + memcpy (&next[i], dn_vector_index_t (&seq_points, SeqPoint, next_index), sizeof (SeqPoint)); } - g_array_free (seq_points, TRUE); + dn_vector_dispose (&seq_points); } gboolean From e8c7deaae5f697745f9f559fcf9b1b5c43c4267a Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 28 Mar 2023 12:35:11 -0400 Subject: [PATCH 04/23] [custom-attrs] Use init/dispose instead of alloc/free for dn_vector_t Use a stack allocated container (with heap-allocated data) to avoid one extra allocation --- src/mono/mono/metadata/custom-attrs.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/mono/mono/metadata/custom-attrs.c b/src/mono/mono/metadata/custom-attrs.c index eb27ccd9eb967c..78ea4948e86617 100644 --- a/src/mono/mono/metadata/custom-attrs.c +++ b/src/mono/mono/metadata/custom-attrs.c @@ -1893,7 +1893,7 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig guint32 cols [MONO_CUSTOM_ATTR_SIZE]; MonoTableInfo *ca; MonoCustomAttrInfo *ainfo; - dn_vector_t *attr_array; + dn_vector_t attr_array = {0,}; const char *data; MonoCustomAttrEntry* attr; @@ -1908,8 +1908,7 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig // initial size chosen arbitrarily, but default is 16 which is rather small dn_vector_custom_alloc_params_t vec_params = {0,}; vec_params.capacity = 128; - vec_params.attributes = DN_VECTOR_ATTRIBUTE_MEMORY_INIT; - attr_array = dn_vector_custom_alloc_t (&vec_params, uint32_t); + dn_vector_custom_init_t (&attr_array, &vec_params, uint32_t); while (!mono_metadata_table_bounds_check (image, MONO_TABLE_CUSTOMATTRIBUTE, i + 1)) { if (mono_metadata_decode_row_col (ca, i, MONO_CUSTOM_ATTR_PARENT) != idx) { if (G_LIKELY (!image->has_updates)) { @@ -1921,19 +1920,19 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig continue; } } - dn_vector_push_back (attr_array, i); + dn_vector_push_back (&attr_array, i); ++i; } - len = dn_vector_size (attr_array); + len = dn_vector_size (&attr_array); if (!len) { - dn_vector_free (attr_array); + dn_vector_dispose (&attr_array); return NULL; } ainfo = (MonoCustomAttrInfo *)g_malloc0 (MONO_SIZEOF_CUSTOM_ATTR_INFO + sizeof (MonoCustomAttrEntry) * len); ainfo->num_attrs = len; ainfo->image = image; for (i = 0; i < len; ++i) { - mono_metadata_decode_row (ca, *dn_vector_index_t (attr_array, uint32_t, i), cols, MONO_CUSTOM_ATTR_SIZE); + mono_metadata_decode_row (ca, *dn_vector_index_t (&attr_array, uint32_t, i), cols, MONO_CUSTOM_ATTR_SIZE); mtoken = cols [MONO_CUSTOM_ATTR_TYPE] >> MONO_CUSTOM_ATTR_TYPE_BITS; switch (cols [MONO_CUSTOM_ATTR_TYPE] & MONO_CUSTOM_ATTR_TYPE_MASK) { case MONO_CUSTOM_ATTR_TYPE_METHODDEF: @@ -1954,7 +1953,7 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig mono_error_cleanup (error); error_init (error); } else { - dn_vector_free (attr_array); + dn_vector_dispose (&attr_array); g_free (ainfo); return NULL; } @@ -1964,7 +1963,7 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig attr->data_size = mono_metadata_decode_value (data, &data); attr->data = (guchar*)data; } - dn_vector_free (attr_array); + dn_vector_dispose (&attr_array); return ainfo; } From 2c5c00a4c4508c0c877be110e5096f1811537bd4 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 28 Mar 2023 13:02:49 -0400 Subject: [PATCH 05/23] move container logic to toplevel; add deps to runtime components Add a way to specify target_link_libraries for runtime components. Use it to link in the shared containers. Avoids duplicate linking of the container objects in static linking scenarios. --- src/mono/CMakeLists.txt | 19 +++++++++++++++++++ src/mono/mono/CMakeLists.txt | 2 -- src/mono/mono/component/CMakeLists.txt | 14 ++++++++++++-- src/mono/mono/metadata/CMakeLists.txt | 14 -------------- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 7b57776aa007c7..136c2dbc5e3e67 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -929,6 +929,25 @@ if(NOT DISABLE_LIBS) endif() add_subdirectory("${CLR_SRC_NATIVE_DIR}/public" public_apis) +### Paths and Targets for Shared Containers +set(SHARED_CONTAINERS_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/containers/") +include (${SHARED_CONTAINERS_SOURCE_PATH}containers.cmake) + +set(shared_container_sources "") + +list(APPEND shared_container_sources + ${SHARED_CONTAINER_SOURCES} + ${SHARED_CONTAINER_HEADERS} +) + +addprefix(shared_container_sources ${SHARED_CONTAINERS_SOURCE_PATH} "${shared_container_sources}") + +add_library(shared_container_objects OBJECT ${shared_container_sources}) +target_include_directories(shared_container_objects PUBLIC ${SHARED_CONTAINERS_SOURCE_PATH}) + + +### Mono runtime and components + add_subdirectory(mono) if (ENABLE_MSCORDBI AND NOT TARGET_ARCH STREQUAL "arm64" AND NOT CMAKE_CROSSCOMPILING AND NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT TARGET_WASI AND NOT HOST_MACCAT) add_subdirectory(dlls/mscordbi) diff --git a/src/mono/mono/CMakeLists.txt b/src/mono/mono/CMakeLists.txt index 75815d178ee343..c59470996f5825 100644 --- a/src/mono/mono/CMakeLists.txt +++ b/src/mono/mono/CMakeLists.txt @@ -1,7 +1,5 @@ project(mono) -set(SHARED_CONTAINERS_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/containers/") - set(subdirs eglib utils diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 8a8964efc087e5..fc5388f785382b 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -1,5 +1,4 @@ set(MONO_COMPONENT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../component") -set(SHARED_CONTAINERS_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/containers/") set(SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe/") set(MONO_EVENTPIPE_SHIM_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../eventpipe/") set(MONO_EVENTPIPE_GEN_INCLUDE_PATH "${CMAKE_CURRENT_BINARY_DIR}/eventpipe") @@ -68,7 +67,6 @@ include_directories( ) set(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-sources - ${container_sources} ${eventpipe_sources} ${diagnostic_server_sources} ${MONO_COMPONENT_PATH}/event_pipe.c @@ -86,6 +84,9 @@ set(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-dependencies ${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-gen-sources ) +set(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-link_libraries + shared_container_objects) + # marshal-ilgen list(APPEND components ${MONO_MARSHAL_ILGEN_COMPONENT_NAME} @@ -155,6 +156,9 @@ foreach(component IN LISTS components) add_library("${component}-objects" OBJECT "${${component}-sources}") target_link_libraries("${component}-objects" PRIVATE component_base) target_link_libraries("${component}-objects" PUBLIC eglib_api) + if(DEFINED "${component}-link_libraries") + target_link_libraries("${component}-objects" PRIVATE "${${component}-link_libraries}") + endif() foreach(dependency IN LISTS "${component}-dependencies") add_dependencies("${component}-objects" "${dependency}") endforeach() @@ -170,9 +174,15 @@ if(NOT DISABLE_COMPONENTS AND NOT STATIC_COMPONENTS) # NOTE: keep library naming pattern in sync with RuntimeComponentManifest.targets if(HOST_WIN32) add_library("mono-component-${component}" SHARED "${${component}-sources}") + if(DEFINED "${component}-link_libraries") + target_link_libraries("mono-component-${component}" PRIVATE "${${component}-link_libraries}") + endif() target_compile_definitions("mono-component-${component}" PRIVATE -DCOMPILING_COMPONENT_DYNAMIC;-DMONO_DLL_IMPORT) else() add_library("mono-component-${component}" SHARED $) + if(DEFINED "${component}-link_libraries") + target_link_libraries("mono-component-${component}" PRIVATE "${${component}-link_libraries}") + endif() target_compile_definitions("${component}-objects" PRIVATE -DCOMPILING_COMPONENT_DYNAMIC;-DMONO_DLL_IMPORT) endif() foreach(dependency IN LISTS "${component}-dependencies") diff --git a/src/mono/mono/metadata/CMakeLists.txt b/src/mono/mono/metadata/CMakeLists.txt index a7a9460304bfd8..8f649a67d4c7ec 100644 --- a/src/mono/mono/metadata/CMakeLists.txt +++ b/src/mono/mono/metadata/CMakeLists.txt @@ -1,19 +1,5 @@ project(metadata C) -include (${SHARED_CONTAINERS_SOURCE_PATH}containers.cmake) - -set(shared_container_sources "") - -list(APPEND shared_container_sources - ${SHARED_CONTAINER_SOURCES} - ${SHARED_CONTAINER_HEADERS} -) - -addprefix(shared_container_sources ${SHARED_CONTAINERS_SOURCE_PATH} "${shared_container_sources}") - -add_library(shared_container_objects OBJECT ${shared_container_sources}) -target_include_directories(shared_container_objects PUBLIC ${SHARED_CONTAINERS_SOURCE_PATH}) - # # This library contains the icall tables if the runtime was configured with DISABLE_ICALL_TABLES # From 301c2a47997906e395db24a859c5feda66643453 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 28 Mar 2023 14:31:44 -0400 Subject: [PATCH 06/23] fix windows build --- src/mono/mono/metadata/seq-points-data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/metadata/seq-points-data.c b/src/mono/mono/metadata/seq-points-data.c index 5680dde50ef38c..2894a88a499553 100644 --- a/src/mono/mono/metadata/seq-points-data.c +++ b/src/mono/mono/metadata/seq-points-data.c @@ -291,7 +291,7 @@ mono_seq_point_init_next (MonoSeqPointInfo* info, SeqPoint sp, SeqPoint* next) for (i = 0; i < sp.next_len; i++) { int next_index; next_index = decode_var_int (ptr, &ptr); - g_assert (next_index < dn_vector_size (&seq_points)); + g_assert (next_index < GUINT_TO_INT (dn_vector_size (&seq_points))); memcpy (&next[i], dn_vector_index_t (&seq_points, SeqPoint, next_index), sizeof (SeqPoint)); } From ec1bf21c86d7eabb57289e9d2bc3559383c927c1 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 28 Mar 2023 16:00:23 -0400 Subject: [PATCH 07/23] fix Darwin frameworks builds --- src/mono/mono/mini/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 843b64f63f6a66..12c4280224062c 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -435,7 +435,7 @@ if(NOT DISABLE_SHARED_LIBS) endif() add_library(${frameworkconfig} SHARED $) target_compile_definitions(${frameworkconfig} PRIVATE -DMONO_DLL_EXPORT) - target_link_libraries(${frameworkconfig} PRIVATE monoapi eglib_objects utils_objects sgen_objects metadata_objects) + target_link_libraries(${frameworkconfig} PRIVATE monoapi eglib_objects utils_objects sgen_objects metadata_objects shared_container_objects) target_link_libraries(${frameworkconfig} PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) if(ICU_LDFLAGS) From 473df840bd310765e7b1696cf5e3f25bf8d43602 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 28 Mar 2023 15:29:06 -0400 Subject: [PATCH 08/23] replace 2 uses of GArray in interp/transform.c --- src/mono/mono/mini/CMakeLists.txt | 2 +- src/mono/mono/mini/interp/transform.c | 32 ++++++++++++++------------- src/mono/mono/mini/interp/transform.h | 3 ++- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 12c4280224062c..8f56ea8cbe528b 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -296,7 +296,7 @@ endif() if(ENABLE_INTERP_LIB) add_library(mono-ee-interp STATIC "${interp_sources}") -target_link_libraries(mono-ee-interp PRIVATE monoapi eglib_api) +target_link_libraries(mono-ee-interp PRIVATE monoapi eglib_api shared_container_objects) target_include_directories(mono-ee-interp PRIVATE ${PROJECT_BINARY_DIR}/../.. ${PROJECT_SOURCE_DIR}/../.. ${PROJECT_SOURCE_DIR}/..) diff --git a/src/mono/mono/mini/interp/transform.c b/src/mono/mono/mini/interp/transform.c index 895b5cc6bda071..87a93942e71cce 100644 --- a/src/mono/mono/mini/interp/transform.c +++ b/src/mono/mono/mini/interp/transform.c @@ -9,6 +9,7 @@ #include "config.h" #include +#include #include #include #include @@ -3879,7 +3880,7 @@ get_basic_blocks (TransformData *td, MonoMethodHeader *header, gboolean make_lis } static void -interp_save_debug_info (InterpMethod *rtm, MonoMethodHeader *header, TransformData *td, GArray *line_numbers) +interp_save_debug_info (InterpMethod *rtm, MonoMethodHeader *header, TransformData *td, dn_vector_t *line_numbers) { MonoDebugMethodJitInfo *dinfo; @@ -3899,7 +3900,7 @@ interp_save_debug_info (InterpMethod *rtm, MonoMethodHeader *header, TransformDa dinfo->code_size = GPTRDIFF_TO_UINT32 (td->new_code_end - td->new_code); dinfo->epilogue_begin = 0; dinfo->has_var_info = TRUE; - dinfo->num_line_numbers = line_numbers->len; + dinfo->num_line_numbers = dn_vector_size (line_numbers); dinfo->line_numbers = g_new0 (MonoDebugLineNumberEntry, dinfo->num_line_numbers); for (guint32 i = 0; i < dinfo->num_params; i++) { @@ -3912,7 +3913,7 @@ interp_save_debug_info (InterpMethod *rtm, MonoMethodHeader *header, TransformDa } for (guint32 i = 0; i < dinfo->num_line_numbers; i++) - dinfo->line_numbers [i] = g_array_index (line_numbers, MonoDebugLineNumberEntry, i); + dinfo->line_numbers [i] = *dn_vector_index_t (line_numbers, MonoDebugLineNumberEntry, i); mono_debug_add_method (rtm->method, dinfo, NULL); mono_debug_free_method_jit_info (dinfo); @@ -3939,7 +3940,8 @@ recursively_make_pred_seq_points (TransformData *td, InterpBasicBlock *bb) { SeqPoint ** const MONO_SEQ_SEEN_LOOP = (SeqPoint**)GINT_TO_POINTER(-1); - GArray *predecessors = g_array_new (FALSE, TRUE, sizeof (gpointer)); + dn_vector_t predecessors = {0,}; + dn_vector_init_t (&predecessors, SeqPoint*); GHashTable *seen = g_hash_table_new_full (g_direct_hash, NULL, NULL, NULL); // Insert/remove sentinel into the memoize table to detect loops containing bb @@ -3950,7 +3952,7 @@ recursively_make_pred_seq_points (TransformData *td, InterpBasicBlock *bb) // This bb has the last seq point, append it and continue if (in_bb->last_seq_point != NULL) { - predecessors = g_array_append_val (predecessors, in_bb->last_seq_point); + dn_vector_push_back (&predecessors, in_bb->last_seq_point); continue; } @@ -3970,8 +3972,7 @@ recursively_make_pred_seq_points (TransformData *td, InterpBasicBlock *bb) // Union sequence points with incoming bb's for (guint j = 0; j < in_bb->num_pred_seq_points; j++) { if (!g_hash_table_lookup (seen, in_bb->pred_seq_points [j])) { - g_array_append_val (predecessors, in_bb->pred_seq_points [j]); - g_hash_table_insert (seen, in_bb->pred_seq_points [j], (gpointer)&MONO_SEQ_SEEN_LOOP); + dn_vector_push_back (&predecessors, in_bb->pred_seq_points [j]); } } // predecessors = g_array_append_vals (predecessors, in_bb->pred_seq_points, in_bb->num_pred_seq_points); @@ -3979,16 +3980,17 @@ recursively_make_pred_seq_points (TransformData *td, InterpBasicBlock *bb) g_hash_table_destroy (seen); - if (predecessors->len != 0) { - bb->pred_seq_points = (SeqPoint**)mono_mempool_alloc0 (td->mempool, sizeof (SeqPoint *) * predecessors->len); - bb->num_pred_seq_points = predecessors->len; + if (!dn_vector_empty (&predecessors)) { + uint32_t count = dn_vector_size (&predecessors); + bb->pred_seq_points = (SeqPoint**)mono_mempool_alloc0 (td->mempool, sizeof (SeqPoint *) * count); + bb->num_pred_seq_points = count; for (guint newer = 0; newer < bb->num_pred_seq_points; newer++) { - bb->pred_seq_points [newer] = (SeqPoint*)g_array_index (predecessors, gpointer, newer); + bb->pred_seq_points [newer] = *dn_vector_index_t (&predecessors, SeqPoint*, newer); } } - g_array_free (predecessors, TRUE); + dn_vector_dispose (&predecessors); } static void @@ -8181,7 +8183,7 @@ emit_compacted_instruction (TransformData *td, guint16* start_ip, InterpInst *in MonoDebugLineNumberEntry lne; lne.native_offset = GPTRDIFF_TO_UINT32 ((guint8*)start_ip - (guint8*)td->new_code); lne.il_offset = ins->il_offset; - g_array_append_val (td->line_numbers, lne); + dn_vector_push_back (td->line_numbers, lne); } if (opcode == MINT_NOP || opcode == MINT_DEF || opcode == MINT_DUMMY_USE) @@ -10815,7 +10817,7 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG td->stack_capacity = header->max_stack + 1; td->sp = td->stack; td->max_stack_height = 0; - td->line_numbers = g_array_new (FALSE, TRUE, sizeof (MonoDebugLineNumberEntry)); + td->line_numbers = dn_vector_alloc_t (MonoDebugLineNumberEntry); td->current_il_offset = -1; generate_code (td, method, header, generic_context, error); @@ -10951,7 +10953,7 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG #endif g_ptr_array_free (td->seq_points, TRUE); if (td->line_numbers) - g_array_free (td->line_numbers, TRUE); + dn_vector_free (td->line_numbers); g_slist_free (td->imethod_items); mono_mempool_destroy (td->mempool); if (retry_compilation) diff --git a/src/mono/mono/mini/interp/transform.h b/src/mono/mono/mini/interp/transform.h index 7b3e8cf1f2d760..a70442044c1bbc 100644 --- a/src/mono/mono/mini/interp/transform.h +++ b/src/mono/mono/mini/interp/transform.h @@ -1,5 +1,6 @@ #ifndef __MONO_MINI_INTERP_TRANSFORM_H__ #define __MONO_MINI_INTERP_TRANSFORM_H__ +#include #include #include #include "interp-internals.h" @@ -249,7 +250,7 @@ typedef struct GList *basic_blocks; GPtrArray *relocs; gboolean verbose_level; - GArray *line_numbers; + dn_vector_t *line_numbers; gboolean prof_coverage; MonoProfilerCoverageInfo *coverage_info; GList *dont_inline; From 5e4b4534e04beaaa3cf2b1d729a86545e9b40996 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 28 Mar 2023 15:33:30 -0400 Subject: [PATCH 09/23] replace a use of GArray in mini/seq-points.c --- src/mono/mono/mini/seq-points.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/mono/mono/mini/seq-points.c b/src/mono/mono/mini/seq-points.c index b998c6c86d97b6..f378432690b549 100644 --- a/src/mono/mono/mini/seq-points.c +++ b/src/mono/mono/mini/seq-points.c @@ -9,6 +9,8 @@ * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ +#include +#include #include "mini.h" #include "mini-runtime.h" #include "seq-points.h" @@ -33,7 +35,9 @@ recursively_make_pred_seq_points (MonoCompile *cfg, MonoBasicBlock *bb) { const gpointer MONO_SEQ_SEEN_LOOP = GINT_TO_POINTER(-1); - GArray *predecessors = g_array_new (FALSE, TRUE, sizeof (gpointer)); + + dn_vector_t predecessors = {0,}; + dn_vector_init_t (&predecessors, MonoInst*); GHashTable *seen = g_hash_table_new_full (g_direct_hash, NULL, NULL, NULL); // Insert/remove sentinel into the memoize table to detect loops containing bb @@ -44,7 +48,7 @@ recursively_make_pred_seq_points (MonoCompile *cfg, MonoBasicBlock *bb) // This bb has the last seq point, append it and continue if (in_bb->last_seq_point != NULL) { - predecessors = g_array_append_val (predecessors, in_bb->last_seq_point); + dn_vector_push_back (&predecessors, in_bb->last_seq_point); continue; } @@ -64,7 +68,7 @@ recursively_make_pred_seq_points (MonoCompile *cfg, MonoBasicBlock *bb) // Union sequence points with incoming bb's for (guint j = 0; j < in_bb->num_pred_seq_points; j++) { if (!g_hash_table_lookup (seen, in_bb->pred_seq_points [j])) { - g_array_append_val (predecessors, in_bb->pred_seq_points [j]); + dn_vector_push_back (&predecessors, in_bb->pred_seq_points [j]); g_hash_table_insert (seen, in_bb->pred_seq_points [j], (gpointer)&MONO_SEQ_SEEN_LOOP); } } @@ -73,16 +77,17 @@ recursively_make_pred_seq_points (MonoCompile *cfg, MonoBasicBlock *bb) g_hash_table_destroy (seen); - if (predecessors->len != 0) { - bb->pred_seq_points = (MonoInst **)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoInst *) * predecessors->len); - bb->num_pred_seq_points = predecessors->len; + if (!dn_vector_empty (&predecessors)) { + uint32_t count = dn_vector_size (&predecessors); + bb->pred_seq_points = (MonoInst **)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoInst *) * count); + bb->num_pred_seq_points = count; for (guint newer = 0; newer < bb->num_pred_seq_points; newer++) { - bb->pred_seq_points [newer] = g_array_index(predecessors, MonoInst*, newer); + bb->pred_seq_points [newer] = *dn_vector_index_t (&predecessors, MonoInst*, newer); } } - g_array_free (predecessors, TRUE); + dn_vector_dispose (&predecessors); } static void From 6029c3355b82c6b1328b5927a1bc144da237ec25 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 28 Mar 2023 15:41:49 -0400 Subject: [PATCH 10/23] replace use of GArray for debug-mini --- src/mono/mono/mini/debug-mini.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mono/mono/mini/debug-mini.c b/src/mono/mono/mini/debug-mini.c index f307d08bf7f511..2ad9345880eb29 100644 --- a/src/mono/mono/mini/debug-mini.c +++ b/src/mono/mono/mini/debug-mini.c @@ -12,6 +12,7 @@ #include "mini-runtime.h" #include #include "config.h" +#include #include #include #include @@ -30,7 +31,7 @@ typedef struct { typedef struct { MonoDebugMethodJitInfo *jit; - GArray *line_numbers; + dn_vector_t *line_numbers; guint32 has_line_numbers; guint32 breakpoint_id; } MiniDebugMethodInfo; @@ -43,7 +44,7 @@ record_line_number (MiniDebugMethodInfo *info, guint32 address, guint32 offset) lne.native_offset = address; lne.il_offset = offset; - g_array_append_val (info->line_numbers, lne); + dn_vector_push_back (info->line_numbers, lne); } @@ -78,7 +79,7 @@ mono_debug_open_method (MonoCompile *cfg) g_assert (header); info->jit = jit = g_new0 (MonoDebugMethodJitInfo, 1); - info->line_numbers = g_array_new (FALSE, TRUE, sizeof (MonoDebugLineNumberEntry)); + info->line_numbers = dn_vector_alloc_t (MonoDebugLineNumberEntry); jit->num_locals = header->num_locals; jit->locals = g_new0 (MonoDebugVarInfo, jit->num_locals); } @@ -269,11 +270,11 @@ mono_debug_close_method (MonoCompile *cfg) } } - jit->num_line_numbers = info->line_numbers->len; + jit->num_line_numbers = dn_vector_size (info->line_numbers); jit->line_numbers = g_new0 (MonoDebugLineNumberEntry, jit->num_line_numbers); for (guint32 i = 0; i < jit->num_line_numbers; i++) - jit->line_numbers [i] = g_array_index (info->line_numbers, MonoDebugLineNumberEntry, i); + jit->line_numbers [i] = *dn_vector_index_t (info->line_numbers, MonoDebugLineNumberEntry, i); mono_debug_add_method (cfg->method_to_register, jit, NULL); @@ -291,7 +292,7 @@ mono_debug_free_method (MonoCompile *cfg) info = (MiniDebugMethodInfo *) cfg->debug_info; if (info) { if (info->line_numbers) - g_array_free (info->line_numbers, TRUE); + dn_vector_free (info->line_numbers); g_free (info); cfg->debug_info = NULL; } From 0082829ffb47b670193dc107cf13728a67482a52 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 4 Apr 2023 16:04:42 -0400 Subject: [PATCH 11/23] WIP: start a dn_checkfail helper like g_assertf Will need the same kind of output redirection that mono does for Android and iOS. --- src/native/containers/containers.cmake | 2 ++ src/native/containers/dn-compiler.h | 29 ++++++++++++++++++++++++++ src/native/containers/dn-rt.h | 17 +++++++++++++++ src/native/containers/dn-utils.h | 25 +++++++++++++++------- 4 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 src/native/containers/dn-compiler.h create mode 100644 src/native/containers/dn-rt.h diff --git a/src/native/containers/containers.cmake b/src/native/containers/containers.cmake index dd8829e3bf0426..b1102220939ce3 100644 --- a/src/native/containers/containers.cmake +++ b/src/native/containers/containers.cmake @@ -12,9 +12,11 @@ list(APPEND SHARED_CONTAINER_SOURCES list(APPEND SHARED_CONTAINER_HEADERS dn-allocator.h + dn-compiler.h dn-fwd-list.h dn-list.h dn-queue.h + dn-rt.h dn-sort-frag.inc dn-umap.h dn-umap-t.h diff --git a/src/native/containers/dn-compiler.h b/src/native/containers/dn-compiler.h new file mode 100644 index 00000000000000..cb1867b7e63756 --- /dev/null +++ b/src/native/containers/dn-compiler.h @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#ifndef __DN_COMPILER_H__ +#define __DN_COMPILER_H__ + +#if defined(__GNUC__) && (__GNUC__ > 2) +#define DN_LIKELY(expr) (__builtin_expect ((expr) != 0, 1)) +#define DN_UNLIKELY(expr) (__builtin_expect ((expr) != 0, 0)) +#else +#define DN_LIKELY(x) (x) +#define DN_UNLIKELY(x) (x) +#endif + +#if defined(__GNUC__) +#define DN_NORETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define DN_NORETURN __declspec(noreturn) +#else +#define DN_NORETURN /*empty*/ +#endif + +#if defined(__GNUC__) +#define DN_ATTR_FORMAT_PRINTF(fmt_pos,arg_pos) __attribute((__format__(__printf__,fmt_pos,arg_pos))) +#else +#define DN_ATTR_FORMAT_PRINTF(fmt_pos,arg_pos) /*empty*/ +#endif + +#endif /* __DN_COMPILER_H__ */ diff --git a/src/native/containers/dn-rt.h b/src/native/containers/dn-rt.h new file mode 100644 index 00000000000000..797891d1f89d66 --- /dev/null +++ b/src/native/containers/dn-rt.h @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#ifndef __DN_RT_H__ +#define __DN_RT_H__ + +#include + +#include + +DN_NORETURN static void +dn_rt_failfast_msgv(const char* fmt, va_list ap); + +DN_NORETURN static void +dn_rt_failfast_msg(const char* file, int line); + +#endif /* __DN_RT_H__ */ diff --git a/src/native/containers/dn-utils.h b/src/native/containers/dn-utils.h index 7c07f5f8df7ecb..ebdbb7e3c50161 100644 --- a/src/native/containers/dn-utils.h +++ b/src/native/containers/dn-utils.h @@ -15,6 +15,8 @@ #include #include +#include + #if defined(_DEBUG) #include #define DN_ASSERT(x) assert(x) @@ -36,14 +38,6 @@ #define DN_CALLBACK_CALLTYPE #endif -#if defined(__GNUC__) && (__GNUC__ > 2) -#define DN_LIKELY(expr) (__builtin_expect ((expr) != 0, 1)) -#define DN_UNLIKELY(expr) (__builtin_expect ((expr) != 0, 0)) -#else -#define DN_LIKELY(x) (x) -#define DN_UNLIKELY(x) (x) -#endif - #define DN_UNREFERENCED_PARAMETER(expr) (void)(expr) // Until C11 support, use typedef expression for static assertion. @@ -76,4 +70,19 @@ dn_safe_uint32_t_add (uint32_t lhs, uint32_t rhs, uint32_t *result) return true; } +DN_NORETURN DN_ATTR_FORMAT_PRINTF(1,2) static inline void +dn_failfast_msg(const char* fmt, ...) +{ + va_list args; + va_start (args, fmt); + dn_rt_failfast_msgv(fmt, args); + va_end (args); +} + +#ifdef DISABLE_ASSERT_MESSAGES +#define dn_checkfail(cond, format, ...) (DN_LIKELY((cond)) ? 1 : (dn_rt_failfast_nomsg (__FILE__, __LINE__), 0)) +#else +#define dn_checkfail(cond,format,...) (DN_LIKELY((cond)) ? 1 : (dn_failfast_msg ("* Assertion at %s:%d, condition `%s' not met, function:%s, " format "\n", __FILE__, __LINE__, #cond, __func__, ##__VA_ARGS__), 0)) +#endif + #endif /* __DN_UTILS_H__ */ From 1cf3d19dca09ffa9cb9234ea8a9fdbdc474cafce Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 5 Apr 2023 11:48:38 -0400 Subject: [PATCH 12/23] remove some unused assignments from eventpipe.cmake fragment We get the shared containers via a dependency on the containers object library now --- src/mono/mono/eventpipe/eventpipe.cmake | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/mono/mono/eventpipe/eventpipe.cmake b/src/mono/mono/eventpipe/eventpipe.cmake index cd0d4a6f123c82..303eeeb61d963c 100644 --- a/src/mono/mono/eventpipe/eventpipe.cmake +++ b/src/mono/mono/eventpipe/eventpipe.cmake @@ -26,17 +26,6 @@ if(ENABLE_PERFTRACING) add_definitions(-DBIGENDIAN) endif (TARGET_S390X) - include (${SHARED_CONTAINERS_SOURCE_PATH}containers.cmake) - - set(container_sources "") - - list(APPEND container_sources - ${SHARED_CONTAINER_SOURCES} - ${SHARED_CONTAINER_HEADERS} - ) - - addprefix(container_sources ${SHARED_CONTAINERS_SOURCE_PATH} "${container_sources}") - include (${SHARED_EVENTPIPE_SOURCE_PATH}eventpipe.cmake) set(MONO_EVENTPIPE_SHIM_SOURCES "") From e5d2108b2112a4015ed05d2c0f496a8929d26faf Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 5 Apr 2023 11:49:26 -0400 Subject: [PATCH 13/23] make containers a normal sub-project for Mono Preliminary step before adding runtime-specific container code --- src/mono/CMakeLists.txt | 4 ---- src/mono/mono/CMakeLists.txt | 1 + src/mono/mono/containers/CMakeLists.txt | 5 +++++ 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 src/mono/mono/containers/CMakeLists.txt diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 136c2dbc5e3e67..658a439edb4144 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -942,10 +942,6 @@ list(APPEND shared_container_sources addprefix(shared_container_sources ${SHARED_CONTAINERS_SOURCE_PATH} "${shared_container_sources}") -add_library(shared_container_objects OBJECT ${shared_container_sources}) -target_include_directories(shared_container_objects PUBLIC ${SHARED_CONTAINERS_SOURCE_PATH}) - - ### Mono runtime and components add_subdirectory(mono) diff --git a/src/mono/mono/CMakeLists.txt b/src/mono/mono/CMakeLists.txt index c59470996f5825..b8ce461272eeff 100644 --- a/src/mono/mono/CMakeLists.txt +++ b/src/mono/mono/CMakeLists.txt @@ -1,6 +1,7 @@ project(mono) set(subdirs + containers eglib utils sgen diff --git a/src/mono/mono/containers/CMakeLists.txt b/src/mono/mono/containers/CMakeLists.txt new file mode 100644 index 00000000000000..6e3877ad77415f --- /dev/null +++ b/src/mono/mono/containers/CMakeLists.txt @@ -0,0 +1,5 @@ +project(containers C) + +add_library(shared_container_objects OBJECT ${shared_container_sources}) +target_include_directories(shared_container_objects PUBLIC ${SHARED_CONTAINERS_SOURCE_PATH}) + From adcb5a671333ed70fa6456ec89ef923003391541 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 5 Apr 2023 14:41:53 -0400 Subject: [PATCH 14/23] Add mono implementation of dn-rt.h --- src/mono/CMakeLists.txt | 13 ------------ src/mono/mono/CMakeLists.txt | 2 +- src/mono/mono/containers/CMakeLists.txt | 25 +++++++++++++++++++++-- src/mono/mono/containers/dn-rt-mono.h | 27 +++++++++++++++++++++++++ src/mono/mono/containers/dn-rt-utils.c | 18 +++++++++++++++++ src/native/containers/dn-rt.h | 11 +++++++++- 6 files changed, 79 insertions(+), 17 deletions(-) create mode 100644 src/mono/mono/containers/dn-rt-mono.h create mode 100644 src/mono/mono/containers/dn-rt-utils.c diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 658a439edb4144..a9efed905158cd 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -929,19 +929,6 @@ if(NOT DISABLE_LIBS) endif() add_subdirectory("${CLR_SRC_NATIVE_DIR}/public" public_apis) -### Paths and Targets for Shared Containers -set(SHARED_CONTAINERS_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/containers/") -include (${SHARED_CONTAINERS_SOURCE_PATH}containers.cmake) - -set(shared_container_sources "") - -list(APPEND shared_container_sources - ${SHARED_CONTAINER_SOURCES} - ${SHARED_CONTAINER_HEADERS} -) - -addprefix(shared_container_sources ${SHARED_CONTAINERS_SOURCE_PATH} "${shared_container_sources}") - ### Mono runtime and components add_subdirectory(mono) diff --git a/src/mono/mono/CMakeLists.txt b/src/mono/mono/CMakeLists.txt index b8ce461272eeff..15321254966934 100644 --- a/src/mono/mono/CMakeLists.txt +++ b/src/mono/mono/CMakeLists.txt @@ -1,8 +1,8 @@ project(mono) set(subdirs - containers eglib + containers utils sgen metadata diff --git a/src/mono/mono/containers/CMakeLists.txt b/src/mono/mono/containers/CMakeLists.txt index 6e3877ad77415f..4b169efcf360b6 100644 --- a/src/mono/mono/containers/CMakeLists.txt +++ b/src/mono/mono/containers/CMakeLists.txt @@ -1,5 +1,26 @@ project(containers C) -add_library(shared_container_objects OBJECT ${shared_container_sources}) -target_include_directories(shared_container_objects PUBLIC ${SHARED_CONTAINERS_SOURCE_PATH}) +### Paths and Targets for Shared Containers +set(SHARED_CONTAINERS_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/containers/") +include (${SHARED_CONTAINERS_SOURCE_PATH}containers.cmake) + +set(shared_container_sources "") + +list(APPEND shared_container_sources + ${SHARED_CONTAINER_SOURCES} + ${SHARED_CONTAINER_HEADERS} +) + +addprefix(shared_container_sources ${SHARED_CONTAINERS_SOURCE_PATH} "${shared_container_sources}") + +set(rt_mono_container_sources + dn-rt-mono.h + dn-rt-utils.c) + +add_library(shared_container_objects OBJECT ${shared_container_sources} ${rt_mono_container_sources}) +target_link_libraries(shared_container_objects PRIVATE eglib_api) +target_include_directories(shared_container_objects PUBLIC ${SHARED_CONTAINERS_SOURCE_PATH} .) +# to pick up config.h +target_include_directories(shared_container_objects PRIVATE + ${PROJECT_BINARY_DIR}/../..) diff --git a/src/mono/mono/containers/dn-rt-mono.h b/src/mono/mono/containers/dn-rt-mono.h new file mode 100644 index 00000000000000..b9cfea00a26b19 --- /dev/null +++ b/src/mono/mono/containers/dn-rt-mono.h @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#ifndef __DN_RT_MONO_H__ +#define __DN_RT_MONO_H__ + +#include + +DN_NORETURN void +dn_rt_mono_failfast_msgv (const char* fmt, va_list ap); + +DN_NORETURN void +dn_rt_mono_failfast_nomsg (const char* file, int line); + +DN_NORETURN static inline void +dn_rt_failfast_msgv(const char* fmt, va_list ap) +{ + dn_rt_mono_failfast_msgv (fmt, ap); +} + +DN_NORETURN static inline void +dn_rt_failfast_nomsg(const char* fmt, int line) +{ + dn_rt_mono_failfast_nomsg(fmt, line); +} + +#endif /* __DN_RT_MONO_H__ */ diff --git a/src/mono/mono/containers/dn-rt-utils.c b/src/mono/mono/containers/dn-rt-utils.c new file mode 100644 index 00000000000000..fc0555009c6a89 --- /dev/null +++ b/src/mono/mono/containers/dn-rt-utils.c @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#include +#include +#include + +void +dn_rt_mono_failfast_msgv (const char *format, va_list ap) +{ + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, ap); +} + +void +dn_rt_mono_failfast_nosmg (const char *file, int line) +{ + mono_assertion_message_disabled (file, line); +} diff --git a/src/native/containers/dn-rt.h b/src/native/containers/dn-rt.h index 797891d1f89d66..02eb225425a0b9 100644 --- a/src/native/containers/dn-rt.h +++ b/src/native/containers/dn-rt.h @@ -12,6 +12,15 @@ DN_NORETURN static void dn_rt_failfast_msgv(const char* fmt, va_list ap); DN_NORETURN static void -dn_rt_failfast_msg(const char* file, int line); +dn_rt_failfast_nomsg(const char* file, int line); + +#if defined(FEATUERE_CORECLR) +// TODO: add CoreCLR runtime impl +#elif defined(FEATURE_NATIVEAOT) +// TODO: add NativeAOT runtime impl +#else +// Mono +#include +#endif #endif /* __DN_RT_H__ */ From 0eb1fd51b15281edc6c2698f571a321a09bbcd77 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 5 Apr 2023 14:46:35 -0400 Subject: [PATCH 15/23] check dn_vector_alloc_t result --- src/mono/mono/mini/debug-mini.c | 1 + src/mono/mono/mini/interp/transform.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/mono/mono/mini/debug-mini.c b/src/mono/mono/mini/debug-mini.c index 2ad9345880eb29..77008c70d14db4 100644 --- a/src/mono/mono/mini/debug-mini.c +++ b/src/mono/mono/mini/debug-mini.c @@ -80,6 +80,7 @@ mono_debug_open_method (MonoCompile *cfg) info->jit = jit = g_new0 (MonoDebugMethodJitInfo, 1); info->line_numbers = dn_vector_alloc_t (MonoDebugLineNumberEntry); + dn_checkfail (info->line_numbers != NULL, "Allocation failed"); jit->num_locals = header->num_locals; jit->locals = g_new0 (MonoDebugVarInfo, jit->num_locals); } diff --git a/src/mono/mono/mini/interp/transform.c b/src/mono/mono/mini/interp/transform.c index 87a93942e71cce..75994598456c72 100644 --- a/src/mono/mono/mini/interp/transform.c +++ b/src/mono/mono/mini/interp/transform.c @@ -10818,6 +10818,7 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG td->sp = td->stack; td->max_stack_height = 0; td->line_numbers = dn_vector_alloc_t (MonoDebugLineNumberEntry); + dn_checkfail (td->line_numbers != NULL, "Allocation failed"); td->current_il_offset = -1; generate_code (td, method, header, generic_context, error); From 15d11fd9ec6a0fe75ee38ccc7a3175fb07a2305f Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 5 Apr 2023 18:21:59 -0400 Subject: [PATCH 16/23] fix coreclr build --- src/native/containers/dn-rt.h | 4 ++-- src/native/containers/dn-utils.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/native/containers/dn-rt.h b/src/native/containers/dn-rt.h index 02eb225425a0b9..ac9f2e9089369e 100644 --- a/src/native/containers/dn-rt.h +++ b/src/native/containers/dn-rt.h @@ -6,7 +6,7 @@ #include -#include +#include "dn-compiler.h" DN_NORETURN static void dn_rt_failfast_msgv(const char* fmt, va_list ap); @@ -20,7 +20,7 @@ dn_rt_failfast_nomsg(const char* file, int line); // TODO: add NativeAOT runtime impl #else // Mono -#include +#include "dn-rt-mono.h" #endif #endif /* __DN_RT_H__ */ diff --git a/src/native/containers/dn-utils.h b/src/native/containers/dn-utils.h index ebdbb7e3c50161..110773d5b2452b 100644 --- a/src/native/containers/dn-utils.h +++ b/src/native/containers/dn-utils.h @@ -15,7 +15,7 @@ #include #include -#include +#include "dn-rt.h" #if defined(_DEBUG) #include From 71fb5c28c8b8ae3100c20682bafafd2c6c058e7f Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 5 Apr 2023 22:15:55 -0400 Subject: [PATCH 17/23] add placeholder dn_rt functions for coreclr and nativeaot --- src/native/containers/dn-rt.h | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/native/containers/dn-rt.h b/src/native/containers/dn-rt.h index ac9f2e9089369e..b181176f25ca55 100644 --- a/src/native/containers/dn-rt.h +++ b/src/native/containers/dn-rt.h @@ -14,10 +14,43 @@ dn_rt_failfast_msgv(const char* fmt, va_list ap); DN_NORETURN static void dn_rt_failfast_nomsg(const char* file, int line); -#if defined(FEATUERE_CORECLR) +#if defined(FEATURE_CORECLR) +#include "pal.h" // TODO: add CoreCLR runtime impl +DN_NORETURN static inline void +dn_rt_failfast_msgv(const char* fmt, va_list ap) +{ + RaiseFailFastException(nullptr, nullptr, 0); +} + +DN_NORETURN static inline void +dn_rt_failfast_nomsg(const char* file, int line) +{ + RaiseFailFastException(nullptr, nullptr, 0); +} + #elif defined(FEATURE_NATIVEAOT) +#include "common.h" +#include "gcenv.h" +#include "CommonTypes.h" +#include "CommonMacros.h" +#include "PalRedhawkCommon.h" +#include "PalRedhawk.h" +#include "rhassert.h" // TODO: add NativeAOT runtime impl +DN_NORETURN static inline void +dn_rt_failfast_msgv(const char* fmt, va_list ap) +{ + RhFailFast(); + UNREACHABLE(); +} + +DN_NORETURN static inline void +dn_rt_failfast_nomsg(const char* file, int line) +{ + RhFailFast(); + UNREACHABLE(); +} #else // Mono #include "dn-rt-mono.h" From fa05fbf73e2b8de530d6253630f16d4837669f8b Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 5 Apr 2023 22:29:28 -0400 Subject: [PATCH 18/23] fix mono build --- src/mono/mono/containers/dn-rt-utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/containers/dn-rt-utils.c b/src/mono/mono/containers/dn-rt-utils.c index fc0555009c6a89..df1bc8dc51d0a1 100644 --- a/src/mono/mono/containers/dn-rt-utils.c +++ b/src/mono/mono/containers/dn-rt-utils.c @@ -9,10 +9,11 @@ void dn_rt_mono_failfast_msgv (const char *format, va_list ap) { g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, ap); + g_assert_not_reached (); } void -dn_rt_mono_failfast_nosmg (const char *file, int line) +dn_rt_mono_failfast_nomsg (const char *file, int line) { mono_assertion_message_disabled (file, line); } From 695575f68db1ec37f5e9df4bdf4bcdc126e47456 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 5 Apr 2023 23:30:04 -0400 Subject: [PATCH 19/23] maybe fix coreclr/nativeaot windows build? --- src/native/containers/dn-rt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/containers/dn-rt.h b/src/native/containers/dn-rt.h index b181176f25ca55..e248db7f998514 100644 --- a/src/native/containers/dn-rt.h +++ b/src/native/containers/dn-rt.h @@ -31,7 +31,7 @@ dn_rt_failfast_nomsg(const char* file, int line) #elif defined(FEATURE_NATIVEAOT) #include "common.h" -#include "gcenv.h" +#include "gcenv.base.h" #include "CommonTypes.h" #include "CommonMacros.h" #include "PalRedhawkCommon.h" From c4a28a5e1bce8a9996fe6694213a8f37e11d2794 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Thu, 6 Apr 2023 00:26:12 -0400 Subject: [PATCH 20/23] move nativeaot shims to a separate file fix windows include problems, I guess? --- .../Runtime/eventpipe/CMakeLists.txt | 10 +++++++ .../nativeaot/Runtime/eventpipe/dn-rt-aot.cpp | 27 +++++++++++++++++++ .../nativeaot/Runtime/eventpipe/dn-rt-aot.h | 25 +++++++++++++++++ src/native/containers/dn-rt.h | 22 +-------------- 4 files changed, 63 insertions(+), 21 deletions(-) create mode 100644 src/coreclr/nativeaot/Runtime/eventpipe/dn-rt-aot.cpp create mode 100644 src/coreclr/nativeaot/Runtime/eventpipe/dn-rt-aot.h diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt index d91a084c01a6fc..45a34b274a538d 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt @@ -81,6 +81,14 @@ list(APPEND AOT_EVENTPIPE_MANAGED_TO_NATIVE_SOURCES ${RUNTIME_DIR}/EnabledEventPipeInterface.cpp ) +set(CONTAINER_SHIM_SOURCES + ${AOT_EVENTPIPE_SHIM_DIR}/dn-rt-aot.cpp +) + +set(CONTAINER_SHIM_HEADERS + ${AOT_EVENTPIPE_SHIM_DIR}/dn-rt-aot.h +) + list(APPEND EVENTPIPE_SOURCES ${AOT_EVENTPIPE_SHIM_SOURCES} ${AOT_EVENTPIPE_SHIM_HEADERS} @@ -88,6 +96,8 @@ list(APPEND EVENTPIPE_SOURCES ${SHARED_EVENTPIPE_CONFIG_HEADERS} ${CONTAINER_SOURCES} ${CONTAINER_HEADERS} + ${CONTAINER_SHIM_HEADERS} + ${CONTAINER_SHIM_SOURCES} ) list(APPEND AOT_EVENTPIPE_DISABLED_SOURCES diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/dn-rt-aot.cpp b/src/coreclr/nativeaot/Runtime/eventpipe/dn-rt-aot.cpp new file mode 100644 index 00000000000000..d3bb67ddedbc75 --- /dev/null +++ b/src/coreclr/nativeaot/Runtime/eventpipe/dn-rt-aot.cpp @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#include "common.h" +#include "gcenv.base.h" +#include "CommonTypes.h" +#include "CommonMacros.h" +#include "PalRedhawkCommon.h" +#include "PalRedhawk.h" +#include "rhassert.h" + +#include "containers/dn-rt.h" + +DN_NORETURN void +dn_rt_aot_failfast_msgv (const char* fmt, va_list ap) +{ + RhFailFast(); + UNREACHABLE(); +} + +DN_NORETURN void +dn_rt_aot_failfast_nomsg(const char* file, int line) +{ + RhFailFast(); + UNREACHABLE(); +} + diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/dn-rt-aot.h b/src/coreclr/nativeaot/Runtime/eventpipe/dn-rt-aot.h new file mode 100644 index 00000000000000..d9aec77041aa24 --- /dev/null +++ b/src/coreclr/nativeaot/Runtime/eventpipe/dn-rt-aot.h @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#ifndef __DN_RT_AOT_H__ +#define __DN_RT_AOT_H__ + +DN_NORETURN void +dn_rt_aot_failfast_msgv(const char* fmt, va_list ap); + +DN_NORETURN static inline void +dn_rt_failfast_msgv(const char* fmt, va_list ap) +{ + dn_rt_aot_failfast_msgv(fmt, ap); +} + +DN_NORETURN void +dn_rt_aot_failfast_nomsg(const char* file, int line); + +DN_NORETURN static inline void +dn_rt_failfast_nomsg(const char* file, int line) +{ + dn_rt_aot_failfast_nomsg(file, line); +} + +#endif /* __DN_RT_AOT_H__ */ diff --git a/src/native/containers/dn-rt.h b/src/native/containers/dn-rt.h index e248db7f998514..26334590eb25d3 100644 --- a/src/native/containers/dn-rt.h +++ b/src/native/containers/dn-rt.h @@ -30,27 +30,7 @@ dn_rt_failfast_nomsg(const char* file, int line) } #elif defined(FEATURE_NATIVEAOT) -#include "common.h" -#include "gcenv.base.h" -#include "CommonTypes.h" -#include "CommonMacros.h" -#include "PalRedhawkCommon.h" -#include "PalRedhawk.h" -#include "rhassert.h" -// TODO: add NativeAOT runtime impl -DN_NORETURN static inline void -dn_rt_failfast_msgv(const char* fmt, va_list ap) -{ - RhFailFast(); - UNREACHABLE(); -} - -DN_NORETURN static inline void -dn_rt_failfast_nomsg(const char* file, int line) -{ - RhFailFast(); - UNREACHABLE(); -} +#include #else // Mono #include "dn-rt-mono.h" From e0526c1704b38c0a36080c0e08c792532cc6556b Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Thu, 6 Apr 2023 00:49:36 -0400 Subject: [PATCH 21/23] fix coreclr windows? --- src/native/containers/dn-rt.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/native/containers/dn-rt.h b/src/native/containers/dn-rt.h index 26334590eb25d3..a5f276ca67728b 100644 --- a/src/native/containers/dn-rt.h +++ b/src/native/containers/dn-rt.h @@ -15,7 +15,9 @@ DN_NORETURN static void dn_rt_failfast_nomsg(const char* file, int line); #if defined(FEATURE_CORECLR) +#ifdef TARGET_UNIX #include "pal.h" +#endif // TARGET_UNIX // TODO: add CoreCLR runtime impl DN_NORETURN static inline void dn_rt_failfast_msgv(const char* fmt, va_list ap) From 7fc5ecce3bdb69f0c8873874aff7e92468a59e03 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Thu, 6 Apr 2023 11:03:21 -0400 Subject: [PATCH 22/23] add typed dn_vector_ptr accessor macros --- src/native/containers/dn-vector-ptr.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/native/containers/dn-vector-ptr.h b/src/native/containers/dn-vector-ptr.h index ca5be73797f398..6df84c61cb7d5b 100644 --- a/src/native/containers/dn-vector-ptr.h +++ b/src/native/containers/dn-vector-ptr.h @@ -24,4 +24,19 @@ DN_DEFINE_VECTOR_T (ptr, void *) } \ } while (0) +#define dn_vector_ptr_index_t(vector, type, index) \ + (type*)dn_vector_ptr_index (vector,index) + +#define dn_vector_ptr_at_t(vector, type, index) \ + (type*)dn_vector_ptr_at (vector, index) + +#define dn_vector_ptr_front_t(vector, type) \ + (type*)dn_vector_ptr_front (vector) + +#define dn_vector_ptr_back_t(vector, type) \ + (type*)dn_vector_ptr_back (vector) + +#define dn_vector_ptr_data_t(vector, type) \ + (type*)dn_vector_btr_data (vector) + #endif /* __DN_VECTOR_PTR_H__ */ From e93efdc79e72c3b13738b97b4dbbe1313f6c32ff Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Thu, 6 Apr 2023 11:14:06 -0400 Subject: [PATCH 23/23] Use dn_vector_ptr in a few places instead of dn_vector --- src/mono/mono/mini/interp/transform.c | 17 +++++++++-------- src/mono/mono/mini/seq-points.c | 18 +++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/mono/mono/mini/interp/transform.c b/src/mono/mono/mini/interp/transform.c index 75994598456c72..44d631efef4746 100644 --- a/src/mono/mono/mini/interp/transform.c +++ b/src/mono/mono/mini/interp/transform.c @@ -10,6 +10,7 @@ #include "config.h" #include #include +#include #include #include #include @@ -3940,8 +3941,8 @@ recursively_make_pred_seq_points (TransformData *td, InterpBasicBlock *bb) { SeqPoint ** const MONO_SEQ_SEEN_LOOP = (SeqPoint**)GINT_TO_POINTER(-1); - dn_vector_t predecessors = {0,}; - dn_vector_init_t (&predecessors, SeqPoint*); + dn_vector_ptr_t predecessors = {0,}; + dn_vector_ptr_init (&predecessors); GHashTable *seen = g_hash_table_new_full (g_direct_hash, NULL, NULL, NULL); // Insert/remove sentinel into the memoize table to detect loops containing bb @@ -3952,7 +3953,7 @@ recursively_make_pred_seq_points (TransformData *td, InterpBasicBlock *bb) // This bb has the last seq point, append it and continue if (in_bb->last_seq_point != NULL) { - dn_vector_push_back (&predecessors, in_bb->last_seq_point); + dn_vector_ptr_push_back (&predecessors, in_bb->last_seq_point); continue; } @@ -3972,7 +3973,7 @@ recursively_make_pred_seq_points (TransformData *td, InterpBasicBlock *bb) // Union sequence points with incoming bb's for (guint j = 0; j < in_bb->num_pred_seq_points; j++) { if (!g_hash_table_lookup (seen, in_bb->pred_seq_points [j])) { - dn_vector_push_back (&predecessors, in_bb->pred_seq_points [j]); + dn_vector_ptr_push_back (&predecessors, in_bb->pred_seq_points [j]); } } // predecessors = g_array_append_vals (predecessors, in_bb->pred_seq_points, in_bb->num_pred_seq_points); @@ -3980,17 +3981,17 @@ recursively_make_pred_seq_points (TransformData *td, InterpBasicBlock *bb) g_hash_table_destroy (seen); - if (!dn_vector_empty (&predecessors)) { - uint32_t count = dn_vector_size (&predecessors); + if (!dn_vector_ptr_empty (&predecessors)) { + uint32_t count = dn_vector_ptr_size (&predecessors); bb->pred_seq_points = (SeqPoint**)mono_mempool_alloc0 (td->mempool, sizeof (SeqPoint *) * count); bb->num_pred_seq_points = count; for (guint newer = 0; newer < bb->num_pred_seq_points; newer++) { - bb->pred_seq_points [newer] = *dn_vector_index_t (&predecessors, SeqPoint*, newer); + bb->pred_seq_points [newer] = *dn_vector_ptr_index_t (&predecessors, SeqPoint*, newer); } } - dn_vector_dispose (&predecessors); + dn_vector_ptr_dispose (&predecessors); } static void diff --git a/src/mono/mono/mini/seq-points.c b/src/mono/mono/mini/seq-points.c index f378432690b549..38a09494d0f380 100644 --- a/src/mono/mono/mini/seq-points.c +++ b/src/mono/mono/mini/seq-points.c @@ -10,7 +10,7 @@ */ #include -#include +#include #include "mini.h" #include "mini-runtime.h" #include "seq-points.h" @@ -36,8 +36,8 @@ recursively_make_pred_seq_points (MonoCompile *cfg, MonoBasicBlock *bb) const gpointer MONO_SEQ_SEEN_LOOP = GINT_TO_POINTER(-1); - dn_vector_t predecessors = {0,}; - dn_vector_init_t (&predecessors, MonoInst*); + dn_vector_ptr_t predecessors = {0,}; + dn_vector_ptr_init (&predecessors); GHashTable *seen = g_hash_table_new_full (g_direct_hash, NULL, NULL, NULL); // Insert/remove sentinel into the memoize table to detect loops containing bb @@ -48,7 +48,7 @@ recursively_make_pred_seq_points (MonoCompile *cfg, MonoBasicBlock *bb) // This bb has the last seq point, append it and continue if (in_bb->last_seq_point != NULL) { - dn_vector_push_back (&predecessors, in_bb->last_seq_point); + dn_vector_ptr_push_back (&predecessors, in_bb->last_seq_point); continue; } @@ -68,7 +68,7 @@ recursively_make_pred_seq_points (MonoCompile *cfg, MonoBasicBlock *bb) // Union sequence points with incoming bb's for (guint j = 0; j < in_bb->num_pred_seq_points; j++) { if (!g_hash_table_lookup (seen, in_bb->pred_seq_points [j])) { - dn_vector_push_back (&predecessors, in_bb->pred_seq_points [j]); + dn_vector_ptr_push_back (&predecessors, in_bb->pred_seq_points [j]); g_hash_table_insert (seen, in_bb->pred_seq_points [j], (gpointer)&MONO_SEQ_SEEN_LOOP); } } @@ -77,17 +77,17 @@ recursively_make_pred_seq_points (MonoCompile *cfg, MonoBasicBlock *bb) g_hash_table_destroy (seen); - if (!dn_vector_empty (&predecessors)) { - uint32_t count = dn_vector_size (&predecessors); + if (!dn_vector_ptr_empty (&predecessors)) { + uint32_t count = dn_vector_ptr_size (&predecessors); bb->pred_seq_points = (MonoInst **)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoInst *) * count); bb->num_pred_seq_points = count; for (guint newer = 0; newer < bb->num_pred_seq_points; newer++) { - bb->pred_seq_points [newer] = *dn_vector_index_t (&predecessors, MonoInst*, newer); + bb->pred_seq_points [newer] = *dn_vector_ptr_index_t (&predecessors, MonoInst*, newer); } } - dn_vector_dispose (&predecessors); + dn_vector_ptr_dispose (&predecessors); } static void