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

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

Issue 2471033004: [ignition,modules] Introduce bytecodes for loading/storing module variables. (Closed)
Patch Set: Address other feedback. 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 <imm>
932 //
933 // Load the contents of a module variable into the accumulator. The variable is
934 // identified by its index <imm>.
935 void Interpreter::DoLdaModuleVariable(InterpreterAssembler* assembler) {
Benedikt Meurer 2016/11/04 16:45:59 Cool! I like this!
936 Node* raw_index = __ BytecodeOperandImm(0);
937
938 Node* module_context = __ LoadModuleContext(__ GetContext());
939 Node* module = __ LoadContextSlot(module_context, Context::EXTENSION_INDEX);
940
941 Label if_export(assembler), if_import(assembler), end(assembler);
942 __ Branch(__ IntPtrGreaterThan(raw_index, __ IntPtrConstant(0)), &if_export,
943 &if_import);
944
945 __ Bind(&if_export);
946 {
947 Node* regular_exports =
948 __ LoadObjectField(module, Module::kRegularExportsOffset);
949 // The actual array index is (raw_index - 1).
950 Node* export_index = __ IntPtrSub(raw_index, __ IntPtrConstant(1));
951 Node* cell = __ LoadFixedArrayElement(regular_exports, export_index);
952 __ SetAccumulator(__ LoadObjectField(cell, Cell::kValueOffset));
953 __ Goto(&end);
954 }
955
956 __ Bind(&if_import);
957 {
958 Node* regular_imports =
959 __ LoadObjectField(module, Module::kRegularImportsOffset);
960 // The actual array index is (-raw_index - 1).
961 Node* import_index = __ IntPtrSub(
962 __ IntPtrMul(raw_index, __ IntPtrConstant(-1)), __ IntPtrConstant(1));
963 Node* cell = __ LoadFixedArrayElement(regular_imports, import_index);
964 __ SetAccumulator(__ LoadObjectField(cell, Cell::kValueOffset));
965 __ Goto(&end);
966 }
967
968 __ Bind(&end);
969 __ Dispatch();
970 }
971
972 // StaModuleVariable <imm>
973 //
974 // Store accumulator to the module variable identified by its index <imm>.
975 void Interpreter::DoStaModuleVariable(InterpreterAssembler* assembler) {
976 Node* value = __ GetAccumulator();
977 Node* raw_index = __ BytecodeOperandImm(0);
978
979 Node* module_context = __ LoadModuleContext(__ GetContext());
980 Node* module = __ LoadContextSlot(module_context, Context::EXTENSION_INDEX);
981
982 Label if_export(assembler), if_import(assembler), end(assembler);
983 __ Branch(__ IntPtrGreaterThan(raw_index, __ IntPtrConstant(0)), &if_export,
984 &if_import);
985
986 __ Bind(&if_export);
987 {
988 Node* regular_exports =
989 __ LoadObjectField(module, Module::kRegularExportsOffset);
990 Node* export_index = __ IntPtrSub(raw_index, __ IntPtrConstant(1));
991 Node* cell = __ LoadFixedArrayElement(regular_exports, export_index);
992 __ StoreObjectField(cell, Cell::kValueOffset, value);
993 __ Goto(&end);
994 }
995
996 __ Bind(&if_import);
997 {
998 // Not supported (probably never).
999 __ Abort(kUnsupportedModuleOperation);
1000 __ Goto(&end);
1001 }
1002
1003 __ Bind(&end);
1004 __ Dispatch();
1005 }
1006
931 // PushContext <context> 1007 // PushContext <context>
932 // 1008 //
933 // Saves the current context in <context>, and pushes the accumulator as the 1009 // Saves the current context in <context>, and pushes the accumulator as the
934 // new current context. 1010 // new current context.
935 void Interpreter::DoPushContext(InterpreterAssembler* assembler) { 1011 void Interpreter::DoPushContext(InterpreterAssembler* assembler) {
936 Node* reg_index = __ BytecodeOperandReg(0); 1012 Node* reg_index = __ BytecodeOperandReg(0);
937 Node* new_context = __ GetAccumulator(); 1013 Node* new_context = __ GetAccumulator();
938 Node* old_context = __ GetContext(); 1014 Node* old_context = __ GetContext();
939 __ StoreRegister(old_context, reg_index); 1015 __ StoreRegister(old_context, reg_index);
940 __ SetContext(new_context); 1016 __ SetContext(new_context);
(...skipping 1754 matching lines...) Expand 10 before | Expand all | Expand 10 after
2695 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 2771 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
2696 __ SmiTag(new_state)); 2772 __ SmiTag(new_state));
2697 __ SetAccumulator(old_state); 2773 __ SetAccumulator(old_state);
2698 2774
2699 __ Dispatch(); 2775 __ Dispatch();
2700 } 2776 }
2701 2777
2702 } // namespace interpreter 2778 } // namespace interpreter
2703 } // namespace internal 2779 } // namespace internal
2704 } // namespace v8 2780 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698