From 46e54d19f334edc449b61fbbbfa11ac50e4ab3bf Mon Sep 17 00:00:00 2001 From: lewurm Date: Fri, 7 Feb 2020 20:36:49 +0000 Subject: [PATCH] [abi-details] add explaining comment for macro magic I think the fallback was added because "let's get it back to work quickly", back in the dark times without CI: https://github.com/mono/mono/commit/b655fb35c61fd3422003de01eed8e634d46b4186 --- src/mono/mono/metadata/abi-details.h | 15 ++++++++++----- src/mono/mono/metadata/object-internals.h | 2 +- src/mono/mono/metadata/object-offsets.h | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/mono/mono/metadata/abi-details.h b/src/mono/mono/metadata/abi-details.h index 37566f43301e6..a2376816e331a 100644 --- a/src/mono/mono/metadata/abi-details.h +++ b/src/mono/mono/metadata/abi-details.h @@ -54,15 +54,20 @@ enum { #ifdef USED_CROSS_COMPILER_OFFSETS #define MONO_STRUCT_OFFSET(struct,field) MONO_OFFSET_ ## struct ## _ ## field +#define MONO_STRUCT_OFFSET_CONSTANT(struct,field) MONO_STRUCT_OFFSET(struct,field) #define MONO_STRUCT_SIZE(struct) MONO_SIZEOF_ ## struct #else -#if defined(HAS_CROSS_COMPILER_OFFSETS) || defined(MONO_CROSS_COMPILE) +/* This macro is expanding to something that uses the comma operator in C [0]. + * The first part introduces an expression that uses the `MONO_OFFSET_*` + * define. The result isn't used, but it forces the compiler to bail out if the + * define doesn't exist; this happens when we forgot to add an entry in + * `object-offsets.h` accordingly. + * + * [0] https://en.wikipedia.org/wiki/Comma_operator + */ #define MONO_STRUCT_OFFSET(struct,field) (MONO_OFFSET_ ## struct ## _ ## field == -1, G_STRUCT_OFFSET (struct,field)) +#define MONO_STRUCT_OFFSET_CONSTANT(struct,field) G_STRUCT_OFFSET (struct,field) #define MONO_STRUCT_SIZE(struct) (MONO_SIZEOF_ ## struct == -1, (int)sizeof(struct)) -#else -#define MONO_STRUCT_OFFSET(struct,field) G_STRUCT_OFFSET (struct,field) -#define MONO_STRUCT_SIZE(struct) ((int)sizeof(struct)) -#endif #endif // #define MONO_SIZEOF_MonoObject (2 * MONO_ABI_SIZEOF(gpointer)) diff --git a/src/mono/mono/metadata/object-internals.h b/src/mono/mono/metadata/object-internals.h index 4e4378302b96c..63c70adeaf0af 100644 --- a/src/mono/mono/metadata/object-internals.h +++ b/src/mono/mono/metadata/object-internals.h @@ -175,7 +175,7 @@ struct _MonoArray { mono_64bitaligned_t vector [MONO_ZERO_LEN_ARRAY]; }; -#define MONO_SIZEOF_MONO_ARRAY (MONO_STRUCT_OFFSET (MonoArray, vector)) +#define MONO_SIZEOF_MONO_ARRAY (MONO_STRUCT_OFFSET_CONSTANT (MonoArray, vector)) struct _MonoString { MonoObject object; diff --git a/src/mono/mono/metadata/object-offsets.h b/src/mono/mono/metadata/object-offsets.h index d956b47387350..8e235409969c8 100644 --- a/src/mono/mono/metadata/object-offsets.h +++ b/src/mono/mono/metadata/object-offsets.h @@ -123,6 +123,7 @@ DECL_OFFSET(MonoString, length) DECL_OFFSET(MonoString, chars) DECL_OFFSET(MonoException, message) +DECL_OFFSET(MonoException, caught_in_unmanaged) DECL_OFFSET(MonoTypedRef, type) DECL_OFFSET(MonoTypedRef, klass) @@ -159,6 +160,9 @@ DECL_OFFSET(MonoMethodRuntimeGenericContext, class_vtable) DECL_OFFSET(MonoJitTlsData, lmf) DECL_OFFSET(MonoJitTlsData, class_cast_from) DECL_OFFSET(MonoJitTlsData, class_cast_to) +#ifdef TARGET_WIN32 +DECL_OFFSET(MonoJitTlsData, stack_restore_ctx) +#endif DECL_OFFSET(MonoGSharedVtMethodRuntimeInfo, locals_size) DECL_OFFSET(MonoGSharedVtMethodRuntimeInfo, entries) //XXX more to fix here @@ -211,6 +215,10 @@ DECL_OFFSET(MonoLMF, rsp) DECL_OFFSET(MonoLMF, rbp) DECL_OFFSET(DynCallArgs, res) +DECL_OFFSET(DynCallArgs, fregs) +DECL_OFFSET(DynCallArgs, has_fp) +DECL_OFFSET(DynCallArgs, nstack_args) +DECL_OFFSET(DynCallArgs, regs) DECL_OFFSET(MonoLMFTramp, ctx) DECL_OFFSET(MonoLMFTramp, lmf_addr) @@ -290,6 +298,14 @@ DECL_OFFSET(GSharedVtCallInfo, ret_marshal) DECL_OFFSET(GSharedVtCallInfo, gsharedvt_in) #endif +#if defined(TARGET_AMD64) +DECL_OFFSET(GSharedVtCallInfo, ret_marshal) +DECL_OFFSET(GSharedVtCallInfo, vret_arg_reg) +DECL_OFFSET(GSharedVtCallInfo, vret_slot) +DECL_OFFSET(GSharedVtCallInfo, stack_usage) +DECL_OFFSET(GSharedVtCallInfo, gsharedvt_in) +#endif + DECL_OFFSET(MonoFtnDesc, arg) DECL_OFFSET(MonoFtnDesc, addr)