Skip to content

Commit

Permalink
Fixup labels for osx assembler / linker
Browse files Browse the repository at this point in the history
  • Loading branch information
kangaroo committed Feb 5, 2015
1 parent 68d9bad commit 2644cdd
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/debug/ee/amd64/dbghelpers.S
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ NESTED_ENTRY FuncEvalHijack, _TEXT, FuncEvalHijackPersonalityRoutine
END_PROLOGUE

mov [rsp], rdi
call FuncEvalHijackWorker
PLATFORM_CALL FuncEvalHijackWorker

//
// The following nop is crucial. It is important that the OS *not* recognize
Expand Down Expand Up @@ -67,7 +67,7 @@ NESTED_ENTRY ExceptionHijack, _TEXT, ExceptionHijackPersonalityRoutine
mov [rsp + 18h], rax

// DD Hijack primitive already set the stack. So just make the call now.
call ExceptionHijackWorker
PLATFORM_CALL ExceptionHijackWorker

//
// The following nop is crucial. It is important that the OS *not* recognize
Expand Down
4 changes: 2 additions & 2 deletions src/vm/amd64/jithelpers_fast.S
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LEAF_ENTRY JIT_WriteBarrier, _TEXT

#ifdef _DEBUG
// In debug builds, this just contains jump to the debug version of the write barrier by default
jmp JIT_WriteBarrier_Debug
PLATFORM_JMP JIT_WriteBarrier_Debug
#endif

// Do the move into the GC . It is correct to take an AV here, the EH code
Expand Down Expand Up @@ -104,7 +104,7 @@ LEAF_ENTRY JIT_CheckedWriteBarrier, _TEXT
cmp rdi, [rax]
jnb NotInHeap

jmp JIT_WriteBarrier
PLATFORM_CALL JIT_WriteBarrier

NotInHeap:
// See comment above about possible AV
Expand Down
2 changes: 1 addition & 1 deletion src/vm/amd64/theprestubamd64.S
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NESTED_ENTRY ThePreStub, _TEXT, ProcessCLRException
//
lea rdi, [rsp + __PWTB_TransitionBlock] // pTransitionBlock*
mov rsi, METHODDESC_REGISTER
call PreStubWorker
PLATFORM_CALL PreStubWorker

EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
TAILJMP_RAX
Expand Down
6 changes: 3 additions & 3 deletions src/vm/amd64/unixasmhelpers.S
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ LEAF_ENTRY PrecodeFixupThunk, _TEXT
lea METHODDESC_REGISTER,[rax+r11*8]

// Tail call to prestub
jmp ThePreStub
PLATFORM_CALL ThePreStub

LEAF_END PrecodeFixupThunk, _TEXT

Expand Down Expand Up @@ -116,7 +116,7 @@ NESTED_ENTRY NDirectImportThunk, _TEXT, Handler
// Call NDirectImportWorker w/ the NDirectMethodDesc*
//
mov rdi, METHODDESC_REGISTER
call NDirectImportWorker
PLATFORM_CALL NDirectImportWorker

RESTORE_FLOAT_ARGUMENT_REGISTERS 0

Expand Down Expand Up @@ -163,7 +163,7 @@ NESTED_ENTRY JIT_RareDisableHelper, _TEXT, Handler
// Second float return register
movdqa [rsp+0x10], xmm1

call JIT_RareDisableHelperWorker
PLATFORM_CALL JIT_RareDisableHelperWorker

movdqa xmm0, [rsp]
movdqa xmm1, [rsp+0x10]
Expand Down
32 changes: 30 additions & 2 deletions src/vm/amd64/unixasmmacros.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,50 @@
.byte 0xE0
.endm

.macro PLATFORM_JMP Name
#if defined(__APPLE__)
jmp _\Name
#else
jmp _\Name

This comment has been minimized.

Copy link
@lucasmeijer

lucasmeijer Feb 5, 2015

typo?

This comment has been minimized.

Copy link
@kangaroo

kangaroo Feb 6, 2015

Author Owner

yeah, I thought I fixed that in a later commit, but that was for PLATFORM_CALL. Thanks -- fixed in c7cf6f7

#endif
.endm

.macro PLATFORM_CALL Name
#if defined(__APPLE__)
call _\Name
#else
call \Name
#endif
.endm

.macro PATCH_LABEL Name
#if defined(__APPLE__)
.global _\Name
_\Name:
#else
.global \Name
\Name:
#endif
.endm

.macro LEAF_ENTRY Name, Section
#if defined(__APPLE__)
.global _\Name
.text
_\Name:
#else
.global \Name
.type \Name, %function
#endif
\Name:
#endif
.endm

.macro LEAF_END_MARKED Name, Section
\Name\()_End:
#if defined(__APPLE__)
_\Name\()_End:
.global _\Name\()_End
#else
\Name\()_End:
.global \Name\()_End
.size \Name, .-\Name
#endif
Expand All @@ -54,7 +78,11 @@
.endm

.macro PREPARE_EXTERNAL_VAR Name, HelperReg
#if defined(__APPLE__)
mov \HelperReg, [rip + _\Name@GOTPCREL]
#else
mov \HelperReg, [rip + \Name@GOTPCREL]
#endif
.endm

.macro push_nonvol_reg Register
Expand Down
8 changes: 6 additions & 2 deletions src/vm/amd64/virtualcallstubamd64.S
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ NESTED_ENTRY ResolveWorkerAsmStub, _TEXT, Handler
and rcx, 7 // flags
sub rsi, rcx // indirection cell

call VSD_ResolveWorker
PLATFORM_CALL VSD_ResolveWorker

EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
TAILJMP_RAX
Expand Down Expand Up @@ -69,7 +69,7 @@ MainLoop_RWCLAS:
cmp r10, [rax+08h] // compare our DispatchToken with one in the ResolveCacheElem
jne MainLoop_RWCLAS
Success_RWCLAS:
PREPARE_EXTERNAL_VAR CHAIN_SUCCESS_COUNTER, rsi
PREPARE_EXTERNAL_VAR g_dispatch_cache_chain_success_counter, rsi
sub qword ptr [rsi],1 // decrement success counter
jl Promote_RWCLAS
mov rax, [rax+10h] // get the ImplTarget
Expand All @@ -85,6 +85,10 @@ Fail_RWCLAS:
pop rsi // Restore the original saved rdx value
push r10 // pass the DispatchToken or ResolveCacheElem to promote to ResolveWorkerAsmStub

#if defined(__APPLE__)
jmp _ResolveWorkerAsmStub
#else
jmp ResolveWorkerAsmStub
#endif

LEAF_END ResolveWorkerChainLookupAsmStub, _TEXT

4 comments on commit 2644cdd

@janvorli
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was wrong with using the CHAIN_SUCCESS_COUNTER?

@kangaroo
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apples preprocessor was having an issue with the double expansion and tried to actually use CHAIN_SUCCESS_COUNTER as the symbol.

@janvorli
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems some versions of clang also does have a problem with it. I've checked in a fix - using #define for the CHAIN_SUCCESS_COUNTER - in dotnet#109

@kangaroo
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d6b48b1

Please sign in to comment.