From 661364f0e15b690abeb1ed42dccbcf38ce1863e6 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Fri, 9 Feb 2024 00:40:16 -0500 Subject: [PATCH] [mono] Fix a windows build issue. Extracted from https://github.com/dotnet/runtime/pull/97096. Author: Johan Lorensson lateralusx.github@gmail.com. --- src/mono/mono/mini/aot-compiler.c | 4 +-- src/mono/mono/mini/exceptions-amd64.c | 42 +++++++++++++-------------- src/mono/mono/mini/mini-amd64.h | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index bcc251ea7c902..f8275230e210b 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -12791,7 +12791,7 @@ emit_unwind_info_data_win32 (MonoAotCompile *acfg, PUNWIND_INFO unwind_info) while (current_unwind_node < last_unwind_node) { guint8 node_count = 0; - switch (current_unwind_node->UnwindOp) { + switch (current_unwind_node->UnwindCode.UnwindOp) { case UWOP_PUSH_NONVOL: case UWOP_ALLOC_SMALL: case UWOP_SET_FPREG: @@ -12807,7 +12807,7 @@ emit_unwind_info_data_win32 (MonoAotCompile *acfg, PUNWIND_INFO unwind_info) node_count = 3; break; case UWOP_ALLOC_LARGE: - if (current_unwind_node->OpInfo == 0) + if (current_unwind_node->UnwindCode.OpInfo == 0) node_count = 2; else node_count = 3; diff --git a/src/mono/mono/mini/exceptions-amd64.c b/src/mono/mono/mini/exceptions-amd64.c index 20ba681ab5265..5049bc799700f 100644 --- a/src/mono/mono/mini/exceptions-amd64.c +++ b/src/mono/mono/mini/exceptions-amd64.c @@ -1044,14 +1044,14 @@ mono_arch_unwindinfo_add_push_nonvol (PUNWIND_INFO unwindinfo, MonoUnwindOp *unw codeindex = MONO_MAX_UNWIND_CODES - (++unwindinfo->CountOfCodes); unwindcode = &unwindinfo->UnwindCode [codeindex]; - unwindcode->UnwindOp = UWOP_PUSH_NONVOL; - unwindcode->CodeOffset = GUINT32_TO_UINT8 (unwind_op->when); - unwindcode->OpInfo = GUINT32_TO_UINT8 (unwind_op->reg); + unwindcode->UnwindCode.UnwindOp = UWOP_PUSH_NONVOL; + unwindcode->UnwindCode.CodeOffset = GUINT32_TO_UINT8 (unwind_op->when); + unwindcode->UnwindCode.OpInfo = GUINT32_TO_UINT8 (unwind_op->reg); - if (unwindinfo->SizeOfProlog >= unwindcode->CodeOffset) + if (unwindinfo->SizeOfProlog >= unwindcode->UnwindCode.CodeOffset) g_error ("Adding unwind info in wrong order."); - unwindinfo->SizeOfProlog = unwindcode->CodeOffset; + unwindinfo->SizeOfProlog = unwindcode->UnwindCode.CodeOffset; } void @@ -1067,17 +1067,17 @@ mono_arch_unwindinfo_add_set_fpreg (PUNWIND_INFO unwindinfo, MonoUnwindOp *unwin codeindex = MONO_MAX_UNWIND_CODES - (++unwindinfo->CountOfCodes); unwindcode = &unwindinfo->UnwindCode [codeindex]; - unwindcode->UnwindOp = UWOP_SET_FPREG; - unwindcode->CodeOffset = (guchar)unwind_op->when; + unwindcode->UnwindCode.UnwindOp = UWOP_SET_FPREG; + unwindcode->UnwindCode.CodeOffset = (guchar)unwind_op->when; g_assert (unwind_op->val % 16 == 0); unwindinfo->FrameRegister = GUINT16_TO_UINT8 (unwind_op->reg); unwindinfo->FrameOffset = GINT32_TO_UINT8 (unwind_op->val / 16); - if (unwindinfo->SizeOfProlog >= unwindcode->CodeOffset) + if (unwindinfo->SizeOfProlog >= unwindcode->UnwindCode.CodeOffset) g_error ("Adding unwind info in wrong order."); - unwindinfo->SizeOfProlog = unwindcode->CodeOffset; + unwindinfo->SizeOfProlog = unwindcode->UnwindCode.CodeOffset; } void @@ -1108,13 +1108,13 @@ mono_arch_unwindinfo_add_alloc_stack (PUNWIND_INFO unwindinfo, MonoUnwindOp *unw codeindex = MONO_MAX_UNWIND_CODES - (unwindinfo->CountOfCodes += codesneeded); unwindcode = &unwindinfo->UnwindCode [codeindex]; - unwindcode->CodeOffset = (guchar)unwind_op->when; + unwindcode->UnwindCode.CodeOffset = (guchar)unwind_op->when; if (codesneeded == 1) { /*The size of the allocation is (the number in the OpInfo member) times 8 plus 8*/ - unwindcode->UnwindOp = UWOP_ALLOC_SMALL; - unwindcode->OpInfo = GUINT_TO_UINT8 ((size - 8)/8); + unwindcode->UnwindCode.UnwindOp = UWOP_ALLOC_SMALL; + unwindcode->UnwindCode.OpInfo = GUINT_TO_UINT8 ((size - 8)/8); } else { if (codesneeded == 3) { @@ -1123,8 +1123,8 @@ mono_arch_unwindinfo_add_alloc_stack (PUNWIND_INFO unwindinfo, MonoUnwindOp *unw NOTE, unwind codes are allocated from end to beginning of list so unwind code will have right execution order. List is sorted on CodeOffset using descending sort order.*/ - unwindcode->UnwindOp = UWOP_ALLOC_LARGE; - unwindcode->OpInfo = 1; + unwindcode->UnwindCode.UnwindOp = UWOP_ALLOC_LARGE; + unwindcode->UnwindCode.OpInfo = 1; *((unsigned int*)(&(unwindcode + 1)->FrameOffset)) = size; } else { @@ -1133,16 +1133,16 @@ mono_arch_unwindinfo_add_alloc_stack (PUNWIND_INFO unwindinfo, MonoUnwindOp *unw NOTE, unwind codes are allocated from end to beginning of list so unwind code will have right execution order. List is sorted on CodeOffset using descending sort order.*/ - unwindcode->UnwindOp = UWOP_ALLOC_LARGE; - unwindcode->OpInfo = 0; + unwindcode->UnwindCode.UnwindOp = UWOP_ALLOC_LARGE; + unwindcode->UnwindCode.OpInfo = 0; (unwindcode + 1)->FrameOffset = (gushort)(size/8); } } - if (unwindinfo->SizeOfProlog >= unwindcode->CodeOffset) + if (unwindinfo->SizeOfProlog >= unwindcode->UnwindCode.CodeOffset) g_error ("Adding unwind info in wrong order."); - unwindinfo->SizeOfProlog = unwindcode->CodeOffset; + unwindinfo->SizeOfProlog = unwindcode->UnwindCode.CodeOffset; } static gboolean g_dyn_func_table_inited; @@ -1879,10 +1879,10 @@ mono_arch_unwindinfo_install_method_unwind_info (PUNWIND_INFO *monoui, gpointer // In first iteration previous == current, this is intended to handle UWOP_ALLOC_LARGE as first item. int previous = 0; for (int current = 0; current < codecount; current++) { - g_assert_checked (targetinfo->UnwindCode [previous].CodeOffset >= targetinfo->UnwindCode [current].CodeOffset); + g_assert_checked (targetinfo->UnwindCode [previous].UnwindCode.CodeOffset >= targetinfo->UnwindCode [current].UnwindCode.CodeOffset); previous = current; - if (targetinfo->UnwindCode [current].UnwindOp == UWOP_ALLOC_LARGE) { - if (targetinfo->UnwindCode [current].OpInfo == 0) { + if (targetinfo->UnwindCode [current].UnwindCode.UnwindOp == UWOP_ALLOC_LARGE) { + if (targetinfo->UnwindCode [current].UnwindCode.OpInfo == 0) { current++; } else { current += 2; diff --git a/src/mono/mono/mini/mini-amd64.h b/src/mono/mono/mini/mini-amd64.h index 0dda406f95b8b..a042311eed05e 100644 --- a/src/mono/mono/mini/mini-amd64.h +++ b/src/mono/mono/mini/mini-amd64.h @@ -552,7 +552,7 @@ typedef union _UNWIND_CODE { guchar CodeOffset; guchar UnwindOp : 4; guchar OpInfo : 4; - }; + } UnwindCode; gushort FrameOffset; } UNWIND_CODE, *PUNWIND_CODE;