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

Side by Side Diff: src/interpreter/interpreter.cc

Issue 2471033004: [ignition,modules] Introduce bytecodes for loading/storing module variables. (Closed)
Patch Set: Rebase. 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
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/interpreter/interpreter.h" 5 #include "src/interpreter/interpreter.h"
6 6
7 #include <fstream> 7 #include <fstream>
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/ast/prettyprinter.h" 10 #include "src/ast/prettyprinter.h"
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 921
922 // StaKeyedPropertyStrict <object> <key> <slot> 922 // StaKeyedPropertyStrict <object> <key> <slot>
923 // 923 //
924 // Calls the strict mode KeyStoreIC at FeedBackVector slot <slot> for <object> 924 // Calls the strict mode KeyStoreIC at FeedBackVector slot <slot> for <object>
925 // and the key <key> with the value in the accumulator. 925 // and the key <key> with the value in the accumulator.
926 void Interpreter::DoStaKeyedPropertyStrict(InterpreterAssembler* assembler) { 926 void Interpreter::DoStaKeyedPropertyStrict(InterpreterAssembler* assembler) {
927 Callable ic = CodeFactory::KeyedStoreICInOptimizedCode(isolate_, STRICT); 927 Callable ic = CodeFactory::KeyedStoreICInOptimizedCode(isolate_, STRICT);
928 DoKeyedStoreIC(ic, assembler); 928 DoKeyedStoreIC(ic, assembler);
929 } 929 }
930 930
931 // LdaModuleVariable <cell_index> <depth>
932 //
933 // Load the contents of a module variable into the accumulator. The variable is
934 // identified by <cell_index>. <depth> is the depth of the current context
935 // relative to the module context.
936 void Interpreter::DoLdaModuleVariable(InterpreterAssembler* assembler) {
937 Node* cell_index = __ BytecodeOperandImm(0);
938 Node* depth = __ BytecodeOperandUImm(1);
939
940 Node* module_context = __ GetContextAtDepth(__ GetContext(), depth);
941 Node* module =
942 __ LoadContextElement(module_context, Context::EXTENSION_INDEX);
943
944 Label if_export(assembler), if_import(assembler), end(assembler);
945 __ Branch(__ IntPtrGreaterThan(cell_index, __ IntPtrConstant(0)), &if_export,
946 &if_import);
947
948 __ Bind(&if_export);
949 {
950 Node* regular_exports =
951 __ LoadObjectField(module, Module::kRegularExportsOffset);
952 // The actual array index is (cell_index - 1).
953 Node* export_index = __ IntPtrSub(cell_index, __ IntPtrConstant(1));
954 Node* cell = __ LoadFixedArrayElement(regular_exports, export_index);
955 __ SetAccumulator(__ LoadObjectField(cell, Cell::kValueOffset));
956 __ Goto(&end);
957 }
958
959 __ Bind(&if_import);
960 {
961 Node* regular_imports =
962 __ LoadObjectField(module, Module::kRegularImportsOffset);
963 // The actual array index is (-cell_index - 1).
964 Node* import_index = __ IntPtrSub(__ IntPtrConstant(-1), cell_index);
965 Node* cell = __ LoadFixedArrayElement(regular_imports, import_index);
966 __ SetAccumulator(__ LoadObjectField(cell, Cell::kValueOffset));
967 __ Goto(&end);
968 }
969
970 __ Bind(&end);
971 __ Dispatch();
972 }
973
974 // StaModuleVariable <cell_index> <depth>
975 //
976 // Store accumulator to the module variable identified by <cell_index>.
977 // <depth> is the depth of the current context relative to the module context.
978 void Interpreter::DoStaModuleVariable(InterpreterAssembler* assembler) {
979 Node* value = __ GetAccumulator();
980 Node* cell_index = __ BytecodeOperandImm(0);
981 Node* depth = __ BytecodeOperandUImm(1);
982
983 Node* module_context = __ GetContextAtDepth(__ GetContext(), depth);
984 Node* module =
985 __ LoadContextElement(module_context, Context::EXTENSION_INDEX);
986
987 Label if_export(assembler), if_import(assembler), end(assembler);
988 __ Branch(__ IntPtrGreaterThan(cell_index, __ IntPtrConstant(0)), &if_export,
989 &if_import);
990
991 __ Bind(&if_export);
992 {
993 Node* regular_exports =
994 __ LoadObjectField(module, Module::kRegularExportsOffset);
995 // The actual array index is (cell_index - 1).
996 Node* export_index = __ IntPtrSub(cell_index, __ IntPtrConstant(1));
997 Node* cell = __ LoadFixedArrayElement(regular_exports, export_index);
998 __ StoreObjectField(cell, Cell::kValueOffset, value);
999 __ Goto(&end);
1000 }
1001
1002 __ Bind(&if_import);
1003 {
1004 // Not supported (probably never).
1005 __ Abort(kUnsupportedModuleOperation);
1006 __ Goto(&end);
1007 }
1008
1009 __ Bind(&end);
1010 __ Dispatch();
1011 }
1012
931 // PushContext <context> 1013 // PushContext <context>
932 // 1014 //
933 // Saves the current context in <context>, and pushes the accumulator as the 1015 // Saves the current context in <context>, and pushes the accumulator as the
934 // new current context. 1016 // new current context.
935 void Interpreter::DoPushContext(InterpreterAssembler* assembler) { 1017 void Interpreter::DoPushContext(InterpreterAssembler* assembler) {
936 Node* reg_index = __ BytecodeOperandReg(0); 1018 Node* reg_index = __ BytecodeOperandReg(0);
937 Node* new_context = __ GetAccumulator(); 1019 Node* new_context = __ GetAccumulator();
938 Node* old_context = __ GetContext(); 1020 Node* old_context = __ GetContext();
939 __ StoreRegister(old_context, reg_index); 1021 __ StoreRegister(old_context, reg_index);
940 __ SetContext(new_context); 1022 __ SetContext(new_context);
(...skipping 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after
2694 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 2776 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
2695 __ SmiTag(new_state)); 2777 __ SmiTag(new_state));
2696 __ SetAccumulator(old_state); 2778 __ SetAccumulator(old_state);
2697 2779
2698 __ Dispatch(); 2780 __ Dispatch();
2699 } 2781 }
2700 2782
2701 } // namespace interpreter 2783 } // namespace interpreter
2702 } // namespace internal 2784 } // namespace internal
2703 } // namespace v8 2785 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | test/cctest/interpreter/bytecode_expectations/Modules.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698