ce05280bfc
Modules now 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 (innermost) enclosing global 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 global 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. R=mstarzinger@chromium.org,svenpanne@chromium.org BUG= Review URL: https://codereview.chromium.org/11093074 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13033 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 |
||
---|---|---|
.. | ||
cctest.cc | ||
cctest.gyp | ||
cctest.h | ||
cctest.status | ||
gay-fixed.cc | ||
gay-fixed.h | ||
gay-precision.cc | ||
gay-precision.h | ||
gay-shortest.cc | ||
gay-shortest.h | ||
log-eq-of-logging-and-traversal.js | ||
SConscript | ||
test-accessors.cc | ||
test-alloc.cc | ||
test-api.cc | ||
test-assembler-arm.cc | ||
test-assembler-ia32.cc | ||
test-assembler-mips.cc | ||
test-assembler-x64.cc | ||
test-ast.cc | ||
test-bignum-dtoa.cc | ||
test-bignum.cc | ||
test-circular-queue.cc | ||
test-compiler.cc | ||
test-conversions.cc | ||
test-cpu-profiler.cc | ||
test-dataflow.cc | ||
test-date.cc | ||
test-debug.cc | ||
test-decls.cc | ||
test-deoptimization.cc | ||
test-dictionary.cc | ||
test-disasm-arm.cc | ||
test-disasm-ia32.cc | ||
test-disasm-mips.cc | ||
test-disasm-x64.cc | ||
test-diy-fp.cc | ||
test-double.cc | ||
test-dtoa.cc | ||
test-fast-dtoa.cc | ||
test-fixed-dtoa.cc | ||
test-flags.cc | ||
test-func-name-inference.cc | ||
test-hashing.cc | ||
test-hashmap.cc | ||
test-heap-profiler.cc | ||
test-heap.cc | ||
test-list.cc | ||
test-liveedit.cc | ||
test-lock.cc | ||
test-lockers.cc | ||
test-log-stack-tracer.cc | ||
test-log.cc | ||
test-macro-assembler-x64.cc | ||
test-mark-compact.cc | ||
test-object-observe.cc | ||
test-parsing.cc | ||
test-platform-linux.cc | ||
test-platform-macos.cc | ||
test-platform-nullos.cc | ||
test-platform-tls.cc | ||
test-platform-win32.cc | ||
test-profile-generator.cc | ||
test-random.cc | ||
test-regexp.cc | ||
test-reloc-info.cc | ||
test-serialize.cc | ||
test-sockets.cc | ||
test-spaces.cc | ||
test-strings.cc | ||
test-strtod.cc | ||
test-thread-termination.cc | ||
test-threads.cc | ||
test-unbound-queue.cc | ||
test-utils.cc | ||
test-version.cc | ||
test-weakmaps.cc | ||
testcfg.py |