summaryrefslogtreecommitdiff
path: root/src/vm/i386/cgenx86.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vm/i386/cgenx86.cpp')
-rw-r--r--src/vm/i386/cgenx86.cpp79
1 files changed, 76 insertions, 3 deletions
diff --git a/src/vm/i386/cgenx86.cpp b/src/vm/i386/cgenx86.cpp
index ff2f2df5a3..08ccd01086 100644
--- a/src/vm/i386/cgenx86.cpp
+++ b/src/vm/i386/cgenx86.cpp
@@ -760,6 +760,7 @@ WORD GetUnpatchedCodeData(LPCBYTE pAddr)
#ifndef DACCESS_COMPILE
+#if defined(_TARGET_X86_) && !defined(FEATURE_STUBS_AS_IL)
//-------------------------------------------------------------------------
// One-time creation of special prestub to initialize UMEntryThunks.
//-------------------------------------------------------------------------
@@ -809,6 +810,7 @@ Stub *GenerateUMThunkPrestub()
RETURN psl->Link(SystemDomain::GetGlobalLoaderAllocator()->GetExecutableHeap());
}
+#endif // _TARGET_X86_ && !FEATURE_STUBS_AS_IL
Stub *GenerateInitPInvokeFrameHelper()
{
@@ -1593,6 +1595,7 @@ extern "C" VOID STDCALL StubRareDisableTHROWWorker(Thread *pThread)
pThread->HandleThreadAbort();
}
+#ifndef FEATURE_PAL
// Note that this logic is copied below, in PopSEHRecords
__declspec(naked)
VOID __cdecl PopSEHRecords(LPVOID pTargetSP)
@@ -1614,6 +1617,7 @@ VOID __cdecl PopSEHRecords(LPVOID pTargetSP)
retn
}
}
+#endif // FEATURE_PAL
//////////////////////////////////////////////////////////////////////////////
//
@@ -1680,9 +1684,10 @@ void ResumeAtJit(PCONTEXT pContext, LPVOID oldESP)
#endif // !EnC_SUPPORTED
+#ifndef FEATURE_PAL
#pragma warning(push)
#pragma warning(disable: 4035)
-DWORD getcpuid(DWORD arg, unsigned char result[16])
+extern "C" DWORD __stdcall getcpuid(DWORD arg, unsigned char result[16])
{
LIMITED_METHOD_CONTRACT
@@ -1709,7 +1714,7 @@ DWORD getcpuid(DWORD arg, unsigned char result[16])
// Arg3 is a pointer to the return buffer
// No need to check whether or not CPUID is supported because we have already called CPUID with success to come here.
-DWORD getextcpuid(DWORD arg1, DWORD arg2, unsigned char result[16])
+extern "C" DWORD __stdcall getextcpuid(DWORD arg1, DWORD arg2, unsigned char result[16])
{
LIMITED_METHOD_CONTRACT
@@ -1730,8 +1735,75 @@ DWORD getextcpuid(DWORD arg1, DWORD arg2, unsigned char result[16])
}
}
+extern "C" DWORD __stdcall xmmYmmStateSupport()
+{
+ // No CONTRACT
+ STATIC_CONTRACT_NOTHROW;
+ STATIC_CONTRACT_GC_NOTRIGGER;
+
+ __asm
+ {
+ mov ecx, 0 ; Specify xcr0
+ xgetbv ; result in EDX:EAX
+ and eax, 06H
+ cmp eax, 06H ; check OS has enabled both XMM and YMM state support
+ jne not_supported
+ mov eax, 1
+ jmp done
+ not_supported:
+ mov eax, 0
+ done:
+ }
+}
+
#pragma warning(pop)
+#else // !FEATURE_PAL
+
+extern "C" DWORD __stdcall getcpuid(DWORD arg, unsigned char result[16])
+{
+ DWORD eax;
+ __asm(" xor %%ecx, %%ecx\n" \
+ " cpuid\n" \
+ " mov %%eax, 0(%[result])\n" \
+ " mov %%ebx, 4(%[result])\n" \
+ " mov %%ecx, 8(%[result])\n" \
+ " mov %%edx, 12(%[result])\n" \
+ : "=a"(eax) /*output in eax*/\
+ : "a"(arg), [result]"r"(result) /*inputs - arg in eax, result in any register*/\
+ : "eax", "rbx", "ecx", "edx", "memory" /* registers that are clobbered, *result is clobbered */
+ );
+ return eax;
+}
+
+extern "C" DWORD __stdcall getextcpuid(DWORD arg1, DWORD arg2, unsigned char result[16])
+{
+ DWORD eax;
+ __asm(" cpuid\n" \
+ " mov %%eax, 0(%[result])\n" \
+ " mov %%ebx, 4(%[result])\n" \
+ " mov %%ecx, 8(%[result])\n" \
+ " mov %%edx, 12(%[result])\n" \
+ : "=a"(eax) /*output in eax*/\
+ : "c"(arg1), "a"(arg2), [result]"r"(result) /*inputs - arg1 in ecx, arg2 in eax, result in any register*/\
+ : "eax", "rbx", "ecx", "edx", "memory" /* registers that are clobbered, *result is clobbered */
+ );
+ return eax;
+}
+
+extern "C" DWORD __stdcall xmmYmmStateSupport()
+{
+ DWORD eax;
+ __asm(" xgetbv\n" \
+ : "=a"(eax) /*output in eax*/\
+ : "c"(0) /*inputs - 0 in ecx*/\
+ : "eax", "edx" /* registers that are clobbered*/
+ );
+ // check OS has enabled both XMM and YMM state support
+ return ((eax & 0x06) == 0x06) ? 1 : 0;
+}
+
+#endif // !FEATURE_PAL
// This function returns the number of logical processors on a given physical chip. If it cannot
// determine the number of logical cpus, or the machine is not populated uniformly with the same
@@ -1761,13 +1833,14 @@ DWORD GetLogicalCpuCount()
PAL_TRY(Param *, pParam, &param)
{
unsigned char buffer[16];
+ DWORD* dwBuffer = NULL;
DWORD maxCpuId = getcpuid(0, buffer);
if (maxCpuId < 1)
goto lDone;
- DWORD* dwBuffer = (DWORD*)buffer;
+ dwBuffer = (DWORD*)buffer;
if (dwBuffer[1] == 'uneG') {
if (dwBuffer[3] == 'Ieni') {