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

Unified Diff: runtime/vm/isolate.h

Issue 1277473004: Safe and efficient stack-limit based interrupt checking in C++. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Comments. Created 5 years, 4 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: runtime/vm/isolate.h
diff --git a/runtime/vm/isolate.h b/runtime/vm/isolate.h
index c43a3fa7f5fa6c3075a8c8ec8e0bb5f50d77d6b2..004c9763435c2233274d5cc414ae1d3c031c899f 100644
--- a/runtime/vm/isolate.h
+++ b/runtime/vm/isolate.h
@@ -7,6 +7,7 @@
#include "include/dart_api.h"
#include "platform/assert.h"
+#include "vm/atomic.h"
#include "vm/base_isolate.h"
#include "vm/class_table.h"
#include "vm/counters.h"
@@ -272,13 +273,25 @@ class Isolate : public BaseIsolate {
// stack allocated local, but plays well with AddressSanitizer.
static uword GetCurrentStackPointer();
+ // Returns true if any of the interrupts specified by 'interrupt_bits' are
+ // currently scheduled for this isolate, but leaves them unchanged.
+ //
+ // NOTE: The read uses relaxed memory ordering, i.e., it is atomic and
+ // an interrupt is guaranteed to be observed eventually, but any further
+ // order guarantees must be ensured by other synchronization. See the
+ // tests in isolate_test.cc for example usage.
+ bool HasInterruptsScheduled(uword interrupt_bits) {
+ ASSERT(interrupt_bits == (interrupt_bits & kInterruptsMask));
+ uword limit = AtomicOperations::LoadRelaxed(&stack_limit_);
+ return (limit != saved_stack_limit_) &&
+ (((limit & kInterruptsMask) & interrupt_bits) != 0);
+ }
+
+ // Access to the current stack limit for generated code. This may be
+ // overwritten with a special value to trigger interrupts.
uword stack_limit_address() const {
return reinterpret_cast<uword>(&stack_limit_);
}
-
- // The current stack limit. This may be overwritten with a special
- // value to trigger interrupts.
- uword stack_limit() const { return stack_limit_; }
static intptr_t stack_limit_offset() {
return OFFSET_OF(Isolate, stack_limit_);
}

Powered by Google App Engine
This is Rietveld 408576698