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

Side by Side Diff: src/v8threads.cc

Issue 17416: * Move irregexp backtrack stack to external memory area, instead of the system stack. (Closed)
Patch Set: Added explicit stack check requests to push operations. Created 11 years, 11 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
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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "api.h" 30 #include "api.h"
31 #include "debug.h" 31 #include "debug.h"
32 #include "execution.h" 32 #include "execution.h"
33 #include "v8threads.h" 33 #include "v8threads.h"
34 #include "regexp-stack.h"
34 35
35 namespace v8 { 36 namespace v8 {
36 37
37 static internal::Thread::LocalStorageKey thread_state_key = 38 static internal::Thread::LocalStorageKey thread_state_key =
38 internal::Thread::CreateThreadLocalKey(); 39 internal::Thread::CreateThreadLocalKey();
39 40
40 // Constructor for the Locker object. Once the Locker is constructed the 41 // Constructor for the Locker object. Once the Locker is constructed the
41 // current thread will be guaranteed to have the big V8 lock. 42 // current thread will be guaranteed to have the big V8 lock.
42 Locker::Locker() : has_lock_(false), top_level_(true) { 43 Locker::Locker() : has_lock_(false), top_level_(true) {
43 // Get the big lock if necessary. 44 // Get the big lock if necessary.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 ThreadState* state = 119 ThreadState* state =
119 reinterpret_cast<ThreadState*>(Thread::GetThreadLocal(thread_state_key)); 120 reinterpret_cast<ThreadState*>(Thread::GetThreadLocal(thread_state_key));
120 if (state == NULL) { 121 if (state == NULL) {
121 return false; 122 return false;
122 } 123 }
123 char* from = state->data(); 124 char* from = state->data();
124 from = HandleScopeImplementer::RestoreThread(from); 125 from = HandleScopeImplementer::RestoreThread(from);
125 from = Top::RestoreThread(from); 126 from = Top::RestoreThread(from);
126 from = Debug::RestoreDebug(from); 127 from = Debug::RestoreDebug(from);
127 from = StackGuard::RestoreStackGuard(from); 128 from = StackGuard::RestoreStackGuard(from);
129 from = RegExpStack::RestoreStack(from);
128 Thread::SetThreadLocal(thread_state_key, NULL); 130 Thread::SetThreadLocal(thread_state_key, NULL);
129 state->Unlink(); 131 state->Unlink();
130 state->LinkInto(ThreadState::FREE_LIST); 132 state->LinkInto(ThreadState::FREE_LIST);
131 return true; 133 return true;
132 } 134 }
133 135
134 136
135 void ThreadManager::Lock() { 137 void ThreadManager::Lock() {
136 mutex_->Lock(); 138 mutex_->Lock();
137 mutex_owner_.Initialize(ThreadHandle::SELF); 139 mutex_owner_.Initialize(ThreadHandle::SELF);
138 ASSERT(IsLockedByCurrentThread()); 140 ASSERT(IsLockedByCurrentThread());
139 } 141 }
140 142
141 143
142 void ThreadManager::Unlock() { 144 void ThreadManager::Unlock() {
143 mutex_owner_.Initialize(ThreadHandle::INVALID); 145 mutex_owner_.Initialize(ThreadHandle::INVALID);
144 mutex_->Unlock(); 146 mutex_->Unlock();
145 } 147 }
146 148
147 149
148 static int ArchiveSpacePerThread() { 150 static int ArchiveSpacePerThread() {
149 return HandleScopeImplementer::ArchiveSpacePerThread() + 151 return HandleScopeImplementer::ArchiveSpacePerThread() +
150 Top::ArchiveSpacePerThread() + 152 Top::ArchiveSpacePerThread() +
151 Debug::ArchiveSpacePerThread() + 153 Debug::ArchiveSpacePerThread() +
152 StackGuard::ArchiveSpacePerThread(); 154 StackGuard::ArchiveSpacePerThread() +
155 RegExpStack::ArchiveSpacePerThread();
153 } 156 }
154 157
155 158
156 ThreadState* ThreadState::free_anchor_ = new ThreadState(); 159 ThreadState* ThreadState::free_anchor_ = new ThreadState();
157 ThreadState* ThreadState::in_use_anchor_ = new ThreadState(); 160 ThreadState* ThreadState::in_use_anchor_ = new ThreadState();
158 161
159 162
160 ThreadState::ThreadState() : next_(this), previous_(this) { 163 ThreadState::ThreadState() : next_(this), previous_(this) {
161 } 164 }
162 165
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 226
224 227
225 void ThreadManager::EagerlyArchiveThread() { 228 void ThreadManager::EagerlyArchiveThread() {
226 ThreadState* state = lazily_archived_thread_state_; 229 ThreadState* state = lazily_archived_thread_state_;
227 state->LinkInto(ThreadState::IN_USE_LIST); 230 state->LinkInto(ThreadState::IN_USE_LIST);
228 char* to = state->data(); 231 char* to = state->data();
229 to = HandleScopeImplementer::ArchiveThread(to); 232 to = HandleScopeImplementer::ArchiveThread(to);
230 to = Top::ArchiveThread(to); 233 to = Top::ArchiveThread(to);
231 to = Debug::ArchiveDebug(to); 234 to = Debug::ArchiveDebug(to);
232 to = StackGuard::ArchiveStackGuard(to); 235 to = StackGuard::ArchiveStackGuard(to);
236 to = RegExpStack::ArchiveStack(to);
233 lazily_archived_thread_.Initialize(ThreadHandle::INVALID); 237 lazily_archived_thread_.Initialize(ThreadHandle::INVALID);
234 lazily_archived_thread_state_ = NULL; 238 lazily_archived_thread_state_ = NULL;
235 } 239 }
236 240
237 241
238 void ThreadManager::Iterate(ObjectVisitor* v) { 242 void ThreadManager::Iterate(ObjectVisitor* v) {
239 // Expecting no threads during serialization/deserialization 243 // Expecting no threads during serialization/deserialization
240 for (ThreadState* state = ThreadState::FirstInUse(); 244 for (ThreadState* state = ThreadState::FirstInUse();
241 state != NULL; 245 state != NULL;
242 state = state->Next()) { 246 state = state->Next()) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // Acknowledge the preemption by the receiving thread. 329 // Acknowledge the preemption by the receiving thread.
326 void ContextSwitcher::PreemptionReceived() { 330 void ContextSwitcher::PreemptionReceived() {
327 ASSERT(Locker::IsLocked()); 331 ASSERT(Locker::IsLocked());
328 // There is currently no accounting being done for this. But could be in the 332 // There is currently no accounting being done for this. But could be in the
329 // future, which is why we leave this in. 333 // future, which is why we leave this in.
330 } 334 }
331 335
332 336
333 } // namespace internal 337 } // namespace internal
334 } // namespace v8 338 } // namespace v8
OLDNEW
« src/regexp-stack.h ('K') | « src/regexp-stack.cc ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698