| 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 | |
| 403 char* StackGuard::ArchiveStackGuard(char* to) { | 391 char* StackGuard::ArchiveStackGuard(char* to) { |
| 404 ExecutionAccess access(isolate_); | 392 ExecutionAccess access(isolate_); |
| 405 OS::MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); | 393 OS::MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); |
| 406 ThreadLocal blank; | 394 ThreadLocal blank; |
| 407 | 395 |
| 408 // Set the stack limits using the old thread_local_. | 396 // Set the stack limits using the old thread_local_. |
| 409 // TODO(isolates): This was the old semantics of constructing a ThreadLocal | 397 // TODO(isolates): This was the old semantics of constructing a ThreadLocal |
| 410 // (as the ctor called SetStackLimits, which looked at the | 398 // (as the ctor called SetStackLimits, which looked at the |
| 411 // current thread_local_ from StackGuard)-- but is this | 399 // current thread_local_ from StackGuard)-- but is this |
| 412 // really what was intended? | 400 // really what was intended? |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 if (debugger.FailedToEnter()) return; | 713 if (debugger.FailedToEnter()) return; |
| 726 | 714 |
| 727 // Notify the debug event listeners. Indicate auto continue if the break was | 715 // Notify the debug event listeners. Indicate auto continue if the break was |
| 728 // a debug command break. | 716 // a debug command break. |
| 729 isolate->debugger()->OnDebugBreak(isolate->factory()->undefined_value(), | 717 isolate->debugger()->OnDebugBreak(isolate->factory()->undefined_value(), |
| 730 debug_command_only); | 718 debug_command_only); |
| 731 } | 719 } |
| 732 | 720 |
| 733 | 721 |
| 734 Object* StackGuard::HandleInterrupts() { | 722 Object* StackGuard::HandleInterrupts() { |
| 735 ExecutionAccess access(isolate_); | 723 { ExecutionAccess access(isolate_); |
| 736 if (should_postpone_interrupts(access)) { | 724 if (should_postpone_interrupts(access)) { |
| 737 return isolate_->heap()->undefined_value(); | 725 return isolate_->heap()->undefined_value(); |
| 726 } |
| 738 } | 727 } |
| 739 | 728 |
| 740 if (CheckAndClearInterrupt(API_INTERRUPT, access)) { | 729 if (CheckApiInterrupt()) { |
| 730 ClearApiInterrupt(); |
| 741 isolate_->InvokeApiInterruptCallback(); | 731 isolate_->InvokeApiInterruptCallback(); |
| 742 } | 732 } |
| 743 | 733 |
| 744 if (CheckAndClearInterrupt(GC_REQUEST, access)) { | 734 if (CheckGC()) { |
| 745 isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt"); | 735 isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt"); |
| 736 ClearGC(); |
| 746 } | 737 } |
| 747 | 738 |
| 748 if (CheckDebugBreak() || CheckDebugCommand()) { | 739 if (CheckDebugBreak() || CheckDebugCommand()) { |
| 749 Execution::DebugBreakHelper(isolate_); | 740 Execution::DebugBreakHelper(isolate_); |
| 750 } | 741 } |
| 751 | 742 |
| 752 if (CheckAndClearInterrupt(TERMINATE_EXECUTION, access)) { | 743 if (CheckTerminateExecution()) { |
| 744 ClearTerminateExecution(); |
| 753 return isolate_->TerminateExecution(); | 745 return isolate_->TerminateExecution(); |
| 754 } | 746 } |
| 755 | 747 |
| 756 if (CheckAndClearInterrupt(FULL_DEOPT, access)) { | 748 if (CheckFullDeopt()) { |
| 749 ClearFullDeopt(); |
| 757 Deoptimizer::DeoptimizeAll(isolate_); | 750 Deoptimizer::DeoptimizeAll(isolate_); |
| 758 } | 751 } |
| 759 | 752 |
| 760 if (CheckAndClearInterrupt(DEOPT_MARKED_ALLOCATION_SITES, access)) { | 753 if (CheckDeoptMarkedAllocationSites()) { |
| 754 ClearDeoptMarkedAllocationSites(); |
| 761 isolate_->heap()->DeoptMarkedAllocationSites(); | 755 isolate_->heap()->DeoptMarkedAllocationSites(); |
| 762 } | 756 } |
| 763 | 757 |
| 764 if (CheckAndClearInterrupt(INSTALL_CODE, access)) { | 758 if (CheckInstallCode()) { |
| 765 ASSERT(isolate_->concurrent_recompilation_enabled()); | 759 ASSERT(isolate_->concurrent_recompilation_enabled()); |
| 760 ClearInstallCode(); |
| 766 isolate_->optimizing_compiler_thread()->InstallOptimizedFunctions(); | 761 isolate_->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
| 767 } | 762 } |
| 768 | 763 |
| 769 isolate_->counters()->stack_interrupts()->Increment(); | 764 isolate_->counters()->stack_interrupts()->Increment(); |
| 770 isolate_->counters()->runtime_profiler_ticks()->Increment(); | 765 isolate_->counters()->runtime_profiler_ticks()->Increment(); |
| 771 isolate_->runtime_profiler()->OptimizeNow(); | 766 isolate_->runtime_profiler()->OptimizeNow(); |
| 772 return isolate_->heap()->undefined_value(); | 767 return isolate_->heap()->undefined_value(); |
| 773 } | 768 } |
| 774 | 769 |
| 775 } } // namespace v8::internal | 770 } } // namespace v8::internal |
| OLD | NEW |