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

Side by Side Diff: runtime/vm/reusable_handles.h

Issue 181843007: 1. Added new versions of Api::UnWrapStringHandle Api::UnWrapInstanceHandle to (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_REUSABLE_HANDLES_H_ 5 #ifndef VM_REUSABLE_HANDLES_H_
6 #define VM_REUSABLE_HANDLES_H_ 6 #define VM_REUSABLE_HANDLES_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/handles.h" 9 #include "vm/handles.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 24 matching lines...) Expand all
35 ReusableObjectHandleScope() 35 ReusableObjectHandleScope()
36 : StackResource(Isolate::Current()), isolate_(Isolate::Current()) { 36 : StackResource(Isolate::Current()), isolate_(Isolate::Current()) {
37 ASSERT(!isolate()->reusable_handle_scope_active()); 37 ASSERT(!isolate()->reusable_handle_scope_active());
38 isolate()->set_reusable_handle_scope_active(true); 38 isolate()->set_reusable_handle_scope_active(true);
39 } 39 }
40 ~ReusableObjectHandleScope() { 40 ~ReusableObjectHandleScope() {
41 ASSERT(isolate()->reusable_handle_scope_active()); 41 ASSERT(isolate()->reusable_handle_scope_active());
42 isolate()->set_reusable_handle_scope_active(false); 42 isolate()->set_reusable_handle_scope_active(false);
43 Handle().raw_ = Object::null(); 43 Handle().raw_ = Object::null();
44 } 44 }
45 Object& Handle() { 45 Object& Handle() const {
46 ASSERT(isolate_->Object_handle_ != NULL); 46 ASSERT(isolate_->Object_handle_ != NULL);
47 return *isolate_->Object_handle_; 47 return *isolate_->Object_handle_;
48 } 48 }
49 49
50 private: 50 private:
51 Isolate* isolate_; 51 Isolate* isolate_;
52 DISALLOW_COPY_AND_ASSIGN(ReusableObjectHandleScope); 52 DISALLOW_COPY_AND_ASSIGN(ReusableObjectHandleScope);
53 }; 53 };
54 54
55 55
(...skipping 12 matching lines...) Expand all
68 ~ReusableHandleScope() { 68 ~ReusableHandleScope() {
69 ASSERT(isolate()->reusable_handle_scope_active()); 69 ASSERT(isolate()->reusable_handle_scope_active());
70 isolate()->set_reusable_handle_scope_active(false); 70 isolate()->set_reusable_handle_scope_active(false);
71 #define CLEAR_REUSABLE_HANDLE(object) \ 71 #define CLEAR_REUSABLE_HANDLE(object) \
72 object##Handle().raw_ = Object::null(); \ 72 object##Handle().raw_ = Object::null(); \
73 73
74 REUSABLE_HANDLE_LIST(CLEAR_REUSABLE_HANDLE); 74 REUSABLE_HANDLE_LIST(CLEAR_REUSABLE_HANDLE);
75 } 75 }
76 76
77 #define REUSABLE_HANDLE_ACCESSORS(object) \ 77 #define REUSABLE_HANDLE_ACCESSORS(object) \
78 object& object##Handle() { \ 78 object& object##Handle() const { \
79 ASSERT(isolate_->object##_handle_ != NULL); \ 79 ASSERT(isolate_->object##_handle_ != NULL); \
80 return *isolate_->object##_handle_; \ 80 return *isolate_->object##_handle_; \
81 } \ 81 } \
82 82
83 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ACCESSORS) 83 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ACCESSORS)
84 #undef REUSABLE_HANDLE_ACCESSORS 84 #undef REUSABLE_HANDLE_ACCESSORS
85 85
86 private: 86 private:
87 void ResetHandles(); 87 void ResetHandles();
88 Isolate* isolate_; 88 Isolate* isolate_;
89 DISALLOW_COPY_AND_ASSIGN(ReusableHandleScope); 89 DISALLOW_COPY_AND_ASSIGN(ReusableHandleScope);
90 }; 90 };
91 #else 91 #else
92 class ReusableObjectHandleScope : public ValueObject { 92 class ReusableObjectHandleScope : public ValueObject {
93 public: 93 public:
94 explicit ReusableObjectHandleScope(Isolate* isolate) 94 explicit ReusableObjectHandleScope(Isolate* isolate)
95 : handle_(isolate->Object_handle_) { 95 : handle_(isolate->Object_handle_) {
96 } 96 }
97 ReusableObjectHandleScope() : handle_(Isolate::Current()->Object_handle_) { 97 ReusableObjectHandleScope() : handle_(Isolate::Current()->Object_handle_) {
98 } 98 }
99 ~ReusableObjectHandleScope() { 99 ~ReusableObjectHandleScope() {
100 handle_->raw_ = Object::null(); 100 handle_->raw_ = Object::null();
101 } 101 }
102 Object& Handle() { 102 Object& Handle() const {
103 ASSERT(handle_ != NULL); 103 ASSERT(handle_ != NULL);
104 return *handle_; 104 return *handle_;
105 } 105 }
106 106
107 private: 107 private:
108 Object* handle_; 108 Object* handle_;
109 DISALLOW_COPY_AND_ASSIGN(ReusableObjectHandleScope); 109 DISALLOW_COPY_AND_ASSIGN(ReusableObjectHandleScope);
110 }; 110 };
111 111
112 112
113 class ReusableHandleScope : public ValueObject { 113 class ReusableHandleScope : public ValueObject {
114 public: 114 public:
115 explicit ReusableHandleScope(Isolate* isolate) : isolate_(isolate) { 115 explicit ReusableHandleScope(Isolate* isolate) : isolate_(isolate) {
116 } 116 }
117 ReusableHandleScope() : isolate_(Isolate::Current()) { 117 ReusableHandleScope() : isolate_(Isolate::Current()) {
118 } 118 }
119 ~ReusableHandleScope() { 119 ~ReusableHandleScope() {
120 #define CLEAR_REUSABLE_HANDLE(object) \ 120 #define CLEAR_REUSABLE_HANDLE(object) \
121 object##Handle().raw_ = Object::null(); \ 121 object##Handle().raw_ = Object::null(); \
122 122
123 REUSABLE_HANDLE_LIST(CLEAR_REUSABLE_HANDLE); 123 REUSABLE_HANDLE_LIST(CLEAR_REUSABLE_HANDLE);
124 } 124 }
125 125
126 #define REUSABLE_HANDLE_ACCESSORS(object) \ 126 #define REUSABLE_HANDLE_ACCESSORS(object) \
127 object& object##Handle() { \ 127 object& object##Handle() const { \
128 ASSERT(isolate_->object##_handle_ != NULL); \ 128 ASSERT(isolate_->object##_handle_ != NULL); \
129 return *isolate_->object##_handle_; \ 129 return *isolate_->object##_handle_; \
130 } \ 130 } \
131 131
132 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ACCESSORS) 132 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ACCESSORS)
133 #undef REUSABLE_HANDLE_ACCESSORS 133 #undef REUSABLE_HANDLE_ACCESSORS
134 134
135 private: 135 private:
136 void ResetHandles(); 136 void ResetHandles();
137 Isolate* isolate_; 137 Isolate* isolate_;
138 DISALLOW_COPY_AND_ASSIGN(ReusableHandleScope); 138 DISALLOW_COPY_AND_ASSIGN(ReusableHandleScope);
139 }; 139 };
140 #endif // defined(DEBUG) 140 #endif // defined(DEBUG)
141 141
142 } // namespace dart 142 } // namespace dart
143 143
144 #endif // VM_REUSABLE_HANDLES_H_ 144 #endif // VM_REUSABLE_HANDLES_H_
OLDNEW
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698