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/utils.h" | 10 #include "platform/utils.h" |
11 #include "vm/bitfield.h" | 11 #include "vm/bitfield.h" |
12 #include "vm/dart_api_impl.h" | 12 #include "vm/dart_api_impl.h" |
13 #include "vm/flags.h" | 13 #include "vm/flags.h" |
14 #include "vm/growable_array.h" | 14 #include "vm/growable_array.h" |
15 #include "vm/handles.h" | 15 #include "vm/handles.h" |
16 #include "vm/object.h" | 16 #include "vm/object.h" |
17 #include "vm/os.h" | 17 #include "vm/os.h" |
18 #include "vm/raw_object.h" | 18 #include "vm/raw_object.h" |
19 #include "vm/thread.h" | 19 #include "vm/os_thread.h" |
20 #include "vm/visitor.h" | 20 #include "vm/visitor.h" |
21 | 21 |
22 #include "vm/handles_impl.h" | 22 #include "vm/handles_impl.h" |
23 | 23 |
24 namespace dart { | 24 namespace dart { |
25 | 25 |
26 DECLARE_DEBUG_FLAG(bool, trace_zones); | 26 DECLARE_DEBUG_FLAG(bool, trace_zones); |
27 DECLARE_DEBUG_FLAG(bool, trace_handles); | 27 DECLARE_DEBUG_FLAG(bool, trace_handles); |
28 | 28 |
29 // Implementation of Zone support for very fast allocation of small chunks | 29 // Implementation of Zone support for very fast allocation of small chunks |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 | 610 |
611 DISALLOW_COPY_AND_ASSIGN(ApiLocalScope); | 611 DISALLOW_COPY_AND_ASSIGN(ApiLocalScope); |
612 }; | 612 }; |
613 | 613 |
614 | 614 |
615 class ApiNativeScope { | 615 class ApiNativeScope { |
616 public: | 616 public: |
617 ApiNativeScope() { | 617 ApiNativeScope() { |
618 // Currently no support for nesting native scopes. | 618 // Currently no support for nesting native scopes. |
619 ASSERT(Current() == NULL); | 619 ASSERT(Current() == NULL); |
620 Thread::SetThreadLocal(Api::api_native_key_, reinterpret_cast<uword>(this)); | 620 OSThread::SetThreadLocal(Api::api_native_key_, |
| 621 reinterpret_cast<uword>(this)); |
621 } | 622 } |
622 | 623 |
623 ~ApiNativeScope() { | 624 ~ApiNativeScope() { |
624 ASSERT(Current() == this); | 625 ASSERT(Current() == this); |
625 Thread::SetThreadLocal(Api::api_native_key_, 0); | 626 OSThread::SetThreadLocal(Api::api_native_key_, 0); |
626 } | 627 } |
627 | 628 |
628 static inline ApiNativeScope* Current() { | 629 static inline ApiNativeScope* Current() { |
629 return reinterpret_cast<ApiNativeScope*>( | 630 return reinterpret_cast<ApiNativeScope*>( |
630 Thread::GetThreadLocal(Api::api_native_key_)); | 631 OSThread::GetThreadLocal(Api::api_native_key_)); |
631 } | 632 } |
632 | 633 |
633 Zone* zone() { return zone_.GetZone(); } | 634 Zone* zone() { return zone_.GetZone(); } |
634 | 635 |
635 private: | 636 private: |
636 ApiZone zone_; | 637 ApiZone zone_; |
637 }; | 638 }; |
638 | 639 |
639 | 640 |
640 // Api growable arrays use a zone for allocation. The constructor | 641 // Api growable arrays use a zone for allocation. The constructor |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 ref->set_peer(peer); | 971 ref->set_peer(peer); |
971 ref->set_callback(callback); | 972 ref->set_callback(callback); |
972 // This may trigger GC, so it must be called last. | 973 // This may trigger GC, so it must be called last. |
973 ref->SetExternalSize(external_size, isolate); | 974 ref->SetExternalSize(external_size, isolate); |
974 return ref; | 975 return ref; |
975 } | 976 } |
976 | 977 |
977 } // namespace dart | 978 } // namespace dart |
978 | 979 |
979 #endif // VM_DART_API_STATE_H_ | 980 #endif // VM_DART_API_STATE_H_ |
OLD | NEW |