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

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

Issue 868913002: Add Zone-based handle allocation interface and reduce use of Isolate-based interfaces. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/handles.cc ('k') | runtime/vm/object.h » ('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) 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/visitor.h" 10 #include "vm/visitor.h"
10 11
11 namespace dart { 12 namespace dart {
12 13
13 DECLARE_DEBUG_FLAG(bool, trace_handles); 14 DECLARE_DEBUG_FLAG(bool, trace_handles);
14 15
15 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> 16 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
16 void Handles<kHandleSizeInWords, 17 void Handles<kHandleSizeInWords,
17 kHandlesPerChunk, 18 kHandlesPerChunk,
18 kOffsetOfRawPtr>::VisitObjectPointers( 19 kOffsetOfRawPtr>::VisitObjectPointers(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 79 }
79 80
80 // Delete all the extra scoped handle blocks allocated and reinit the first 81 // Delete all the extra scoped handle blocks allocated and reinit the first
81 // scoped block. 82 // scoped block.
82 DeleteHandleBlocks(first_scoped_block_.next_block()); 83 DeleteHandleBlocks(first_scoped_block_.next_block());
83 first_scoped_block_.ReInit(); 84 first_scoped_block_.ReInit();
84 scoped_blocks_ = &first_scoped_block_; 85 scoped_blocks_ = &first_scoped_block_;
85 } 86 }
86 87
87 88
88 // Figure out the current handle scope using the current Isolate and 89 // Figure out the current handle scope using the current Zone and
89 // allocate a handle in that scope. The function assumes that a 90 // allocate a handle in that scope. The function assumes that a
90 // current Isolate, current zone and current handle scope exist. It 91 // current handle scope exists. It asserts for this appropriately.
91 // 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(Isolate* isolate) { 95 kOffsetOfRawPtr>::AllocateHandle(Zone* zone) {
96 #if defined(DEBUG)
97 Thread* thread = Thread::Current();
98 ASSERT(thread->zone() == zone);
99 Isolate* isolate = thread->isolate();
96 ASSERT(isolate != NULL); 100 ASSERT(isolate != NULL);
97 ASSERT(isolate->current_zone() != NULL);
98 ASSERT(isolate->top_handle_scope() != NULL); 101 ASSERT(isolate->top_handle_scope() != NULL);
99 ASSERT(isolate->no_handle_scope_depth() == 0); 102 ASSERT(isolate->no_handle_scope_depth() == 0);
100 Handles* handles = isolate->current_zone()->handles(); 103 #endif // DEBUG
104 Handles* handles = zone->handles();
101 ASSERT(handles != NULL); 105 ASSERT(handles != NULL);
102 return handles->AllocateScopedHandle(); 106 return handles->AllocateScopedHandle();
103 } 107 }
104 108
105 109
106 // Figure out the current zone using the current Isolate and 110 // 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. 111 // this appropriately.
110 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> 112 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
111 uword Handles<kHandleSizeInWords, 113 uword Handles<kHandleSizeInWords,
112 kHandlesPerChunk, 114 kHandlesPerChunk,
113 kOffsetOfRawPtr>::AllocateZoneHandle(Isolate* isolate) { 115 kOffsetOfRawPtr>::AllocateZoneHandle(Zone* zone) {
116 #if defined(DEBUG)
117 Thread* thread = Thread::Current();
118 ASSERT(thread->zone() == zone);
119 Isolate* isolate = thread->isolate();
114 ASSERT(isolate != NULL); 120 ASSERT(isolate != NULL);
115 ASSERT(isolate->current_zone() != NULL);
116 ASSERT(isolate->no_handle_scope_depth() == 0); 121 ASSERT(isolate->no_handle_scope_depth() == 0);
117 Handles* handles = isolate->current_zone()->handles(); 122 #endif // DEBUG
123 Handles* handles = zone->handles();
118 ASSERT(handles != NULL); 124 ASSERT(handles != NULL);
119 uword address = handles->AllocateHandleInZone(); 125 uword address = handles->AllocateHandleInZone();
120 return address; 126 return address;
121 } 127 }
122 128
123 129
124 // Figure out the current zone using the current Isolate and 130 // Figure out the current zone using the current Isolate and
125 // check if the specified handle has been allocated in this zone. 131 // check if the specified handle has been allocated in this zone.
126 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> 132 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
127 bool Handles<kHandleSizeInWords, 133 bool Handles<kHandleSizeInWords,
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> 373 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
368 int Handles<kHandleSizeInWords, 374 int Handles<kHandleSizeInWords,
369 kHandlesPerChunk, 375 kHandlesPerChunk,
370 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { 376 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const {
371 return (next_handle_slot_ / kHandleSizeInWords); 377 return (next_handle_slot_ / kHandleSizeInWords);
372 } 378 }
373 379
374 } // namespace dart 380 } // namespace dart
375 381
376 #endif // VM_HANDLES_IMPL_H_ 382 #endif // VM_HANDLES_IMPL_H_
OLDNEW
« no previous file with comments | « runtime/vm/handles.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698