2012-04-06 18:00:51 +00:00
|
|
|
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef VM_BASE_ISOLATE_H_
|
|
|
|
#define VM_BASE_ISOLATE_H_
|
|
|
|
|
|
|
|
namespace dart {
|
|
|
|
|
|
|
|
class HandleScope;
|
|
|
|
class StackResource;
|
2012-10-16 22:05:40 +00:00
|
|
|
class Zone;
|
2012-04-06 18:00:51 +00:00
|
|
|
|
|
|
|
// A BaseIsolate contains just enough functionality to allocate
|
|
|
|
// StackResources. This allows us to inline the StackResource
|
|
|
|
// constructor/destructor for performance.
|
|
|
|
class BaseIsolate {
|
|
|
|
public:
|
|
|
|
StackResource* top_resource() const { return top_resource_; }
|
|
|
|
void set_top_resource(StackResource* value) { top_resource_ = value; }
|
|
|
|
|
2012-10-16 22:05:40 +00:00
|
|
|
Zone* current_zone() const { return current_zone_; }
|
|
|
|
void set_current_zone(Zone* zone) { current_zone_ = zone; }
|
2012-04-06 18:00:51 +00:00
|
|
|
|
|
|
|
HandleScope* top_handle_scope() const {
|
|
|
|
#if defined(DEBUG)
|
|
|
|
return top_handle_scope_;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_top_handle_scope(HandleScope* handle_scope) {
|
|
|
|
#if defined(DEBUG)
|
|
|
|
top_handle_scope_ = handle_scope;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t no_handle_scope_depth() const {
|
|
|
|
#if defined(DEBUG)
|
|
|
|
return no_handle_scope_depth_;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void IncrementNoHandleScopeDepth() {
|
|
|
|
#if defined(DEBUG)
|
|
|
|
ASSERT(no_handle_scope_depth_ < INT_MAX);
|
|
|
|
no_handle_scope_depth_ += 1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void DecrementNoHandleScopeDepth() {
|
|
|
|
#if defined(DEBUG)
|
|
|
|
ASSERT(no_handle_scope_depth_ > 0);
|
|
|
|
no_handle_scope_depth_ -= 1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t no_gc_scope_depth() const {
|
|
|
|
#if defined(DEBUG)
|
|
|
|
return no_gc_scope_depth_;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void IncrementNoGCScopeDepth() {
|
|
|
|
#if defined(DEBUG)
|
|
|
|
ASSERT(no_gc_scope_depth_ < INT_MAX);
|
|
|
|
no_gc_scope_depth_ += 1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void DecrementNoGCScopeDepth() {
|
|
|
|
#if defined(DEBUG)
|
|
|
|
ASSERT(no_gc_scope_depth_ > 0);
|
|
|
|
no_gc_scope_depth_ -= 1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-01-31 23:56:48 +00:00
|
|
|
int32_t no_callback_scope_depth() const {
|
|
|
|
return no_callback_scope_depth_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void IncrementNoCallbackScopeDepth() {
|
|
|
|
ASSERT(no_callback_scope_depth_ < INT_MAX);
|
|
|
|
no_callback_scope_depth_ += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DecrementNoCallbackScopeDepth() {
|
|
|
|
ASSERT(no_callback_scope_depth_ > 0);
|
|
|
|
no_callback_scope_depth_ -= 1;
|
|
|
|
}
|
|
|
|
|
2012-04-06 18:00:51 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
static void AssertCurrent(BaseIsolate* isolate);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
|
|
|
BaseIsolate()
|
|
|
|
: top_resource_(NULL),
|
|
|
|
current_zone_(NULL),
|
2013-01-31 23:56:48 +00:00
|
|
|
#if defined(DEBUG)
|
2012-04-06 18:00:51 +00:00
|
|
|
top_handle_scope_(NULL),
|
|
|
|
no_handle_scope_depth_(0),
|
2013-01-31 23:56:48 +00:00
|
|
|
no_gc_scope_depth_(0),
|
2012-04-06 18:00:51 +00:00
|
|
|
#endif
|
2013-01-31 23:56:48 +00:00
|
|
|
no_callback_scope_depth_(0)
|
2012-04-06 18:00:51 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
~BaseIsolate() {
|
|
|
|
// Do not delete stack resources: top_resource_ and current_zone_.
|
|
|
|
}
|
|
|
|
|
|
|
|
StackResource* top_resource_;
|
2012-10-16 22:05:40 +00:00
|
|
|
Zone* current_zone_;
|
2012-04-06 18:00:51 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
HandleScope* top_handle_scope_;
|
|
|
|
int32_t no_handle_scope_depth_;
|
|
|
|
int32_t no_gc_scope_depth_;
|
|
|
|
#endif
|
2013-01-31 23:56:48 +00:00
|
|
|
int32_t no_callback_scope_depth_;
|
2012-04-06 18:00:51 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(BaseIsolate);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dart
|
|
|
|
|
|
|
|
#endif // VM_BASE_ISOLATE_H_
|