OLD | NEW |
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 bool StackGuard::IsStackOverflow() { | 215 bool StackGuard::IsStackOverflow() { |
216 ExecutionAccess access; | 216 ExecutionAccess access; |
217 return (thread_local_.jslimit_ != kInterruptLimit && | 217 return (thread_local_.jslimit_ != kInterruptLimit && |
218 thread_local_.climit_ != kInterruptLimit); | 218 thread_local_.climit_ != kInterruptLimit); |
219 } | 219 } |
220 | 220 |
221 | 221 |
222 void StackGuard::EnableInterrupts() { | 222 void StackGuard::EnableInterrupts() { |
223 ExecutionAccess access; | 223 ExecutionAccess access; |
224 if (IsSet(access)) { | 224 if (has_pending_interrupts(access)) { |
225 set_limits(kInterruptLimit, access); | 225 set_interrupt_limits(access); |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 | 229 |
230 void StackGuard::SetStackLimit(uintptr_t limit) { | 230 void StackGuard::SetStackLimit(uintptr_t limit) { |
231 ExecutionAccess access; | 231 ExecutionAccess access; |
232 // If the current limits are special (eg due to a pending interrupt) then | 232 // If the current limits are special (eg due to a pending interrupt) then |
233 // leave them alone. | 233 // leave them alone. |
234 uintptr_t jslimit = SimulatorStack::JsLimitFromCLimit(limit); | 234 uintptr_t jslimit = SimulatorStack::JsLimitFromCLimit(limit); |
235 if (thread_local_.jslimit_ == thread_local_.real_jslimit_) { | 235 if (thread_local_.jslimit_ == thread_local_.real_jslimit_) { |
236 thread_local_.jslimit_ = jslimit; | 236 thread_local_.jslimit_ = jslimit; |
237 } | 237 } |
238 if (thread_local_.climit_ == thread_local_.real_climit_) { | 238 if (thread_local_.climit_ == thread_local_.real_climit_) { |
239 thread_local_.climit_ = limit; | 239 thread_local_.climit_ = limit; |
240 } | 240 } |
241 thread_local_.real_climit_ = limit; | 241 thread_local_.real_climit_ = limit; |
242 thread_local_.real_jslimit_ = jslimit; | 242 thread_local_.real_jslimit_ = jslimit; |
243 } | 243 } |
244 | 244 |
245 | 245 |
246 void StackGuard::DisableInterrupts() { | 246 void StackGuard::DisableInterrupts() { |
247 ExecutionAccess access; | 247 ExecutionAccess access; |
248 reset_limits(access); | 248 reset_limits(access); |
249 } | 249 } |
250 | 250 |
251 | 251 |
252 bool StackGuard::IsSet(const ExecutionAccess& lock) { | |
253 return thread_local_.interrupt_flags_ != 0; | |
254 } | |
255 | |
256 | |
257 bool StackGuard::IsInterrupted() { | 252 bool StackGuard::IsInterrupted() { |
258 ExecutionAccess access; | 253 ExecutionAccess access; |
259 return thread_local_.interrupt_flags_ & INTERRUPT; | 254 return thread_local_.interrupt_flags_ & INTERRUPT; |
260 } | 255 } |
261 | 256 |
262 | 257 |
263 void StackGuard::Interrupt() { | 258 void StackGuard::Interrupt() { |
264 ExecutionAccess access; | 259 ExecutionAccess access; |
265 thread_local_.interrupt_flags_ |= INTERRUPT; | 260 thread_local_.interrupt_flags_ |= INTERRUPT; |
266 set_limits(kInterruptLimit, access); | 261 set_interrupt_limits(access); |
267 } | 262 } |
268 | 263 |
269 | 264 |
270 bool StackGuard::IsPreempted() { | 265 bool StackGuard::IsPreempted() { |
271 ExecutionAccess access; | 266 ExecutionAccess access; |
272 return thread_local_.interrupt_flags_ & PREEMPT; | 267 return thread_local_.interrupt_flags_ & PREEMPT; |
273 } | 268 } |
274 | 269 |
275 | 270 |
276 void StackGuard::Preempt() { | 271 void StackGuard::Preempt() { |
277 ExecutionAccess access; | 272 ExecutionAccess access; |
278 thread_local_.interrupt_flags_ |= PREEMPT; | 273 thread_local_.interrupt_flags_ |= PREEMPT; |
279 set_limits(kInterruptLimit, access); | 274 set_interrupt_limits(access); |
280 } | 275 } |
281 | 276 |
282 | 277 |
283 bool StackGuard::IsTerminateExecution() { | 278 bool StackGuard::IsTerminateExecution() { |
284 ExecutionAccess access; | 279 ExecutionAccess access; |
285 return thread_local_.interrupt_flags_ & TERMINATE; | 280 return thread_local_.interrupt_flags_ & TERMINATE; |
286 } | 281 } |
287 | 282 |
288 | 283 |
289 void StackGuard::TerminateExecution() { | 284 void StackGuard::TerminateExecution() { |
290 ExecutionAccess access; | 285 ExecutionAccess access; |
291 thread_local_.interrupt_flags_ |= TERMINATE; | 286 thread_local_.interrupt_flags_ |= TERMINATE; |
292 set_limits(kInterruptLimit, access); | 287 set_interrupt_limits(access); |
293 } | 288 } |
294 | 289 |
295 | 290 |
296 #ifdef ENABLE_DEBUGGER_SUPPORT | 291 #ifdef ENABLE_DEBUGGER_SUPPORT |
297 bool StackGuard::IsDebugBreak() { | 292 bool StackGuard::IsDebugBreak() { |
298 ExecutionAccess access; | 293 ExecutionAccess access; |
299 return thread_local_.interrupt_flags_ & DEBUGBREAK; | 294 return thread_local_.interrupt_flags_ & DEBUGBREAK; |
300 } | 295 } |
301 | 296 |
302 | 297 |
303 void StackGuard::DebugBreak() { | 298 void StackGuard::DebugBreak() { |
304 ExecutionAccess access; | 299 ExecutionAccess access; |
305 thread_local_.interrupt_flags_ |= DEBUGBREAK; | 300 thread_local_.interrupt_flags_ |= DEBUGBREAK; |
306 set_limits(kInterruptLimit, access); | 301 set_interrupt_limits(access); |
307 } | 302 } |
308 | 303 |
309 | 304 |
310 bool StackGuard::IsDebugCommand() { | 305 bool StackGuard::IsDebugCommand() { |
311 ExecutionAccess access; | 306 ExecutionAccess access; |
312 return thread_local_.interrupt_flags_ & DEBUGCOMMAND; | 307 return thread_local_.interrupt_flags_ & DEBUGCOMMAND; |
313 } | 308 } |
314 | 309 |
315 | 310 |
316 void StackGuard::DebugCommand() { | 311 void StackGuard::DebugCommand() { |
317 if (FLAG_debugger_auto_break) { | 312 if (FLAG_debugger_auto_break) { |
318 ExecutionAccess access; | 313 ExecutionAccess access; |
319 thread_local_.interrupt_flags_ |= DEBUGCOMMAND; | 314 thread_local_.interrupt_flags_ |= DEBUGCOMMAND; |
320 set_limits(kInterruptLimit, access); | 315 set_interrupt_limits(access); |
321 } | 316 } |
322 } | 317 } |
323 #endif | 318 #endif |
324 | 319 |
325 void StackGuard::Continue(InterruptFlag after_what) { | 320 void StackGuard::Continue(InterruptFlag after_what) { |
326 ExecutionAccess access; | 321 ExecutionAccess access; |
327 thread_local_.interrupt_flags_ &= ~static_cast<int>(after_what); | 322 thread_local_.interrupt_flags_ &= ~static_cast<int>(after_what); |
328 if (thread_local_.interrupt_flags_ == 0) { | 323 if (!should_postpone_interrupts(access) && !has_pending_interrupts(access)) { |
329 reset_limits(access); | 324 reset_limits(access); |
330 } | 325 } |
331 } | 326 } |
332 | 327 |
333 | 328 |
334 int StackGuard::ArchiveSpacePerThread() { | 329 int StackGuard::ArchiveSpacePerThread() { |
335 return sizeof(ThreadLocal); | 330 return sizeof(ThreadLocal); |
336 } | 331 } |
337 | 332 |
338 | 333 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 // All allocation spaces other than NEW_SPACE have the same effect. | 695 // All allocation spaces other than NEW_SPACE have the same effect. |
701 Heap::CollectAllGarbage(false); | 696 Heap::CollectAllGarbage(false); |
702 return v8::Undefined(); | 697 return v8::Undefined(); |
703 } | 698 } |
704 | 699 |
705 | 700 |
706 static GCExtension kGCExtension; | 701 static GCExtension kGCExtension; |
707 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); | 702 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); |
708 | 703 |
709 } } // namespace v8::internal | 704 } } // namespace v8::internal |
OLD | NEW |