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_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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 210 } |
211 Dart_WeakPersistentHandle apiHandle() { | 211 Dart_WeakPersistentHandle apiHandle() { |
212 return reinterpret_cast<Dart_WeakPersistentHandle>(this); | 212 return reinterpret_cast<Dart_WeakPersistentHandle>(this); |
213 } | 213 } |
214 | 214 |
215 static bool IsPrologueWeakPersistentHandle(Dart_WeakPersistentHandle handle) { | 215 static bool IsPrologueWeakPersistentHandle(Dart_WeakPersistentHandle handle) { |
216 uword addr = reinterpret_cast<uword>(handle); | 216 uword addr = reinterpret_cast<uword>(handle); |
217 return (addr & kWeakPersistentTagMask) == kPrologueWeakPersistentTag; | 217 return (addr & kWeakPersistentTagMask) == kPrologueWeakPersistentTag; |
218 } | 218 } |
219 static FinalizablePersistentHandle* Cast(Dart_WeakPersistentHandle handle); | 219 static FinalizablePersistentHandle* Cast(Dart_WeakPersistentHandle handle); |
220 static void Finalize(FinalizablePersistentHandle* handle, | 220 static void Finalize(Isolate* isolate, |
| 221 FinalizablePersistentHandle* handle, |
221 bool is_prologue_weak) { | 222 bool is_prologue_weak) { |
222 Dart_WeakPersistentHandleFinalizer callback = handle->callback(); | 223 Dart_WeakPersistentHandleFinalizer callback = handle->callback(); |
223 if (callback != NULL) { | 224 if (callback != NULL) { |
224 void* peer = handle->peer(); | 225 void* peer = handle->peer(); |
225 handle->Clear(); | 226 handle->Clear(); |
226 Dart_WeakPersistentHandle object = is_prologue_weak ? | 227 Dart_WeakPersistentHandle object = is_prologue_weak ? |
227 handle->apiPrologueHandle() : | 228 handle->apiPrologueHandle() : |
228 handle->apiHandle(); | 229 handle->apiHandle(); |
229 (*callback)(object, peer); | 230 (*callback)(reinterpret_cast<Dart_Isolate>(isolate), object, peer); |
230 } else { | 231 } else { |
231 handle->Clear(); | 232 handle->Clear(); |
232 } | 233 } |
233 } | 234 } |
234 | 235 |
235 private: | 236 private: |
236 enum { | 237 enum { |
237 kWeakPersistentTag = 0, | 238 kWeakPersistentTag = 0, |
238 kPrologueWeakPersistentTag = 1, | 239 kPrologueWeakPersistentTag = 1, |
239 kWeakPersistentTagSize = 1, | 240 kWeakPersistentTagSize = 1, |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 ApiNativeScope::Current()->zone()) {} | 816 ApiNativeScope::Current()->zone()) {} |
816 ApiGrowableArray() | 817 ApiGrowableArray() |
817 : BaseGrowableArray<T, ValueObject>( | 818 : BaseGrowableArray<T, ValueObject>( |
818 ApiNativeScope::Current()->zone()) {} | 819 ApiNativeScope::Current()->zone()) {} |
819 }; | 820 }; |
820 | 821 |
821 | 822 |
822 } // namespace dart | 823 } // namespace dart |
823 | 824 |
824 #endif // VM_DART_API_STATE_H_ | 825 #endif // VM_DART_API_STATE_H_ |
OLD | NEW |