Chromium Code Reviews| 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/visitor.h" | 9 #include "vm/visitor.h" |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 } | 78 } |
| 79 | 79 |
| 80 // Delete all the extra scoped handle blocks allocated and reinit the first | 80 // Delete all the extra scoped handle blocks allocated and reinit the first |
| 81 // scoped block. | 81 // scoped block. |
| 82 DeleteHandleBlocks(first_scoped_block_.next_block()); | 82 DeleteHandleBlocks(first_scoped_block_.next_block()); |
| 83 first_scoped_block_.ReInit(); | 83 first_scoped_block_.ReInit(); |
| 84 scoped_blocks_ = &first_scoped_block_; | 84 scoped_blocks_ = &first_scoped_block_; |
| 85 } | 85 } |
| 86 | 86 |
| 87 | 87 |
| 88 // Figure out the current handle scope using the current Isolate and | 88 // Figure out the current handle scope using the current Zone and |
| 89 // allocate a handle in that scope. The function assumes that a | 89 // allocate a handle in that scope. The function assumes that a |
| 90 // current Isolate, current zone and current handle scope exist. It | 90 // current handle scope exists. It asserts for this appropriately. |
| 91 // asserts for this appropriately. | |
| 92 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 91 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 93 uword Handles<kHandleSizeInWords, | 92 uword Handles<kHandleSizeInWords, |
| 94 kHandlesPerChunk, | 93 kHandlesPerChunk, |
| 95 kOffsetOfRawPtr>::AllocateHandle(Isolate* isolate) { | 94 kOffsetOfRawPtr>::AllocateHandle(Zone* zone) { |
| 95 #if defined(DEBUG) | |
| 96 Isolate* isolate = Isolate::Current(); | |
|
siva
2015/01/23 19:29:27
I think this should be
Thread* thread = Thread::Cu
koda
2015/01/23 21:09:42
Agreed. That's why I already marked it as obsolete
| |
| 96 ASSERT(isolate != NULL); | 97 ASSERT(isolate != NULL); |
| 97 ASSERT(isolate->current_zone() != NULL); | 98 ASSERT(isolate->current_zone() == zone); |
| 98 ASSERT(isolate->top_handle_scope() != NULL); | 99 ASSERT(isolate->top_handle_scope() != NULL); |
| 99 ASSERT(isolate->no_handle_scope_depth() == 0); | 100 ASSERT(isolate->no_handle_scope_depth() == 0); |
| 100 Handles* handles = isolate->current_zone()->handles(); | 101 #endif // DEBUG |
| 102 Handles* handles = zone->handles(); | |
| 101 ASSERT(handles != NULL); | 103 ASSERT(handles != NULL); |
| 102 return handles->AllocateScopedHandle(); | 104 return handles->AllocateScopedHandle(); |
| 103 } | 105 } |
| 104 | 106 |
| 105 | 107 |
| 106 // Figure out the current zone using the current Isolate and | 108 // The function assumes that 'zone' is the current zone and asserts for |
| 107 // allocate a handle in that zone. The function assumes that a | |
| 108 // current Isolate and current zone exist. It asserts for | |
| 109 // this appropriately. | 109 // this appropriately. |
| 110 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 110 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 111 uword Handles<kHandleSizeInWords, | 111 uword Handles<kHandleSizeInWords, |
| 112 kHandlesPerChunk, | 112 kHandlesPerChunk, |
| 113 kOffsetOfRawPtr>::AllocateZoneHandle(Isolate* isolate) { | 113 kOffsetOfRawPtr>::AllocateZoneHandle(Zone* zone) { |
| 114 #if defined(DEBUG) | |
| 115 Isolate* isolate = Isolate::Current(); | |
|
siva
2015/01/23 19:29:27
Ditto here Thread::Current();
koda
2015/01/23 21:09:42
Done.
| |
| 114 ASSERT(isolate != NULL); | 116 ASSERT(isolate != NULL); |
| 115 ASSERT(isolate->current_zone() != NULL); | 117 ASSERT(isolate->current_zone() == zone); |
| 116 ASSERT(isolate->no_handle_scope_depth() == 0); | 118 ASSERT(isolate->no_handle_scope_depth() == 0); |
| 117 Handles* handles = isolate->current_zone()->handles(); | 119 #endif // DEBUG |
| 120 Handles* handles = zone->handles(); | |
| 118 ASSERT(handles != NULL); | 121 ASSERT(handles != NULL); |
| 119 uword address = handles->AllocateHandleInZone(); | 122 uword address = handles->AllocateHandleInZone(); |
| 120 return address; | 123 return address; |
| 121 } | 124 } |
| 122 | 125 |
| 123 | 126 |
| 124 // Figure out the current zone using the current Isolate and | 127 // Figure out the current zone using the current Isolate and |
| 125 // check if the specified handle has been allocated in this zone. | 128 // check if the specified handle has been allocated in this zone. |
| 126 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 129 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 127 bool Handles<kHandleSizeInWords, | 130 bool Handles<kHandleSizeInWords, |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 370 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 368 int Handles<kHandleSizeInWords, | 371 int Handles<kHandleSizeInWords, |
| 369 kHandlesPerChunk, | 372 kHandlesPerChunk, |
| 370 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { | 373 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { |
| 371 return (next_handle_slot_ / kHandleSizeInWords); | 374 return (next_handle_slot_ / kHandleSizeInWords); |
| 372 } | 375 } |
| 373 | 376 |
| 374 } // namespace dart | 377 } // namespace dart |
| 375 | 378 |
| 376 #endif // VM_HANDLES_IMPL_H_ | 379 #endif // VM_HANDLES_IMPL_H_ |
| OLD | NEW |