| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 RUNTIME_VM_THREAD_H_ | 5 #ifndef RUNTIME_VM_THREAD_H_ |
| 6 #define RUNTIME_VM_THREAD_H_ | 6 #define RUNTIME_VM_THREAD_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "vm/atomic.h" | 10 #include "vm/atomic.h" |
| 11 #include "vm/bitfield.h" | 11 #include "vm/bitfield.h" |
| 12 #include "vm/globals.h" | 12 #include "vm/globals.h" |
| 13 #include "vm/handles.h" | 13 #include "vm/handles.h" |
| 14 #include "vm/os_thread.h" | 14 #include "vm/os_thread.h" |
| 15 #include "vm/store_buffer.h" | 15 #include "vm/store_buffer.h" |
| 16 #include "vm/runtime_entry_list.h" | 16 #include "vm/runtime_entry_list.h" |
| 17 | |
| 18 namespace dart { | 17 namespace dart { |
| 19 | 18 |
| 20 class AbstractType; | 19 class AbstractType; |
| 21 class ApiLocalScope; | 20 class ApiLocalScope; |
| 22 class Array; | 21 class Array; |
| 23 class CHA; | 22 class CHA; |
| 24 class Class; | 23 class Class; |
| 25 class Code; | 24 class Code; |
| 26 class CompilerStats; | 25 class CompilerStats; |
| 27 class Error; | 26 class Error; |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 void set_os_thread(OSThread* os_thread) { os_thread_ = os_thread; } | 258 void set_os_thread(OSThread* os_thread) { os_thread_ = os_thread; } |
| 260 | 259 |
| 261 // Monitor corresponding to this thread. | 260 // Monitor corresponding to this thread. |
| 262 Monitor* thread_lock() const { return thread_lock_; } | 261 Monitor* thread_lock() const { return thread_lock_; } |
| 263 | 262 |
| 264 // The topmost zone used for allocation in this thread. | 263 // The topmost zone used for allocation in this thread. |
| 265 Zone* zone() const { return zone_; } | 264 Zone* zone() const { return zone_; } |
| 266 | 265 |
| 267 bool ZoneIsOwnedByThread(Zone* zone) const; | 266 bool ZoneIsOwnedByThread(Zone* zone) const; |
| 268 | 267 |
| 269 void IncrementMemoryUsage(uintptr_t value) { | 268 void IncrementMemoryCapacity(uintptr_t value) { |
| 270 current_thread_memory_ += value; | 269 current_zone_capacity_ += value; |
| 271 if (current_thread_memory_ > memory_high_watermark_) { | 270 if (current_zone_capacity_ > zone_high_watermark_) { |
| 272 memory_high_watermark_ = current_thread_memory_; | 271 zone_high_watermark_ = current_zone_capacity_; |
| 273 } | 272 } |
| 274 } | 273 } |
| 275 | 274 |
| 276 void DecrementMemoryUsage(uintptr_t value) { | 275 void DecrementMemoryCapacity(uintptr_t value) { |
| 277 ASSERT(current_thread_memory_ >= value); | 276 ASSERT(current_zone_capacity_ >= value); |
| 278 current_thread_memory_ -= value; | 277 current_zone_capacity_ -= value; |
| 279 } | 278 } |
| 280 | 279 |
| 281 uintptr_t memory_high_watermark() const { return memory_high_watermark_; } | 280 uintptr_t current_zone_capacity() { return current_zone_capacity_; } |
| 282 | 281 |
| 283 void ResetHighWatermark() { memory_high_watermark_ = current_thread_memory_; } | 282 uintptr_t zone_high_watermark() const { return zone_high_watermark_; } |
| 283 |
| 284 void ResetHighWatermark() { zone_high_watermark_ = current_zone_capacity_; } |
| 284 | 285 |
| 285 // The reusable api local scope for this thread. | 286 // The reusable api local scope for this thread. |
| 286 ApiLocalScope* api_reusable_scope() const { return api_reusable_scope_; } | 287 ApiLocalScope* api_reusable_scope() const { return api_reusable_scope_; } |
| 287 void set_api_reusable_scope(ApiLocalScope* value) { | 288 void set_api_reusable_scope(ApiLocalScope* value) { |
| 288 ASSERT(value == NULL || api_reusable_scope_ == NULL); | 289 ASSERT(value == NULL || api_reusable_scope_ == NULL); |
| 289 api_reusable_scope_ = value; | 290 api_reusable_scope_ = value; |
| 290 } | 291 } |
| 291 | 292 |
| 292 // The api local scope for this thread, this where all local handles | 293 // The api local scope for this thread, this where all local handles |
| 293 // are allocated. | 294 // are allocated. |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 #undef DECLARE_MEMBERS | 711 #undef DECLARE_MEMBERS |
| 711 | 712 |
| 712 #define DECLARE_MEMBERS(returntype, name, ...) uword name##_entry_point_; | 713 #define DECLARE_MEMBERS(returntype, name, ...) uword name##_entry_point_; |
| 713 LEAF_RUNTIME_ENTRY_LIST(DECLARE_MEMBERS) | 714 LEAF_RUNTIME_ENTRY_LIST(DECLARE_MEMBERS) |
| 714 #undef DECLARE_MEMBERS | 715 #undef DECLARE_MEMBERS |
| 715 | 716 |
| 716 TimelineStream* dart_stream_; | 717 TimelineStream* dart_stream_; |
| 717 OSThread* os_thread_; | 718 OSThread* os_thread_; |
| 718 Monitor* thread_lock_; | 719 Monitor* thread_lock_; |
| 719 Zone* zone_; | 720 Zone* zone_; |
| 720 uintptr_t current_thread_memory_; | 721 uintptr_t current_zone_capacity_; |
| 721 uintptr_t memory_high_watermark_; | 722 uintptr_t zone_high_watermark_; |
| 722 ApiLocalScope* api_reusable_scope_; | 723 ApiLocalScope* api_reusable_scope_; |
| 723 ApiLocalScope* api_top_scope_; | 724 ApiLocalScope* api_top_scope_; |
| 724 StackResource* top_resource_; | 725 StackResource* top_resource_; |
| 725 LongJumpScope* long_jump_base_; | 726 LongJumpScope* long_jump_base_; |
| 726 int32_t no_callback_scope_depth_; | 727 int32_t no_callback_scope_depth_; |
| 727 #if defined(DEBUG) | 728 #if defined(DEBUG) |
| 728 HandleScope* top_handle_scope_; | 729 HandleScope* top_handle_scope_; |
| 729 int32_t no_handle_scope_depth_; | 730 int32_t no_handle_scope_depth_; |
| 730 int32_t no_safepoint_scope_depth_; | 731 int32_t no_safepoint_scope_depth_; |
| 731 #endif | 732 #endif |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 #undef REUSABLE_FRIEND_DECLARATION | 797 #undef REUSABLE_FRIEND_DECLARATION |
| 797 | 798 |
| 798 friend class ApiZone; | 799 friend class ApiZone; |
| 799 friend class InterruptChecker; | 800 friend class InterruptChecker; |
| 800 friend class Isolate; | 801 friend class Isolate; |
| 801 friend class IsolateTestHelper; | 802 friend class IsolateTestHelper; |
| 802 friend class NoOOBMessageScope; | 803 friend class NoOOBMessageScope; |
| 803 friend class Simulator; | 804 friend class Simulator; |
| 804 friend class StackZone; | 805 friend class StackZone; |
| 805 friend class ThreadRegistry; | 806 friend class ThreadRegistry; |
| 806 | |
| 807 DISALLOW_COPY_AND_ASSIGN(Thread); | 807 DISALLOW_COPY_AND_ASSIGN(Thread); |
| 808 }; | 808 }; |
| 809 | 809 |
| 810 | 810 |
| 811 #if defined(HOST_OS_WINDOWS) | 811 #if defined(HOST_OS_WINDOWS) |
| 812 // Clears the state of the current thread and frees the allocation. | 812 // Clears the state of the current thread and frees the allocation. |
| 813 void WindowsThreadCleanUp(); | 813 void WindowsThreadCleanUp(); |
| 814 #endif | 814 #endif |
| 815 | 815 |
| 816 | 816 |
| 817 // Disable thread interrupts. | 817 // Disable thread interrupts. |
| 818 class DisableThreadInterruptsScope : public StackResource { | 818 class DisableThreadInterruptsScope : public StackResource { |
| 819 public: | 819 public: |
| 820 explicit DisableThreadInterruptsScope(Thread* thread); | 820 explicit DisableThreadInterruptsScope(Thread* thread); |
| 821 ~DisableThreadInterruptsScope(); | 821 ~DisableThreadInterruptsScope(); |
| 822 }; | 822 }; |
| 823 | 823 |
| 824 } // namespace dart | 824 } // namespace dart |
| 825 | 825 |
| 826 #endif // RUNTIME_VM_THREAD_H_ | 826 #endif // RUNTIME_VM_THREAD_H_ |
| OLD | NEW |