JS engine modularization: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
The goal of this project is to ''incrementally'' tease apart JS engine source code into separate "modules" so that: | |||
The goal of this project is to incrementally tease apart JS engine source code into separate "modules" so that: | |||
* it is easier to understand a module in isolation | * it is easier to understand a module in isolation | ||
* it is easier to get a high-level breakdown of SM code | * it is easier to get a high-level breakdown of SM code | ||
Line 13: | Line 11: | ||
Additionally, we can use directories to group related modules. Again, this is primarily useful to assist newcomers in developing a hierarchical understanding of the code. | Additionally, we can use directories to group related modules. Again, this is primarily useful to assist newcomers in developing a hierarchical understanding of the code. | ||
This is an incremental project. As developers work on a hunk of code, things tend to be rewritten/refactored into the new SpiderMonkey C++ style; hopefully the developer will consider doing a bit of extra work hoist out coherent hunks of code into new modules according to the following plan of record. | |||
== Plan of Record == | == Plan of Record == | ||
A [https://bugzilla.mozilla.org/show_bug.cgi?id=653057 meta bug] tracks bugs for individual pieces. This document serves to collect consensus of the direction we'd like things to head. | |||
A meta bug tracks bugs for individual pieces | |||
Preliminary directory/module structure: | Preliminary directory/module structure: | ||
Line 28: | Line 26: | ||
* js/src/tracejit | * js/src/tracejit | ||
* js/src/*jit | * js/src/*jit | ||
* js/src/vm: central, execution mode independent data structures: types and operations | * js/src/vm: central, execution-mode-independent data structures: types and operations | ||
** [https://bugzilla.mozilla.org/show_bug.cgi?id=644074 Stack]: execution stack (done) | ** [https://bugzilla.mozilla.org/show_bug.cgi?id=644074 Stack]: execution stack (done) | ||
** Value: JS value representation | ** Value: JS value representation | ||
** String: JS string value representation | ** [https://bugzilla.mozilla.org/show_bug.cgi?id=665189 String]: JS string value representation | ||
** Perhaps these next two need short distinctive names: | ** Perhaps these next two need short distinctive names: | ||
*** Low-level object representation: property tree, shapes, and raw object storage | *** Low-level object representation: property tree, shapes, and raw object storage | ||
Line 40: | Line 38: | ||
*** Function: (object) perhaps also contains closely-related JSFunctino/JSScript/Bindings? | *** Function: (object) perhaps also contains closely-related JSFunctino/JSScript/Bindings? | ||
* js/src/gc: garbage collector data structures and algorithms | * js/src/gc: garbage collector data structures and algorithms | ||
* js/src/parser: its not entirely clear how to cleanly break this into pieces, other than treating the whole thing as a module that takes in chars and puts out JSScripts | |||
* js/src/parser: | |||
* js/src/builtin: builtins specified by JS language spec (e.g., String, Array.prototype.sort) | * js/src/builtin: builtins specified by JS language spec (e.g., String, Array.prototype.sort) | ||
** String | ** String |
Revision as of 21:52, 17 June 2011
The goal of this project is to incrementally tease apart JS engine source code into separate "modules" so that:
- it is easier to understand a module in isolation
- it is easier to get a high-level breakdown of SM code
- module dependencies are DAG-y as opposed to clique-y or spaghetti (as it is now)
The plan isn't to do anything radical to simulate "modules" in C++. Rather, we can just say a "module" X is a triple: X.cpp, X.h, X-inl.h. Here, X.h acts as the "module interface" to the rest of the code-base. X-inl.h contains inline files that are pulled out of X.h so that:
- X.h is more readable as a whole and
- we can reduce average translation unit size (which right now is hard because of the dependency clique).
The granularity of modules isn't fixed; the goal is to try to have a module encapsulate a coherent hunk of interdependent logic and implementation details. This may be a single type (e.g., js::Value) or a set of related types (the stack types in vm/Stack.h).
Additionally, we can use directories to group related modules. Again, this is primarily useful to assist newcomers in developing a hierarchical understanding of the code.
This is an incremental project. As developers work on a hunk of code, things tend to be rewritten/refactored into the new SpiderMonkey C++ style; hopefully the developer will consider doing a bit of extra work hoist out coherent hunks of code into new modules according to the following plan of record.
Plan of Record
A meta bug tracks bugs for individual pieces. This document serves to collect consensus of the direction we'd like things to head.
Preliminary directory/module structure:
- js/src
- JSAPI implementation (jsapi.cpp, js::Invoke, js::Execute)
- Interpreter (ideally, if we had maximum code reuse, this would be just the one function calling lots of module (inline) functions)
- Grotty bits and bobs that don't make sense to modularize
- js/src/methodjit
- js/src/tracejit
- js/src/*jit
- js/src/vm: central, execution-mode-independent data structures: types and operations
- Stack: execution stack (done)
- Value: JS value representation
- String: JS string value representation
- Perhaps these next two need short distinctive names:
- Low-level object representation: property tree, shapes, and raw object storage
- General high-level objects: high level generic set/get/call operations respecting JS semantics
- Class-specific high-level objects: statically typed interfaces for native objects of a given class
- Global: the global object
- Arguments: object accessed through 'arguments' keyword
- Function: (object) perhaps also contains closely-related JSFunctino/JSScript/Bindings?
- js/src/gc: garbage collector data structures and algorithms
- js/src/parser: its not entirely clear how to cleanly break this into pieces, other than treating the whole thing as a module that takes in chars and puts out JSScripts
- js/src/builtin: builtins specified by JS language spec (e.g., String, Array.prototype.sort)
- String
- Number
- Boolean
- Array
- Date
- Math
- ...