OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_IMPL_H_ | 5 #ifndef VM_HANDLES_IMPL_H_ |
6 #define VM_HANDLES_IMPL_H_ | 6 #define VM_HANDLES_IMPL_H_ |
7 | 7 |
8 #include "vm/heap.h" | 8 #include "vm/heap.h" |
9 #include "vm/thread.h" | 9 #include "vm/thread.h" |
10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // Figure out the current handle scope using the current Zone and | 89 // Figure out the current handle scope using the current Zone and |
90 // allocate a handle in that scope. The function assumes that a | 90 // allocate a handle in that scope. The function assumes that a |
91 // current handle scope exists. It asserts for this appropriately. | 91 // current handle scope exists. It asserts for this appropriately. |
92 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 92 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
93 uword Handles<kHandleSizeInWords, | 93 uword Handles<kHandleSizeInWords, |
94 kHandlesPerChunk, | 94 kHandlesPerChunk, |
95 kOffsetOfRawPtr>::AllocateHandle(Zone* zone) { | 95 kOffsetOfRawPtr>::AllocateHandle(Zone* zone) { |
96 #if defined(DEBUG) | 96 #if defined(DEBUG) |
97 Thread* thread = Thread::Current(); | 97 Thread* thread = Thread::Current(); |
98 ASSERT(thread->zone() == zone); | 98 ASSERT(thread->zone() == zone); |
99 Isolate* isolate = thread->isolate(); | 99 ASSERT(thread->top_handle_scope() != NULL); |
100 ASSERT(isolate != NULL); | 100 ASSERT(thread->no_handle_scope_depth() == 0); |
101 ASSERT(isolate->top_handle_scope() != NULL); | |
102 ASSERT(isolate->no_handle_scope_depth() == 0); | |
103 #endif // DEBUG | 101 #endif // DEBUG |
104 Handles* handles = zone->handles(); | 102 Handles* handles = zone->handles(); |
105 ASSERT(handles != NULL); | 103 ASSERT(handles != NULL); |
106 return handles->AllocateScopedHandle(); | 104 return handles->AllocateScopedHandle(); |
107 } | 105 } |
108 | 106 |
109 | 107 |
110 // The function assumes that 'zone' is the current zone and asserts for | 108 // The function assumes that 'zone' is the current zone and asserts for |
111 // this appropriately. | 109 // this appropriately. |
112 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 110 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
113 uword Handles<kHandleSizeInWords, | 111 uword Handles<kHandleSizeInWords, |
114 kHandlesPerChunk, | 112 kHandlesPerChunk, |
115 kOffsetOfRawPtr>::AllocateZoneHandle(Zone* zone) { | 113 kOffsetOfRawPtr>::AllocateZoneHandle(Zone* zone) { |
116 #if defined(DEBUG) | 114 #if defined(DEBUG) |
117 Thread* thread = Thread::Current(); | 115 Thread* thread = Thread::Current(); |
118 ASSERT(thread->zone() == zone); | 116 ASSERT(thread->zone() == zone); |
119 Isolate* isolate = thread->isolate(); | 117 ASSERT(thread->no_handle_scope_depth() == 0); |
120 ASSERT(isolate != NULL); | |
121 ASSERT(isolate->no_handle_scope_depth() == 0); | |
122 #endif // DEBUG | 118 #endif // DEBUG |
123 Handles* handles = zone->handles(); | 119 Handles* handles = zone->handles(); |
124 ASSERT(handles != NULL); | 120 ASSERT(handles != NULL); |
125 uword address = handles->AllocateHandleInZone(); | 121 uword address = handles->AllocateHandleInZone(); |
126 return address; | 122 return address; |
127 } | 123 } |
128 | 124 |
129 | 125 |
130 // Figure out the current zone using the current Isolate and | 126 // Figure out the current zone using the current Isolate and |
131 // check if the specified handle has been allocated in this zone. | 127 // check if the specified handle has been allocated in this zone. |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 369 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
374 int Handles<kHandleSizeInWords, | 370 int Handles<kHandleSizeInWords, |
375 kHandlesPerChunk, | 371 kHandlesPerChunk, |
376 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { | 372 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { |
377 return (next_handle_slot_ / kHandleSizeInWords); | 373 return (next_handle_slot_ / kHandleSizeInWords); |
378 } | 374 } |
379 | 375 |
380 } // namespace dart | 376 } // namespace dart |
381 | 377 |
382 #endif // VM_HANDLES_IMPL_H_ | 378 #endif // VM_HANDLES_IMPL_H_ |
OLD | NEW |