| OLD | NEW |
| 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 #include "vm/handles.h" | 5 #include "vm/handles.h" |
| 6 | 6 |
| 7 #include "vm/assert.h" | 7 #include "vm/assert.h" |
| 8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/os.h" | 10 #include "vm/os.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 int VMHandles::ZoneHandleCount() { | 64 int VMHandles::ZoneHandleCount() { |
| 65 Isolate* isolate = Isolate::Current(); | 65 Isolate* isolate = Isolate::Current(); |
| 66 ASSERT(isolate->current_zone() != NULL); | 66 ASSERT(isolate->current_zone() != NULL); |
| 67 VMHandles* handles = isolate->current_zone()->handles(); | 67 VMHandles* handles = isolate->current_zone()->handles(); |
| 68 return handles->CountZoneHandles(); | 68 return handles->CountZoneHandles(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 | 71 |
| 72 HandleScope::HandleScope() : StackResource() { | 72 HandleScope::HandleScope() : StackResource() { |
| 73 Isolate* isolate = Isolate::Current(); | 73 ASSERT(isolate()->no_handle_scope_depth() == 0); |
| 74 ASSERT(isolate->no_handle_scope_depth() == 0); | 74 VMHandles* handles = isolate()->current_zone()->handles(); |
| 75 VMHandles* handles = isolate->current_zone()->handles(); | |
| 76 ASSERT(handles != NULL); | 75 ASSERT(handles != NULL); |
| 77 saved_handle_block_ = handles->scoped_blocks_; | 76 saved_handle_block_ = handles->scoped_blocks_; |
| 78 saved_handle_slot_ = handles->scoped_blocks_->next_handle_slot(); | 77 saved_handle_slot_ = handles->scoped_blocks_->next_handle_slot(); |
| 79 #if defined(DEBUG) | 78 #if defined(DEBUG) |
| 80 link_ = isolate->top_handle_scope(); | 79 link_ = isolate()->top_handle_scope(); |
| 81 isolate->set_top_handle_scope(this); | 80 isolate()->set_top_handle_scope(this); |
| 82 #endif | 81 #endif |
| 83 } | 82 } |
| 84 | 83 |
| 85 | 84 |
| 86 HandleScope::~HandleScope() { | 85 HandleScope::~HandleScope() { |
| 87 Isolate* isolate = Isolate::Current(); | 86 ASSERT(isolate()->current_zone() != NULL); |
| 88 ASSERT(isolate->current_zone() != NULL); | 87 VMHandles* handles = isolate()->current_zone()->handles(); |
| 89 VMHandles* handles = isolate->current_zone()->handles(); | |
| 90 ASSERT(handles != NULL); | 88 ASSERT(handles != NULL); |
| 91 handles->scoped_blocks_ = saved_handle_block_; | 89 handles->scoped_blocks_ = saved_handle_block_; |
| 92 handles->scoped_blocks_->set_next_handle_slot(saved_handle_slot_); | 90 handles->scoped_blocks_->set_next_handle_slot(saved_handle_slot_); |
| 93 #if defined(DEBUG) | 91 #if defined(DEBUG) |
| 94 handles->VerifyScopedHandleState(); | 92 handles->VerifyScopedHandleState(); |
| 95 handles->ZapFreeScopedHandles(); | 93 handles->ZapFreeScopedHandles(); |
| 96 ASSERT(isolate->top_handle_scope() == this); | 94 ASSERT(isolate()->top_handle_scope() == this); |
| 97 isolate->set_top_handle_scope(link_); | 95 isolate()->set_top_handle_scope(link_); |
| 98 #endif | 96 #endif |
| 99 } | 97 } |
| 100 | 98 |
| 101 | 99 |
| 102 #if defined(DEBUG) | 100 #if defined(DEBUG) |
| 103 NoHandleScope::NoHandleScope() : StackResource() { | 101 NoHandleScope::NoHandleScope() : StackResource() { |
| 104 Isolate* isolate = Isolate::Current(); | 102 isolate()->IncrementNoHandleScopeDepth(); |
| 105 isolate->IncrementNoHandleScopeDepth(); | |
| 106 } | 103 } |
| 107 | 104 |
| 108 | 105 |
| 109 NoHandleScope::~NoHandleScope() { | 106 NoHandleScope::~NoHandleScope() { |
| 110 Isolate* isolate = Isolate::Current(); | 107 isolate()->DecrementNoHandleScopeDepth(); |
| 111 isolate->DecrementNoHandleScopeDepth(); | |
| 112 } | 108 } |
| 113 #endif // defined(DEBUG) | 109 #endif // defined(DEBUG) |
| 114 | 110 |
| 115 } // namespace dart | 111 } // namespace dart |
| OLD | NEW |