diff options
| author | LDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com> | 2020-05-15 13:46:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-15 13:46:35 +0200 |
| commit | 3b70a28087a52f18c376a5cdf35fd6c910e064e8 (patch) | |
| tree | 30687a3434b22d260a7a6ad221f5a5b44f09fe44 /ARMeilleure/CodeGen | |
| parent | da3fd3f71bae0677c794d11b48131823e183194c (diff) | |
Unwinding Follow-up. Fix a bug in JitUnwindWindows where ... (#1238)
... in case of "Vector" unwind codes the remaining unwind codes could be corrupted.
Nits.
Diffstat (limited to 'ARMeilleure/CodeGen')
| -rw-r--r-- | ARMeilleure/CodeGen/Unwinding/UnwindInfo.cs | 12 | ||||
| -rw-r--r-- | ARMeilleure/CodeGen/Unwinding/UnwindPseudoOperation.cs | 11 | ||||
| -rw-r--r-- | ARMeilleure/CodeGen/Unwinding/UnwindPushEntry.cs | 20 | ||||
| -rw-r--r-- | ARMeilleure/CodeGen/X86/CodeGenerator.cs | 17 |
4 files changed, 32 insertions, 28 deletions
diff --git a/ARMeilleure/CodeGen/Unwinding/UnwindInfo.cs b/ARMeilleure/CodeGen/Unwinding/UnwindInfo.cs index 4955f1b4..8072acd9 100644 --- a/ARMeilleure/CodeGen/Unwinding/UnwindInfo.cs +++ b/ARMeilleure/CodeGen/Unwinding/UnwindInfo.cs @@ -3,16 +3,12 @@ namespace ARMeilleure.CodeGen.Unwinding struct UnwindInfo { public UnwindPushEntry[] PushEntries { get; } + public int PrologSize { get; } - public int PrologueSize { get; } - - public int FixedAllocSize { get; } - - public UnwindInfo(UnwindPushEntry[] pushEntries, int prologueSize, int fixedAllocSize) + public UnwindInfo(UnwindPushEntry[] pushEntries, int prologSize) { - PushEntries = pushEntries; - PrologueSize = prologueSize; - FixedAllocSize = fixedAllocSize; + PushEntries = pushEntries; + PrologSize = prologSize; } } }
\ No newline at end of file diff --git a/ARMeilleure/CodeGen/Unwinding/UnwindPseudoOperation.cs b/ARMeilleure/CodeGen/Unwinding/UnwindPseudoOperation.cs new file mode 100644 index 00000000..44ed23f5 --- /dev/null +++ b/ARMeilleure/CodeGen/Unwinding/UnwindPseudoOperation.cs @@ -0,0 +1,11 @@ +namespace ARMeilleure.CodeGen.Unwinding +{ + enum UnwindPseudoOp + { + PushReg, + SetFrame, + AllocStack, + SaveReg, + SaveXmm128 + } +}
\ No newline at end of file diff --git a/ARMeilleure/CodeGen/Unwinding/UnwindPushEntry.cs b/ARMeilleure/CodeGen/Unwinding/UnwindPushEntry.cs index 6597e2b4..021479a4 100644 --- a/ARMeilleure/CodeGen/Unwinding/UnwindPushEntry.cs +++ b/ARMeilleure/CodeGen/Unwinding/UnwindPushEntry.cs @@ -1,20 +1,18 @@ -using ARMeilleure.IntermediateRepresentation; - namespace ARMeilleure.CodeGen.Unwinding { struct UnwindPushEntry { - public int Index { get; } - - public RegisterType Type { get; } - - public int StreamEndOffset { get; } + public UnwindPseudoOp PseudoOp { get; } + public int PrologOffset { get; } + public int RegIndex { get; } + public int StackOffsetOrAllocSize { get; } - public UnwindPushEntry(int index, RegisterType type, int streamEndOffset) + public UnwindPushEntry(UnwindPseudoOp pseudoOp, int prologOffset, int regIndex = -1, int stackOffsetOrAllocSize = -1) { - Index = index; - Type = type; - StreamEndOffset = streamEndOffset; + PseudoOp = pseudoOp; + PrologOffset = prologOffset; + RegIndex = regIndex; + StackOffsetOrAllocSize = stackOffsetOrAllocSize; } } }
\ No newline at end of file diff --git a/ARMeilleure/CodeGen/X86/CodeGenerator.cs b/ARMeilleure/CodeGen/X86/CodeGenerator.cs index a6347b27..0faba6dd 100644 --- a/ARMeilleure/CodeGen/X86/CodeGenerator.cs +++ b/ARMeilleure/CodeGen/X86/CodeGenerator.cs @@ -1525,30 +1525,27 @@ namespace ARMeilleure.CodeGen.X86 context.Assembler.Pshufd(dest, dest, 0xfc); } + [Conditional("DEBUG")] private static void ValidateUnOp(Operand dest, Operand source) { -#if DEBUG EnsureSameReg (dest, source); EnsureSameType(dest, source); -#endif } + [Conditional("DEBUG")] private static void ValidateBinOp(Operand dest, Operand src1, Operand src2) { -#if DEBUG EnsureSameReg (dest, src1); EnsureSameType(dest, src1, src2); -#endif } + [Conditional("DEBUG")] private static void ValidateShift(Operand dest, Operand src1, Operand src2) { -#if DEBUG EnsureSameReg (dest, src1); EnsureSameType(dest, src1); Debug.Assert(dest.Type.IsInteger() && src2.Type == OperandType.I32); -#endif } private static void EnsureSameReg(Operand op1, Operand op2) @@ -1595,7 +1592,7 @@ namespace ARMeilleure.CodeGen.X86 context.Assembler.Push(Register((X86Register)bit)); - pushEntries.Add(new UnwindPushEntry(bit, RegisterType.Integer, context.StreamOffset)); + pushEntries.Add(new UnwindPushEntry(UnwindPseudoOp.PushReg, context.StreamOffset, regIndex: bit)); mask &= ~(1 << bit); } @@ -1612,6 +1609,8 @@ namespace ARMeilleure.CodeGen.X86 if (reservedStackSize != 0) { context.Assembler.Sub(rsp, Const(reservedStackSize), OperandType.I64); + + pushEntries.Add(new UnwindPushEntry(UnwindPseudoOp.AllocStack, context.StreamOffset, stackOffsetOrAllocSize: reservedStackSize)); } int offset = reservedStackSize; @@ -1628,12 +1627,12 @@ namespace ARMeilleure.CodeGen.X86 context.Assembler.Movdqu(memOp, Xmm((X86Register)bit)); - pushEntries.Add(new UnwindPushEntry(bit, RegisterType.Vector, context.StreamOffset)); + pushEntries.Add(new UnwindPushEntry(UnwindPseudoOp.SaveXmm128, context.StreamOffset, bit, offset)); mask &= ~(1 << bit); } - return new UnwindInfo(pushEntries.ToArray(), context.StreamOffset, reservedStackSize); + return new UnwindInfo(pushEntries.ToArray(), context.StreamOffset); } private static void WriteEpilogue(CodeGenContext context) |
