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

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 2388153003: [modules] Implement namespace imports. (Closed)
Patch Set: Extend a test. Created 4 years, 2 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/interpreter/bytecode-generator.h ('k') | src/objects.h » ('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/interpreter/bytecode-generator.h" 5 #include "src/interpreter/bytecode-generator.h"
6 6
7 #include "src/ast/compile-time-value.h" 7 #include "src/ast/compile-time-value.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/compilation-info.h" 10 #include "src/compilation-info.h"
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 VisitNewTargetVariable(scope()->new_target_var()); 667 VisitNewTargetVariable(scope()->new_target_var());
668 668
669 // TODO(rmcilroy): Emit tracing call if requested to do so. 669 // TODO(rmcilroy): Emit tracing call if requested to do so.
670 if (FLAG_trace) { 670 if (FLAG_trace) {
671 UNIMPLEMENTED(); 671 UNIMPLEMENTED();
672 } 672 }
673 673
674 // Visit declarations within the function scope. 674 // Visit declarations within the function scope.
675 VisitDeclarations(scope()->declarations()); 675 VisitDeclarations(scope()->declarations());
676 676
677 VisitModuleNamespaceImports();
Michael Starzinger 2016/10/05 13:07:30 nit: Please add "// Visit module imports if needed
neis 2016/10/06 08:56:44 Done.
678
677 // Perform a stack-check before the body. 679 // Perform a stack-check before the body.
678 builder()->StackCheck(info()->literal()->start_position()); 680 builder()->StackCheck(info()->literal()->start_position());
679 681
680 // Visit statements in the function body. 682 // Visit statements in the function body.
681 VisitStatements(info()->literal()->body()); 683 VisitStatements(info()->literal()->body());
682 } 684 }
683 685
684 void BytecodeGenerator::BuildIndexedJump(Register index, size_t start_index, 686 void BytecodeGenerator::BuildIndexedJump(Register index, size_t start_index,
685 size_t size, 687 size_t size,
686 ZoneVector<BytecodeLabel>& targets) { 688 ZoneVector<BytecodeLabel>& targets) {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 case VariableLocation::MODULE: 868 case VariableLocation::MODULE:
867 DCHECK_EQ(variable->mode(), LET); 869 DCHECK_EQ(variable->mode(), LET);
868 DCHECK(variable->IsExport()); 870 DCHECK(variable->IsExport());
869 VisitForAccumulatorValue(decl->fun()); 871 VisitForAccumulatorValue(decl->fun());
870 VisitVariableAssignment(variable, Token::INIT, 872 VisitVariableAssignment(variable, Token::INIT,
871 FeedbackVectorSlot::Invalid()); 873 FeedbackVectorSlot::Invalid());
872 break; 874 break;
873 } 875 }
874 } 876 }
875 877
878 void BytecodeGenerator::VisitModuleNamespaceImports() {
879 if (!scope()->is_module_scope()) return;
880
881 RegisterAllocationScope register_scope(this);
882 Register module_request = register_allocator()->NewRegister();
883
884 ModuleDescriptor* descriptor = scope()->AsModuleScope()->module();
885 for (auto entry : descriptor->namespace_imports()) {
886 builder()
887 ->LoadLiteral(Smi::FromInt(entry->module_request))
888 .StoreAccumulatorInRegister(module_request)
889 .CallRuntime(Runtime::kGetModuleNamespace, module_request);
890 Variable* var = scope()->LookupLocal(entry->local_name);
891 DCHECK_NOT_NULL(var);
892 VisitVariableAssignment(var, Token::INIT, FeedbackVectorSlot::Invalid());
893 }
894 }
895
876 void BytecodeGenerator::VisitDeclarations( 896 void BytecodeGenerator::VisitDeclarations(
877 ZoneList<Declaration*>* declarations) { 897 ZoneList<Declaration*>* declarations) {
878 RegisterAllocationScope register_scope(this); 898 RegisterAllocationScope register_scope(this);
879 DCHECK(globals_builder()->empty()); 899 DCHECK(globals_builder()->empty());
880 for (int i = 0; i < declarations->length(); i++) { 900 for (int i = 0; i < declarations->length(); i++) {
881 RegisterAllocationScope register_scope(this); 901 RegisterAllocationScope register_scope(this);
882 Visit(declarations->at(i)); 902 Visit(declarations->at(i));
883 } 903 }
884 if (globals_builder()->empty()) return; 904 if (globals_builder()->empty()) return;
885 905
(...skipping 2260 matching lines...) Expand 10 before | Expand all | Expand 10 after
3146 } 3166 }
3147 3167
3148 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3168 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3149 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3169 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3150 : Runtime::kStoreKeyedToSuper_Sloppy; 3170 : Runtime::kStoreKeyedToSuper_Sloppy;
3151 } 3171 }
3152 3172
3153 } // namespace interpreter 3173 } // namespace interpreter
3154 } // namespace internal 3174 } // namespace internal
3155 } // namespace v8 3175 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698