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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 | 528 |
529 static inline ApiNativeScope* Current() { | 529 static inline ApiNativeScope* Current() { |
530 return reinterpret_cast<ApiNativeScope*>( | 530 return reinterpret_cast<ApiNativeScope*>( |
531 Thread::GetThreadLocal(Api::api_native_key_)); | 531 Thread::GetThreadLocal(Api::api_native_key_)); |
532 } | 532 } |
533 | 533 |
534 ApiZone* zone() { return &zone_; } | 534 ApiZone* zone() { return &zone_; } |
535 | 535 |
536 private: | 536 private: |
537 ApiZone zone_; | 537 ApiZone zone_; |
| 538 ThreadLocalKey key_; |
538 }; | 539 }; |
539 | 540 |
540 | 541 |
541 // Api growable arrays use a zone for allocation. The constructor | 542 // Api growable arrays use a zone for allocation. The constructor |
542 // picks the zone from the current isolate if in an isolate | 543 // picks the zone from the current isolate if in an isolate |
543 // environment. When outside an isolate environment it picks the zone | 544 // environment. When outside an isolate environment it picks the zone |
544 // from the current native scope. | 545 // from the current native scope. |
545 template<typename T> | 546 template<typename T> |
546 class ApiGrowableArray : public BaseGrowableArray<T, ValueObject> { | 547 class ApiGrowableArray : public BaseGrowableArray<T, ValueObject> { |
547 public: | 548 public: |
548 explicit ApiGrowableArray(int initial_capacity) | 549 explicit ApiGrowableArray(int initial_capacity) |
549 : BaseGrowableArray<T, ValueObject>( | 550 : BaseGrowableArray<T, ValueObject>( |
550 initial_capacity, | 551 initial_capacity, |
551 ApiNativeScope::Current()->zone()->GetBaseZone()) {} | 552 ApiNativeScope::Current()->zone()->GetBaseZone()) {} |
552 ApiGrowableArray() | 553 ApiGrowableArray() |
553 : BaseGrowableArray<T, ValueObject>( | 554 : BaseGrowableArray<T, ValueObject>( |
554 ApiNativeScope::Current()->zone()->GetBaseZone()) {} | 555 ApiNativeScope::Current()->zone()->GetBaseZone()) {} |
555 }; | 556 }; |
556 | 557 |
557 | 558 |
558 } // namespace dart | 559 } // namespace dart |
559 | 560 |
560 #endif // VM_DART_API_STATE_H_ | 561 #endif // VM_DART_API_STATE_H_ |
OLD | NEW |