OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // In the following two lists there is always at least one object on the list. | 72 // In the following two lists there is always at least one object on the list. |
73 // The first object is a flying anchor that is only there to simplify linking | 73 // The first object is a flying anchor that is only there to simplify linking |
74 // and unlinking. | 74 // and unlinking. |
75 // Head of linked list of free states. | 75 // Head of linked list of free states. |
76 static ThreadState* free_anchor_; | 76 static ThreadState* free_anchor_; |
77 // Head of linked list of states in use. | 77 // Head of linked list of states in use. |
78 static ThreadState* in_use_anchor_; | 78 static ThreadState* in_use_anchor_; |
79 }; | 79 }; |
80 | 80 |
81 | 81 |
| 82 // Defined in top.h |
| 83 class ThreadLocalTop; |
| 84 |
| 85 |
| 86 class ThreadVisitor { |
| 87 public: |
| 88 // ThreadLocalTop may be only available during this call. |
| 89 virtual void VisitThread(ThreadLocalTop* top) = 0; |
| 90 |
| 91 protected: |
| 92 virtual ~ThreadVisitor() {} |
| 93 }; |
| 94 |
| 95 |
82 class ThreadManager : public AllStatic { | 96 class ThreadManager : public AllStatic { |
83 public: | 97 public: |
84 static void Lock(); | 98 static void Lock(); |
85 static void Unlock(); | 99 static void Unlock(); |
86 | 100 |
87 static void ArchiveThread(); | 101 static void ArchiveThread(); |
88 static bool RestoreThread(); | 102 static bool RestoreThread(); |
89 static void FreeThreadResources(); | 103 static void FreeThreadResources(); |
90 static bool IsArchived(); | 104 static bool IsArchived(); |
91 | 105 |
92 static void Iterate(ObjectVisitor* v); | 106 static void Iterate(ObjectVisitor* v); |
| 107 static void IterateThreads(ThreadVisitor* v); |
93 static void MarkCompactPrologue(bool is_compacting); | 108 static void MarkCompactPrologue(bool is_compacting); |
94 static void MarkCompactEpilogue(bool is_compacting); | 109 static void MarkCompactEpilogue(bool is_compacting); |
95 static bool IsLockedByCurrentThread() { return mutex_owner_.IsSelf(); } | 110 static bool IsLockedByCurrentThread() { return mutex_owner_.IsSelf(); } |
96 | 111 |
97 static int CurrentId(); | 112 static int CurrentId(); |
98 static void AssignId(); | 113 static void AssignId(); |
99 static bool HasId(); | 114 static bool HasId(); |
100 | 115 |
101 static void TerminateExecution(int thread_id); | 116 static void TerminateExecution(int thread_id); |
102 | 117 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 150 |
136 bool keep_going_; | 151 bool keep_going_; |
137 int sleep_ms_; | 152 int sleep_ms_; |
138 | 153 |
139 static ContextSwitcher* singleton_; | 154 static ContextSwitcher* singleton_; |
140 }; | 155 }; |
141 | 156 |
142 } } // namespace v8::internal | 157 } } // namespace v8::internal |
143 | 158 |
144 #endif // V8_V8THREADS_H_ | 159 #endif // V8_V8THREADS_H_ |
OLD | NEW |