OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "execution.h" | 5 #include "execution.h" |
6 | 6 |
7 #include "bootstrapper.h" | 7 #include "bootstrapper.h" |
8 #include "codegen.h" | 8 #include "codegen.h" |
9 #include "deoptimizer.h" | 9 #include "deoptimizer.h" |
10 #include "isolate-inl.h" | 10 #include "isolate-inl.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 | 381 |
382 void StackGuard::ClearInterrupt(int flagbit) { | 382 void StackGuard::ClearInterrupt(int flagbit) { |
383 ExecutionAccess access(isolate_); | 383 ExecutionAccess access(isolate_); |
384 thread_local_.interrupt_flags_ &= ~flagbit; | 384 thread_local_.interrupt_flags_ &= ~flagbit; |
385 if (!should_postpone_interrupts(access) && !has_pending_interrupts(access)) { | 385 if (!should_postpone_interrupts(access) && !has_pending_interrupts(access)) { |
386 reset_limits(access); | 386 reset_limits(access); |
387 } | 387 } |
388 } | 388 } |
389 | 389 |
390 | 390 |
| 391 bool StackGuard::CheckAndClearInterrupt(InterruptFlag flag, |
| 392 const ExecutionAccess& lock) { |
| 393 int flagbit = 1 << flag; |
| 394 bool result = (thread_local_.interrupt_flags_ & flagbit); |
| 395 thread_local_.interrupt_flags_ &= ~flagbit; |
| 396 if (!should_postpone_interrupts(lock) && !has_pending_interrupts(lock)) { |
| 397 reset_limits(lock); |
| 398 } |
| 399 return result; |
| 400 } |
| 401 |
| 402 |
391 char* StackGuard::ArchiveStackGuard(char* to) { | 403 char* StackGuard::ArchiveStackGuard(char* to) { |
392 ExecutionAccess access(isolate_); | 404 ExecutionAccess access(isolate_); |
393 OS::MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); | 405 OS::MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); |
394 ThreadLocal blank; | 406 ThreadLocal blank; |
395 | 407 |
396 // Set the stack limits using the old thread_local_. | 408 // Set the stack limits using the old thread_local_. |
397 // TODO(isolates): This was the old semantics of constructing a ThreadLocal | 409 // TODO(isolates): This was the old semantics of constructing a ThreadLocal |
398 // (as the ctor called SetStackLimits, which looked at the | 410 // (as the ctor called SetStackLimits, which looked at the |
399 // current thread_local_ from StackGuard)-- but is this | 411 // current thread_local_ from StackGuard)-- but is this |
400 // really what was intended? | 412 // really what was intended? |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 if (debugger.FailedToEnter()) return; | 725 if (debugger.FailedToEnter()) return; |
714 | 726 |
715 // Notify the debug event listeners. Indicate auto continue if the break was | 727 // Notify the debug event listeners. Indicate auto continue if the break was |
716 // a debug command break. | 728 // a debug command break. |
717 isolate->debugger()->OnDebugBreak(isolate->factory()->undefined_value(), | 729 isolate->debugger()->OnDebugBreak(isolate->factory()->undefined_value(), |
718 debug_command_only); | 730 debug_command_only); |
719 } | 731 } |
720 | 732 |
721 | 733 |
722 Object* StackGuard::HandleInterrupts() { | 734 Object* StackGuard::HandleInterrupts() { |
723 { ExecutionAccess access(isolate_); | 735 ExecutionAccess access(isolate_); |
724 if (should_postpone_interrupts(access)) { | 736 if (should_postpone_interrupts(access)) { |
725 return isolate_->heap()->undefined_value(); | 737 return isolate_->heap()->undefined_value(); |
726 } | |
727 } | 738 } |
728 | 739 |
729 if (CheckApiInterrupt()) { | 740 if (CheckAndClearInterrupt(API_INTERRUPT, access)) { |
730 ClearApiInterrupt(); | |
731 isolate_->InvokeApiInterruptCallback(); | 741 isolate_->InvokeApiInterruptCallback(); |
732 } | 742 } |
733 | 743 |
734 if (CheckGC()) { | 744 if (CheckAndClearInterrupt(GC_REQUEST, access)) { |
735 isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt"); | 745 isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt"); |
736 ClearGC(); | |
737 } | 746 } |
738 | 747 |
739 if (CheckDebugBreak() || CheckDebugCommand()) { | 748 if (CheckDebugBreak() || CheckDebugCommand()) { |
740 Execution::DebugBreakHelper(isolate_); | 749 Execution::DebugBreakHelper(isolate_); |
741 } | 750 } |
742 | 751 |
743 if (CheckTerminateExecution()) { | 752 if (CheckAndClearInterrupt(TERMINATE_EXECUTION, access)) { |
744 ClearTerminateExecution(); | |
745 return isolate_->TerminateExecution(); | 753 return isolate_->TerminateExecution(); |
746 } | 754 } |
747 | 755 |
748 if (CheckFullDeopt()) { | 756 if (CheckAndClearInterrupt(FULL_DEOPT, access)) { |
749 ClearFullDeopt(); | |
750 Deoptimizer::DeoptimizeAll(isolate_); | 757 Deoptimizer::DeoptimizeAll(isolate_); |
751 } | 758 } |
752 | 759 |
753 if (CheckDeoptMarkedAllocationSites()) { | 760 if (CheckAndClearInterrupt(DEOPT_MARKED_ALLOCATION_SITES, access)) { |
754 ClearDeoptMarkedAllocationSites(); | |
755 isolate_->heap()->DeoptMarkedAllocationSites(); | 761 isolate_->heap()->DeoptMarkedAllocationSites(); |
756 } | 762 } |
757 | 763 |
758 if (CheckInstallCode()) { | 764 if (CheckAndClearInterrupt(INSTALL_CODE, access)) { |
759 ASSERT(isolate_->concurrent_recompilation_enabled()); | 765 ASSERT(isolate_->concurrent_recompilation_enabled()); |
760 ClearInstallCode(); | |
761 isolate_->optimizing_compiler_thread()->InstallOptimizedFunctions(); | 766 isolate_->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
762 } | 767 } |
763 | 768 |
764 isolate_->counters()->stack_interrupts()->Increment(); | 769 isolate_->counters()->stack_interrupts()->Increment(); |
765 isolate_->counters()->runtime_profiler_ticks()->Increment(); | 770 isolate_->counters()->runtime_profiler_ticks()->Increment(); |
766 isolate_->runtime_profiler()->OptimizeNow(); | 771 isolate_->runtime_profiler()->OptimizeNow(); |
767 return isolate_->heap()->undefined_value(); | 772 return isolate_->heap()->undefined_value(); |
768 } | 773 } |
769 | 774 |
770 } } // namespace v8::internal | 775 } } // namespace v8::internal |
OLD | NEW |