| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 void LinkInto(List list); | 44 void LinkInto(List list); |
| 45 void Unlink(); | 45 void Unlink(); |
| 46 | 46 |
| 47 static ThreadState* GetFree(); | 47 static ThreadState* GetFree(); |
| 48 | 48 |
| 49 // Id of thread. | 49 // Id of thread. |
| 50 void set_id(int id) { id_ = id; } | 50 void set_id(int id) { id_ = id; } |
| 51 int id() { return id_; } | 51 int id() { return id_; } |
| 52 | 52 |
| 53 // Should the thread be terminated when it is restored? |
| 54 bool terminate_on_restore() { return terminate_on_restore_; } |
| 55 void set_terminate_on_restore(bool terminate_on_restore) { |
| 56 terminate_on_restore_ = terminate_on_restore; |
| 57 } |
| 58 |
| 53 // Get data area for archiving a thread. | 59 // Get data area for archiving a thread. |
| 54 char* data() { return data_; } | 60 char* data() { return data_; } |
| 55 private: | 61 private: |
| 56 ThreadState(); | 62 ThreadState(); |
| 57 | 63 |
| 58 void AllocateSpace(); | 64 void AllocateSpace(); |
| 59 | 65 |
| 60 int id_; | 66 int id_; |
| 67 bool terminate_on_restore_; |
| 61 char* data_; | 68 char* data_; |
| 62 ThreadState* next_; | 69 ThreadState* next_; |
| 63 ThreadState* previous_; | 70 ThreadState* previous_; |
| 64 | 71 |
| 65 // 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. |
| 66 // 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 |
| 67 // and unlinking. | 74 // and unlinking. |
| 68 // Head of linked list of free states. | 75 // Head of linked list of free states. |
| 69 static ThreadState* free_anchor_; | 76 static ThreadState* free_anchor_; |
| 70 // Head of linked list of states in use. | 77 // Head of linked list of states in use. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 81 static bool RestoreThread(); | 88 static bool RestoreThread(); |
| 82 | 89 |
| 83 static void Iterate(ObjectVisitor* v); | 90 static void Iterate(ObjectVisitor* v); |
| 84 static void MarkCompactPrologue(bool is_compacting); | 91 static void MarkCompactPrologue(bool is_compacting); |
| 85 static void MarkCompactEpilogue(bool is_compacting); | 92 static void MarkCompactEpilogue(bool is_compacting); |
| 86 static bool IsLockedByCurrentThread() { return mutex_owner_.IsSelf(); } | 93 static bool IsLockedByCurrentThread() { return mutex_owner_.IsSelf(); } |
| 87 | 94 |
| 88 static int CurrentId(); | 95 static int CurrentId(); |
| 89 static void AssignId(); | 96 static void AssignId(); |
| 90 | 97 |
| 98 static void TerminateExecution(int thread_id); |
| 99 |
| 91 static const int kInvalidId = -1; | 100 static const int kInvalidId = -1; |
| 92 private: | 101 private: |
| 93 static void EagerlyArchiveThread(); | 102 static void EagerlyArchiveThread(); |
| 94 | 103 |
| 95 static int next_id_; // V8 threads are identified through an integer. | 104 static int next_id_; // V8 threads are identified through an integer. |
| 96 static Mutex* mutex_; | 105 static Mutex* mutex_; |
| 97 static ThreadHandle mutex_owner_; | 106 static ThreadHandle mutex_owner_; |
| 98 static ThreadHandle lazily_archived_thread_; | 107 static ThreadHandle lazily_archived_thread_; |
| 99 static ThreadState* lazily_archived_thread_state_; | 108 static ThreadState* lazily_archived_thread_state_; |
| 100 }; | 109 }; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 123 | 132 |
| 124 bool keep_going_; | 133 bool keep_going_; |
| 125 int sleep_ms_; | 134 int sleep_ms_; |
| 126 | 135 |
| 127 static ContextSwitcher* singleton_; | 136 static ContextSwitcher* singleton_; |
| 128 }; | 137 }; |
| 129 | 138 |
| 130 } } // namespace v8::internal | 139 } } // namespace v8::internal |
| 131 | 140 |
| 132 #endif // V8_V8THREADS_H_ | 141 #endif // V8_V8THREADS_H_ |
| OLD | NEW |