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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 args); | 647 args); |
648 Handle<Object> result; | 648 Handle<Object> result; |
649 if (!maybe_result.ToHandle(&result) || !result->IsString()) { | 649 if (!maybe_result.ToHandle(&result) || !result->IsString()) { |
650 return isolate->factory()->empty_string(); | 650 return isolate->factory()->empty_string(); |
651 } | 651 } |
652 | 652 |
653 return Handle<String>::cast(result); | 653 return Handle<String>::cast(result); |
654 } | 654 } |
655 | 655 |
656 | 656 |
657 void Execution::DebugBreakHelper(Isolate* isolate) { | |
658 // Just continue if breaks are disabled. | |
659 if (isolate->debug()->disable_break()) return; | |
660 | |
661 // Ignore debug break during bootstrapping. | |
662 if (isolate->bootstrapper()->IsActive()) return; | |
663 | |
664 // Ignore debug break if debugger is not active. | |
665 if (!isolate->debug()->is_active()) return; | |
666 | |
667 StackLimitCheck check(isolate); | |
668 if (check.HasOverflowed()) return; | |
669 | |
670 { JavaScriptFrameIterator it(isolate); | |
671 ASSERT(!it.done()); | |
672 Object* fun = it.frame()->function(); | |
673 if (fun && fun->IsJSFunction()) { | |
674 // Don't stop in builtin functions. | |
675 if (JSFunction::cast(fun)->IsBuiltin()) return; | |
676 GlobalObject* global = JSFunction::cast(fun)->context()->global_object(); | |
677 // Don't stop in debugger functions. | |
678 if (isolate->debug()->IsDebugGlobal(global)) return; | |
679 } | |
680 } | |
681 | |
682 // Collect the break state before clearing the flags. | |
683 bool debug_command_only = isolate->stack_guard()->CheckDebugCommand() && | |
684 !isolate->stack_guard()->CheckDebugBreak(); | |
685 | |
686 isolate->stack_guard()->ClearDebugBreak(); | |
687 | |
688 Execution::ProcessDebugMessages(isolate, debug_command_only); | |
689 } | |
690 | |
691 | |
692 void Execution::ProcessDebugMessages(Isolate* isolate, | |
693 bool debug_command_only) { | |
694 isolate->stack_guard()->ClearDebugCommand(); | |
695 | |
696 StackLimitCheck check(isolate); | |
697 if (check.HasOverflowed()) return; | |
698 | |
699 HandleScope scope(isolate); | |
700 // Enter the debugger. Just continue if we fail to enter the debugger. | |
701 EnterDebugger debugger(isolate); | |
702 if (debugger.FailedToEnter()) return; | |
703 | |
704 // Notify the debug event listeners. Indicate auto continue if the break was | |
705 // a debug command break. | |
706 isolate->debug()->OnDebugBreak(isolate->factory()->undefined_value(), | |
707 debug_command_only); | |
708 } | |
709 | |
710 | |
711 Object* StackGuard::HandleInterrupts() { | 657 Object* StackGuard::HandleInterrupts() { |
712 bool has_api_interrupt = false; | 658 bool has_api_interrupt = false; |
713 { | 659 { |
714 ExecutionAccess access(isolate_); | 660 ExecutionAccess access(isolate_); |
715 if (should_postpone_interrupts(access)) { | 661 if (should_postpone_interrupts(access)) { |
716 return isolate_->heap()->undefined_value(); | 662 return isolate_->heap()->undefined_value(); |
717 } | 663 } |
718 | 664 |
719 if (CheckAndClearInterrupt(GC_REQUEST, access)) { | 665 if (CheckAndClearInterrupt(GC_REQUEST, access)) { |
720 isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt"); | 666 isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt"); |
721 } | 667 } |
722 | 668 |
723 if (CheckDebugBreak() || CheckDebugCommand()) { | 669 if (CheckDebugBreak() || CheckDebugCommand()) { |
724 Execution::DebugBreakHelper(isolate_); | 670 isolate_->debug()->DebugBreakHelper(); |
725 } | 671 } |
726 | 672 |
727 if (CheckAndClearInterrupt(TERMINATE_EXECUTION, access)) { | 673 if (CheckAndClearInterrupt(TERMINATE_EXECUTION, access)) { |
728 return isolate_->TerminateExecution(); | 674 return isolate_->TerminateExecution(); |
729 } | 675 } |
730 | 676 |
731 if (CheckAndClearInterrupt(DEOPT_MARKED_ALLOCATION_SITES, access)) { | 677 if (CheckAndClearInterrupt(DEOPT_MARKED_ALLOCATION_SITES, access)) { |
732 isolate_->heap()->DeoptMarkedAllocationSites(); | 678 isolate_->heap()->DeoptMarkedAllocationSites(); |
733 } | 679 } |
734 | 680 |
(...skipping 11 matching lines...) Expand all Loading... |
746 | 692 |
747 if (has_api_interrupt) { | 693 if (has_api_interrupt) { |
748 // Callback must be invoked outside of ExecusionAccess lock. | 694 // Callback must be invoked outside of ExecusionAccess lock. |
749 isolate_->InvokeApiInterruptCallback(); | 695 isolate_->InvokeApiInterruptCallback(); |
750 } | 696 } |
751 | 697 |
752 return isolate_->heap()->undefined_value(); | 698 return isolate_->heap()->undefined_value(); |
753 } | 699 } |
754 | 700 |
755 } } // namespace v8::internal | 701 } } // namespace v8::internal |
OLD | NEW |