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

Unified Diff: src/trap-handler/handler-shared.cc

Issue 2371833007: [wasm] Initial signal handler (Closed)
Patch Set: Restore signal mask at the right place Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: src/trap-handler/handler-shared.cc
diff --git a/src/trap-handler/handler-shared.cc b/src/trap-handler/handler-shared.cc
new file mode 100644
index 0000000000000000000000000000000000000000..88984c6978b72eed1d71ef4a300d8db15bc577d7
--- /dev/null
+++ b/src/trap-handler/handler-shared.cc
@@ -0,0 +1,52 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// PLEASE READ BEFORE CHANGING THIS FILE!
+//
+// This file contains code that is used both inside and outside the out of
+// bounds signal handler. Because this code runs in a signal handler context,
+// use extra care when modifying this file. Here are some rules to follow.
+//
+// 1. Do not introduce any new external dependencies. This file needs
+// to be self contained so it is easy to audit everything that a
+// signal handler might do.
+//
+// 2. Any changes must be reviewed by someone from the crash reporting
+// or security team. See OWNERS for suggested reviewers.
+//
+// For more information, see https://goo.gl/yMeyUY.
+
+#include "src/trap-handler/trap-handler-internal.h"
+
+namespace v8 {
+namespace internal {
+namespace trap_handler {
+
+THREAD_LOCAL bool g_thread_in_wasm_code = false;
+
+size_t gNumCodeObjects = 0;
+CodeProtectionInfo** gCodeObjects = nullptr;
+
+std::atomic_flag MetadataLock::spinlock_ = ATOMIC_FLAG_INIT;
+
+MetadataLock::MetadataLock() {
+ if (g_thread_in_wasm_code) {
ahaas 2017/02/20 09:27:24 CHECK(!g_thread_in_wasm_code)?
Eric Holk 2017/02/23 02:16:57 This code can run within a signal handler, which m
+ abort();
+ }
+
+ while (spinlock_.test_and_set(std::memory_order::memory_order_acquire)) {
+ }
+}
+
+MetadataLock::~MetadataLock() {
+ if (g_thread_in_wasm_code) {
ahaas 2017/02/20 09:27:24 same here
Eric Holk 2017/02/23 02:16:57 See above comment.
+ abort();
+ }
+
+ spinlock_.clear(std::memory_order::memory_order_release);
+}
+
+} // namespace trap_handler
+} // namespace internal
+} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698