summaryrefslogtreecommitdiff
path: root/deps/v8/src/trap-handler/trap-handler.h
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2021-02-11 19:03:35 +0100
committerMichaël Zasso <targos@protonmail.com>2021-02-11 19:09:18 +0100
commitc7b329225126ad3b9eeb2408e0f0801f1aea5eb1 (patch)
tree193c193111d5f302031ad345bc94d17a3f67bf66 /deps/v8/src/trap-handler/trap-handler.h
parent6ea9af9906cd74ed07ca05cf6aa44382025a6044 (diff)
downloadnode-new-c7b329225126ad3b9eeb2408e0f0801f1aea5eb1.tar.gz
deps: update V8 to 8.8.278.17
PR-URL: https://github.com/nodejs/node/pull/36139 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Diffstat (limited to 'deps/v8/src/trap-handler/trap-handler.h')
-rw-r--r--deps/v8/src/trap-handler/trap-handler.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/deps/v8/src/trap-handler/trap-handler.h b/deps/v8/src/trap-handler/trap-handler.h
index f6fdca553e..e75355decd 100644
--- a/deps/v8/src/trap-handler/trap-handler.h
+++ b/deps/v8/src/trap-handler/trap-handler.h
@@ -8,6 +8,8 @@
#include <stdint.h>
#include <stdlib.h>
+#include <atomic>
+
#include "src/base/build_config.h"
#include "src/common/globals.h"
#include "src/flags/flags.h"
@@ -64,15 +66,32 @@ void V8_EXPORT_PRIVATE ReleaseHandlerData(int index);
#define THREAD_LOCAL __thread
#endif
+// Initially false, set to true if when trap handlers are enabled. Never goes
+// back to false then.
extern bool g_is_trap_handler_enabled;
+
+// Initially true, set to false when either {IsTrapHandlerEnabled} or
+// {EnableTrapHandler} is called to prevent calling {EnableTrapHandler}
+// repeatedly, or after {IsTrapHandlerEnabled}. Needs to be atomic because
+// {IsTrapHandlerEnabled} can be called from any thread. Updated using relaxed
+// semantics, since it's not used for synchronization.
+extern std::atomic<bool> g_can_enable_trap_handler;
+
// Enables trap handling for WebAssembly bounds checks.
//
// use_v8_handler indicates that V8 should install its own handler
// rather than relying on the embedder to do it.
-bool EnableTrapHandler(bool use_v8_handler);
+V8_EXPORT_PRIVATE bool EnableTrapHandler(bool use_v8_handler);
inline bool IsTrapHandlerEnabled() {
DCHECK_IMPLIES(g_is_trap_handler_enabled, V8_TRAP_HANDLER_SUPPORTED);
+ // Disallow enabling the trap handler after retrieving the current value.
+ // Re-enabling them late can produce issues because code or objects might have
+ // been generated under the assumption that trap handlers are disabled.
+ // Note: We test before setting to avoid contention by an unconditional write.
+ if (g_can_enable_trap_handler.load(std::memory_order_relaxed)) {
+ g_can_enable_trap_handler.store(false, std::memory_order_relaxed);
+ }
return g_is_trap_handler_enabled;
}