Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: src/v8threads.h

Issue 48009: Add thread information to the debugger (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 27 matching lines...) Expand all
38 // Returns NULL after the last one. 38 // Returns NULL after the last one.
39 ThreadState* Next(); 39 ThreadState* Next();
40 40
41 enum List {FREE_LIST, IN_USE_LIST}; 41 enum List {FREE_LIST, IN_USE_LIST};
42 42
43 void LinkInto(List list); 43 void LinkInto(List list);
44 void Unlink(); 44 void Unlink();
45 45
46 static ThreadState* GetFree(); 46 static ThreadState* GetFree();
47 47
48 // Id of thread.
49 void set_id(int id) { id_ = id; }
50 int id() { return id_; }
51
48 // Get data area for archiving a thread. 52 // Get data area for archiving a thread.
49 char* data() { return data_; } 53 char* data() { return data_; }
50 private: 54 private:
51 ThreadState(); 55 ThreadState();
52 56
53 void AllocateSpace(); 57 void AllocateSpace();
54 58
59 int id_;
55 char* data_; 60 char* data_;
56 ThreadState* next_; 61 ThreadState* next_;
57 ThreadState* previous_; 62 ThreadState* previous_;
63
58 // In the following two lists there is always at least one object on the list. 64 // In the following two lists there is always at least one object on the list.
59 // The first object is a flying anchor that is only there to simplify linking 65 // The first object is a flying anchor that is only there to simplify linking
60 // and unlinking. 66 // and unlinking.
61 // Head of linked list of free states. 67 // Head of linked list of free states.
62 static ThreadState* free_anchor_; 68 static ThreadState* free_anchor_;
63 // Head of linked list of states in use. 69 // Head of linked list of states in use.
64 static ThreadState* in_use_anchor_; 70 static ThreadState* in_use_anchor_;
65 }; 71 };
66 72
67 73
68 class ThreadManager : public AllStatic { 74 class ThreadManager : public AllStatic {
69 public: 75 public:
70 static void Lock(); 76 static void Lock();
71 static void Unlock(); 77 static void Unlock();
72 78
73 static void ArchiveThread(); 79 static void ArchiveThread();
74 static bool RestoreThread(); 80 static bool RestoreThread();
75 81
76 static void Iterate(ObjectVisitor* v); 82 static void Iterate(ObjectVisitor* v);
77 static void MarkCompactPrologue(bool is_compacting); 83 static void MarkCompactPrologue(bool is_compacting);
78 static void MarkCompactEpilogue(bool is_compacting); 84 static void MarkCompactEpilogue(bool is_compacting);
79 static bool IsLockedByCurrentThread() { return mutex_owner_.IsSelf(); } 85 static bool IsLockedByCurrentThread() { return mutex_owner_.IsSelf(); }
86
87 static int CurrentId();
88 static void AssignId();
89
90 static const int kInvalidId = -1;
80 private: 91 private:
81 static void EagerlyArchiveThread(); 92 static void EagerlyArchiveThread();
82 93
94 static int next_id_; // V8 threads are identified through an integer.
83 static Mutex* mutex_; 95 static Mutex* mutex_;
84 static ThreadHandle mutex_owner_; 96 static ThreadHandle mutex_owner_;
85 static ThreadHandle lazily_archived_thread_; 97 static ThreadHandle lazily_archived_thread_;
86 static ThreadState* lazily_archived_thread_state_; 98 static ThreadState* lazily_archived_thread_state_;
87 }; 99 };
88 100
89 101
90 // The ContextSwitcher thread is used to schedule regular preemptions to 102 // The ContextSwitcher thread is used to schedule regular preemptions to
91 // multiple running V8 threads. Generally it is necessary to call 103 // multiple running V8 threads. Generally it is necessary to call
92 // StartPreemption if there is more than one thread running. If not, a single 104 // StartPreemption if there is more than one thread running. If not, a single
(...skipping 17 matching lines...) Expand all
110 122
111 bool keep_going_; 123 bool keep_going_;
112 int sleep_ms_; 124 int sleep_ms_;
113 125
114 static ContextSwitcher* singleton_; 126 static ContextSwitcher* singleton_;
115 }; 127 };
116 128
117 } } // namespace v8::internal 129 } } // namespace v8::internal
118 130
119 #endif // V8_V8THREADS_H_ 131 #endif // V8_V8THREADS_H_
OLDNEW
« src/runtime.cc ('K') | « src/runtime.cc ('k') | src/v8threads.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698