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

perf(es/codegen): Use Vec<T> from swc_allocator #9280

Merged
merged 6 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/hip-spiders-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
swc_compiler_base: patch
swc_ecma_codegen: patch
swc_ecma_transforms_react: patch
swc_fast_ts_strip: patch
---

perf(es/codegen): Use `Vec<T>` from `swc_allocator`
1 change: 1 addition & 0 deletions crates/swc_compiler_base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use once_cell::sync::Lazy;
use rustc_hash::FxHashMap;
#[allow(unused)]
use serde::{Deserialize, Serialize};
use swc_allocator::maybe::vec::Vec;
use swc_atoms::JsWord;
use swc_common::{
collections::AHashMap,
Expand Down
1 change: 1 addition & 0 deletions crates/swc_ecma_codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ codspeed-criterion-compat = { workspace = true }
criterion = { workspace = true }
serde_json = { workspace = true }

swc_allocator = { version = "0.1.7", path = "../swc_allocator" }
swc_common = { version = "0.36.0", path = "../swc_common", features = [
"sourcemap",
] }
Expand Down
4 changes: 4 additions & 0 deletions crates/swc_ecma_codegen/benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extern crate swc_malloc;

use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion};
use swc_allocator::{maybe::vec::Vec, Allocator};
use swc_common::FileName;
use swc_ecma_codegen::Emitter;
use swc_ecma_parser::{Parser, StringInput, Syntax};
Expand Down Expand Up @@ -94,6 +95,9 @@ fn bench_emitter(b: &mut Bencher, s: &str) {
}

b.iter(|| {
let alloc = Allocator::default();
let mut _guard = unsafe { alloc.guard() };

let mut src_map_buf = Vec::new();
let mut buf = Vec::new();
{
Expand Down
1 change: 1 addition & 0 deletions crates/swc_ecma_codegen/benches/with_parse.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extern crate swc_malloc;

use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion};
use swc_allocator::maybe::vec::Vec;
use swc_common::FileName;
use swc_ecma_codegen::Emitter;
use swc_ecma_parser::{Parser, StringInput, Syntax};
Expand Down
1 change: 1 addition & 0 deletions crates/swc_ecma_codegen/examples/sourcemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::{
time::Instant,
};

use swc_allocator::maybe::vec::Vec;
use swc_common::input::SourceFileInput;
use swc_ecma_ast::*;
use swc_ecma_codegen::{text_writer::JsWriter, Emitter};
Expand Down
1 change: 1 addition & 0 deletions crates/swc_ecma_codegen/src/text_writer/basic_impl.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::io::Write;

use rustc_hash::FxHashSet;
use swc_allocator::maybe::vec::Vec;
use swc_common::{sync::Lrc, BytePos, LineCol, SourceMap, Span};

use super::{Result, WriteJs};
Expand Down
1 change: 1 addition & 0 deletions crates/swc_ecma_codegen/tests/sourcemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{fs::read_to_string, path::PathBuf};
use base64::prelude::{Engine, BASE64_STANDARD};
use rustc_hash::FxHashSet;
use sourcemap::SourceMap;
use swc_allocator::maybe::vec::Vec;
use swc_common::{comments::SingleThreadedComments, source_map::SourceMapGenConfig};
use swc_ecma_ast::EsVersion;
use swc_ecma_codegen::{text_writer::WriteJs, Emitter};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use swc_allocator::maybe::vec::Vec;
use swc_common::{comments::SingleThreadedComments, sync::Lrc, FileName, Mark, SourceMap};
use swc_ecma_codegen::{text_writer::JsWriter, Emitter};
use swc_ecma_parser::{Parser, StringInput};
Expand Down
1 change: 1 addition & 0 deletions crates/swc_fast_ts_strip/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::{cell::RefCell, rc::Rc};

use anyhow::{Context, Error};
use serde::{Deserialize, Serialize};
use swc_allocator::maybe::vec::Vec;
use swc_common::{
comments::SingleThreadedComments,
errors::{Handler, HANDLER},
Expand Down
Loading