| 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 22 matching lines...) Expand all Loading... |
| 33 // Create an empty zone. | 33 // Create an empty zone. |
| 34 ApiZone() : zone_() { | 34 ApiZone() : zone_() { |
| 35 Isolate* isolate = Isolate::Current(); | 35 Isolate* isolate = Isolate::Current(); |
| 36 Zone* current_zone = isolate != NULL ? isolate->current_zone() : NULL; | 36 Zone* current_zone = isolate != NULL ? isolate->current_zone() : NULL; |
| 37 zone_.Link(current_zone); | 37 zone_.Link(current_zone); |
| 38 if (isolate != NULL) { | 38 if (isolate != NULL) { |
| 39 isolate->set_current_zone(&zone_); | 39 isolate->set_current_zone(&zone_); |
| 40 } | 40 } |
| 41 #ifdef DEBUG | 41 #ifdef DEBUG |
| 42 if (FLAG_trace_zones) { | 42 if (FLAG_trace_zones) { |
| 43 OS::PrintErr("*** Starting a new Api zone 0x%"Px"(0x%"Px")\n", | 43 OS::PrintErr("*** Starting a new Api zone 0x%" Px "(0x%" Px ")\n", |
| 44 reinterpret_cast<intptr_t>(this), | 44 reinterpret_cast<intptr_t>(this), |
| 45 reinterpret_cast<intptr_t>(&zone_)); | 45 reinterpret_cast<intptr_t>(&zone_)); |
| 46 } | 46 } |
| 47 #endif | 47 #endif |
| 48 } | 48 } |
| 49 | 49 |
| 50 // Delete all memory associated with the zone. | 50 // Delete all memory associated with the zone. |
| 51 ~ApiZone() { | 51 ~ApiZone() { |
| 52 Isolate* isolate = Isolate::Current(); | 52 Isolate* isolate = Isolate::Current(); |
| 53 if ((isolate != NULL) && (isolate->current_zone() == &zone_)) { | 53 if ((isolate != NULL) && (isolate->current_zone() == &zone_)) { |
| 54 isolate->set_current_zone(zone_.previous_); | 54 isolate->set_current_zone(zone_.previous_); |
| 55 } | 55 } |
| 56 #ifdef DEBUG | 56 #ifdef DEBUG |
| 57 if (FLAG_trace_zones) { | 57 if (FLAG_trace_zones) { |
| 58 OS::PrintErr("*** Deleting Api zone 0x%"Px"(0x%"Px")\n", | 58 OS::PrintErr("*** Deleting Api zone 0x%" Px "(0x%" Px ")\n", |
| 59 reinterpret_cast<intptr_t>(this), | 59 reinterpret_cast<intptr_t>(this), |
| 60 reinterpret_cast<intptr_t>(&zone_)); | 60 reinterpret_cast<intptr_t>(&zone_)); |
| 61 } | 61 } |
| 62 #endif | 62 #endif |
| 63 } | 63 } |
| 64 | 64 |
| 65 // Allocates an array sized to hold 'len' elements of type | 65 // Allocates an array sized to hold 'len' elements of type |
| 66 // 'ElementType'. Checks for integer overflow when performing the | 66 // 'ElementType'. Checks for integer overflow when performing the |
| 67 // size computation. | 67 // size computation. |
| 68 template <class ElementType> | 68 template <class ElementType> |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 static const int kOffsetOfRawPtrInLocalHandle = 0; | 249 static const int kOffsetOfRawPtrInLocalHandle = 0; |
| 250 class LocalHandles : Handles<kLocalHandleSizeInWords, | 250 class LocalHandles : Handles<kLocalHandleSizeInWords, |
| 251 kLocalHandlesPerChunk, | 251 kLocalHandlesPerChunk, |
| 252 kOffsetOfRawPtrInLocalHandle> { | 252 kOffsetOfRawPtrInLocalHandle> { |
| 253 public: | 253 public: |
| 254 LocalHandles() : Handles<kLocalHandleSizeInWords, | 254 LocalHandles() : Handles<kLocalHandleSizeInWords, |
| 255 kLocalHandlesPerChunk, | 255 kLocalHandlesPerChunk, |
| 256 kOffsetOfRawPtrInLocalHandle>() { | 256 kOffsetOfRawPtrInLocalHandle>() { |
| 257 #ifdef DEBUG | 257 #ifdef DEBUG |
| 258 if (FLAG_trace_handles) { | 258 if (FLAG_trace_handles) { |
| 259 OS::PrintErr("*** Starting a new Local handle block 0x%"Px"\n", | 259 OS::PrintErr("*** Starting a new Local handle block 0x%" Px "\n", |
| 260 reinterpret_cast<intptr_t>(this)); | 260 reinterpret_cast<intptr_t>(this)); |
| 261 } | 261 } |
| 262 #endif | 262 #endif |
| 263 } | 263 } |
| 264 ~LocalHandles() { | 264 ~LocalHandles() { |
| 265 #ifdef DEBUG | 265 #ifdef DEBUG |
| 266 if (FLAG_trace_handles) { | 266 if (FLAG_trace_handles) { |
| 267 OS::PrintErr("*** Handle Counts for 0x(%"Px"):Scoped = %d\n", | 267 OS::PrintErr("*** Handle Counts for 0x(%" Px "):Scoped = %d\n", |
| 268 reinterpret_cast<intptr_t>(this), | 268 reinterpret_cast<intptr_t>(this), |
| 269 CountHandles()); | 269 CountHandles()); |
| 270 OS::PrintErr("*** Deleting Local handle block 0x%"Px"\n", | 270 OS::PrintErr("*** Deleting Local handle block 0x%" Px "\n", |
| 271 reinterpret_cast<intptr_t>(this)); | 271 reinterpret_cast<intptr_t>(this)); |
| 272 } | 272 } |
| 273 #endif | 273 #endif |
| 274 } | 274 } |
| 275 | 275 |
| 276 | 276 |
| 277 // Visit all object pointers stored in the various handles. | 277 // Visit all object pointers stored in the various handles. |
| 278 void VisitObjectPointers(ObjectPointerVisitor* visitor) { | 278 void VisitObjectPointers(ObjectPointerVisitor* visitor) { |
| 279 Handles<kLocalHandleSizeInWords, | 279 Handles<kLocalHandleSizeInWords, |
| 280 kLocalHandlesPerChunk, | 280 kLocalHandlesPerChunk, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 class PersistentHandles : Handles<kPersistentHandleSizeInWords, | 318 class PersistentHandles : Handles<kPersistentHandleSizeInWords, |
| 319 kPersistentHandlesPerChunk, | 319 kPersistentHandlesPerChunk, |
| 320 kOffsetOfRawPtrInPersistentHandle> { | 320 kOffsetOfRawPtrInPersistentHandle> { |
| 321 public: | 321 public: |
| 322 PersistentHandles() : Handles<kPersistentHandleSizeInWords, | 322 PersistentHandles() : Handles<kPersistentHandleSizeInWords, |
| 323 kPersistentHandlesPerChunk, | 323 kPersistentHandlesPerChunk, |
| 324 kOffsetOfRawPtrInPersistentHandle>(), | 324 kOffsetOfRawPtrInPersistentHandle>(), |
| 325 free_list_(NULL) { | 325 free_list_(NULL) { |
| 326 #ifdef DEBUG | 326 #ifdef DEBUG |
| 327 if (FLAG_trace_handles) { | 327 if (FLAG_trace_handles) { |
| 328 OS::PrintErr("*** Starting a new Persistent handle block 0x%"Px"\n", | 328 OS::PrintErr("*** Starting a new Persistent handle block 0x%" Px "\n", |
| 329 reinterpret_cast<intptr_t>(this)); | 329 reinterpret_cast<intptr_t>(this)); |
| 330 } | 330 } |
| 331 #endif | 331 #endif |
| 332 } | 332 } |
| 333 ~PersistentHandles() { | 333 ~PersistentHandles() { |
| 334 free_list_ = NULL; | 334 free_list_ = NULL; |
| 335 #ifdef DEBUG | 335 #ifdef DEBUG |
| 336 if (FLAG_trace_handles) { | 336 if (FLAG_trace_handles) { |
| 337 OS::PrintErr("*** Handle Counts for 0x(%"Px"):Scoped = %d\n", | 337 OS::PrintErr("*** Handle Counts for 0x(%" Px "):Scoped = %d\n", |
| 338 reinterpret_cast<intptr_t>(this), | 338 reinterpret_cast<intptr_t>(this), |
| 339 CountHandles()); | 339 CountHandles()); |
| 340 OS::PrintErr("*** Deleting Persistent handle block 0x%"Px"\n", | 340 OS::PrintErr("*** Deleting Persistent handle block 0x%" Px "\n", |
| 341 reinterpret_cast<intptr_t>(this)); | 341 reinterpret_cast<intptr_t>(this)); |
| 342 } | 342 } |
| 343 #endif | 343 #endif |
| 344 } | 344 } |
| 345 | 345 |
| 346 // Accessors. | 346 // Accessors. |
| 347 PersistentHandle* free_list() const { return free_list_; } | 347 PersistentHandle* free_list() const { return free_list_; } |
| 348 void set_free_list(PersistentHandle* value) { free_list_ = value; } | 348 void set_free_list(PersistentHandle* value) { free_list_ = value; } |
| 349 | 349 |
| 350 // Visit all object pointers stored in the various handles. | 350 // Visit all object pointers stored in the various handles. |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 ApiNativeScope::Current()->zone()) {} | 782 ApiNativeScope::Current()->zone()) {} |
| 783 ApiGrowableArray() | 783 ApiGrowableArray() |
| 784 : BaseGrowableArray<T, ValueObject>( | 784 : BaseGrowableArray<T, ValueObject>( |
| 785 ApiNativeScope::Current()->zone()) {} | 785 ApiNativeScope::Current()->zone()) {} |
| 786 }; | 786 }; |
| 787 | 787 |
| 788 | 788 |
| 789 } // namespace dart | 789 } // namespace dart |
| 790 | 790 |
| 791 #endif // VM_DART_API_STATE_H_ | 791 #endif // VM_DART_API_STATE_H_ |
| OLD | NEW |