Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Side by Side Diff: src/debug/debug-scopes.cc

Issue 2449883002: Revert of [modules] Add partial support for debug-scopes. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/debug/debug-scopes.h ('k') | src/debug/mirrors.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 7 #include <memory>
8 8
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/debug/debug.h" 10 #include "src/debug/debug.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 Handle<Script> script(Script::cast(shared_info->script())); 94 Handle<Script> script(Script::cast(shared_info->script()));
95 info.reset(new ParseInfo(&zone, script)); 95 info.reset(new ParseInfo(&zone, script));
96 if (scope_info->scope_type() == EVAL_SCOPE) { 96 if (scope_info->scope_type() == EVAL_SCOPE) {
97 info->set_eval(); 97 info->set_eval();
98 if (!function->context()->IsNativeContext()) { 98 if (!function->context()->IsNativeContext()) {
99 info->set_outer_scope_info(handle(function->context()->scope_info())); 99 info->set_outer_scope_info(handle(function->context()->scope_info()));
100 } 100 }
101 // Language mode may be inherited from the eval caller. 101 // Language mode may be inherited from the eval caller.
102 // Retrieve it from shared function info. 102 // Retrieve it from shared function info.
103 info->set_language_mode(shared_info->language_mode()); 103 info->set_language_mode(shared_info->language_mode());
104 } else if (scope_info->scope_type() == MODULE_SCOPE) {
105 info->set_module();
106 } else { 104 } else {
107 DCHECK(scope_info->scope_type() == SCRIPT_SCOPE); 105 DCHECK(scope_info->scope_type() == SCRIPT_SCOPE);
108 } 106 }
109 } else { 107 } else {
110 // Inner function. 108 // Inner function.
111 info.reset(new ParseInfo(&zone, shared_info)); 109 info.reset(new ParseInfo(&zone, shared_info));
112 } 110 }
113 if (Parser::ParseStatic(info.get()) && Rewriter::Rewrite(info.get())) { 111 if (Parser::ParseStatic(info.get()) && Rewriter::Rewrite(info.get())) {
114 DeclarationScope* scope = info->literal()->scope(); 112 DeclarationScope* scope = info->literal()->scope();
115 if (!ignore_nested_scopes || collect_non_locals) { 113 if (!ignore_nested_scopes || collect_non_locals) {
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 return inner_scope; 601 return inner_scope;
604 } 602 }
605 603
606 604
607 // Create a plain JSObject which materializes the module scope for the specified 605 // Create a plain JSObject which materializes the module scope for the specified
608 // module context. 606 // module context.
609 MaybeHandle<JSObject> ScopeIterator::MaterializeModuleScope() { 607 MaybeHandle<JSObject> ScopeIterator::MaterializeModuleScope() {
610 Handle<Context> context = CurrentContext(); 608 Handle<Context> context = CurrentContext();
611 DCHECK(context->IsModuleContext()); 609 DCHECK(context->IsModuleContext());
612 Handle<ScopeInfo> scope_info(context->scope_info()); 610 Handle<ScopeInfo> scope_info(context->scope_info());
611
612 // Allocate and initialize a JSObject with all the members of the debugged
613 // module.
613 Handle<JSObject> module_scope = 614 Handle<JSObject> module_scope =
614 isolate_->factory()->NewJSObjectWithNullProto(); 615 isolate_->factory()->NewJSObjectWithNullProto();
616
617 // Fill all context locals.
615 CopyContextLocalsToScopeObject(scope_info, context, module_scope); 618 CopyContextLocalsToScopeObject(scope_info, context, module_scope);
616 CopyModuleVarsToScopeObject(scope_info, context, module_scope); 619
620 // TODO(neis): Also collect stack locals as well as imports and exports.
621
617 return module_scope; 622 return module_scope;
618 } 623 }
619 624
620 bool ScopeIterator::SetParameterValue(Handle<ScopeInfo> scope_info, 625 bool ScopeIterator::SetParameterValue(Handle<ScopeInfo> scope_info,
621 JavaScriptFrame* frame, 626 JavaScriptFrame* frame,
622 Handle<String> parameter_name, 627 Handle<String> parameter_name,
623 Handle<Object> new_value) { 628 Handle<Object> new_value) {
624 // Setting stack locals of optimized frames is not supported. 629 // Setting stack locals of optimized frames is not supported.
625 if (frame->is_optimized()) return false; 630 if (frame->is_optimized()) return false;
626 HandleScope scope(isolate_); 631 HandleScope scope(isolate_);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 Handle<Object> value = Handle<Object>(context->get(context_index), isolate); 782 Handle<Object> value = Handle<Object>(context->get(context_index), isolate);
778 // Reflect variables under TDZ as undefined in scope object. 783 // Reflect variables under TDZ as undefined in scope object.
779 if (value->IsTheHole(isolate)) continue; 784 if (value->IsTheHole(isolate)) continue;
780 // This should always succeed. 785 // This should always succeed.
781 // TODO(verwaest): Use AddDataProperty instead. 786 // TODO(verwaest): Use AddDataProperty instead.
782 JSObject::SetOwnPropertyIgnoreAttributes(scope_object, name, value, NONE) 787 JSObject::SetOwnPropertyIgnoreAttributes(scope_object, name, value, NONE)
783 .Check(); 788 .Check();
784 } 789 }
785 } 790 }
786 791
787 void ScopeIterator::CopyModuleVarsToScopeObject(Handle<ScopeInfo> scope_info,
788 Handle<Context> context,
789 Handle<JSObject> scope_object) {
790 Isolate* isolate = scope_info->GetIsolate();
791
792 int module_variable_count =
793 Smi::cast(scope_info->get(scope_info->ModuleVariableCountIndex()))
794 ->value();
795 for (int i = 0; i < module_variable_count; ++i) {
796 Handle<String> local_name;
797 bool is_export;
798 {
799 String* name;
800 int index;
801 scope_info->ModuleVariable(i, &name, &index);
802 CHECK(!ScopeInfo::VariableIsSynthetic(name));
803 local_name = handle(name, isolate);
804 is_export = index == Variable::kModuleExportIndex;
805 }
806
807 Handle<Object> value;
808 if (is_export) {
809 value =
810 Module::LoadExport(handle(context->module(), isolate), local_name);
811 } else {
812 Handle<ModuleInfo> module_info(scope_info->ModuleDescriptorInfo(),
813 isolate);
814 Handle<ModuleInfoEntry> entry =
815 ModuleInfo::LookupRegularImport(module_info, local_name);
816 Handle<String> import_name(String::cast(entry->import_name()), isolate);
817 int module_request = Smi::cast(entry->module_request())->value();
818 value = Module::LoadImport(handle(context->module(), isolate),
819 import_name, module_request);
820 }
821
822 // Reflect variables under TDZ as undefined in scope object.
823 if (value->IsTheHole(isolate)) continue;
824 // This should always succeed.
825 // TODO(verwaest): Use AddDataProperty instead.
826 JSObject::SetOwnPropertyIgnoreAttributes(scope_object, local_name, value,
827 NONE)
828 .Check();
829 }
830 }
831
832 void ScopeIterator::CopyContextExtensionToScopeObject( 792 void ScopeIterator::CopyContextExtensionToScopeObject(
833 Handle<Context> context, Handle<JSObject> scope_object, 793 Handle<Context> context, Handle<JSObject> scope_object,
834 KeyCollectionMode mode) { 794 KeyCollectionMode mode) {
835 if (context->extension_object() == nullptr) return; 795 if (context->extension_object() == nullptr) return;
836 Handle<JSObject> extension(context->extension_object()); 796 Handle<JSObject> extension(context->extension_object());
837 Handle<FixedArray> keys = 797 Handle<FixedArray> keys =
838 KeyAccumulator::GetKeys(extension, mode, ENUMERABLE_STRINGS) 798 KeyAccumulator::GetKeys(extension, mode, ENUMERABLE_STRINGS)
839 .ToHandleChecked(); 799 .ToHandleChecked();
840 800
841 for (int i = 0; i < keys->length(); i++) { 801 for (int i = 0; i < keys->length(); i++) {
(...skipping 29 matching lines...) Expand all
871 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); 831 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden());
872 if (beg_pos <= position && position < end_pos) { 832 if (beg_pos <= position && position < end_pos) {
873 GetNestedScopeChain(isolate, inner_scope, position); 833 GetNestedScopeChain(isolate, inner_scope, position);
874 return; 834 return;
875 } 835 }
876 } 836 }
877 } 837 }
878 838
879 } // namespace internal 839 } // namespace internal
880 } // namespace v8 840 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug-scopes.h ('k') | src/debug/mirrors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698