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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 253 |
254 | 254 |
255 void StackGuard::DisableInterrupts() { | 255 void StackGuard::DisableInterrupts() { |
256 ExecutionAccess access; | 256 ExecutionAccess access; |
257 reset_limits(access); | 257 reset_limits(access); |
258 } | 258 } |
259 | 259 |
260 | 260 |
261 bool StackGuard::IsInterrupted() { | 261 bool StackGuard::IsInterrupted() { |
262 ExecutionAccess access; | 262 ExecutionAccess access; |
263 return thread_local_.interrupt_flags_ & INTERRUPT; | 263 return (thread_local_.interrupt_flags_ & INTERRUPT) != 0; |
264 } | 264 } |
265 | 265 |
266 | 266 |
267 void StackGuard::Interrupt() { | 267 void StackGuard::Interrupt() { |
268 ExecutionAccess access; | 268 ExecutionAccess access; |
269 thread_local_.interrupt_flags_ |= INTERRUPT; | 269 thread_local_.interrupt_flags_ |= INTERRUPT; |
270 set_interrupt_limits(access); | 270 set_interrupt_limits(access); |
271 } | 271 } |
272 | 272 |
273 | 273 |
274 bool StackGuard::IsPreempted() { | 274 bool StackGuard::IsPreempted() { |
275 ExecutionAccess access; | 275 ExecutionAccess access; |
276 return thread_local_.interrupt_flags_ & PREEMPT; | 276 return thread_local_.interrupt_flags_ & PREEMPT; |
277 } | 277 } |
278 | 278 |
279 | 279 |
280 void StackGuard::Preempt() { | 280 void StackGuard::Preempt() { |
281 ExecutionAccess access; | 281 ExecutionAccess access; |
282 thread_local_.interrupt_flags_ |= PREEMPT; | 282 thread_local_.interrupt_flags_ |= PREEMPT; |
283 set_interrupt_limits(access); | 283 set_interrupt_limits(access); |
284 } | 284 } |
285 | 285 |
286 | 286 |
287 bool StackGuard::IsTerminateExecution() { | 287 bool StackGuard::IsTerminateExecution() { |
288 ExecutionAccess access; | 288 ExecutionAccess access; |
289 return thread_local_.interrupt_flags_ & TERMINATE; | 289 return (thread_local_.interrupt_flags_ & TERMINATE) != 0; |
290 } | 290 } |
291 | 291 |
292 | 292 |
293 void StackGuard::TerminateExecution() { | 293 void StackGuard::TerminateExecution() { |
294 ExecutionAccess access; | 294 ExecutionAccess access; |
295 thread_local_.interrupt_flags_ |= TERMINATE; | 295 thread_local_.interrupt_flags_ |= TERMINATE; |
296 set_interrupt_limits(access); | 296 set_interrupt_limits(access); |
297 } | 297 } |
298 | 298 |
299 | 299 |
300 bool StackGuard::IsRuntimeProfilerTick() { | 300 bool StackGuard::IsRuntimeProfilerTick() { |
301 ExecutionAccess access; | 301 ExecutionAccess access; |
302 return thread_local_.interrupt_flags_ & RUNTIME_PROFILER_TICK; | 302 return (thread_local_.interrupt_flags_ & RUNTIME_PROFILER_TICK) != 0; |
303 } | 303 } |
304 | 304 |
305 | 305 |
306 void StackGuard::RequestRuntimeProfilerTick() { | 306 void StackGuard::RequestRuntimeProfilerTick() { |
307 // Ignore calls if we're not optimizing or if we can't get the lock. | 307 // Ignore calls if we're not optimizing or if we can't get the lock. |
308 if (FLAG_opt && ExecutionAccess::TryLock()) { | 308 if (FLAG_opt && ExecutionAccess::TryLock()) { |
309 thread_local_.interrupt_flags_ |= RUNTIME_PROFILER_TICK; | 309 thread_local_.interrupt_flags_ |= RUNTIME_PROFILER_TICK; |
310 if (thread_local_.postpone_interrupts_nesting_ == 0) { | 310 if (thread_local_.postpone_interrupts_nesting_ == 0) { |
311 thread_local_.jslimit_ = thread_local_.climit_ = kInterruptLimit; | 311 thread_local_.jslimit_ = thread_local_.climit_ = kInterruptLimit; |
312 Heap::SetStackLimits(); | 312 Heap::SetStackLimits(); |
313 } | 313 } |
314 ExecutionAccess::Unlock(); | 314 ExecutionAccess::Unlock(); |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 | 318 |
| 319 bool StackGuard::IsGCRequest() { |
| 320 ExecutionAccess access; |
| 321 return (thread_local_.interrupt_flags_ & GC_REQUEST) != 0; |
| 322 } |
| 323 |
| 324 |
| 325 void StackGuard::RequestGC() { |
| 326 ExecutionAccess access; |
| 327 thread_local_.interrupt_flags_ |= GC_REQUEST; |
| 328 if (thread_local_.postpone_interrupts_nesting_ == 0) { |
| 329 thread_local_.jslimit_ = thread_local_.climit_ = kInterruptLimit; |
| 330 Heap::SetStackLimits(); |
| 331 } |
| 332 } |
| 333 |
| 334 |
319 #ifdef ENABLE_DEBUGGER_SUPPORT | 335 #ifdef ENABLE_DEBUGGER_SUPPORT |
320 bool StackGuard::IsDebugBreak() { | 336 bool StackGuard::IsDebugBreak() { |
321 ExecutionAccess access; | 337 ExecutionAccess access; |
322 return thread_local_.interrupt_flags_ & DEBUGBREAK; | 338 return thread_local_.interrupt_flags_ & DEBUGBREAK; |
323 } | 339 } |
324 | 340 |
325 | 341 |
326 void StackGuard::DebugBreak() { | 342 void StackGuard::DebugBreak() { |
327 ExecutionAccess access; | 343 ExecutionAccess access; |
328 thread_local_.interrupt_flags_ |= DEBUGBREAK; | 344 thread_local_.interrupt_flags_ |= DEBUGBREAK; |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 | 713 |
698 // Notify the debug event listeners. Indicate auto continue if the break was | 714 // Notify the debug event listeners. Indicate auto continue if the break was |
699 // a debug command break. | 715 // a debug command break. |
700 Debugger::OnDebugBreak(Factory::undefined_value(), debug_command_only); | 716 Debugger::OnDebugBreak(Factory::undefined_value(), debug_command_only); |
701 } | 717 } |
702 | 718 |
703 | 719 |
704 #endif | 720 #endif |
705 | 721 |
706 MaybeObject* Execution::HandleStackGuardInterrupt() { | 722 MaybeObject* Execution::HandleStackGuardInterrupt() { |
| 723 if (StackGuard::IsGCRequest()) { |
| 724 Heap::CollectAllGarbage(false); |
| 725 StackGuard::Continue(GC_REQUEST); |
| 726 } |
| 727 |
707 Counters::stack_interrupts.Increment(); | 728 Counters::stack_interrupts.Increment(); |
708 if (StackGuard::IsRuntimeProfilerTick()) { | 729 if (StackGuard::IsRuntimeProfilerTick()) { |
709 Counters::runtime_profiler_ticks.Increment(); | 730 Counters::runtime_profiler_ticks.Increment(); |
710 StackGuard::Continue(RUNTIME_PROFILER_TICK); | 731 StackGuard::Continue(RUNTIME_PROFILER_TICK); |
711 RuntimeProfiler::OptimizeNow(); | 732 RuntimeProfiler::OptimizeNow(); |
712 } | 733 } |
713 #ifdef ENABLE_DEBUGGER_SUPPORT | 734 #ifdef ENABLE_DEBUGGER_SUPPORT |
714 if (StackGuard::IsDebugBreak() || StackGuard::IsDebugCommand()) { | 735 if (StackGuard::IsDebugBreak() || StackGuard::IsDebugCommand()) { |
715 DebugBreakHelper(); | 736 DebugBreakHelper(); |
716 } | 737 } |
717 #endif | 738 #endif |
718 if (StackGuard::IsPreempted()) RuntimePreempt(); | 739 if (StackGuard::IsPreempted()) RuntimePreempt(); |
719 if (StackGuard::IsTerminateExecution()) { | 740 if (StackGuard::IsTerminateExecution()) { |
720 StackGuard::Continue(TERMINATE); | 741 StackGuard::Continue(TERMINATE); |
721 return Top::TerminateExecution(); | 742 return Top::TerminateExecution(); |
722 } | 743 } |
723 if (StackGuard::IsInterrupted()) { | 744 if (StackGuard::IsInterrupted()) { |
724 StackGuard::Continue(INTERRUPT); | 745 StackGuard::Continue(INTERRUPT); |
725 return Top::StackOverflow(); | 746 return Top::StackOverflow(); |
726 } | 747 } |
727 return Heap::undefined_value(); | 748 return Heap::undefined_value(); |
728 } | 749 } |
729 | 750 |
730 } } // namespace v8::internal | 751 } } // namespace v8::internal |
OLD | NEW |