From 5759447250b684460b2e24e28988c53bf0694936 Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Mon, 7 Feb 2022 23:13:58 +0000 Subject: [PATCH] Reduced the size of AST nodes (#1821) This PR boxes the `Try` and `TaggedTemplate` nodes reducing the size of the `Node` structure from 88 to 56 bytes. This should improve performance in most cases, by adding another indirection with code with `try` and templates. --- Cargo.lock | 4 ++-- boa/src/syntax/ast/node/mod.rs | 4 ++-- boa/src/syntax/ast/node/template/mod.rs | 2 +- boa/src/syntax/ast/node/try_node/mod.rs | 2 +- yarn.lock | 19 ++++++++++++------- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a3a693651..ae9d6273af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1495,9 +1495,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" [[package]] name = "unicode-width" diff --git a/boa/src/syntax/ast/node/mod.rs b/boa/src/syntax/ast/node/mod.rs index 0429964e39..9e9a84dc65 100644 --- a/boa/src/syntax/ast/node/mod.rs +++ b/boa/src/syntax/ast/node/mod.rs @@ -166,7 +166,7 @@ pub enum Node { Spread(Spread), /// A tagged template. [More information](./template/struct.TaggedTemplate.html). - TaggedTemplate(TaggedTemplate), + TaggedTemplate(Box), /// A template literal. [More information](./template/struct.TemplateLit.html). TemplateLit(TemplateLit), @@ -175,7 +175,7 @@ pub enum Node { Throw(Throw), /// A `try...catch` node. [More information](./try_node/struct.Try.htl). - Try(Try), + Try(Box), /// The JavaScript `this` keyword refers to the object it belongs to. /// diff --git a/boa/src/syntax/ast/node/template/mod.rs b/boa/src/syntax/ast/node/template/mod.rs index 3a3209e1d7..199fa7a980 100644 --- a/boa/src/syntax/ast/node/template/mod.rs +++ b/boa/src/syntax/ast/node/template/mod.rs @@ -117,7 +117,7 @@ impl ToInternedString for TaggedTemplate { impl From for Node { fn from(template: TaggedTemplate) -> Self { - Self::TaggedTemplate(template) + Self::TaggedTemplate(Box::new(template)) } } diff --git a/boa/src/syntax/ast/node/try_node/mod.rs b/boa/src/syntax/ast/node/try_node/mod.rs index 16d7ce6329..9171ea5ec1 100644 --- a/boa/src/syntax/ast/node/try_node/mod.rs +++ b/boa/src/syntax/ast/node/try_node/mod.rs @@ -99,7 +99,7 @@ impl ToInternedString for Try { impl From for Node { fn from(try_catch: Try) -> Self { - Self::Try(try_catch) + Self::Try(Box::new(try_catch)) } } diff --git a/yarn.lock b/yarn.lock index 07fb03b99a..46bbd929a7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -74,7 +74,12 @@ "@types/estree" "*" "@types/json-schema" "*" -"@types/estree@*", "@types/estree@^0.0.50": +"@types/estree@*": + version "0.0.51" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40" + integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ== + +"@types/estree@^0.0.50": version "0.0.50" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.50.tgz#1e0caa9364d3fccd2931c3ed96fdbeaa5d4cca83" integrity sha512-C6N5s2ZFtuZRj54k2/zyRhNDjJwwcViAM3Nbm8zjBpbqAdZ00mr0CFxvSKeO8Y/e03WVFLpQMdHYVfUd6SB+Hw== @@ -595,9 +600,9 @@ camel-case@^4.1.2: tslib "^2.0.3" caniuse-lite@^1.0.30001286: - version "1.0.30001307" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001307.tgz#27a67f13ebc4aa9c977e6b8256a11d5eafb30f27" - integrity sha512-+MXEMczJ4FuxJAUp0jvAl6Df0NI/OfW1RWEE61eSmzS7hw6lz4IKutbhbXendwq8BljfFuHtu26VWsg4afQ7Ng== + version "1.0.30001309" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001309.tgz#e0ee78b9bec0704f67304b00ff3c5c0c768a9f62" + integrity sha512-Pl8vfigmBXXq+/yUz1jUwULeq9xhMJznzdc/xwl4WclDAuebcTHVefpz8lE/bMI+UN7TOkSSe7B7RnZd6+dzjA== chalk@^2.4.1: version "2.4.2" @@ -1795,9 +1800,9 @@ minimalistic-assert@^1.0.0: integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== minimatch@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== + version "3.0.5" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.5.tgz#4da8f1290ee0f0f8e83d60ca69f8f134068604a3" + integrity sha512-tUpxzX0VAzJHjLu0xUfFv1gwVp9ba3IOuRAVH2EGuRW8a5emA2FlACLqiT/lDVtS1W+TGNwqz3sWaNyLgDJWuw== dependencies: brace-expansion "^1.1.7"