Index: runtime/vm/reusable_handles.h |
=================================================================== |
--- runtime/vm/reusable_handles.h (revision 33332) |
+++ runtime/vm/reusable_handles.h (working copy) |
@@ -24,121 +24,77 @@ |
// Array& funcs = reused_handles.ArrayHandle(); |
// .... |
// } |
-#if defined(DEBUG) |
-class ReusableObjectHandleScope : public StackResource { |
- public: |
- explicit ReusableObjectHandleScope(Isolate* isolate) |
- : StackResource(isolate), isolate_(isolate) { |
- ASSERT(!isolate->reusable_handle_scope_active()); |
- isolate->set_reusable_handle_scope_active(true); |
- } |
- ReusableObjectHandleScope() |
- : StackResource(Isolate::Current()), isolate_(Isolate::Current()) { |
- ASSERT(!isolate()->reusable_handle_scope_active()); |
- isolate()->set_reusable_handle_scope_active(true); |
- } |
- ~ReusableObjectHandleScope() { |
- ASSERT(isolate()->reusable_handle_scope_active()); |
- isolate()->set_reusable_handle_scope_active(false); |
- Handle().raw_ = Object::null(); |
- } |
- Object& Handle() const { |
- ASSERT(isolate_->Object_handle_ != NULL); |
- return *isolate_->Object_handle_; |
- } |
- private: |
- Isolate* isolate_; |
- DISALLOW_COPY_AND_ASSIGN(ReusableObjectHandleScope); |
-}; |
- |
- |
-class ReusableHandleScope : public StackResource { |
- public: |
- explicit ReusableHandleScope(Isolate* isolate) |
- : StackResource(isolate), isolate_(isolate) { |
- ASSERT(!isolate->reusable_handle_scope_active()); |
- isolate->set_reusable_handle_scope_active(true); |
- } |
- ReusableHandleScope() |
- : StackResource(Isolate::Current()), isolate_(Isolate::Current()) { |
- ASSERT(!isolate()->reusable_handle_scope_active()); |
- isolate()->set_reusable_handle_scope_active(true); |
- } |
- ~ReusableHandleScope() { |
- ASSERT(isolate()->reusable_handle_scope_active()); |
- isolate()->set_reusable_handle_scope_active(false); |
-#define CLEAR_REUSABLE_HANDLE(object) \ |
- object##Handle().raw_ = Object::null(); \ |
- |
- REUSABLE_HANDLE_LIST(CLEAR_REUSABLE_HANDLE); |
- } |
- |
-#define REUSABLE_HANDLE_ACCESSORS(object) \ |
- object& object##Handle() const { \ |
- ASSERT(isolate_->object##_handle_ != NULL); \ |
- return *isolate_->object##_handle_; \ |
- } \ |
- |
- REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ACCESSORS) |
-#undef REUSABLE_HANDLE_ACCESSORS |
- |
- private: |
- void ResetHandles(); |
- Isolate* isolate_; |
- DISALLOW_COPY_AND_ASSIGN(ReusableHandleScope); |
-}; |
+#if defined(DEBUG) |
+#define REUSABLE_SCOPE(name) \ |
+ class Reusable##name##HandleScope : public ValueObject { \ |
+ public: \ |
+ explicit Reusable##name##HandleScope(Isolate* isolate) \ |
+ : isolate_(isolate) { \ |
+ ASSERT(!isolate->reusable_##name##_handle_scope_active()); \ |
+ isolate->set_reusable_##name##_handle_scope_active(true); \ |
+ } \ |
+ Reusable##name##HandleScope() : isolate_(Isolate::Current()) { \ |
+ ASSERT(!isolate_->reusable_##name##_handle_scope_active()); \ |
+ isolate_->set_reusable_##name##_handle_scope_active(true); \ |
+ } \ |
+ ~Reusable##name##HandleScope() { \ |
+ ASSERT(isolate_->reusable_##name##_handle_scope_active()); \ |
+ isolate_->set_reusable_##name##_handle_scope_active(false); \ |
+ Handle().raw_ = name::null(); \ |
+ } \ |
+ name& Handle() const { \ |
+ ASSERT(isolate_->name##_handle_ != NULL); \ |
+ return *isolate_->name##_handle_; \ |
+ } \ |
+ private: \ |
+ Isolate* isolate_; \ |
+ DISALLOW_COPY_AND_ASSIGN(Reusable##name##HandleScope); \ |
+ }; |
#else |
-class ReusableObjectHandleScope : public ValueObject { |
- public: |
- explicit ReusableObjectHandleScope(Isolate* isolate) |
- : handle_(isolate->Object_handle_) { |
- } |
- ReusableObjectHandleScope() : handle_(Isolate::Current()->Object_handle_) { |
- } |
- ~ReusableObjectHandleScope() { |
- handle_->raw_ = Object::null(); |
- } |
- Object& Handle() const { |
- ASSERT(handle_ != NULL); |
- return *handle_; |
- } |
- |
- private: |
- Object* handle_; |
- DISALLOW_COPY_AND_ASSIGN(ReusableObjectHandleScope); |
-}; |
- |
- |
-class ReusableHandleScope : public ValueObject { |
- public: |
- explicit ReusableHandleScope(Isolate* isolate) : isolate_(isolate) { |
- } |
- ReusableHandleScope() : isolate_(Isolate::Current()) { |
- } |
- ~ReusableHandleScope() { |
-#define CLEAR_REUSABLE_HANDLE(object) \ |
- object##Handle().raw_ = Object::null(); \ |
- |
- REUSABLE_HANDLE_LIST(CLEAR_REUSABLE_HANDLE); |
- } |
- |
-#define REUSABLE_HANDLE_ACCESSORS(object) \ |
- object& object##Handle() const { \ |
- ASSERT(isolate_->object##_handle_ != NULL); \ |
- return *isolate_->object##_handle_; \ |
- } \ |
- |
- REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ACCESSORS) |
-#undef REUSABLE_HANDLE_ACCESSORS |
- |
- private: |
- void ResetHandles(); |
- Isolate* isolate_; |
- DISALLOW_COPY_AND_ASSIGN(ReusableHandleScope); |
-}; |
+#define REUSABLE_SCOPE(name) \ |
+ class Reusable##name##HandleScope : public ValueObject { \ |
+ public: \ |
+ explicit Reusable##name##HandleScope(Isolate* isolate) \ |
+ : handle_(isolate->name##_handle_) { \ |
+ } \ |
+ Reusable##name##HandleScope() \ |
+ : handle_(Isolate::Current()->name##_handle_) { \ |
+ } \ |
+ ~Reusable##name##HandleScope() { \ |
+ handle_->raw_ = name::null(); \ |
+ } \ |
+ name& Handle() const { \ |
+ ASSERT(handle_ != NULL); \ |
+ return *handle_; \ |
+ } \ |
+ private: \ |
+ name* handle_; \ |
+ DISALLOW_COPY_AND_ASSIGN(Reusable##name##HandleScope); \ |
+ }; |
#endif // defined(DEBUG) |
+REUSABLE_HANDLE_LIST(REUSABLE_SCOPE) |
+#undef REUSABLE_SCOPE |
+#define REUSABLE_OBJECT_HANDLESCOPE(isolate) \ |
+ ReusableObjectHandleScope reused_object_handle(isolate); |
+#define REUSABLE_ARRAY_HANDLESCOPE(isolate) \ |
+ ReusableArrayHandleScope reused_array_handle(isolate); |
+#define REUSABLE_STRING_HANDLESCOPE(isolate) \ |
+ ReusableStringHandleScope reused_string_handle(isolate); |
+#define REUSABLE_INSTANCE_HANDLESCOPE(isolate) \ |
+ ReusableInstanceHandleScope reused_instance_handle(isolate); |
+#define REUSABLE_FUNCTION_HANDLESCOPE(isolate) \ |
+ ReusableFunctionHandleScope reused_function_handle(isolate); |
+#define REUSABLE_FIELD_HANDLESCOPE(isolate) \ |
+ ReusableFieldHandleScope reused_field_handle(isolate); |
+#define REUSABLE_CLASS_HANDLESCOPE(isolate) \ |
+ ReusableClassHandleScope reused_class_handle(isolate); |
+#define REUSABLE_TYPE_PARAMETER_HANDLESCOPE(isolate) \ |
+ ReusableTypeParameterHandleScope reused_type_parameter(isolate); |
+#define REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(isolate) \ |
+ ReusableTypeArgumentsHandleScope reused_type_arguments_handle(isolate); |
+ |
} // namespace dart |
#endif // VM_REUSABLE_HANDLES_H_ |