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

Side by Side Diff: src/execution.h

Issue 242014: Adds an API for setting the stack limit per-thread. (Closed)
Patch Set: Leaves the limits of pending interrupts alone instead of reestablishing them." Created 11 years, 2 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
« no previous file with comments | « src/arm/simulator-arm.h ('k') | src/execution.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 static void SetStackLimit(uintptr_t limit); 152 static void SetStackLimit(uintptr_t limit);
153 153
154 static Address address_of_jslimit() { 154 static Address address_of_jslimit() {
155 return reinterpret_cast<Address>(&thread_local_.jslimit_); 155 return reinterpret_cast<Address>(&thread_local_.jslimit_);
156 } 156 }
157 157
158 // Threading support. 158 // Threading support.
159 static char* ArchiveStackGuard(char* to); 159 static char* ArchiveStackGuard(char* to);
160 static char* RestoreStackGuard(char* from); 160 static char* RestoreStackGuard(char* from);
161 static int ArchiveSpacePerThread(); 161 static int ArchiveSpacePerThread();
162 static void InitThread(const ExecutionAccess& lock);
162 163
163 static bool IsStackOverflow(); 164 static bool IsStackOverflow();
164 static bool IsPreempted(); 165 static bool IsPreempted();
165 static void Preempt(); 166 static void Preempt();
166 static bool IsInterrupted(); 167 static bool IsInterrupted();
167 static void Interrupt(); 168 static void Interrupt();
168 static bool IsTerminateExecution(); 169 static bool IsTerminateExecution();
169 static void TerminateExecution(); 170 static void TerminateExecution();
170 #ifdef ENABLE_DEBUGGER_SUPPORT 171 #ifdef ENABLE_DEBUGGER_SUPPORT
171 static bool IsDebugBreak(); 172 static bool IsDebugBreak();
(...skipping 11 matching lines...) Expand all
183 // You should hold the ExecutionAccess lock when calling this method. 184 // You should hold the ExecutionAccess lock when calling this method.
184 static bool IsSet(const ExecutionAccess& lock); 185 static bool IsSet(const ExecutionAccess& lock);
185 186
186 // This provides an asynchronous read of the stack limit for the current 187 // This provides an asynchronous read of the stack limit for the current
187 // thread. There are no locks protecting this, but it is assumed that you 188 // thread. There are no locks protecting this, but it is assumed that you
188 // have the global V8 lock if you are using multiple V8 threads. 189 // have the global V8 lock if you are using multiple V8 threads.
189 static uintptr_t climit() { 190 static uintptr_t climit() {
190 return thread_local_.climit_; 191 return thread_local_.climit_;
191 } 192 }
192 193
193 // You should hold the ExecutionAccess lock when calling this method. 194 // Sets the JavaScript and C stack limits, and updates the stack
194 static void set_limits(uintptr_t value, const ExecutionAccess& lock) { 195 // limit in the heap. You should hold the ExecutionAccess lock when
195 Heap::SetStackLimit(value); 196 // calling this method.
196 thread_local_.jslimit_ = value; 197 static void set_limits(uintptr_t jslimit, uintptr_t climit,
197 thread_local_.climit_ = value; 198 const ExecutionAccess& lock) {
199 Heap::SetStackLimit(jslimit);
200 thread_local_.jslimit_ = jslimit;
201 thread_local_.climit_ = climit;
202 }
203
204 // You should hold the ExecutionAccess lock when calling this
205 // method.
206 static void set_illegal_limit(const ExecutionAccess& lock) {
207 set_limits(kIllegalLimit, kIllegalLimit, lock);
208 }
209
210 // You should hold the ExecutionAccess lock when calling this
211 // method.
212 static void set_interrupt_limit(const ExecutionAccess& lock) {
213 set_limits(kInterruptLimit, kInterruptLimit, lock);
198 } 214 }
199 215
200 // Reset limits to initial values. For example after handling interrupt. 216 // Reset limits to initial values. For example after handling interrupt.
201 // You should hold the ExecutionAccess lock when calling this method. 217 // You should hold the ExecutionAccess lock when calling this method.
202 static void reset_limits(const ExecutionAccess& lock) { 218 static void reset_limits(const ExecutionAccess& lock) {
203 if (thread_local_.nesting_ == 0) { 219 if (thread_local_.nesting_ == 0) {
204 // No limits have been set yet. 220 // No limits have been set yet.
205 set_limits(kIllegalLimit, lock); 221 set_illegal_limit(lock);
206 } else { 222 } else {
207 thread_local_.jslimit_ = thread_local_.initial_jslimit_; 223 set_limits(thread_local_.initial_jslimit_, thread_local_.initial_climit_,
208 Heap::SetStackLimit(thread_local_.jslimit_); 224 lock);
209 thread_local_.climit_ = thread_local_.initial_climit_;
210 } 225 }
211 } 226 }
212 227
213 // Enable or disable interrupts. 228 // Enable or disable interrupts.
214 static void EnableInterrupts(); 229 static void EnableInterrupts();
215 static void DisableInterrupts(); 230 static void DisableInterrupts();
216 231
217 static const uintptr_t kLimitSize = kPointerSize * 128 * KB; 232 static const uintptr_t kLimitSize = kPointerSize * 128 * KB;
218 #ifdef V8_TARGET_ARCH_X64 233 #ifdef V8_TARGET_ARCH_X64
219 static const uintptr_t kInterruptLimit = V8_UINT64_C(0xfffffffffffffffe); 234 static const uintptr_t kInterruptLimit = V8_UINT64_C(0xfffffffffffffffe);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 v8::Handle<v8::String> name); 306 v8::Handle<v8::String> name);
292 static v8::Handle<v8::Value> GC(const v8::Arguments& args); 307 static v8::Handle<v8::Value> GC(const v8::Arguments& args);
293 private: 308 private:
294 static const char* kSource; 309 static const char* kSource;
295 }; 310 };
296 311
297 312
298 } } // namespace v8::internal 313 } } // namespace v8::internal
299 314
300 #endif // V8_EXECUTION_H_ 315 #endif // V8_EXECUTION_H_
OLDNEW
« no previous file with comments | « src/arm/simulator-arm.h ('k') | src/execution.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698