perf(es/transforms): Exclude old inlining pass (#6203)

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6194.
This commit is contained in:
Donny/강동윤 2022-10-19 13:53:46 +09:00 committed by GitHub
parent b48ec880fd
commit 27896f4751
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 10 deletions

View File

@ -2,7 +2,7 @@ extern crate swc_node_base;
use std::{io::stderr, path::Path};
use criterion::{criterion_group, criterion_main, Bencher, Criterion};
use criterion::{black_box, criterion_group, criterion_main, Bencher, Criterion};
use swc::config::{Config, IsModule, Options};
use swc_common::{errors::Handler, sync::Lrc, FilePathMapping, SourceMap};
use swc_ecma_utils::swc_common::GLOBALS;
@ -37,7 +37,7 @@ fn bench_file(b: &mut Bencher, path: &Path) {
.unwrap()
})
};
println!("{}", result.code);
black_box(result);
});
}

View File

@ -1,6 +1,6 @@
"use strict";
function foo() {
let arr;
let arr = [];
arr = [
1,
2,

View File

@ -25,7 +25,6 @@ pub struct Config {
pub fn simplifier(unresolved_mark: Mark, c: Config) -> impl RepeatedJsPass {
Repeat::new(chain!(
expr_simplifier(unresolved_mark, c.expr),
inlining::inlining(c.inlining),
dead_branch_remover(unresolved_mark),
dce::dce(c.dce, unresolved_mark)
))

View File

@ -8,7 +8,9 @@ use swc_ecma_transforms_base::{helpers::inject_helpers, resolver};
use swc_ecma_transforms_compat::{es2015, es2016, es2017, es2018, es2022::class_properties, es3};
use swc_ecma_transforms_module::{common_js::common_js, import_analysis::import_analyzer};
use swc_ecma_transforms_optimization::simplify::{
dce::dce, dead_branch_remover, expr_simplifier, inlining::inlining, simplifier,
dce::{self, dce},
dead_branch_remover, expr_simplifier,
inlining::{self, inlining},
};
use swc_ecma_transforms_proposal::decorators;
use swc_ecma_transforms_testing::{test, test_transform};
@ -23,7 +25,12 @@ fn test(src: &str, expected: &str) {
chain!(
resolver(unresolved_mark, top_level_mark, false),
simplifier(unresolved_mark, Default::default())
Repeat::new(chain!(
expr_simplifier(unresolved_mark, Default::default()),
inlining::inlining(Default::default()),
dead_branch_remover(unresolved_mark),
dce::dce(Default::default(), unresolved_mark)
)),
)
},
src,
@ -46,7 +53,12 @@ macro_rules! to {
chain!(
resolver(unresolved_mark, top_level_mark, false),
simplifier(unresolved_mark, Default::default())
Repeat::new(chain!(
expr_simplifier(unresolved_mark, Default::default()),
inlining::inlining(Default::default()),
dead_branch_remover(unresolved_mark),
dce::dce(Default::default(), unresolved_mark)
)),
)
},
$name,
@ -574,7 +586,12 @@ test!(
resolver(unresolved_mark, top_level_mark, false),
strip(top_level_mark),
class_properties(Some(t.comments.clone()), Default::default()),
simplifier(unresolved_mark, Default::default()),
Repeat::new(chain!(
expr_simplifier(unresolved_mark, Default::default()),
inlining::inlining(Default::default()),
dead_branch_remover(unresolved_mark),
dce::dce(Default::default(), unresolved_mark)
)),
es2018(Default::default()),
es2017(
Default::default(),

View File

@ -799,10 +799,9 @@ fn html5lib_test_tree_construction(input: PathBuf) {
|| file_name.contains("svg_dat.5.fragment_tbody")
|| file_name.contains("svg_dat.6.fragment_tbody")
|| file_name.contains("svg_dat.7.fragment_tbody")
|| file_name.contains("foreign-fragment_dat.3.fragment_svg_path")
{
errors.len() - 1
} else if file_name.contains("foreign-fragment_dat.3.fragment_svg_path") {
errors.len() - 1
} else {
errors.len()
};