Skip to content

Commit

Permalink
Do not run stack level setter for arm64 apple.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Andreenko committed Sep 24, 2020
1 parent 80beef0 commit 49ed384
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/coreclr/src/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2355,25 +2355,25 @@ void CodeGen::genEmitMachineCode()
}
#endif

#if EMIT_TRACK_STACK_DEPTH
#if EMIT_TRACK_STACK_DEPTH && defined(DEBUG) && !defined(OSX_ARM64_ABI)
// 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
unsigned maxAllowedStackDepth = compiler->fgGetPtrArgCntMax() + // 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)
// Convert maxNestedAlignment to DWORD count before adding to maxAllowedStackDepth.
assert(maxNestedAlignment % sizeof(int) == 0);
maxAllowedStackDepth += maxNestedAlignment / sizeof(int);
#endif
noway_assert(GetEmitter()->emitMaxStackDepth <= maxAllowedStackDepth);
assert(GetEmitter()->emitMaxStackDepth <= maxAllowedStackDepth);
}
#endif // EMIT_TRACK_STACK_DEPTH
#endif // EMIT_TRACK_STACK_DEPTH && DEBUG

*nativeSizeOfCode = codeSize;
compiler->info.compNativeCodeSize = (UNATIVE_OFFSET)codeSize;
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/src/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8547,7 +8547,7 @@ void CodeGen::genProfilingEnterCallback(regNumber initReg, bool* pInitRegZeroed)
EA_UNKNOWN); // retSize

// Check that we have place for the push.
assert(compiler->fgPtrArgCntMax >= 1);
assert(compiler->fgGetPtrArgCntMax() >= 1);

#if defined(UNIX_X86_ABI)
// Restoring alignment manually. This is similar to CodeGen::genRemoveAlignmentAfterCall
Expand Down Expand Up @@ -8628,7 +8628,7 @@ void CodeGen::genProfilingLeaveCallback(unsigned helper)
genEmitHelperCall(helper, argSize, EA_UNKNOWN /* retSize */);

// Check that we have place for the push.
assert(compiler->fgPtrArgCntMax >= 1);
assert(compiler->fgGetPtrArgCntMax() >= 1);

#if defined(UNIX_X86_ABI)
// Restoring alignment manually. This is similar to CodeGen::genRemoveAlignmentAfterCall
Expand Down
7 changes: 5 additions & 2 deletions src/coreclr/src/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4921,10 +4921,13 @@ void Compiler::compCompile(void** methodCodePtr, ULONG* methodCodeSize, JitFlags
m_pLowering = new (this, CMK_LSRA) Lowering(this, m_pLinearScan); // PHASE_LOWERING
m_pLowering->Run();

// Set stack levels
//
#if !defined(OSX_ARM64_ABI)
// Set stack levels, this informmation is necessary for x86
// but on other platforms it is used only in asserts
// TODO: do not run it in release on other platforms, see https://github.com/dotnet/runtime/issues/42673.
StackLevelSetter stackLevelSetter(this);
stackLevelSetter.Run();
#endif // !OSX_ARM64_ABI

// We can not add any new tracked variables after this point.
lvaTrackedFixed = true;
Expand Down

0 comments on commit 49ed384

Please sign in to comment.