diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 84dfdf83a489..43b0fec2ec11 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,8 +14,6 @@ env: DIFF: 0 # For faster CI RUST_LOG: "off" - # https://github.com/swc-project/swc/pull/3742 - RUST_MIN_STACK: 4194304 # https://github.com/actions/setup-node/issues/899#issuecomment-1819151595 SKIP_YARN_COREPACK_CHECK: 1 diff --git a/crates/swc_ecma_parser/src/parser/stmt.rs b/crates/swc_ecma_parser/src/parser/stmt.rs index 9738fd0525af..c5e6a6421a3b 100644 --- a/crates/swc_ecma_parser/src/parser/stmt.rs +++ b/crates/swc_ecma_parser/src/parser/stmt.rs @@ -519,7 +519,7 @@ impl<'a, I: Tokens> Parser { let cons = { // Prevent stack overflow - crate::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + crate::maybe_grow(256 * 1024, 1024 * 1024, || { // Annex B if !self.ctx().strict && is!(self, "function") { // TODO: report error? @@ -551,15 +551,13 @@ impl<'a, I: Tokens> Parser { } if !is!(self, "if") { - // As we eat `else` above, we need to parse statement once. - let last = crate::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let ctx = Context { - ignore_else_clause: false, - ..self.ctx() - }; + let ctx = Context { + ignore_else_clause: false, + ..self.ctx() + }; - self.with_ctx(ctx).parse_stmt(false) - })?; + // As we eat `else` above, we need to parse statement once. + let last = self.with_ctx(ctx).parse_stmt(false)?; break Some(last); } diff --git a/crates/swc_ecma_utils/src/stack_size.rs b/crates/swc_ecma_utils/src/stack_size.rs index d05d03cdaa9e..5841529688a6 100644 --- a/crates/swc_ecma_utils/src/stack_size.rs +++ b/crates/swc_ecma_utils/src/stack_size.rs @@ -25,5 +25,11 @@ pub fn maybe_grow R>(red_zone: usize, stack_size: usize, callb /// /// `maybe_grow` with default values. pub fn maybe_grow_default R>(callback: F) -> R { - maybe_grow(4 * 1024, 16 * 1024, callback) + let (red_zone, stack_size) = if cfg!(target_os = "linux") { + (4 * 1024, 16 * 1024) + } else { + (1024, 4 * 1024) + }; + + maybe_grow(red_zone, stack_size, callback) } diff --git a/xtask/src/bench.rs b/xtask/src/bench.rs index 38e57cc96c8c..851b9e42b6f1 100644 --- a/xtask/src/bench.rs +++ b/xtask/src/bench.rs @@ -15,6 +15,10 @@ pub(super) struct BenchCmd { #[clap(long)] debug: bool, + /// Template to use while instrumenting + #[clap(short = 't')] + template: Option, + #[clap(long)] no_lib: bool, @@ -50,7 +54,8 @@ impl BenchCmd { // ddt profile instruments cargo -t time let mut cmd = Command::new("ddt"); cmd.arg("profile").arg("instruments").arg("cargo"); - cmd.arg("-t").arg("time"); + cmd.arg("-t") + .arg(self.template.as_deref().unwrap_or("time")); if !self.debug { cmd.arg("--release");