OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ast.h" | 7 #include "src/ast.h" |
8 #include "src/ast-numbering.h" | 8 #include "src/ast-numbering.h" |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 void BreakableStatementChecker::VisitExportDeclaration( | 54 void BreakableStatementChecker::VisitExportDeclaration( |
55 ExportDeclaration* decl) { | 55 ExportDeclaration* decl) { |
56 } | 56 } |
57 | 57 |
58 | 58 |
59 void BreakableStatementChecker::VisitModuleLiteral(ModuleLiteral* module) { | 59 void BreakableStatementChecker::VisitModuleLiteral(ModuleLiteral* module) { |
60 } | 60 } |
61 | 61 |
62 | 62 |
63 void BreakableStatementChecker::VisitModuleVariable(ModuleVariable* module) { | |
64 } | |
65 | |
66 | |
67 void BreakableStatementChecker::VisitModulePath(ModulePath* module) { | 63 void BreakableStatementChecker::VisitModulePath(ModulePath* module) { |
68 } | 64 } |
69 | 65 |
70 | 66 |
71 void BreakableStatementChecker::VisitModuleUrl(ModuleUrl* module) { | 67 void BreakableStatementChecker::VisitModuleUrl(ModuleUrl* module) { |
72 } | 68 } |
73 | 69 |
74 | 70 |
75 void BreakableStatementChecker::VisitModuleStatement(ModuleStatement* stmt) { | 71 void BreakableStatementChecker::VisitModuleStatement(ModuleStatement* stmt) { |
76 } | 72 } |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 DCHECK(scope_->is_script_scope()); | 604 DCHECK(scope_->is_script_scope()); |
609 | 605 |
610 for (int i = 0; i < declarations->length(); i++) { | 606 for (int i = 0; i < declarations->length(); i++) { |
611 ModuleDeclaration* declaration = declarations->at(i)->AsModuleDeclaration(); | 607 ModuleDeclaration* declaration = declarations->at(i)->AsModuleDeclaration(); |
612 if (declaration != NULL) { | 608 if (declaration != NULL) { |
613 ModuleLiteral* module = declaration->module()->AsModuleLiteral(); | 609 ModuleLiteral* module = declaration->module()->AsModuleLiteral(); |
614 if (module != NULL) { | 610 if (module != NULL) { |
615 Comment cmnt(masm_, "[ Link nested modules"); | 611 Comment cmnt(masm_, "[ Link nested modules"); |
616 Scope* scope = module->body()->scope(); | 612 Scope* scope = module->body()->scope(); |
617 Interface* interface = scope->interface(); | 613 Interface* interface = scope->interface(); |
618 DCHECK(interface->IsModule() && interface->IsFrozen()); | 614 DCHECK(interface->IsFrozen()); |
619 | 615 |
620 interface->Allocate(scope->module_var()->index()); | 616 interface->Allocate(scope->module_var()->index()); |
621 | 617 |
622 // Set up module context. | 618 // Set up module context. |
623 DCHECK(scope->interface()->Index() >= 0); | 619 DCHECK(scope->interface()->Index() >= 0); |
624 __ Push(Smi::FromInt(scope->interface()->Index())); | 620 __ Push(Smi::FromInt(scope->interface()->Index())); |
625 __ Push(scope->GetScopeInfo(isolate())); | 621 __ Push(scope->GetScopeInfo(isolate())); |
626 __ CallRuntime(Runtime::kPushModuleContext, 2); | 622 __ CallRuntime(Runtime::kPushModuleContext, 2); |
627 StoreToFrameField(StandardFrameConstants::kContextOffset, | 623 StoreToFrameField(StandardFrameConstants::kContextOffset, |
628 context_register()); | 624 context_register()); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 modules_->set(index, *description); | 778 modules_->set(index, *description); |
783 | 779 |
784 scope_ = saved_scope; | 780 scope_ = saved_scope; |
785 // Pop module context. | 781 // Pop module context. |
786 LoadContextField(context_register(), Context::PREVIOUS_INDEX); | 782 LoadContextField(context_register(), Context::PREVIOUS_INDEX); |
787 // Update local stack frame context field. | 783 // Update local stack frame context field. |
788 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register()); | 784 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register()); |
789 } | 785 } |
790 | 786 |
791 | 787 |
792 void FullCodeGenerator::VisitModuleVariable(ModuleVariable* module) { | |
793 // Nothing to do. | |
794 // The instance object is resolved statically through the module's interface. | |
795 } | |
796 | |
797 | |
798 void FullCodeGenerator::VisitModulePath(ModulePath* module) { | 788 void FullCodeGenerator::VisitModulePath(ModulePath* module) { |
799 // Nothing to do. | 789 // Nothing to do. |
800 // The instance object is resolved statically through the module's interface. | 790 // The instance object is resolved statically through the module's interface. |
801 } | 791 } |
802 | 792 |
803 | 793 |
804 void FullCodeGenerator::VisitModuleUrl(ModuleUrl* module) { | 794 void FullCodeGenerator::VisitModuleUrl(ModuleUrl* module) { |
805 // TODO(rossberg): dummy allocation for now. | 795 // TODO(rossberg): dummy allocation for now. |
806 Scope* scope = module->body()->scope(); | 796 Scope* scope = module->body()->scope(); |
807 Interface* interface = scope_->interface(); | 797 Interface* interface = scope_->interface(); |
808 | 798 |
809 DCHECK(interface->IsModule() && interface->IsFrozen()); | 799 DCHECK(interface->IsFrozen()); |
810 DCHECK(!modules_.is_null()); | 800 DCHECK(!modules_.is_null()); |
811 DCHECK(module_index_ < modules_->length()); | 801 DCHECK(module_index_ < modules_->length()); |
812 interface->Allocate(scope->module_var()->index()); | 802 interface->Allocate(scope->module_var()->index()); |
813 int index = module_index_++; | 803 int index = module_index_++; |
814 | 804 |
815 Handle<ModuleInfo> description = | 805 Handle<ModuleInfo> description = |
816 ModuleInfo::Create(isolate(), interface, scope_); | 806 ModuleInfo::Create(isolate(), interface, scope_); |
817 modules_->set(index, *description); | 807 modules_->set(index, *description); |
818 } | 808 } |
819 | 809 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 this, stmt->scope(), stmt->EntryId(), stmt->DeclsId(), stmt->ExitId()); | 1086 this, stmt->scope(), stmt->EntryId(), stmt->DeclsId(), stmt->ExitId()); |
1097 VisitStatements(stmt->statements()); | 1087 VisitStatements(stmt->statements()); |
1098 __ bind(nested_block.break_label()); | 1088 __ bind(nested_block.break_label()); |
1099 } | 1089 } |
1100 } | 1090 } |
1101 | 1091 |
1102 | 1092 |
1103 void FullCodeGenerator::VisitModuleStatement(ModuleStatement* stmt) { | 1093 void FullCodeGenerator::VisitModuleStatement(ModuleStatement* stmt) { |
1104 Comment cmnt(masm_, "[ Module context"); | 1094 Comment cmnt(masm_, "[ Module context"); |
1105 | 1095 |
1106 __ Push(Smi::FromInt(stmt->proxy()->interface()->Index())); | 1096 DCHECK(stmt->body()->scope()->is_module_scope()); |
| 1097 |
| 1098 __ Push(Smi::FromInt(stmt->body()->scope()->interface()->Index())); |
1107 __ Push(Smi::FromInt(0)); | 1099 __ Push(Smi::FromInt(0)); |
1108 __ CallRuntime(Runtime::kPushModuleContext, 2); | 1100 __ CallRuntime(Runtime::kPushModuleContext, 2); |
1109 StoreToFrameField( | 1101 StoreToFrameField( |
1110 StandardFrameConstants::kContextOffset, context_register()); | 1102 StandardFrameConstants::kContextOffset, context_register()); |
1111 | 1103 |
1112 Scope* saved_scope = scope_; | 1104 Scope* saved_scope = scope_; |
1113 scope_ = stmt->body()->scope(); | 1105 scope_ = stmt->body()->scope(); |
1114 VisitStatements(stmt->body()->statements()); | 1106 VisitStatements(stmt->body()->statements()); |
1115 scope_ = saved_scope; | 1107 scope_ = saved_scope; |
1116 LoadContextField(context_register(), Context::PREVIOUS_INDEX); | 1108 LoadContextField(context_register(), Context::PREVIOUS_INDEX); |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 } | 1837 } |
1846 codegen_->PrepareForBailoutForId(exit_id_, NO_REGISTERS); | 1838 codegen_->PrepareForBailoutForId(exit_id_, NO_REGISTERS); |
1847 codegen_->scope_ = saved_scope_; | 1839 codegen_->scope_ = saved_scope_; |
1848 } | 1840 } |
1849 | 1841 |
1850 | 1842 |
1851 #undef __ | 1843 #undef __ |
1852 | 1844 |
1853 | 1845 |
1854 } } // namespace v8::internal | 1846 } } // namespace v8::internal |
OLD | NEW |