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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 ASSERT(thread->zone() == zone); | 116 ASSERT(thread->zone() == zone); |
117 ASSERT(thread->no_handle_scope_depth() == 0); | 117 ASSERT(thread->no_handle_scope_depth() == 0); |
118 #endif // DEBUG | 118 #endif // DEBUG |
119 Handles* handles = zone->handles(); | 119 Handles* handles = zone->handles(); |
120 ASSERT(handles != NULL); | 120 ASSERT(handles != NULL); |
121 uword address = handles->AllocateHandleInZone(); | 121 uword address = handles->AllocateHandleInZone(); |
122 return address; | 122 return address; |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 // Figure out the current zone using the current Isolate and | 126 // Figure out the current zone using the current Thread and |
127 // check if the specified handle has been allocated in this zone. | 127 // check if the specified handle has been allocated in this zone. |
128 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 128 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
129 bool Handles<kHandleSizeInWords, | 129 bool Handles<kHandleSizeInWords, |
130 kHandlesPerChunk, | 130 kHandlesPerChunk, |
131 kOffsetOfRawPtr>::IsZoneHandle(uword handle) { | 131 kOffsetOfRawPtr>::IsZoneHandle(uword handle) { |
132 // TODO(5411412): Accessing the current isolate is a performance problem, | 132 // TODO(5411412): Accessing the current thread is a performance problem, |
133 // consider passing it down as a parameter. | 133 // consider passing it down as a parameter. |
134 Isolate* isolate = Isolate::Current(); | 134 Thread* thread = Thread::Current(); |
135 ASSERT(isolate != NULL); | 135 ASSERT(thread != NULL); |
136 ASSERT(isolate->current_zone() != NULL); | 136 ASSERT(thread->zone() != NULL); |
137 Handles* handles = isolate->current_zone()->handles(); | 137 Handles* handles = thread->zone()->handles(); |
138 ASSERT(handles != NULL); | 138 ASSERT(handles != NULL); |
139 return handles->IsValidZoneHandle(handle); | 139 return handles->IsValidZoneHandle(handle); |
140 } | 140 } |
141 | 141 |
142 | 142 |
143 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 143 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
144 void Handles<kHandleSizeInWords, | 144 void Handles<kHandleSizeInWords, |
145 kHandlesPerChunk, | 145 kHandlesPerChunk, |
146 kOffsetOfRawPtr>::DeleteAll() { | 146 kOffsetOfRawPtr>::DeleteAll() { |
147 // Delete all the zone allocated handle blocks. | 147 // Delete all the zone allocated handle blocks. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 369 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
370 int Handles<kHandleSizeInWords, | 370 int Handles<kHandleSizeInWords, |
371 kHandlesPerChunk, | 371 kHandlesPerChunk, |
372 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { | 372 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { |
373 return (next_handle_slot_ / kHandleSizeInWords); | 373 return (next_handle_slot_ / kHandleSizeInWords); |
374 } | 374 } |
375 | 375 |
376 } // namespace dart | 376 } // namespace dart |
377 | 377 |
378 #endif // VM_HANDLES_IMPL_H_ | 378 #endif // VM_HANDLES_IMPL_H_ |
OLD | NEW |