reduce memory pressure via bit fields (#5203)
This commit is contained in:
52
lib/ast.js
52
lib/ast.js
@@ -50,6 +50,8 @@ function DEFNODE(type, props, methods, base) {
|
||||
if (base && base.PROPS) props = props.concat(base.PROPS);
|
||||
var code = [
|
||||
"return function AST_", type, "(props){",
|
||||
// not essential, but speeds up compress by a few percent
|
||||
"this._bits=0;",
|
||||
"if(props){",
|
||||
];
|
||||
props.forEach(function(prop) {
|
||||
@@ -135,6 +137,52 @@ var AST_Node = DEFNODE("Node", "start end", {
|
||||
},
|
||||
}, null);
|
||||
|
||||
DEF_BITPROPS(AST_Node, [
|
||||
"_optimized",
|
||||
"_squeezed",
|
||||
// AST_Call
|
||||
"call_only",
|
||||
"collapse_scanning",
|
||||
// AST_SymbolRef
|
||||
"defined",
|
||||
"evaluating",
|
||||
"falsy",
|
||||
// AST_SymbolRef
|
||||
"in_arg",
|
||||
// AST_Return
|
||||
"in_bool",
|
||||
// AST_SymbolRef
|
||||
"is_undefined",
|
||||
// AST_LambdaExpression
|
||||
// AST_LambdaDefinition
|
||||
"inlined",
|
||||
// AST_Lambda
|
||||
"length_read",
|
||||
// AST_Yield
|
||||
"nested",
|
||||
// AST_Lambda
|
||||
"new",
|
||||
// AST_Call
|
||||
// AST_PropAccess
|
||||
"optional",
|
||||
// AST_ClassProperty
|
||||
"private",
|
||||
// AST_Call
|
||||
"pure",
|
||||
// AST_Assign
|
||||
"redundant",
|
||||
// AST_ClassProperty
|
||||
"static",
|
||||
// AST_Call
|
||||
// AST_PropAccess
|
||||
"terminal",
|
||||
"truthy",
|
||||
// AST_Scope
|
||||
"uses_eval",
|
||||
// AST_Scope
|
||||
"uses_with",
|
||||
]);
|
||||
|
||||
(AST_Node.log_function = function(fn, verbose) {
|
||||
if (typeof fn != "function") {
|
||||
AST_Node.info = AST_Node.warn = noop;
|
||||
@@ -549,7 +597,7 @@ var AST_Lambda = DEFNODE("Lambda", "argnames length_read rest uses_arguments", {
|
||||
argnames: "[(AST_DefaultValue|AST_Destructured|AST_SymbolFunarg)*] array of function arguments and/or destructured literals",
|
||||
length_read: "[boolean/S] whether length property of this function is accessed",
|
||||
rest: "[(AST_Destructured|AST_SymbolFunarg)?] rest parameter, or null if absent",
|
||||
uses_arguments: "[boolean/S] whether this function accesses the arguments array",
|
||||
uses_arguments: "[boolean|number/S] whether this function accesses the arguments array",
|
||||
},
|
||||
each_argname: function(visit) {
|
||||
var tw = new TreeWalker(function(node) {
|
||||
@@ -1295,7 +1343,7 @@ var AST_Call = DEFNODE("Call", "args expression optional pure terminal", {
|
||||
args: "[AST_Node*] array of arguments",
|
||||
expression: "[AST_Node] expression to invoke as function",
|
||||
optional: "[boolean] whether the expression is optional chaining",
|
||||
pure: "[string/S] marker for side-effect-free call expression",
|
||||
pure: "[boolean/S] marker for side-effect-free call expression",
|
||||
terminal: "[boolean] whether the chain has ended",
|
||||
},
|
||||
walk: function(visitor) {
|
||||
|
||||
Reference in New Issue
Block a user