| 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 #include "vm/handles.h" | 5 #include "vm/handles.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/dart_api_state.h" |
| 9 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| 10 #include "vm/isolate.h" | 11 #include "vm/isolate.h" |
| 11 #include "vm/os.h" | 12 #include "vm/os.h" |
| 12 #include "vm/raw_object.h" | 13 #include "vm/raw_object.h" |
| 13 #include "vm/visitor.h" | 14 #include "vm/visitor.h" |
| 14 #include "vm/zone.h" | 15 #include "vm/zone.h" |
| 15 | 16 |
| 16 #include "vm/handles_impl.h" | 17 #include "vm/handles_impl.h" |
| 17 | 18 |
| 18 namespace dart { | 19 namespace dart { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 36 } | 37 } |
| 37 | 38 |
| 38 | 39 |
| 39 void VMHandles::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 40 void VMHandles::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
| 40 return Handles<kVMHandleSizeInWords, | 41 return Handles<kVMHandleSizeInWords, |
| 41 kVMHandlesPerChunk, | 42 kVMHandlesPerChunk, |
| 42 kOffsetOfRawPtr>::VisitObjectPointers(visitor); | 43 kOffsetOfRawPtr>::VisitObjectPointers(visitor); |
| 43 } | 44 } |
| 44 | 45 |
| 45 | 46 |
| 47 #if defined(DEBUG) |
| 48 static bool IsCurrentApiNativeScope(Zone* zone) { |
| 49 ApiNativeScope* scope = ApiNativeScope::Current(); |
| 50 return (scope != NULL) && (scope->zone() == zone); |
| 51 } |
| 52 #endif // DEBUG |
| 53 |
| 54 |
| 46 uword VMHandles::AllocateHandle(Zone* zone) { | 55 uword VMHandles::AllocateHandle(Zone* zone) { |
| 56 DEBUG_ASSERT(!IsCurrentApiNativeScope(zone)); |
| 47 return Handles<kVMHandleSizeInWords, | 57 return Handles<kVMHandleSizeInWords, |
| 48 kVMHandlesPerChunk, | 58 kVMHandlesPerChunk, |
| 49 kOffsetOfRawPtr>::AllocateHandle(zone); | 59 kOffsetOfRawPtr>::AllocateHandle(zone); |
| 50 } | 60 } |
| 51 | 61 |
| 52 | 62 |
| 53 uword VMHandles::AllocateZoneHandle(Zone* zone) { | 63 uword VMHandles::AllocateZoneHandle(Zone* zone) { |
| 64 DEBUG_ASSERT(!IsCurrentApiNativeScope(zone)); |
| 54 return Handles<kVMHandleSizeInWords, | 65 return Handles<kVMHandleSizeInWords, |
| 55 kVMHandlesPerChunk, | 66 kVMHandlesPerChunk, |
| 56 kOffsetOfRawPtr>::AllocateZoneHandle(zone); | 67 kOffsetOfRawPtr>::AllocateZoneHandle(zone); |
| 57 } | 68 } |
| 58 | 69 |
| 59 | 70 |
| 60 bool VMHandles::IsZoneHandle(uword handle) { | 71 bool VMHandles::IsZoneHandle(uword handle) { |
| 61 return Handles<kVMHandleSizeInWords, | 72 return Handles<kVMHandleSizeInWords, |
| 62 kVMHandlesPerChunk, | 73 kVMHandlesPerChunk, |
| 63 kOffsetOfRawPtr >::IsZoneHandle(handle); | 74 kOffsetOfRawPtr >::IsZoneHandle(handle); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 isolate()->IncrementNoHandleScopeDepth(); | 129 isolate()->IncrementNoHandleScopeDepth(); |
| 119 } | 130 } |
| 120 | 131 |
| 121 | 132 |
| 122 NoHandleScope::~NoHandleScope() { | 133 NoHandleScope::~NoHandleScope() { |
| 123 isolate()->DecrementNoHandleScopeDepth(); | 134 isolate()->DecrementNoHandleScopeDepth(); |
| 124 } | 135 } |
| 125 #endif // defined(DEBUG) | 136 #endif // defined(DEBUG) |
| 126 | 137 |
| 127 } // namespace dart | 138 } // namespace dart |
| OLD | NEW |