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

Side by Side Diff: vm/handles.h

Issue 8562008: Make the implicit constructor private for zone, handlescope and nohandlescope classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years, 1 month 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
« no previous file with comments | « vm/allocation.h ('k') | vm/zone.h » ('j') | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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_HANDLES_H_ 5 #ifndef VM_HANDLES_H_
6 #define VM_HANDLES_H_ 6 #define VM_HANDLES_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 9
10 namespace dart { 10 namespace dart {
11 11
12 // Handles are used in the Dart Virtual Machine to ensure that access 12 // Handles are used in the Dart Virtual Machine to ensure that access
13 // to dart objects in the virtual machine code is done in a 13 // to dart objects in the virtual machine code is done in a
14 // Garbage Collection safe manner. 14 // Garbage Collection safe manner.
15 // 15 //
16 // The class Handles is the basic type that implements creation of handles and 16 // The class Handles is the basic type that implements creation of handles and
17 // manages their life cycle (allocated either in the current zone or 17 // manages their life cycle (allocated either in the current zone or
18 // current handle scope). 18 // current handle scope).
19 // The two forms of handle allocation are: 19 // The two forms of handle allocation are:
20 // - allocation of handles in the current zone (Handle::AllocateZoneHandle). 20 // - allocation of handles in the current zone (Handle::AllocateZoneHandle).
21 // Handles allocated in this manner are destroyed when the zone is destroyed. 21 // Handles allocated in this manner are destroyed when the zone is destroyed.
22 // - allocation of handles in a scoped manner (Handle::AllocateHandle). 22 // - allocation of handles in a scoped manner (Handle::AllocateHandle).
23 // A new scope can be started using HANDLESCOPE(). 23 // A new scope can be started using HANDLESCOPE(isolate).
24 // Handles allocated in this manner are destroyed when the HandleScope 24 // Handles allocated in this manner are destroyed when the HandleScope
25 // object is destroyed. 25 // object is destroyed.
26 // Code that uses scoped handles typically looks as follows: 26 // Code that uses scoped handles typically looks as follows:
27 // { 27 // {
28 // HANDLESCOPE(isolate); 28 // HANDLESCOPE(isolate);
29 // const String& str = String::Handle(String::New("abc")); 29 // const String& str = String::Handle(String::New("abc"));
30 // ..... 30 // .....
31 // ..... 31 // .....
32 // } 32 // }
33 // Code that uses zone handles typically looks as follows: 33 // Code that uses zone handles typically looks as follows:
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 public: 253 public:
254 explicit HandleScope(Isolate* isolate); 254 explicit HandleScope(Isolate* isolate);
255 ~HandleScope(); 255 ~HandleScope();
256 256
257 private: 257 private:
258 VMHandles::HandlesBlock* saved_handle_block_; // Handle block at prev scope. 258 VMHandles::HandlesBlock* saved_handle_block_; // Handle block at prev scope.
259 uword saved_handle_slot_; // Next available handle slot at previous scope. 259 uword saved_handle_slot_; // Next available handle slot at previous scope.
260 #if defined(DEBUG) 260 #if defined(DEBUG)
261 HandleScope* link_; // Link to previous scope. 261 HandleScope* link_; // Link to previous scope.
262 #endif 262 #endif
263 DISALLOW_COPY_AND_ASSIGN(HandleScope); 263 DISALLOW_IMPLICIT_CONSTRUCTORS(HandleScope);
264 }; 264 };
265 265
266 // Macro to start a new Handle scope. 266 // Macro to start a new Handle scope.
267 #define HANDLESCOPE(isolate) \ 267 #define HANDLESCOPE(isolate) \
268 dart::HandleScope vm_internal_handles_scope_(isolate); 268 dart::HandleScope vm_internal_handles_scope_(isolate);
269 269
270 270
271 // The class NoHandleScope is used in critical regions of the virtual machine 271 // The class NoHandleScope is used in critical regions of the virtual machine
272 // code where raw dart object pointers are directly manipulated. 272 // code where raw dart object pointers are directly manipulated.
273 // This class asserts that we do not add code that will allocate new handles 273 // This class asserts that we do not add code that will allocate new handles
274 // during this critical area. 274 // during this critical area.
275 // It is used as follows: 275 // It is used as follows:
276 // { 276 // {
277 // NOHANDLESCOPE(isolate); 277 // NOHANDLESCOPE(isolate);
278 // .... 278 // ....
279 // ..... 279 // .....
280 // critical code that manipulates dart objects directly. 280 // critical code that manipulates dart objects directly.
281 // .... 281 // ....
282 // } 282 // }
283 #if defined(DEBUG) 283 #if defined(DEBUG)
284 class NoHandleScope : public StackResource { 284 class NoHandleScope : public StackResource {
285 public: 285 public:
286 explicit NoHandleScope(Isolate* isolate); 286 explicit NoHandleScope(Isolate* isolate);
287 ~NoHandleScope(); 287 ~NoHandleScope();
288 288
289 private: 289 private:
290 DISALLOW_COPY_AND_ASSIGN(NoHandleScope); 290 DISALLOW_IMPLICIT_CONSTRUCTORS(NoHandleScope);
291 }; 291 };
292 #else // defined(DEBUG) 292 #else // defined(DEBUG)
293 class NoHandleScope : public ValueObject { 293 class NoHandleScope : public ValueObject {
294 public: 294 public:
295 explicit NoHandleScope(Isolate* isolate) { } 295 explicit NoHandleScope(Isolate* isolate) { }
296 ~NoHandleScope() { } 296 ~NoHandleScope() { }
297 297
298 private: 298 private:
299 DISALLOW_COPY_AND_ASSIGN(NoHandleScope); 299 DISALLOW_IMPLICIT_CONSTRUCTORS(NoHandleScope);
300 }; 300 };
301 #endif // defined(DEBUG) 301 #endif // defined(DEBUG)
302 302
303 // Macro to start a no handles scope in the code. 303 // Macro to start a no handles scope in the code.
304 #define NOHANDLESCOPE(isolate) \ 304 #define NOHANDLESCOPE(isolate) \
305 dart::NoHandleScope no_vm_internal_handles_scope_(isolate); 305 dart::NoHandleScope no_vm_internal_handles_scope_(isolate);
306 306
307 } // namespace dart 307 } // namespace dart
308 308
309 #endif // VM_HANDLES_H_ 309 #endif // VM_HANDLES_H_
OLDNEW
« no previous file with comments | « vm/allocation.h ('k') | vm/zone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698