Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pal/inc/rt/palrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1705,7 +1705,7 @@ typedef LONG (WINAPI *PTOP_LEVEL_EXCEPTION_FILTER)(
);
typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;

BOOL VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers);
BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers);

/******************* ntdef ************************************/

Expand Down
6 changes: 3 additions & 3 deletions src/pal/src/exception/seh-unwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static void GetContextPointers(unw_cursor_t *cursor, KNONVOLATILE_CONTEXT_POINTE
#endif
}

BOOL VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers)
BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers)
{
int st;
unw_context_t unwContext;
Expand Down Expand Up @@ -498,7 +498,7 @@ static void RtlpRaiseException(EXCEPTION_RECORD *ExceptionRecord)
// Find the caller of RtlpRaiseException. This provides the exact context
// that handlers expect to see, which is the one they would want to fix up
// to resume after a continuable exception.
VirtualUnwind(&ContextRecord, NULL);
PAL_VirtualUnwind(&ContextRecord, NULL);

// The frame we're looking at now is either RaiseException or PAL_TryExcept.
// If it's RaiseException, we have to unwind one level further to get the
Expand All @@ -512,7 +512,7 @@ static void RtlpRaiseException(EXCEPTION_RECORD *ExceptionRecord)
#endif
if ((SIZE_T) pc - (SIZE_T) RaiseException < (SIZE_T) pc - (SIZE_T) PAL_TryExcept)
{
VirtualUnwind(&ContextRecord, NULL);
PAL_VirtualUnwind(&ContextRecord, NULL);
#if defined(_PPC_)
pc = (void *) ContextRecord.Iar;
#elif defined(_X86_)
Expand Down
4 changes: 0 additions & 4 deletions src/vm/amd64/calldescrworkeramd64.S
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,8 @@ NESTED_END FastCallFinalizeWorker, _TEXT

NESTED_ENTRY CallDescrWorkerInternal, _TEXT, CallDescrWorkerUnwindFrameChainHandler
push_nonvol_reg rbx // save nonvolatile registers
.cfi_def_cfa_offset 16 //
push_nonvol_reg rbp //
.cfi_adjust_cfa_offset 8 //
.cfi_offset rbp, -24 //
set_frame rbp, 0 // set frame pointer
.cfi_def_cfa_register rbp //
lea rsp, [rsp - 8] // ensure proper alignment of the rsp

END_PROLOGUE
Expand Down
2 changes: 1 addition & 1 deletion src/vm/amd64/gmsamd64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void LazyMachState::unwindLazyState(LazyMachState* baseState,
#ifndef FEATURE_PAL
pvControlPc = Thread::VirtualUnwindCallFrame(&ctx, &nonVolRegPtrs);
#else // !FEATURE_PAL
VirtualUnwind(&ctx, &nonVolRegPtrs);
PAL_VirtualUnwind(&ctx, &nonVolRegPtrs);
pvControlPc = GetIP(&ctx);
#endif // !FEATURE_PAL

Expand Down
91 changes: 57 additions & 34 deletions src/vm/amd64/unixasmmacros.inc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ C_FUNC(\Name):
.type \Name, %function
#endif
.cfi_startproc
.cfi_def_cfa_offset 8
C_FUNC(\Name):
.endm

Expand All @@ -73,7 +74,14 @@ C_FUNC(\Name\()_End):

.macro push_nonvol_reg Register
push \Register
//.pushreg \Register
.cfi_adjust_cfa_offset 8
.cfi_rel_offset \Register, 0
.endm

.macro pop_nonvol_reg Register
pop \Register
.cfi_adjust_cfa_offset -8
.cfi_restore \Register
.endm

.macro NESTED_ENTRY Name, Section, Handler
Expand All @@ -94,11 +102,24 @@ C_FUNC(\Name\()_End):
.att_syntax
lea -\Size(%rsp), %rsp
.intel_syntax noprefix
//.allocstack \Size
.cfi_adjust_cfa_offset \Size
.endm

.macro free_stack Size
.att_syntax
lea \Size(%rsp), %rsp
.intel_syntax noprefix
.cfi_adjust_cfa_offset -\Size
.endm

.macro set_frame Reg, Offset
lea \Reg, \Offset[rsp]
.cfi_def_cfa_register \Reg
.endm

.macro restore_frame Reg, Offset
lea rsp, \Offset[\Reg]
.cfi_def_cfa_register rsp
.endm

.macro save_reg_postrsp Reg, Offset
Expand All @@ -109,12 +130,7 @@ C_FUNC(\Name\()_End):

__Offset = \Offset
mov qword ptr [rsp + __Offset], \Reg

//
// TODO: find the right directive
// this one gives an "unknown directive" error
//
// .savereg \Reg, \Offset
.cfi_rel_offset \Reg, __Offset

___STACK_ADJUSTMENT_FORBIDDEN = 1

Expand All @@ -123,6 +139,7 @@ C_FUNC(\Name\()_End):
.macro restore_reg Reg, Offset
__Offset = \Offset
mov \Reg, [rsp + __Offset]
.cfi_restore \Reg
.endm

.macro save_xmm128_postrsp Reg, Offset
Expand All @@ -133,12 +150,7 @@ C_FUNC(\Name\()_End):

__Offset = \Offset
movdqa [rsp + __Offset], \Reg

//
// TODO: find the right directive
// this one gives an "unknown directive" error
//
// .savexmm128 \Reg, \Offset
.cfi_rel_offset \Reg, __Offset

___STACK_ADJUSTMENT_FORBIDDEN = 1

Expand All @@ -147,38 +159,49 @@ C_FUNC(\Name\()_End):
.macro restore_xmm128 Reg, ofs
__Offset = \ofs
movdqa \Reg, [rsp + __Offset]
.cfi_restore \Reg
.endm

.macro POP_CALLEE_SAVED_REGISTERS

pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
pop_nonvol_reg rbx
pop_nonvol_reg rbp
pop_nonvol_reg r12
pop_nonvol_reg r13
pop_nonvol_reg r14
pop_nonvol_reg r15

.endm

.macro push_argument_register Reg
push \Reg
.cfi_adjust_cfa_offset 8
.endm

.macro PUSH_ARGUMENT_REGISTERS

push r9
push r8
push rdx
push rcx
push rsi
push rdi
push_argument_register r9
push_argument_register r8
push_argument_register rdx
push_argument_register rcx
push_argument_register rsi
push_argument_register rdi

.endm

.macro pop_argument_register Reg
pop \Reg
.cfi_adjust_cfa_offset -8
.endm

.macro POP_ARGUMENT_REGISTERS

pop rdi
pop rsi
pop rcx
pop rdx
pop r8
pop r9
pop_argument_register rdi
pop_argument_register rsi
pop_argument_register rcx
pop_argument_register rdx
pop_argument_register r8
pop_argument_register r9

.endm

Expand Down Expand Up @@ -251,7 +274,7 @@ C_FUNC(\Name\()_End):
.endif

.if \stackAllocOnEntry > 0
//.allocstack \stackAllocOnEntry
.cfi_adjust_cfa_offset \stackAllocOnEntry
.endif

// PUSH_CALLEE_SAVED_REGISTERS expanded here
Expand Down Expand Up @@ -300,7 +323,7 @@ C_FUNC(\Name\()_End):
.macro EPILOG_WITH_TRANSITION_BLOCK_TAILCALL

RESTORE_FLOAT_ARGUMENT_REGISTERS __PWTB_FloatArgumentRegisters
lea rsp, [rsp + __PWTB_StackAlloc]
free_stack __PWTB_StackAlloc
POP_ARGUMENT_REGISTERS
POP_CALLEE_SAVED_REGISTERS

Expand Down
2 changes: 1 addition & 1 deletion src/vm/stackwalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ UINT_PTR Thread::VirtualUnwindToFirstManagedCallFrame(T_CONTEXT* pContext)
#ifndef FEATURE_PAL
uControlPc = VirtualUnwindCallFrame(pContext);
#else // !FEATURE_PAL
VirtualUnwind(pContext, NULL);
PAL_VirtualUnwind(pContext, NULL);
uControlPc = GetIP(pContext);
#endif // !FEATURE_PAL
}
Expand Down