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

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

Issue 9413003: Thread the weak persistent handle free-list through the raw_ field. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 8 years, 10 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 | « no previous file | no next file » | 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_DART_API_STATE_H_ 5 #ifndef VM_DART_API_STATE_H_
6 #define VM_DART_API_STATE_H_ 6 #define VM_DART_API_STATE_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 #include "platform/thread.h" 10 #include "platform/thread.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 PersistentHandle() { } 99 PersistentHandle() { }
100 ~PersistentHandle() { } 100 ~PersistentHandle() { }
101 101
102 // Overload the raw_ field as a next pointer when adding freed 102 // Overload the raw_ field as a next pointer when adding freed
103 // handles to the free list. 103 // handles to the free list.
104 PersistentHandle* Next() { 104 PersistentHandle* Next() {
105 return reinterpret_cast<PersistentHandle*>(raw_); 105 return reinterpret_cast<PersistentHandle*>(raw_);
106 } 106 }
107 void SetNext(PersistentHandle* free_list) { 107 void SetNext(PersistentHandle* free_list) {
108 raw_ = reinterpret_cast<RawObject*>(free_list); 108 raw_ = reinterpret_cast<RawObject*>(free_list);
109 ASSERT(!raw_->IsHeapObject());
109 } 110 }
110 void FreeHandle(PersistentHandle* free_list) { 111 void FreeHandle(PersistentHandle* free_list) {
111 SetNext(free_list); 112 SetNext(free_list);
112 } 113 }
113 114
114 RawObject* raw_; 115 RawObject* raw_;
115 DISALLOW_ALLOCATION(); // Allocated through AllocateHandle methods. 116 DISALLOW_ALLOCATION(); // Allocated through AllocateHandle methods.
116 DISALLOW_COPY_AND_ASSIGN(PersistentHandle); 117 DISALLOW_COPY_AND_ASSIGN(PersistentHandle);
117 }; 118 };
118 119
(...skipping 25 matching lines...) Expand all
144 handle->Clear(); 145 handle->Clear();
145 } 146 }
146 } 147 }
147 148
148 private: 149 private:
149 friend class WeakPersistentHandles; 150 friend class WeakPersistentHandles;
150 151
151 WeakPersistentHandle() : raw_(NULL), peer_(NULL), callback_(NULL) { } 152 WeakPersistentHandle() : raw_(NULL), peer_(NULL), callback_(NULL) { }
152 ~WeakPersistentHandle() { } 153 ~WeakPersistentHandle() { }
153 154
154 // Overload the callback_ field as a next pointer when adding freed 155 // Overload the raw_ field as a next pointer when adding freed
155 // handles to the free list. 156 // handles to the free list.
156 WeakPersistentHandle* Next() { 157 WeakPersistentHandle* Next() {
157 return reinterpret_cast<WeakPersistentHandle*>(callback_); 158 return reinterpret_cast<WeakPersistentHandle*>(raw_);
158 } 159 }
159 void SetNext(WeakPersistentHandle* free_list) { 160 void SetNext(WeakPersistentHandle* free_list) {
160 callback_ = reinterpret_cast<Dart_WeakPersistentHandleFinalizer>(free_list); 161 raw_ = reinterpret_cast<RawObject*>(free_list);
162 ASSERT(!raw_->IsHeapObject());
161 } 163 }
162 void FreeHandle(WeakPersistentHandle* free_list) { 164 void FreeHandle(WeakPersistentHandle* free_list) {
163 raw_ = NULL;
164 SetNext(free_list); 165 SetNext(free_list);
165 } 166 }
166 167
167 void Clear() { 168 void Clear() {
168 raw_ = Object::null(); 169 raw_ = Object::null();
169 peer_ = NULL; 170 peer_ = NULL;
170 callback_ = NULL; 171 callback_ = NULL;
171 } 172 }
172 173
173 RawObject* raw_; 174 RawObject* raw_;
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 ApiNativeScope::Current()->zone()->GetBaseZone()) {} 559 ApiNativeScope::Current()->zone()->GetBaseZone()) {}
559 ApiGrowableArray() 560 ApiGrowableArray()
560 : BaseGrowableArray<T, ValueObject>( 561 : BaseGrowableArray<T, ValueObject>(
561 ApiNativeScope::Current()->zone()->GetBaseZone()) {} 562 ApiNativeScope::Current()->zone()->GetBaseZone()) {}
562 }; 563 };
563 564
564 565
565 } // namespace dart 566 } // namespace dart
566 567
567 #endif // VM_DART_API_STATE_H_ 568 #endif // VM_DART_API_STATE_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698