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

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

Issue 1236403004: Migrate handle scope fields to Thread. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Ready for review. 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/base_isolate.h ('k') | runtime/vm/handles.cc » ('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 #include "vm/flags.h" 9 #include "vm/flags.h"
10 #include "vm/os.h" 10 #include "vm/os.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 static int ZoneHandleCount(); 285 static int ZoneHandleCount();
286 286
287 friend class ApiZone; 287 friend class ApiZone;
288 friend class ApiNativeScope; 288 friend class ApiNativeScope;
289 }; 289 };
290 290
291 291
292 // The class HandleScope is used to start a new handles scope in the code. 292 // The class HandleScope is used to start a new handles scope in the code.
293 // It is used as follows: 293 // It is used as follows:
294 // { 294 // {
295 // HANDLESCOPE(isolate); 295 // HANDLESCOPE(thread);
296 // .... 296 // ....
297 // ..... 297 // .....
298 // code that creates some scoped handles. 298 // code that creates some scoped handles.
299 // .... 299 // ....
300 // } 300 // }
301 class HandleScope : public StackResource { 301 class HandleScope : public StackResource {
302 public: 302 public:
303 explicit HandleScope(Thread* thread);
304 // DEPRECATED: Use Thread version.
303 explicit HandleScope(Isolate* isolate); 305 explicit HandleScope(Isolate* isolate);
304 ~HandleScope(); 306 ~HandleScope();
305 307
306 private: 308 private:
309 void Initialize();
310
307 VMHandles::HandlesBlock* saved_handle_block_; // Handle block at prev scope. 311 VMHandles::HandlesBlock* saved_handle_block_; // Handle block at prev scope.
308 uword saved_handle_slot_; // Next available handle slot at previous scope. 312 uword saved_handle_slot_; // Next available handle slot at previous scope.
309 #if defined(DEBUG) 313 #if defined(DEBUG)
310 HandleScope* link_; // Link to previous scope. 314 HandleScope* link_; // Link to previous scope.
311 #endif 315 #endif
312 DISALLOW_IMPLICIT_CONSTRUCTORS(HandleScope); 316 DISALLOW_IMPLICIT_CONSTRUCTORS(HandleScope);
313 }; 317 };
314 318
315 // Macro to start a new Handle scope. 319 // Macro to start a new Handle scope.
316 #define HANDLESCOPE(isolate) \ 320 #define HANDLESCOPE(isolate_or_thread) \
317 dart::HandleScope vm_internal_handles_scope_(isolate); 321 dart::HandleScope vm_internal_handles_scope_(isolate_or_thread);
318 322
319 323
320 // The class NoHandleScope is used in critical regions of the virtual machine 324 // The class NoHandleScope is used in critical regions of the virtual machine
321 // code where raw dart object pointers are directly manipulated. 325 // code where raw dart object pointers are directly manipulated.
322 // This class asserts that we do not add code that will allocate new handles 326 // This class asserts that we do not add code that will allocate new handles
323 // during this critical area. 327 // during this critical area.
324 // It is used as follows: 328 // It is used as follows:
325 // { 329 // {
326 // NOHANDLESCOPE(isolate); 330 // NOHANDLESCOPE(thread);
327 // .... 331 // ....
328 // ..... 332 // .....
329 // critical code that manipulates dart objects directly. 333 // critical code that manipulates dart objects directly.
330 // .... 334 // ....
331 // } 335 // }
332 #if defined(DEBUG) 336 #if defined(DEBUG)
333 class NoHandleScope : public StackResource { 337 class NoHandleScope : public StackResource {
334 public: 338 public:
339 explicit NoHandleScope(Thread* thread);
340 // DEPRECATED: Use Thread version.
335 explicit NoHandleScope(Isolate* isolate); 341 explicit NoHandleScope(Isolate* isolate);
336 NoHandleScope(); 342 NoHandleScope();
337 ~NoHandleScope(); 343 ~NoHandleScope();
338 344
339 private: 345 private:
340 DISALLOW_COPY_AND_ASSIGN(NoHandleScope); 346 DISALLOW_COPY_AND_ASSIGN(NoHandleScope);
341 }; 347 };
342 #else // defined(DEBUG) 348 #else // defined(DEBUG)
343 class NoHandleScope : public ValueObject { 349 class NoHandleScope : public ValueObject {
344 public: 350 public:
351 explicit NoHandleScope(Thread* thread) { }
345 explicit NoHandleScope(Isolate* isolate) { } 352 explicit NoHandleScope(Isolate* isolate) { }
346 NoHandleScope() { } 353 NoHandleScope() { }
347 ~NoHandleScope() { } 354 ~NoHandleScope() { }
348 355
349 private: 356 private:
350 DISALLOW_COPY_AND_ASSIGN(NoHandleScope); 357 DISALLOW_COPY_AND_ASSIGN(NoHandleScope);
351 }; 358 };
352 #endif // defined(DEBUG) 359 #endif // defined(DEBUG)
353 360
354 // Macro to start a no handles scope in the code. 361 // Macro to start a no handles scope in the code.
355 #define NOHANDLESCOPE(isolate) \ 362 #define NOHANDLESCOPE(isolate_or_thread) \
356 dart::NoHandleScope no_vm_internal_handles_scope_(isolate); 363 dart::NoHandleScope no_vm_internal_handles_scope_(isolate_or_thread);
357 364
358 } // namespace dart 365 } // namespace dart
359 366
360 #endif // VM_HANDLES_H_ 367 #endif // VM_HANDLES_H_
OLDNEW
« no previous file with comments | « runtime/vm/base_isolate.h ('k') | runtime/vm/handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698