Skip to content

Commit

Permalink
[mono] Fix a windows build issue. (#98206)
Browse files Browse the repository at this point in the history
Extracted from #97096.

Author: Johan Lorensson lateralusx.github@gmail.com.
  • Loading branch information
vargaz committed Feb 9, 2024
1 parent 512bcaf commit b4c400a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/mono/mono/mini/aot-compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
Expand Down
42 changes: 21 additions & 21 deletions src/mono/mono/mini/exceptions-amd64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/mini-amd64.h
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ typedef union _UNWIND_CODE {
guchar CodeOffset;
guchar UnwindOp : 4;
guchar OpInfo : 4;
};
} UnwindCode;
gushort FrameOffset;
} UNWIND_CODE, *PUNWIND_CODE;

Expand Down

0 comments on commit b4c400a

Please sign in to comment.