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

Side by Side Diff: src/execution.h

Issue 345048: Fix issue 493: Infinite loop when debug break is set when entering function.apply (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 1 month 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
« no previous file with comments | « src/assembler.cc ('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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 // StackGuard contains the handling of the limits that are used to limit the 144 // StackGuard contains the handling of the limits that are used to limit the
145 // number of nested invocations of JavaScript and the stack size used in each 145 // number of nested invocations of JavaScript and the stack size used in each
146 // invocation. 146 // invocation.
147 class StackGuard : public AllStatic { 147 class StackGuard : public AllStatic {
148 public: 148 public:
149 // Pass the address beyond which the stack should not grow. The stack 149 // Pass the address beyond which the stack should not grow. The stack
150 // is assumed to grow downwards. 150 // is assumed to grow downwards.
151 static void SetStackLimit(uintptr_t limit); 151 static void SetStackLimit(uintptr_t limit);
152 152
153 static Address address_of_jslimit() {
154 return reinterpret_cast<Address>(&thread_local_.jslimit_);
155 }
156
157 // Threading support. 153 // Threading support.
158 static char* ArchiveStackGuard(char* to); 154 static char* ArchiveStackGuard(char* to);
159 static char* RestoreStackGuard(char* from); 155 static char* RestoreStackGuard(char* from);
160 static int ArchiveSpacePerThread(); 156 static int ArchiveSpacePerThread();
161 static void FreeThreadResources(); 157 static void FreeThreadResources();
162 // Sets up the default stack guard for this thread if it has not 158 // Sets up the default stack guard for this thread if it has not
163 // already been set up. 159 // already been set up.
164 static void InitThread(const ExecutionAccess& lock); 160 static void InitThread(const ExecutionAccess& lock);
165 // Clears the stack guard for this thread so it does not look as if 161 // Clears the stack guard for this thread so it does not look as if
166 // it has been set up. 162 // it has been set up.
167 static void ClearThread(const ExecutionAccess& lock); 163 static void ClearThread(const ExecutionAccess& lock);
168 164
169 static bool IsStackOverflow(); 165 static bool IsStackOverflow();
170 static bool IsPreempted(); 166 static bool IsPreempted();
171 static void Preempt(); 167 static void Preempt();
172 static bool IsInterrupted(); 168 static bool IsInterrupted();
173 static void Interrupt(); 169 static void Interrupt();
174 static bool IsTerminateExecution(); 170 static bool IsTerminateExecution();
175 static void TerminateExecution(); 171 static void TerminateExecution();
176 #ifdef ENABLE_DEBUGGER_SUPPORT 172 #ifdef ENABLE_DEBUGGER_SUPPORT
177 static bool IsDebugBreak(); 173 static bool IsDebugBreak();
178 static void DebugBreak(); 174 static void DebugBreak();
179 static bool IsDebugCommand(); 175 static bool IsDebugCommand();
180 static void DebugCommand(); 176 static void DebugCommand();
181 #endif 177 #endif
182 static void Continue(InterruptFlag after_what); 178 static void Continue(InterruptFlag after_what);
183 179
184 // This provides an asynchronous read of the stack limit for the current 180 // This provides an asynchronous read of the stack limits for the current
185 // thread. There are no locks protecting this, but it is assumed that you 181 // thread. There are no locks protecting this, but it is assumed that you
186 // have the global V8 lock if you are using multiple V8 threads. 182 // have the global V8 lock if you are using multiple V8 threads.
187 static uintptr_t climit() { 183 static uintptr_t climit() {
188 return thread_local_.climit_; 184 return thread_local_.climit_;
189 } 185 }
190
191 static uintptr_t jslimit() { 186 static uintptr_t jslimit() {
192 return thread_local_.jslimit_; 187 return thread_local_.jslimit_;
193 } 188 }
189 static uintptr_t real_jslimit() {
190 return thread_local_.real_jslimit_;
191 }
192 static Address address_of_jslimit() {
193 return reinterpret_cast<Address>(&thread_local_.jslimit_);
194 }
195 static Address address_of_real_jslimit() {
196 return reinterpret_cast<Address>(&thread_local_.real_jslimit_);
197 }
194 198
195 private: 199 private:
196 // You should hold the ExecutionAccess lock when calling this method. 200 // You should hold the ExecutionAccess lock when calling this method.
197 static bool IsSet(const ExecutionAccess& lock); 201 static bool IsSet(const ExecutionAccess& lock);
198 202
199 // You should hold the ExecutionAccess lock when calling this method. 203 // You should hold the ExecutionAccess lock when calling this method.
200 static void set_limits(uintptr_t value, const ExecutionAccess& lock) { 204 static void set_limits(uintptr_t value, const ExecutionAccess& lock) {
201 Heap::SetStackLimit(value);
202 thread_local_.jslimit_ = value; 205 thread_local_.jslimit_ = value;
203 thread_local_.climit_ = value; 206 thread_local_.climit_ = value;
207 Heap::SetStackLimits();
204 } 208 }
205 209
206 // Reset limits to initial values. For example after handling interrupt. 210 // Reset limits to actual values. For example after handling interrupt.
207 // You should hold the ExecutionAccess lock when calling this method. 211 // You should hold the ExecutionAccess lock when calling this method.
208 static void reset_limits(const ExecutionAccess& lock) { 212 static void reset_limits(const ExecutionAccess& lock) {
209 thread_local_.jslimit_ = thread_local_.initial_jslimit_; 213 thread_local_.jslimit_ = thread_local_.real_jslimit_;
210 Heap::SetStackLimit(thread_local_.jslimit_); 214 thread_local_.climit_ = thread_local_.real_climit_;
211 thread_local_.climit_ = thread_local_.initial_climit_; 215 Heap::SetStackLimits();
212 } 216 }
213 217
214 // Enable or disable interrupts. 218 // Enable or disable interrupts.
215 static void EnableInterrupts(); 219 static void EnableInterrupts();
216 static void DisableInterrupts(); 220 static void DisableInterrupts();
217 221
218 static const uintptr_t kLimitSize = kPointerSize * 128 * KB; 222 static const uintptr_t kLimitSize = kPointerSize * 128 * KB;
219 223
220 #ifdef V8_TARGET_ARCH_X64 224 #ifdef V8_TARGET_ARCH_X64
221 static const uintptr_t kInterruptLimit = V8_UINT64_C(0xfffffffffffffffe); 225 static const uintptr_t kInterruptLimit = V8_UINT64_C(0xfffffffffffffffe);
222 static const uintptr_t kIllegalLimit = V8_UINT64_C(0xfffffffffffffff8); 226 static const uintptr_t kIllegalLimit = V8_UINT64_C(0xfffffffffffffff8);
223 #else 227 #else
224 static const uintptr_t kInterruptLimit = 0xfffffffe; 228 static const uintptr_t kInterruptLimit = 0xfffffffe;
225 static const uintptr_t kIllegalLimit = 0xfffffff8; 229 static const uintptr_t kIllegalLimit = 0xfffffff8;
226 #endif 230 #endif
227 231
228 class ThreadLocal { 232 class ThreadLocal {
229 public: 233 public:
230 ThreadLocal() { Clear(); } 234 ThreadLocal() { Clear(); }
231 // You should hold the ExecutionAccess lock when you call Initialize or 235 // You should hold the ExecutionAccess lock when you call Initialize or
232 // Clear. 236 // Clear.
233 void Initialize(); 237 void Initialize();
234 void Clear(); 238 void Clear();
235 uintptr_t initial_jslimit_; 239
240 // The stack limit is split into a JavaScript and a C++ stack limit. These
241 // two are the same except when running on a simulator where the C++ and
242 // JavaScript stacks are separate. Each of the two stack limits have two
243 // values. The one eith the real_ prefix is the actual stack limit
244 // set for the VM. The one without the real_ prefix has the same value as
245 // the actual stack limit except when there is an interruption (e.g. debug
246 // break or preemption) in which case it is lowered to make stack checks
247 // fail. Both the generated code and the runtime system check against the
248 // one without the real_ prefix.
249 uintptr_t real_jslimit_; // Actual JavaScript stack limit set for the VM.
236 uintptr_t jslimit_; 250 uintptr_t jslimit_;
237 uintptr_t initial_climit_; 251 uintptr_t real_climit_; // Actual C++ stack limit set for the VM.
238 uintptr_t climit_; 252 uintptr_t climit_;
253
239 int nesting_; 254 int nesting_;
240 int postpone_interrupts_nesting_; 255 int postpone_interrupts_nesting_;
241 int interrupt_flags_; 256 int interrupt_flags_;
242 }; 257 };
243 258
244 static ThreadLocal thread_local_; 259 static ThreadLocal thread_local_;
245 260
246 friend class StackLimitCheck; 261 friend class StackLimitCheck;
247 friend class PostponeInterruptsScope; 262 friend class PostponeInterruptsScope;
248 }; 263 };
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 v8::Handle<v8::String> name); 303 v8::Handle<v8::String> name);
289 static v8::Handle<v8::Value> GC(const v8::Arguments& args); 304 static v8::Handle<v8::Value> GC(const v8::Arguments& args);
290 private: 305 private:
291 static const char* kSource; 306 static const char* kSource;
292 }; 307 };
293 308
294 309
295 } } // namespace v8::internal 310 } } // namespace v8::internal
296 311
297 #endif // V8_EXECUTION_H_ 312 #endif // V8_EXECUTION_H_
OLDNEW
« no previous file with comments | « src/assembler.cc ('k') | src/execution.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698