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

Unified Diff: runtime/vm/zone.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 | « runtime/vm/vm_sources.gypi ('k') | runtime/vm/zone.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/zone.h
diff --git a/runtime/vm/zone.h b/runtime/vm/zone.h
index 0d89c5dc1a0391fb5c6f88e1445f0d2078291b67..ee0add5aa8cb7363f9d54dacc8bfcef85a50c034 100644
--- a/runtime/vm/zone.h
+++ b/runtime/vm/zone.h
@@ -174,27 +174,21 @@ class Zone {
class StackZone : public StackResource {
public:
- // Create an empty zone and set is at the current zone for the Isolate.
- explicit StackZone(Isolate* isolate)
- : StackResource(isolate),
- zone_() {
-#ifdef DEBUG
- if (FLAG_trace_zones) {
- OS::PrintErr("*** Starting a new Stack zone 0x%" Px "(0x%" Px ")\n",
- reinterpret_cast<intptr_t>(this),
- reinterpret_cast<intptr_t>(&zone_));
- }
-#endif
- BaseIsolate* base_isolate = reinterpret_cast<BaseIsolate*>(isolate);
- zone_.Link(base_isolate->current_zone());
- base_isolate->set_current_zone(&zone_);
+ // Create an empty zone and set is at the current zone for the Thread.
+ explicit StackZone(Thread* thread) : StackResource(thread), zone_() {
+ Initialize();
+ }
+
+ // DEPRECATED: Use Thread-based interface. During migration, this defaults
+ // to using the mutator thread (which must also be the current thread).
+ explicit StackZone(Isolate* isolate) : StackResource(isolate), zone_() {
+ Initialize();
}
// Delete all memory associated with the zone.
~StackZone() {
- BaseIsolate* base_isolate = reinterpret_cast<BaseIsolate*>(isolate());
- ASSERT(base_isolate->current_zone() == &zone_);
- base_isolate->set_current_zone(zone_.previous_);
+ ASSERT(thread()->zone() == &zone_);
+ thread()->set_zone(zone_.previous_);
#ifdef DEBUG
if (FLAG_trace_zones) {
OS::PrintErr("*** Deleting Stack zone 0x%" Px "(0x%" Px ")\n",
@@ -213,6 +207,18 @@ class StackZone : public StackResource {
private:
Zone zone_;
+ void Initialize() {
+#ifdef DEBUG
+ if (FLAG_trace_zones) {
+ OS::PrintErr("*** Starting a new Stack zone 0x%" Px "(0x%" Px ")\n",
+ reinterpret_cast<intptr_t>(this),
+ reinterpret_cast<intptr_t>(&zone_));
+ }
+#endif
+ zone_.Link(thread()->zone());
+ thread()->set_zone(&zone_);
+ }
+
template<typename T> friend class GrowableArray;
template<typename T> friend class ZoneGrowableArray;
« no previous file with comments | « runtime/vm/vm_sources.gypi ('k') | runtime/vm/zone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698