Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/trap-handler/trap-handler.h

Issue 2744383002: Revert of [wasm] Initial signal handler (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/trap-handler/handler-shared.cc ('k') | src/trap-handler/trap-handler-internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_TRAP_HANDLER_H_ 5 #ifndef V8_TRAP_HANDLER_H_
6 #define V8_TRAP_HANDLER_H_ 6 #define V8_TRAP_HANDLER_H_
7 7
8 #include <signal.h>
9 #include <stdint.h>
10 #include <stdlib.h>
11
12 #include "src/base/build_config.h"
13 #include "src/flags.h"
14 #include "src/globals.h"
15
16 #if V8_OS_LINUX
17 #include <ucontext.h>
18 #endif
19
20 namespace v8 { 8 namespace v8 {
21 namespace internal { 9 namespace internal {
22 namespace trap_handler { 10 namespace trap_handler {
23 11
24 // TODO(eholk): Support trap handlers on other platforms.
25 #if V8_TARGET_ARCH_X64 && V8_OS_LINUX
26 #define V8_TRAP_HANDLER_SUPPORTED 1
27 #else
28 #define V8_TRAP_HANDLER_SUPPORTED 0
29 #endif
30
31 struct ProtectedInstructionData { 12 struct ProtectedInstructionData {
32 // The offset of this instruction from the start of its code object. 13 // The offset of this instruction from the start of its code object.
33 intptr_t instr_offset; 14 intptr_t instr_offset;
34 15
35 // The offset of the landing pad from the start of its code object. 16 // The offset of the landing pad from the start of its code object.
36 // 17 //
37 // TODO(eholk): Using a single landing pad and store parameters here. 18 // TODO(eholk): Using a single landing pad and store parameters here.
38 intptr_t landing_offset; 19 intptr_t landing_offset;
39 }; 20 };
40 21
41 /// Adjusts the base code pointer.
42 void UpdateHandlerDataCodePointer(int index, void* base);
43
44 /// Adds the handler data to the place where the signal handler will find it.
45 ///
46 /// This returns a number that can be used to identify the handler data to
47 /// UpdateHandlerDataCodePointer and ReleaseHandlerData, or -1 on failure.
48 int RegisterHandlerData(void* base, size_t size,
49 size_t num_protected_instructions,
50 ProtectedInstructionData* protected_instructions);
51
52 /// Removes the data from the master list and frees any memory, if necessary.
53 void ReleaseHandlerData(int index);
54
55 #if V8_OS_WIN
56 #define THREAD_LOCAL __declspec(thread)
57 #elif V8_OS_ANDROID
58 // TODO(eholk): fix this before enabling for trap handlers for Android.
59 #define THREAD_LOCAL
60 #else
61 #define THREAD_LOCAL __thread
62 #endif
63
64 inline bool UseTrapHandler() {
65 return FLAG_wasm_trap_handler && V8_TRAP_HANDLER_SUPPORTED;
66 }
67
68 extern THREAD_LOCAL bool g_thread_in_wasm_code;
69
70 inline bool IsThreadInWasm() { return g_thread_in_wasm_code; }
71
72 inline void SetThreadInWasm() {
73 if (UseTrapHandler()) {
74 DCHECK(!IsThreadInWasm());
75 g_thread_in_wasm_code = true;
76 }
77 }
78 inline void ClearThreadInWasm() {
79 if (UseTrapHandler()) {
80 DCHECK(IsThreadInWasm());
81 g_thread_in_wasm_code = false;
82 }
83 }
84
85 bool RegisterDefaultSignalHandler();
86
87 #if V8_OS_LINUX
88 bool TryHandleSignal(int signum, siginfo_t* info, ucontext_t* context);
89 #endif // V8_OS_LINUX
90
91 } // namespace trap_handler 22 } // namespace trap_handler
92 } // namespace internal 23 } // namespace internal
93 } // namespace v8 24 } // namespace v8
94 25
95 #endif // V8_TRAP_HANDLER_H_ 26 #endif // V8_TRAP_HANDLER_H_
OLDNEW
« no previous file with comments | « src/trap-handler/handler-shared.cc ('k') | src/trap-handler/trap-handler-internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698