Skip to content

Commit

Permalink
[win64] Windows64 MSVC compiler dropped support for inline assembly. …
Browse files Browse the repository at this point in the history
…Move that code into a .asm file.
  • Loading branch information
kumpera committed Jun 4, 2014
1 parent d248c15 commit 1505c43
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mono/utils/mono-context.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ typedef struct {
#define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->rbp))
#define MONO_CONTEXT_GET_SP(ctx) ((gpointer)((ctx)->rsp))

#if defined(__native_client__)
#if defined (HOST_WIN32)
extern void mono_context_get_current (void *);
#define MONO_CONTEXT_GET_CURRENT(ctx) do { mono_context_get_current((void*)&(ctx)); } while (0)

#elif defined(__native_client__)
#define MONO_CONTEXT_GET_CURRENT(ctx) \
__asm__ __volatile__( \
"movq $0x0, %%nacl:0x00(%%r15, %0, 1)\n" \
Expand Down
42 changes: 42 additions & 0 deletions mono/utils/win64.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ifndef X64

.386
.model flat, c

endif

.code

ifdef X64

PUBLIC mono_context_get_current

mono_context_get_current PROC
;rdi has the ctx ptr
mov [rcx + 00h], rax
mov [rcx + 08h], rbx
mov [rcx + 10h], rcx
mov [rcx + 18h], rdx
mov [rcx + 20h], rbp
mov [rcx + 28h], rsp
mov [rcx + 30h], rsi
mov [rcx + 38h], rdi
mov [rcx + 40h], r8
mov [rcx + 48h], r9
mov [rcx + 50h], r10
mov [rcx + 58h], r11
mov [rcx + 60h], r12
mov [rcx + 68h], r13
mov [rcx + 70h], r14
mov [rcx + 78h], r15

lea rax, __mono_current_ip
__mono_current_ip:
mov [rcx + 80h], rax
ret

mono_context_get_current endP

endif

end
10 changes: 10 additions & 0 deletions msvc/libmonoutils.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@
<ClInclude Include="..\mono\utils\mono-hwcap-x86.h" />
<ClInclude Include="..\mono\utils\bsearch.h" />
</ItemGroup>
<ItemGroup>
<MASM Include="..\mono\utils\win64.asm">
<FileType>Document</FileType>
</MASM>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{8FC2B0C8-51AD-49DF-851F-5D01A77A75E4}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
Expand Down Expand Up @@ -160,6 +165,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down Expand Up @@ -223,6 +229,9 @@
<PreBuildEvent>
<Command>winsetup.bat</Command>
</PreBuildEvent>
<MASM>
<PreprocessorDefinitions>X64</PreprocessorDefinitions>
</MASM>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
Expand Down Expand Up @@ -268,5 +277,6 @@
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>

0 comments on commit 1505c43

Please sign in to comment.