summaryrefslogtreecommitdiff
path: root/packaging/0030-Remove-exception-records-allocation-from-pal.h.patch
blob: cf099e3a6ec7f5719797dbeba95cdec8c51e262d (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
From 318d7a2dff13634670ef005c4af8115e5c780eb3 Mon Sep 17 00:00:00 2001
From: Mikhail Labiuk <m.labiuk@samsung.com>
Date: Tue, 20 Feb 2018 16:59:27 +0300
Subject: [PATCH 30/47] Remove exception records allocation from pal.h

---
 src/pal/inc/pal.h             | 24 ------------------------
 src/pal/src/exception/seh.cpp | 36 ++++++++++++++++++++++++++++++++++--
 2 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h
index e241219..199ab94 100644
--- a/src/pal/inc/pal.h
+++ b/src/pal/inc/pal.h
@@ -5794,11 +5794,6 @@ PAL_FreeExceptionRecords(
   IN EXCEPTION_RECORD *exceptionRecord, 
   IN CONTEXT *contextRecord);
 
-VOID
-AllocateExceptionRecords(
-    EXCEPTION_RECORD** exceptionRecord,
-    CONTEXT** contextRecord);
-
 #define EXCEPTION_CONTINUE_SEARCH   0
 #define EXCEPTION_EXECUTE_HANDLER   1
 #define EXCEPTION_CONTINUE_EXECUTION -1
@@ -5878,25 +5873,6 @@ public:
         RecordsOnStack = false;
     }
 
-    void EnsureExceptionRecordsOnHeap()
-    {
-        if( !RecordsOnStack || ExceptionPointers.ExceptionRecord == NULL)
-        {
-            return;
-        }
-
-        CONTEXT* contextRecordCopy;
-        EXCEPTION_RECORD* exceptionRecordCopy;
-        AllocateExceptionRecords(&exceptionRecordCopy, &contextRecordCopy);
-
-        *exceptionRecordCopy = *ExceptionPointers.ExceptionRecord;
-        ExceptionPointers.ExceptionRecord = exceptionRecordCopy;
-        *contextRecordCopy = *ExceptionPointers.ContextRecord;
-        ExceptionPointers.ContextRecord = contextRecordCopy;
-
-        RecordsOnStack = false;
-    }
-
     CONTEXT* GetContextRecord()
     {
         return ExceptionPointers.ContextRecord;
diff --git a/src/pal/src/exception/seh.cpp b/src/pal/src/exception/seh.cpp
index 27766f2..8477fd6 100644
--- a/src/pal/src/exception/seh.cpp
+++ b/src/pal/src/exception/seh.cpp
@@ -234,6 +234,38 @@ void ThrowExceptionHelper(PAL_SEHException* ex)
 
 /*++
 Function:
+    EnsureExceptionRecordsOnHeap
+
+    Helper function to move records from stack to heap.
+
+Parameters:
+    PAL_SEHException* exception
+--*/
+static void EnsureExceptionRecordsOnHeap(PAL_SEHException* exception)
+{
+    if( !exception->RecordsOnStack ||
+        exception->ExceptionPointers.ExceptionRecord == NULL )
+    {
+        return;
+    }
+
+    CONTEXT* contextRecord = exception->ExceptionPointers.ContextRecord;
+    EXCEPTION_RECORD* exceptionRecord = exception->ExceptionPointers.ExceptionRecord;
+
+    CONTEXT* contextRecordCopy;
+    EXCEPTION_RECORD* exceptionRecordCopy;
+    AllocateExceptionRecords(&exceptionRecordCopy, &contextRecordCopy);
+
+    *exceptionRecordCopy = *exceptionRecord;
+    *contextRecordCopy = *contextRecord;
+
+    exception->ExceptionPointers.ExceptionRecord = exceptionRecordCopy;
+    exception->ExceptionPointers.ContextRecord = contextRecordCopy;
+    exception->RecordsOnStack = false;
+}
+
+/*++
+Function:
     SEHProcessException
 
     Send the PAL exception to any handler registered.
@@ -280,7 +312,7 @@ SEHProcessException(PAL_SEHException* exception)
                     }
                 }
 
-                exception->EnsureExceptionRecordsOnHeap();
+                EnsureExceptionRecordsOnHeap(exception);
                 if (g_hardwareExceptionHandler(exception))
                 {
                     // The exception happened in managed code and the execution should continue.
@@ -293,7 +325,7 @@ SEHProcessException(PAL_SEHException* exception)
 
         if (CatchHardwareExceptionHolder::IsEnabled())
         {
-            exception->EnsureExceptionRecordsOnHeap();
+            EnsureExceptionRecordsOnHeap(exception);
             PAL_ThrowExceptionFromContext(exception->GetContextRecord(), exception);
         }
     }
-- 
2.7.4