1. 22 Nov, 2012 1 commit
    • rossberg@chromium.org's avatar
      Get rid of static module allocation, do it in code. · ce05280b
      rossberg@chromium.org authored
      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
      ce05280b
  2. 03 Nov, 2011 2 commits
  3. 21 Oct, 2011 1 commit
    • keuchel@chromium.org's avatar
      Reapply r9673 "Scope tree serialization and ScopeIterator cleanup." · 666c4be2
      keuchel@chromium.org authored
      This also includes the two fixes from r9674 and r9675. Here's the diff
      to the previous CL.
      
       --- a/src/runtime.cc
       +++ b/src/runtime.cc
       @@ -11133,17 +11133,26 @@ class ScopeIterator {
              context_(Context::cast(frame->context())),
              nested_scope_chain_(4) {
      
       +    // Catch the case when the debugger stops in an internal function.
       +    Handle<SharedFunctionInfo> shared_info(function_->shared());
       +    if (shared_info->script() == isolate->heap()->undefined_value()) {
       +      if (shared_info->scope_info()->HasContext()) Next();
       +      return;
       +    }
       +
            // Check whether we are in global code or function code. If there is a stack
            // slot for .result then this function has been created for evaluating
            // global code and it is not a real function.
            // Checking for the existence of .result seems fragile, but the scope info
            // saved with the code object does not otherwise have that information.
       -    int index = function_->shared()->scope_info()->
       +    int index = shared_info->scope_info()->
                StackSlotIndex(isolate_->heap()->result_symbol());
      
            // Reparse the code and analyze the scopes.
            ZoneScope zone_scope(isolate, DELETE_ON_EXIT);
       -    Handle<SharedFunctionInfo> shared_info(function_->shared());
            Handle<Script> script(Script::cast(shared_info->script()));
            Scope* scope;
            if (index >= 0) {
      
      Review URL: http://codereview.chromium.org/8344046
      
      git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9734 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
      666c4be2
  4. 19 Oct, 2011 1 commit
  5. 18 Oct, 2011 1 commit
  6. 11 Oct, 2011 1 commit
  7. 08 Sep, 2011 1 commit
  8. 11 Aug, 2011 1 commit
  9. 16 Jun, 2011 2 commits
  10. 15 Jun, 2011 1 commit
  11. 11 May, 2011 1 commit
  12. 06 May, 2011 1 commit
  13. 11 Apr, 2011 1 commit
  14. 18 Mar, 2011 3 commits
  15. 07 Dec, 2010 3 commits
  16. 24 Sep, 2010 1 commit
  17. 14 Jul, 2010 1 commit
  18. 13 Jul, 2010 1 commit
  19. 23 Jun, 2010 1 commit
  20. 09 Mar, 2010 1 commit
    • kmillikin@chromium.org's avatar
      Small simplification of #include dependencies. · 3817a7ba
      kmillikin@chromium.org authored
      Remove messages.h from v8.h and include it explicitly in only the few places
      it is needed.  Many files relied on getting handles-inl.h implicitly from
      messages.h through v8.h, so include handles-inl.h explicitly in v8.h
      instead.
      
      Remove zone-inl.h from header files where it is not needed, can be replaced
      by a forward declaration, or can be replaced by zone.h (specifically,
      factory.h and heap.h).  Include zone.h or zone-inl.h in header files where
      it was implicitly included via heap.h or factory.h.  Prefer zone.h over
      zone-inl.h in header files where possible by including zone-inl.h in .cc
      files.
      
      Review URL: http://codereview.chromium.org/668248
      
      git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4058 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
      3817a7ba
  21. 22 Jun, 2009 1 commit
  22. 25 May, 2009 1 commit
  23. 18 May, 2009 1 commit
  24. 24 Feb, 2009 1 commit
  25. 05 Feb, 2009 1 commit
  26. 09 Sep, 2008 1 commit
  27. 03 Jul, 2008 1 commit