Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: use STL containers instead of v8 values for static module data #24384

Closed
wants to merge 2 commits into from

Commits on Nov 19, 2018

  1. src: use STL containers instead of v8 values for static module data

    Instead of putting the source code and the cache in v8::Objects,
    put them in per-process std::maps. This has the following benefits:
    
    - It's slightly lighter in weight compared to storing things on the
      v8 heap. Also it may be slightly faster since the preivous v8::Object is
      already in dictionary mode - though the difference is very small
      given the number of native modules is limited.
    - The source and code cache generation templates are now much simpler
      since they just initialize static arrays and manipulate STL
      constructs. They are also easier to debug from the C++'s side,
      especially early in the bootstrap process when no inspector
      can be attached.
    - The static native module data can be accessed independent of any
      Environment or Isolate, and it's easy to look them up from the
      C++'s side.
    - It's now impossible to mutate the source code used to compile
      native modules from the JS land since it's completely separate
      from the v8 heap. We can still get the constant strings from
      process.binding('natives') but that's all.
    
    A few drive-by fixes:
    
    - Remove DecorateErrorStack in LookupAndCompile - We don't need to
      capture the exception to decorate when we encounter
      errors during native module compilation, as those errors should be
      syntax errors and v8 is able to decorate them well. We use
      CompileFunctionInContext so there is no need to worry about
      wrappers either.
    - The code cache could be rejected when node is started with v8 flags.
      Instead of aborting in that case, simply keep a record in the
      native_module_without_cache set.
    - Refactor js2c.py a bit, reduce code duplication and inline Render()
      to make the one-byte/two-byte special treatment easier to read.
    joyeecheung committed Nov 19, 2018
    Configuration menu
    Copy the full SHA
    52608c8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    161c9f8 View commit details
    Browse the repository at this point in the history