mirror of
https://github.com/swc-project/swc.git
synced 2024-10-05 20:58:35 +03:00
perf(es): Reduce allocations for dynamic stacks (#9133)
This commit is contained in:
parent
9372030be7
commit
648830a9a9
2
.github/workflows/CI.yml
vendored
2
.github/workflows/CI.yml
vendored
@ -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
|
||||
|
||||
|
@ -519,7 +519,7 @@ impl<'a, I: Tokens> Parser<I> {
|
||||
|
||||
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<I> {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -25,5 +25,11 @@ pub fn maybe_grow<R, F: FnOnce() -> R>(red_zone: usize, stack_size: usize, callb
|
||||
///
|
||||
/// `maybe_grow` with default values.
|
||||
pub fn maybe_grow_default<R, F: FnOnce() -> 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)
|
||||
}
|
||||
|
@ -15,6 +15,10 @@ pub(super) struct BenchCmd {
|
||||
#[clap(long)]
|
||||
debug: bool,
|
||||
|
||||
/// Template to use while instrumenting
|
||||
#[clap(short = 't')]
|
||||
template: Option<String>,
|
||||
|
||||
#[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");
|
||||
|
Loading…
Reference in New Issue
Block a user