OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 "src/debug/debug-scopes.h" | 5 #include "src/debug/debug-scopes.h" |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
11 #include "src/globals.h" | 11 #include "src/globals.h" |
12 #include "src/isolate-inl.h" | 12 #include "src/isolate-inl.h" |
13 #include "src/parsing/parser.h" | 13 #include "src/parsing/parser.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 | 17 |
18 ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, | 18 ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, |
19 ScopeIterator::Option option) | 19 ScopeIterator::Option option) |
20 : isolate_(isolate), | 20 : isolate_(isolate), |
21 frame_inspector_(frame_inspector), | 21 frame_inspector_(frame_inspector), |
22 nested_scope_chain_(4), | 22 nested_scope_chain_(4), |
23 seen_script_scope_(false), | 23 seen_script_scope_(false), |
24 failed_(false) { | 24 failed_(false) { |
25 if (!frame_inspector->GetContext()->IsContext() || | 25 if (!frame_inspector->GetContext()->IsContext()) { |
26 !frame_inspector->GetFunction()->IsJSFunction()) { | |
27 // Optimized frame, context or function cannot be materialized. Give up. | 26 // Optimized frame, context or function cannot be materialized. Give up. |
28 return; | 27 return; |
29 } | 28 } |
30 | 29 |
31 context_ = Handle<Context>::cast(frame_inspector->GetContext()); | 30 context_ = Handle<Context>::cast(frame_inspector->GetContext()); |
32 | 31 |
33 // Catch the case when the debugger stops in an internal function. | 32 // Catch the case when the debugger stops in an internal function. |
34 Handle<JSFunction> function = GetFunction(); | 33 Handle<JSFunction> function = GetFunction(); |
35 Handle<SharedFunctionInfo> shared_info(function->shared()); | 34 Handle<SharedFunctionInfo> shared_info(function->shared()); |
36 Handle<ScopeInfo> scope_info(shared_info->scope_info()); | 35 Handle<ScopeInfo> scope_info(shared_info->scope_info()); |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 606 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
608 if (String::Equals(handle(scope_info->ParameterName(i)), parameter_name)) { | 607 if (String::Equals(handle(scope_info->ParameterName(i)), parameter_name)) { |
609 frame->SetParameterValue(i, *new_value); | 608 frame->SetParameterValue(i, *new_value); |
610 return true; | 609 return true; |
611 } | 610 } |
612 } | 611 } |
613 return false; | 612 return false; |
614 } | 613 } |
615 | 614 |
616 bool ScopeIterator::SetStackVariableValue(Handle<ScopeInfo> scope_info, | 615 bool ScopeIterator::SetStackVariableValue(Handle<ScopeInfo> scope_info, |
617 JavaScriptFrame* frame, | |
618 Handle<String> variable_name, | 616 Handle<String> variable_name, |
619 Handle<Object> new_value) { | 617 Handle<Object> new_value) { |
620 // Setting stack locals of optimized frames is not supported. | 618 StandardFrame* frame = GetFrame(); |
621 if (frame->is_optimized()) return false; | 619 // Setting stack locals of optimized frames and wasm frames is not supported. |
| 620 if (frame->is_optimized() || frame->is_wasm()) return false; |
622 HandleScope scope(isolate_); | 621 HandleScope scope(isolate_); |
623 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 622 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
624 if (String::Equals(handle(scope_info->StackLocalName(i)), variable_name)) { | 623 if (String::Equals(handle(scope_info->StackLocalName(i)), variable_name)) { |
625 frame->SetExpression(scope_info->StackLocalIndex(i), *new_value); | 624 frame->SetExpression(scope_info->StackLocalIndex(i), *new_value); |
626 return true; | 625 return true; |
627 } | 626 } |
628 } | 627 } |
629 return false; | 628 return false; |
630 } | 629 } |
631 | 630 |
(...skipping 26 matching lines...) Expand all Loading... |
658 .Check(); | 657 .Check(); |
659 return true; | 658 return true; |
660 } | 659 } |
661 } | 660 } |
662 | 661 |
663 return false; | 662 return false; |
664 } | 663 } |
665 | 664 |
666 bool ScopeIterator::SetLocalVariableValue(Handle<String> variable_name, | 665 bool ScopeIterator::SetLocalVariableValue(Handle<String> variable_name, |
667 Handle<Object> new_value) { | 666 Handle<Object> new_value) { |
668 JavaScriptFrame* frame = GetFrame(); | 667 StandardFrame* frame0 = GetFrame(); |
| 668 if (frame0->is_wasm()) return false; |
| 669 |
| 670 JavaScriptFrame* frame = JavaScriptFrame::cast(frame0); |
| 671 |
669 Handle<ScopeInfo> scope_info(frame->function()->shared()->scope_info()); | 672 Handle<ScopeInfo> scope_info(frame->function()->shared()->scope_info()); |
670 | 673 |
671 // Parameter might be shadowed in context. Don't stop here. | 674 // Parameter might be shadowed in context. Don't stop here. |
672 bool result = SetParameterValue(scope_info, frame, variable_name, new_value); | 675 bool result = SetParameterValue(scope_info, frame, variable_name, new_value); |
673 | 676 |
674 // Stack locals. | 677 // Stack locals. |
675 if (SetStackVariableValue(scope_info, frame, variable_name, new_value)) { | 678 if (SetStackVariableValue(scope_info, variable_name, new_value)) { |
676 return true; | 679 return true; |
677 } | 680 } |
678 | 681 |
679 if (scope_info->HasContext() && | 682 if (scope_info->HasContext() && |
680 SetContextVariableValue(scope_info, CurrentContext(), variable_name, | 683 SetContextVariableValue(scope_info, CurrentContext(), variable_name, |
681 new_value)) { | 684 new_value)) { |
682 return true; | 685 return true; |
683 } | 686 } |
684 | 687 |
685 return result; | 688 return result; |
686 } | 689 } |
687 | 690 |
688 bool ScopeIterator::SetInnerScopeVariableValue(Handle<String> variable_name, | 691 bool ScopeIterator::SetInnerScopeVariableValue(Handle<String> variable_name, |
689 Handle<Object> new_value) { | 692 Handle<Object> new_value) { |
690 Handle<ScopeInfo> scope_info = CurrentScopeInfo(); | 693 Handle<ScopeInfo> scope_info = CurrentScopeInfo(); |
691 DCHECK(scope_info->scope_type() == BLOCK_SCOPE || | 694 DCHECK(scope_info->scope_type() == BLOCK_SCOPE || |
692 scope_info->scope_type() == EVAL_SCOPE); | 695 scope_info->scope_type() == EVAL_SCOPE); |
693 JavaScriptFrame* frame = GetFrame(); | |
694 | 696 |
695 // Setting stack locals of optimized frames is not supported. | 697 // Setting stack locals of optimized frames is not supported. |
696 if (SetStackVariableValue(scope_info, frame, variable_name, new_value)) { | 698 if (SetStackVariableValue(scope_info, variable_name, new_value)) { |
697 return true; | 699 return true; |
698 } | 700 } |
699 | 701 |
700 if (HasContext() && SetContextVariableValue(scope_info, CurrentContext(), | 702 if (HasContext() && SetContextVariableValue(scope_info, CurrentContext(), |
701 variable_name, new_value)) { | 703 variable_name, new_value)) { |
702 return true; | 704 return true; |
703 } | 705 } |
704 | 706 |
705 return false; | 707 return false; |
706 } | 708 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); | 804 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); |
803 if (beg_pos <= position && position < end_pos) { | 805 if (beg_pos <= position && position < end_pos) { |
804 GetNestedScopeChain(isolate, inner_scope, position); | 806 GetNestedScopeChain(isolate, inner_scope, position); |
805 return; | 807 return; |
806 } | 808 } |
807 } | 809 } |
808 } | 810 } |
809 | 811 |
810 } // namespace internal | 812 } // namespace internal |
811 } // namespace v8 | 813 } // namespace v8 |
OLD | NEW |