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

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

Issue 2081733004: Rip out most of our outdated modules implementation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 years, 5 months 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/runtime/runtime.h ('k') | src/typing-asm.cc » ('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 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 "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/ast/scopeinfo.h" 9 #include "src/ast/scopeinfo.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0); 719 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0);
720 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1); 720 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1);
721 Handle<Context> current(isolate->context()); 721 Handle<Context> current(isolate->context());
722 Handle<Context> context = 722 Handle<Context> context =
723 isolate->factory()->NewBlockContext(function, current, scope_info); 723 isolate->factory()->NewBlockContext(function, current, scope_info);
724 isolate->set_context(*context); 724 isolate->set_context(*context);
725 return *context; 725 return *context;
726 } 726 }
727 727
728 728
729 RUNTIME_FUNCTION(Runtime_IsJSModule) {
730 SealHandleScope shs(isolate);
731 DCHECK(args.length() == 1);
732 CONVERT_ARG_CHECKED(Object, obj, 0);
733 return isolate->heap()->ToBoolean(obj->IsJSModule());
734 }
735
736
737 RUNTIME_FUNCTION(Runtime_PushModuleContext) {
738 SealHandleScope shs(isolate);
739 DCHECK(args.length() == 2);
740 CONVERT_SMI_ARG_CHECKED(index, 0);
741
742 if (!args[1]->IsScopeInfo()) {
743 // Module already initialized. Find hosting context and retrieve context.
744 Context* host = Context::cast(isolate->context())->script_context();
745 Context* context = Context::cast(host->get(index));
746 DCHECK(context->previous() == isolate->context());
747 isolate->set_context(context);
748 return context;
749 }
750
751 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1);
752
753 // Allocate module context.
754 HandleScope scope(isolate);
755 Factory* factory = isolate->factory();
756 Handle<Context> context = factory->NewModuleContext(scope_info);
757 Handle<JSModule> module = factory->NewJSModule(context, scope_info);
758 context->set_module(*module);
759 Context* previous = isolate->context();
760 context->set_previous(previous);
761 context->set_closure(previous->closure());
762 context->set_native_context(previous->native_context());
763 isolate->set_context(*context);
764
765 // Find hosting scope and initialize internal variable holding module there.
766 previous->script_context()->set(index, *context);
767
768 return *context;
769 }
770
771
772 RUNTIME_FUNCTION(Runtime_DeclareModules) {
773 HandleScope scope(isolate);
774 DCHECK(args.length() == 1);
775 CONVERT_ARG_HANDLE_CHECKED(FixedArray, descriptions, 0);
776 Context* host_context = isolate->context();
777
778 for (int i = 0; i < descriptions->length(); ++i) {
779 Handle<ModuleInfo> description(ModuleInfo::cast(descriptions->get(i)));
780 int host_index = description->host_index();
781 Handle<Context> context(Context::cast(host_context->get(host_index)));
782 Handle<JSModule> module(context->module());
783
784 for (int j = 0; j < description->length(); ++j) {
785 Handle<String> name(description->name(j), isolate);
786 VariableMode mode = description->mode(j);
787 int index = description->index(j);
788 switch (mode) {
789 case VAR:
790 case LET:
791 case CONST:
792 case CONST_LEGACY: {
793 PropertyAttributes attr =
794 IsImmutableVariableMode(mode) ? FROZEN : SEALED;
795 Handle<AccessorInfo> info =
796 Accessors::MakeModuleExport(name, index, attr);
797 Handle<Object> result =
798 JSObject::SetAccessor(module, info).ToHandleChecked();
799 DCHECK(!result->IsUndefined(isolate));
800 USE(result);
801 break;
802 }
803 case TEMPORARY:
804 case DYNAMIC:
805 case DYNAMIC_GLOBAL:
806 case DYNAMIC_LOCAL:
807 UNREACHABLE();
808 }
809 }
810
811 if (JSObject::PreventExtensions(module, Object::THROW_ON_ERROR)
812 .IsNothing()) {
813 DCHECK(false);
814 }
815 }
816
817 DCHECK(!isolate->has_pending_exception());
818 return isolate->heap()->undefined_value();
819 }
820
821
822 RUNTIME_FUNCTION(Runtime_DeleteLookupSlot) { 729 RUNTIME_FUNCTION(Runtime_DeleteLookupSlot) {
823 HandleScope scope(isolate); 730 HandleScope scope(isolate);
824 DCHECK_EQ(1, args.length()); 731 DCHECK_EQ(1, args.length());
825 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 732 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
826 733
827 int index; 734 int index;
828 PropertyAttributes attributes; 735 PropertyAttributes attributes;
829 BindingFlags flags; 736 BindingFlags flags;
830 Handle<Object> holder = isolate->context()->Lookup( 737 Handle<Object> holder = isolate->context()->Lookup(
831 name, FOLLOW_CHAINS, &index, &attributes, &flags); 738 name, FOLLOW_CHAINS, &index, &attributes, &flags);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { 935 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) {
1029 HandleScope scope(isolate); 936 HandleScope scope(isolate);
1030 DCHECK_EQ(2, args.length()); 937 DCHECK_EQ(2, args.length());
1031 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 938 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
1032 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); 939 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
1033 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); 940 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT));
1034 } 941 }
1035 942
1036 } // namespace internal 943 } // namespace internal
1037 } // namespace v8 944 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/typing-asm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698