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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 }; | 79 }; |
80 | 80 |
81 | 81 |
82 class ThreadManager : public AllStatic { | 82 class ThreadManager : public AllStatic { |
83 public: | 83 public: |
84 static void Lock(); | 84 static void Lock(); |
85 static void Unlock(); | 85 static void Unlock(); |
86 | 86 |
87 static void ArchiveThread(); | 87 static void ArchiveThread(); |
88 static bool RestoreThread(); | 88 static bool RestoreThread(); |
| 89 static bool IsArchived(); |
89 | 90 |
90 static void Iterate(ObjectVisitor* v); | 91 static void Iterate(ObjectVisitor* v); |
91 static void MarkCompactPrologue(bool is_compacting); | 92 static void MarkCompactPrologue(bool is_compacting); |
92 static void MarkCompactEpilogue(bool is_compacting); | 93 static void MarkCompactEpilogue(bool is_compacting); |
93 static bool IsLockedByCurrentThread() { return mutex_owner_.IsSelf(); } | 94 static bool IsLockedByCurrentThread() { return mutex_owner_.IsSelf(); } |
94 | 95 |
95 static int CurrentId(); | 96 static int CurrentId(); |
96 static void AssignId(); | 97 static void AssignId(); |
| 98 static bool HasId(); |
97 | 99 |
98 static void TerminateExecution(int thread_id); | 100 static void TerminateExecution(int thread_id); |
99 | 101 |
100 static const int kInvalidId = -1; | 102 static const int kInvalidId = -1; |
101 private: | 103 private: |
102 static void EagerlyArchiveThread(); | 104 static void EagerlyArchiveThread(); |
103 | 105 |
104 static int next_id_; // V8 threads are identified through an integer. | 106 static int last_id_; // V8 threads are identified through an integer. |
105 static Mutex* mutex_; | 107 static Mutex* mutex_; |
106 static ThreadHandle mutex_owner_; | 108 static ThreadHandle mutex_owner_; |
107 static ThreadHandle lazily_archived_thread_; | 109 static ThreadHandle lazily_archived_thread_; |
108 static ThreadState* lazily_archived_thread_state_; | 110 static ThreadState* lazily_archived_thread_state_; |
109 }; | 111 }; |
110 | 112 |
111 | 113 |
112 // The ContextSwitcher thread is used to schedule regular preemptions to | 114 // The ContextSwitcher thread is used to schedule regular preemptions to |
113 // multiple running V8 threads. Generally it is necessary to call | 115 // multiple running V8 threads. Generally it is necessary to call |
114 // StartPreemption if there is more than one thread running. If not, a single | 116 // StartPreemption if there is more than one thread running. If not, a single |
(...skipping 17 matching lines...) Expand all Loading... |
132 | 134 |
133 bool keep_going_; | 135 bool keep_going_; |
134 int sleep_ms_; | 136 int sleep_ms_; |
135 | 137 |
136 static ContextSwitcher* singleton_; | 138 static ContextSwitcher* singleton_; |
137 }; | 139 }; |
138 | 140 |
139 } } // namespace v8::internal | 141 } } // namespace v8::internal |
140 | 142 |
141 #endif // V8_V8THREADS_H_ | 143 #endif // V8_V8THREADS_H_ |
OLD | NEW |