Skip to content

Commit 7df2a59

Browse files
committed
chore(es/parser): use stacker in utils
1 parent 6fc3f16 commit 7df2a59

File tree

25 files changed

+34
-64
lines changed

25 files changed

+34
-64
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/swc_common/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ swc_atoms = { version = "5.0.0", path = "../swc_atoms" }
6868
swc_eq_ignore_macros = { version = "1.0.0", path = "../swc_eq_ignore_macros" }
6969
swc_visit = { version = "2.0.0", path = "../swc_visit" }
7070

71+
[target.'cfg(not(any(target_arch = "wasm32", target_arch = "arm")))'.dependencies]
72+
stacker = { version = "0.1.15", optional = true }
7173

7274
[dev-dependencies]
7375
codspeed-criterion-compat = { workspace = true }

crates/swc_common/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub mod private;
6767
mod rustc_data_structures;
6868
pub mod serializer;
6969
pub mod source_map;
70+
pub mod stack_size;
7071
pub mod sync;
7172
mod syntax_pos;
7273
pub mod util;

crates/swc_core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ ecma_plugin_transform = [
196196
]
197197

198198
# Use `stacker` to avoid stack overflow.
199-
stacker = ["swc_ecma_parser/stacker", "swc_ecma_utils/stacker"]
199+
stacker = ["swc_common/stacker"]
200200

201201

202202
typescript = ["swc_typescript"]

crates/swc_ecma_lexer/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bench = false
1919
[features]
2020
# Used for debugging
2121
debug = ["tracing-spans"]
22-
default = ["typescript", "stacker"]
22+
default = ["typescript", "swc_common/stacker"]
2323
tracing-spans = []
2424
typescript = []
2525
verify = ["swc_ecma_visit"]
@@ -44,9 +44,6 @@ swc_common = { version = "11.0.0", path = "../swc_common" }
4444
swc_ecma_ast = { version = "11.0.0", path = "../swc_ecma_ast" }
4545
swc_ecma_visit = { version = "11.0.0", path = "../swc_ecma_visit", optional = true }
4646

47-
[target.'cfg(not(any(target_arch = "wasm32", target_arch = "arm")))'.dependencies]
48-
stacker = { version = "0.1.15", optional = true }
49-
5047
[dev-dependencies]
5148
criterion = { workspace = true }
5249
pretty_assertions = { workspace = true }

crates/swc_ecma_lexer/src/common/parser/stmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ fn parse_if_stmt<'a, P: Parser<'a>>(p: &mut P) -> PResult<IfStmt> {
623623

624624
let cons = {
625625
// Prevent stack overflow
626-
crate::maybe_grow(256 * 1024, 1024 * 1024, || {
626+
swc_common::stack_size::maybe_grow(256 * 1024, 1024 * 1024, || {
627627
// Annex B
628628
if !p.ctx().contains(Context::Strict) && p.input_mut().is(&P::Token::FUNCTION) {
629629
// TODO: report error?

crates/swc_ecma_lexer/src/lib.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -367,27 +367,6 @@ macro_rules! tok {
367367
};
368368
}
369369

370-
#[inline(always)]
371-
#[cfg(any(
372-
target_arch = "wasm32",
373-
target_arch = "arm",
374-
not(feature = "stacker"),
375-
// miri does not work with stacker
376-
miri
377-
))]
378-
fn maybe_grow<R, F: FnOnce() -> R>(_red_zone: usize, _stack_size: usize, callback: F) -> R {
379-
callback()
380-
}
381-
382-
#[inline(always)]
383-
#[cfg(all(
384-
not(any(target_arch = "wasm32", target_arch = "arm", miri)),
385-
feature = "stacker"
386-
))]
387-
fn maybe_grow<R, F: FnOnce() -> R>(red_zone: usize, stack_size: usize, callback: F) -> R {
388-
stacker::maybe_grow(red_zone, stack_size, callback)
389-
}
390-
391370
pub fn lexer(input: Lexer) -> PResult<Vec<token::TokenAndSpan>> {
392371
let capturing = input::Capturing::new(input);
393372
let mut parser = parser::Parser::new_from(capturing);

crates/swc_ecma_parser/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bench = false
1919
[features]
2020
# Used for debugging
2121
debug = ["tracing-spans"]
22-
default = ["typescript", "stacker"]
22+
default = ["typescript"]
2323
tracing-spans = []
2424
typescript = []
2525
verify = ["swc_ecma_visit", "swc_ecma_lexer/verify"]
@@ -45,9 +45,6 @@ swc_ecma_ast = { version = "11.0.0", path = "../swc_ecma_ast" }
4545
swc_ecma_lexer = { version = "14.0.0", path = "../swc_ecma_lexer" }
4646
swc_ecma_visit = { version = "11.0.0", path = "../swc_ecma_visit", optional = true }
4747

48-
[target.'cfg(not(any(target_arch = "wasm32", target_arch = "arm")))'.dependencies]
49-
stacker = { version = "0.1.15", optional = true }
50-
5148
[dev-dependencies]
5249
criterion = { workspace = true }
5350
pretty_assertions = { workspace = true }

crates/swc_ecma_transforms/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ multi-module-decorator = ["swc_ecma_transforms_proposal/multi-module"]
2929
optimization = ["swc_ecma_transforms_optimization"]
3030
proposal = ["swc_ecma_transforms_proposal"]
3131
react = ["swc_ecma_transforms_react"]
32-
stacker = ["swc_ecma_utils/stacker"]
32+
stacker = ["swc_common/stacker"]
3333
typescript = ["swc_ecma_transforms_typescript"]
3434

3535
[dependencies]

0 commit comments

Comments
 (0)