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

Unified Diff: src/full-codegen.cc

Issue 1106383008: Remove unused Module-related AST nodes and associated codegen (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/full-codegen.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/full-codegen.cc
diff --git a/src/full-codegen.cc b/src/full-codegen.cc
index 3386ce12e5546c95dd13733564a667c40e98c033..0dac7d2e0b0bcec68e53eb19192e54fb88793a4e 100644
--- a/src/full-codegen.cc
+++ b/src/full-codegen.cc
@@ -41,11 +41,6 @@ void BreakableStatementChecker::VisitFunctionDeclaration(
}
-void BreakableStatementChecker::VisitModuleDeclaration(
- ModuleDeclaration* decl) {
-}
-
-
void BreakableStatementChecker::VisitImportDeclaration(
ImportDeclaration* decl) {
}
@@ -56,22 +51,6 @@ void BreakableStatementChecker::VisitExportDeclaration(
}
-void BreakableStatementChecker::VisitModuleLiteral(ModuleLiteral* module) {
-}
-
-
-void BreakableStatementChecker::VisitModulePath(ModulePath* module) {
-}
-
-
-void BreakableStatementChecker::VisitModuleUrl(ModuleUrl* module) {
-}
-
-
-void BreakableStatementChecker::VisitModuleStatement(ModuleStatement* stmt) {
-}
-
-
void BreakableStatementChecker::VisitBlock(Block* stmt) {
}
@@ -634,138 +613,14 @@ void FullCodeGenerator::DoTest(const TestContext* context) {
}
-void FullCodeGenerator::AllocateModules(ZoneList<Declaration*>* declarations) {
- DCHECK(scope_->is_script_scope());
-
- for (int i = 0; i < declarations->length(); i++) {
- ModuleDeclaration* declaration = declarations->at(i)->AsModuleDeclaration();
- if (declaration != NULL) {
- ModuleLiteral* module = declaration->module()->AsModuleLiteral();
- if (module != NULL) {
- Comment cmnt(masm_, "[ Link nested modules");
- Scope* scope = module->body()->scope();
- DCHECK(scope->module()->IsFrozen());
-
- scope->module()->Allocate(scope->module_var()->index());
-
- // Set up module context.
- DCHECK(scope->module()->Index() >= 0);
- __ Push(Smi::FromInt(scope->module()->Index()));
- __ Push(scope->GetScopeInfo(isolate()));
- __ CallRuntime(Runtime::kPushModuleContext, 2);
- StoreToFrameField(StandardFrameConstants::kContextOffset,
- context_register());
-
- AllocateModules(scope->declarations());
-
- // Pop module context.
- LoadContextField(context_register(), Context::PREVIOUS_INDEX);
- // Update local stack frame context field.
- StoreToFrameField(StandardFrameConstants::kContextOffset,
- context_register());
- }
- }
- }
-}
-
-
-// Modules have their own local scope, represented by their own context.
-// Module instance objects have an accessor for every export that forwards
-// access to the respective slot from the module's context. (Exports that are
-// modules themselves, however, are simple data properties.)
-//
-// All modules have a _hosting_ scope/context, which (currently) is the
-// enclosing script scope. To deal with recursion, nested modules are hosted
-// by the same scope as global ones.
-//
-// For every (global or nested) module literal, the hosting context has an
-// internal slot that points directly to the respective module context. This
-// enables quick access to (statically resolved) module members by 2-dimensional
-// access through the hosting context. For example,
-//
-// module A {
-// let x;
-// module B { let y; }
-// }
-// module C { let z; }
-//
-// allocates contexts as follows:
-//
-// [header| .A | .B | .C | A | C ] (global)
-// | | |
-// | | +-- [header| z ] (module)
-// | |
-// | +------- [header| y ] (module)
-// |
-// +------------ [header| x | B ] (module)
-//
-// Here, .A, .B, .C are the internal slots pointing to the hosted module
-// contexts, whereas A, B, C hold the actual instance objects (note that every
-// module context also points to the respective instance object through its
-// extension slot in the header).
-//
-// To deal with arbitrary recursion and aliases between modules,
-// they are created and initialized in several stages. Each stage applies to
-// all modules in the hosting script scope, including nested ones.
-//
-// 1. Allocate: for each module _literal_, allocate the module contexts and
-// respective instance object and wire them up. This happens in the
-// PushModuleContext runtime function, as generated by AllocateModules
-// (invoked by VisitDeclarations in the hosting scope).
-//
-// 2. Bind: for each module _declaration_ (i.e. literals as well as aliases),
-// assign the respective instance object to respective local variables. This
-// happens in VisitModuleDeclaration, and uses the instance objects created
-// in the previous stage.
-// For each module _literal_, this phase also constructs a module descriptor
-// for the next stage. This happens in VisitModuleLiteral.
-//
-// 3. Populate: invoke the DeclareModules runtime function to populate each
-// _instance_ object with accessors for it exports. This is generated by
-// DeclareModules (invoked by VisitDeclarations in the hosting scope again),
-// and uses the descriptors generated in the previous stage.
-//
-// 4. Initialize: execute the module bodies (and other code) in sequence. This
-// happens by the separate statements generated for module bodies. To reenter
-// the module scopes properly, the parser inserted ModuleStatements.
-
void FullCodeGenerator::VisitDeclarations(
ZoneList<Declaration*>* declarations) {
- Handle<FixedArray> saved_modules = modules_;
- int saved_module_index = module_index_;
ZoneList<Handle<Object> >* saved_globals = globals_;
ZoneList<Handle<Object> > inner_globals(10, zone());
globals_ = &inner_globals;
- if (scope_->num_modules() != 0) {
- // This is a scope hosting modules. Allocate a descriptor array to pass
- // to the runtime for initialization.
- Comment cmnt(masm_, "[ Allocate modules");
- DCHECK(scope_->is_script_scope());
- modules_ =
- isolate()->factory()->NewFixedArray(scope_->num_modules(), TENURED);
- module_index_ = 0;
-
- // Generate code for allocating all modules, including nested ones.
- // The allocated contexts are stored in internal variables in this scope.
- AllocateModules(declarations);
- }
-
AstVisitor::VisitDeclarations(declarations);
- if (scope_->num_modules() != 0) {
- // TODO(ES6): This step, which creates module instance objects,
- // can probably be delayed until an "import *" declaration
- // reifies a module instance. Until imports are implemented,
- // we skip it altogether.
- //
- // Initialize modules from descriptor array.
- // DCHECK(module_index_ == modules_->length());
- // DeclareModules(modules_);
- modules_ = saved_modules;
- module_index_ = saved_module_index;
- }
-
if (!globals_->is_empty()) {
// Invoke the platform-dependent code generator to do the actual
// declaration of the global functions and variables.
@@ -780,54 +635,6 @@ void FullCodeGenerator::VisitDeclarations(
}
-void FullCodeGenerator::VisitModuleLiteral(ModuleLiteral* module) {
- Block* block = module->body();
- Scope* saved_scope = scope();
- scope_ = block->scope();
- ModuleDescriptor* descriptor = scope_->module();
-
- Comment cmnt(masm_, "[ ModuleLiteral");
- SetStatementPosition(block);
-
- DCHECK(!modules_.is_null());
- DCHECK(module_index_ < modules_->length());
- int index = module_index_++;
-
- // Set up module context.
- DCHECK(descriptor->Index() >= 0);
- __ Push(Smi::FromInt(descriptor->Index()));
- __ Push(Smi::FromInt(0));
- __ CallRuntime(Runtime::kPushModuleContext, 2);
- StoreToFrameField(StandardFrameConstants::kContextOffset, context_register());
-
- {
- Comment cmnt(masm_, "[ Declarations");
- VisitDeclarations(scope_->declarations());
- }
-
- // Populate the module description.
- Handle<ModuleInfo> description =
- ModuleInfo::Create(isolate(), descriptor, scope_);
- modules_->set(index, *description);
-
- scope_ = saved_scope;
- // Pop module context.
- LoadContextField(context_register(), Context::PREVIOUS_INDEX);
- // Update local stack frame context field.
- StoreToFrameField(StandardFrameConstants::kContextOffset, context_register());
-}
-
-
-// TODO(adamk): Delete ModulePath.
-void FullCodeGenerator::VisitModulePath(ModulePath* module) {
-}
-
-
-// TODO(adamk): Delete ModuleUrl.
-void FullCodeGenerator::VisitModuleUrl(ModuleUrl* module) {
-}
-
-
int FullCodeGenerator::DeclareGlobalsFlags() {
DCHECK(DeclareGlobalsLanguageMode::is_valid(language_mode()));
return DeclareGlobalsEvalFlag::encode(is_eval()) |
@@ -1061,28 +868,6 @@ void FullCodeGenerator::VisitBlock(Block* stmt) {
}
-void FullCodeGenerator::VisitModuleStatement(ModuleStatement* stmt) {
- Comment cmnt(masm_, "[ Module context");
-
- DCHECK(stmt->body()->scope()->is_module_scope());
-
- __ Push(Smi::FromInt(stmt->body()->scope()->module()->Index()));
- __ Push(Smi::FromInt(0));
- __ CallRuntime(Runtime::kPushModuleContext, 2);
- StoreToFrameField(
- StandardFrameConstants::kContextOffset, context_register());
-
- Scope* saved_scope = scope_;
- scope_ = stmt->body()->scope();
- VisitStatements(stmt->body()->statements());
- scope_ = saved_scope;
- LoadContextField(context_register(), Context::PREVIOUS_INDEX);
- // Update local stack frame context field.
- StoreToFrameField(StandardFrameConstants::kContextOffset,
- context_register());
-}
-
-
void FullCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) {
Comment cmnt(masm_, "[ ExpressionStatement");
SetStatementPosition(stmt);
« no previous file with comments | « src/full-codegen.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698