summaryrefslogtreecommitdiff
path: root/src/jit/codegencommon.cpp
diff options
context:
space:
mode:
authorsergey ignatov <sergign60@mail.ru>2018-09-01 17:40:44 +0300
committerJan Kotas <jkotas@microsoft.com>2018-09-01 07:40:44 -0700
commita1757ce8e80cd089d9dc31ba2d4e3246e387a6b8 (patch)
tree5de828b15ed9dc639fd5b3215833836d613c0c57 /src/jit/codegencommon.cpp
parentd71ed81a4b9ec9d89bcb5c35174ff60d0991c79c (diff)
downloadcoreclr-a1757ce8e80cd089d9dc31ba2d4e3246e387a6b8.tar.gz
coreclr-a1757ce8e80cd089d9dc31ba2d4e3246e387a6b8.tar.bz2
coreclr-a1757ce8e80cd089d9dc31ba2d4e3246e387a6b8.zip
i386: Fixed definition with declaration in eetoprofinterfaceimpl.cpp (#18792)
Diffstat (limited to 'src/jit/codegencommon.cpp')
-rw-r--r--src/jit/codegencommon.cpp51
1 files changed, 42 insertions, 9 deletions
diff --git a/src/jit/codegencommon.cpp b/src/jit/codegencommon.cpp
index b1b780fb46..c967892bd1 100644
--- a/src/jit/codegencommon.cpp
+++ b/src/jit/codegencommon.cpp
@@ -2436,16 +2436,20 @@ void CodeGen::genGenerateCode(void** codePtr, ULONG* nativeSizeOfCode)
#endif
#if EMIT_TRACK_STACK_DEPTH
- /* Check our max stack level. Needed for fgAddCodeRef().
- We need to relax the assert as our estimation won't include code-gen
- stack changes (which we know don't affect fgAddCodeRef()) */
+ // Check our max stack level. Needed for fgAddCodeRef().
+ // We need to relax the assert as our estimation won't include code-gen
+ // stack changes (which we know don't affect fgAddCodeRef()).
+ // NOTE: after emitEndCodeGen (including here), emitMaxStackDepth is a
+ // count of DWORD-sized arguments, NOT argument size in bytes.
{
unsigned maxAllowedStackDepth = compiler->fgPtrArgCntMax + // Max number of pointer-sized stack arguments.
compiler->compHndBBtabCount + // Return address for locally-called finallys
genTypeStSz(TYP_LONG) + // longs/doubles may be transferred via stack, etc
(compiler->compTailCallUsed ? 4 : 0); // CORINFO_HELP_TAILCALL args
#if defined(UNIX_X86_ABI)
- maxAllowedStackDepth += maxNestedAlignment;
+ // Convert maxNestedAlignment to DWORD count before adding to maxAllowedStackDepth.
+ assert(maxNestedAlignment % sizeof(int) == 0);
+ maxAllowedStackDepth += maxNestedAlignment / sizeof(int);
#endif
noway_assert(getEmitter()->emitMaxStackDepth <= maxAllowedStackDepth);
}
@@ -6926,8 +6930,13 @@ void CodeGen::genProfilingEnterCallback(regNumber initReg, bool* pInitRegZeroed)
unsigned saveStackLvl2 = genStackLevel;
#if defined(_TARGET_X86_)
- // Important note: when you change enter probe layout, you must also update SKIP_ENTER_PROF_CALLBACK()
- // for x86 stack unwinding
+// Important note: when you change enter probe layout, you must also update SKIP_ENTER_PROF_CALLBACK()
+// for x86 stack unwinding
+
+#if defined(UNIX_X86_ABI)
+ // Manually align the stack to be 16-byte aligned. This is similar to CodeGen::genAlignStackBeforeCall()
+ getEmitter()->emitIns_R_I(INS_sub, EA_4BYTE, REG_SPBASE, 0xC);
+#endif // UNIX_X86_ABI
// Push the profilerHandle
if (compiler->compProfilerMethHndIndirected)
@@ -6938,6 +6947,7 @@ void CodeGen::genProfilingEnterCallback(regNumber initReg, bool* pInitRegZeroed)
{
inst_IV(INS_push, (size_t)compiler->compProfilerMethHnd);
}
+
#elif defined(_TARGET_ARM_)
// On Arm arguments are prespilled on stack, which frees r0-r3.
// For generating Enter callout we would need two registers and one of them has to be r0 to pass profiler handle.
@@ -6974,6 +6984,12 @@ void CodeGen::genProfilingEnterCallback(regNumber initReg, bool* pInitRegZeroed)
#if defined(_TARGET_X86_)
// Check that we have place for the push.
assert(compiler->fgPtrArgCntMax >= 1);
+
+#if defined(UNIX_X86_ABI)
+ // Restoring alignment manually. This is similar to CodeGen::genRemoveAlignmentAfterCall
+ getEmitter()->emitIns_R_I(INS_add, EA_4BYTE, REG_SPBASE, 0x10);
+#endif // UNIX_X86_ABI
+
#elif defined(_TARGET_ARM_)
if (initReg == argReg)
{
@@ -7148,6 +7164,13 @@ void CodeGen::genProfilingLeaveCallback(unsigned helper /*= CORINFO_HELP_PROF_FC
#elif defined(_TARGET_X86_)
+#if defined(UNIX_X86_ABI)
+ // Manually align the stack to be 16-byte aligned. This is similar to CodeGen::genAlignStackBeforeCall()
+ getEmitter()->emitIns_R_I(INS_sub, EA_4BYTE, REG_SPBASE, 0xC);
+ AddStackLevel(0xC);
+ AddNestedAlignment(0xC);
+#endif // UNIX_X86_ABI
+
//
// Push the profilerHandle
//
@@ -7162,13 +7185,23 @@ void CodeGen::genProfilingLeaveCallback(unsigned helper /*= CORINFO_HELP_PROF_FC
}
genSinglePush();
- genEmitHelperCall(helper,
- sizeof(int) * 1, // argSize
- EA_UNKNOWN); // retSize
+#if defined(UNIX_X86_ABI)
+ int argSize = -REGSIZE_BYTES; // negative means caller-pop (cdecl)
+#else
+ int argSize = REGSIZE_BYTES;
+#endif
+ genEmitHelperCall(helper, argSize, EA_UNKNOWN /* retSize */);
// Check that we have place for the push.
assert(compiler->fgPtrArgCntMax >= 1);
+#if defined(UNIX_X86_ABI)
+ // Restoring alignment manually. This is similar to CodeGen::genRemoveAlignmentAfterCall
+ getEmitter()->emitIns_R_I(INS_add, EA_4BYTE, REG_SPBASE, 0x10);
+ SubtractStackLevel(0x10);
+ SubtractNestedAlignment(0xC);
+#endif // UNIX_X86_ABI
+
#elif defined(_TARGET_ARM_)
//
// Push the profilerHandle