| 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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 | 726 |
| 727 static inline ApiNativeScope* Current() { | 727 static inline ApiNativeScope* Current() { |
| 728 return reinterpret_cast<ApiNativeScope*>( | 728 return reinterpret_cast<ApiNativeScope*>( |
| 729 Thread::GetThreadLocal(Api::api_native_key_)); | 729 Thread::GetThreadLocal(Api::api_native_key_)); |
| 730 } | 730 } |
| 731 | 731 |
| 732 Zone* zone() { return zone_.GetZone(); } | 732 Zone* zone() { return zone_.GetZone(); } |
| 733 | 733 |
| 734 private: | 734 private: |
| 735 ApiZone zone_; | 735 ApiZone zone_; |
| 736 ThreadLocalKey key_; | |
| 737 }; | 736 }; |
| 738 | 737 |
| 739 | 738 |
| 740 // Api growable arrays use a zone for allocation. The constructor | 739 // Api growable arrays use a zone for allocation. The constructor |
| 741 // picks the zone from the current isolate if in an isolate | 740 // picks the zone from the current isolate if in an isolate |
| 742 // environment. When outside an isolate environment it picks the zone | 741 // environment. When outside an isolate environment it picks the zone |
| 743 // from the current native scope. | 742 // from the current native scope. |
| 744 template<typename T> | 743 template<typename T> |
| 745 class ApiGrowableArray : public BaseGrowableArray<T, ValueObject> { | 744 class ApiGrowableArray : public BaseGrowableArray<T, ValueObject> { |
| 746 public: | 745 public: |
| 747 explicit ApiGrowableArray(int initial_capacity) | 746 explicit ApiGrowableArray(int initial_capacity) |
| 748 : BaseGrowableArray<T, ValueObject>( | 747 : BaseGrowableArray<T, ValueObject>( |
| 749 initial_capacity, | 748 initial_capacity, |
| 750 ApiNativeScope::Current()->zone()) {} | 749 ApiNativeScope::Current()->zone()) {} |
| 751 ApiGrowableArray() | 750 ApiGrowableArray() |
| 752 : BaseGrowableArray<T, ValueObject>( | 751 : BaseGrowableArray<T, ValueObject>( |
| 753 ApiNativeScope::Current()->zone()) {} | 752 ApiNativeScope::Current()->zone()) {} |
| 754 }; | 753 }; |
| 755 | 754 |
| 756 | 755 |
| 757 } // namespace dart | 756 } // namespace dart |
| 758 | 757 |
| 759 #endif // VM_DART_API_STATE_H_ | 758 #endif // VM_DART_API_STATE_H_ |
| OLD | NEW |