1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
From dbfd81c905d8f97aee7b6e595df02d49f98f3f70 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=EB=B0=95=EC=A2=85=ED=98=84/Developer=20Experience=20Lab?=
=?UTF-8?q?=28S/W=EC=84=BC=ED=84=B0=29/Senior=20Engineer/=EC=82=BC?=
=?UTF-8?q?=EC=84=B1=EC=A0=84=EC=9E=90?= <jh1302.park@samsung.com>
Date: Thu, 10 Aug 2017 17:25:46 +0900
Subject: [PATCH 09/29] [x86/Linux] Adjust SP in throwing helper block (#12504)
(#12)
* [x86/Linux] Adjust SP in throwing helper block
* Fix format error
* Use funKind intead of siInFuncletRegion
* Use genSPtoFPdelta (and add some comments)
* Fix a typo
* Revert irrelevant changes
---
src/jit/codegencommon.cpp | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/jit/codegencommon.cpp b/src/jit/codegencommon.cpp
index 94cc9b9..719299e 100644
--- a/src/jit/codegencommon.cpp
+++ b/src/jit/codegencommon.cpp
@@ -1642,6 +1642,18 @@ void CodeGen::genAdjustStackLevel(BasicBlock* block)
{
#if !FEATURE_FIXED_OUT_ARGS
// Check for inserted throw blocks and adjust genStackLevel.
+ CLANG_FORMAT_COMMENT_ANCHOR;
+
+#if defined(UNIX_X86_ABI)
+ if (isFramePointerUsed() && compiler->fgIsThrowHlpBlk(block))
+ {
+ // x86/Linux requires stack frames to be 16-byte aligned, but SP may be unaligned
+ // at this point if a jump to this block is made in the middle of pushing arugments.
+ //
+ // Here we restore SP to prevent potential stack alignment issues.
+ getEmitter()->emitIns_R_AR(INS_lea, EA_PTRSIZE, REG_SPBASE, REG_FPBASE, -genSPtoFPdelta());
+ }
+#endif
if (!isFramePointerUsed() && compiler->fgIsThrowHlpBlk(block))
{
@@ -2694,7 +2706,14 @@ void CodeGen::genExitCode(BasicBlock* block)
void CodeGen::genJumpToThrowHlpBlk(emitJumpKind jumpKind, SpecialCodeKind codeKind, GenTreePtr failBlk)
{
- if (!compiler->opts.compDbgCode)
+ bool useThrowHlpBlk = !compiler->opts.compDbgCode;
+
+#if defined(UNIX_X86_ABI) && FEATURE_EH_FUNCLETS
+ // Inline exception-throwing code in funclet to make it possible to unwind funclet frames.
+ useThrowHlpBlk = useThrowHlpBlk && (compiler->funCurrentFunc()->funKind == FUNC_ROOT);
+#endif // UNIX_X86_ABI && FEATURE_EH_FUNCLETS
+
+ if (useThrowHlpBlk)
{
/* For non-debuggable code, find and use the helper block for
raising the exception. The block may be shared by other trees too. */
--
2.7.4
|