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

Unified Diff: runtime/vm/allocation.h

Issue 1226403003: Support per-thread zones and stack resources. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add thread_registry.h Created 5 years, 5 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
« no previous file with comments | « no previous file | runtime/vm/base_isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/allocation.h
diff --git a/runtime/vm/allocation.h b/runtime/vm/allocation.h
index 579ed7759cdcd6c14c324806c22f90d2254ed330..f6b74b8e972c49c623defea355ca7c9fe9d1db47 100644
--- a/runtime/vm/allocation.h
+++ b/runtime/vm/allocation.h
@@ -8,6 +8,7 @@
#include "platform/assert.h"
#include "vm/base_isolate.h"
#include "vm/globals.h"
+#include "vm/thread.h"
namespace dart {
@@ -36,42 +37,62 @@ class ValueObject {
// to a stack frame above the frame where these objects were allocated.
class StackResource {
public:
- explicit StackResource(Isolate* isolate)
- : isolate_(reinterpret_cast<BaseIsolate*>(isolate)), previous_(NULL) {
- // We can only have longjumps and exceptions when there is a current
- // isolate. If there is no current isolate, we don't need to
- // protect this case.
- if (isolate_ != NULL) {
- previous_ = isolate_->top_resource();
- isolate_->set_top_resource(this);
- }
+ // DEPRECATED: Use Thread-based interface. During migration, this defaults
+ // to using the mutator thread (which must also be the current thread).
+ explicit StackResource(Isolate* isolate) : thread_(NULL), previous_(NULL) {
+ Init((isolate == NULL) ?
+ NULL : reinterpret_cast<BaseIsolate*>(isolate)->mutator_thread_);
+ }
+
+ explicit StackResource(Thread* thread) : thread_(NULL), previous_(NULL) {
+ Init(thread);
}
virtual ~StackResource() {
- if (isolate_ != NULL) {
- StackResource* top = isolate_->top_resource();
+ if (thread_ != NULL) {
+ StackResource* top = thread_->top_resource();
ASSERT(top == this);
- isolate_->set_top_resource(previous_);
+ thread_->set_top_resource(previous_);
}
#if defined(DEBUG)
- if (isolate_ != NULL) {
- BaseIsolate::AssertCurrent(isolate_);
+ if (thread_ != NULL) {
+ ASSERT(Thread::Current() == thread_);
+ BaseIsolate::AssertCurrent(reinterpret_cast<BaseIsolate*>(isolate()));
}
#endif
}
- // We can only create StackResources with Isolates, so provide the original
- // isolate to the subclasses. The only reason we have a BaseIsolate in the
- // StackResource is to break the header include cycles.
- Isolate* isolate() const { return reinterpret_cast<Isolate*>(isolate_); }
+ // Convenient access to the isolate of the thread of this resource.
+ Isolate* isolate() const {
+ return thread_ == NULL ? NULL : thread_->isolate();
+ }
+
+ // The thread that owns this resource.
+ Thread* thread() const { return thread_; }
// Destroy stack resources of isolate until top exit frame.
+ // TODO(koda): Migrate to Thread.
static void Unwind(Isolate* isolate) { UnwindAbove(isolate, NULL); }
+ // TODO(koda): Migrate to Thread.
// Destroy stack resources of isolate above new_top, exclusive.
static void UnwindAbove(Isolate* isolate, StackResource* new_top);
private:
- BaseIsolate* const isolate_; // Current isolate for this stack resource.
+ void Init(Thread* thread) {
+ // We can only have longjumps and exceptions when there is a current
+ // thread and isolate. If there is no current thread, we don't need to
+ // protect this case.
+ // TODO(23807): Eliminate this special case.
+ if (thread != NULL) {
+ ASSERT(Thread::Current() == thread);
+ thread_ = thread;
+ previous_ = thread_->top_resource();
+ ASSERT((previous_ == NULL) || (previous_->thread_ == thread));
+ thread_->set_top_resource(this);
+ }
+ }
+
+ Thread* thread_;
StackResource* previous_;
DISALLOW_ALLOCATION();
« no previous file with comments | « no previous file | runtime/vm/base_isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698