mirror of
https://github.com/swc-project/swc.git
synced 2024-11-30 07:03:50 +03:00
perf(es/parser): Add feature named tracing-spans
(#9019)
This commit is contained in:
parent
2fb890cf20
commit
3bf31148ba
@ -18,10 +18,11 @@ bench = false
|
||||
|
||||
[features]
|
||||
# Used for debugging
|
||||
debug = []
|
||||
default = ["typescript", "stacker"]
|
||||
typescript = []
|
||||
verify = ["swc_ecma_visit"]
|
||||
debug = ["tracing-spans"]
|
||||
default = ["typescript", "stacker"]
|
||||
tracing-spans = []
|
||||
typescript = []
|
||||
verify = ["swc_ecma_visit"]
|
||||
|
||||
[dependencies]
|
||||
either = { workspace = true }
|
||||
|
@ -34,7 +34,7 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
|
||||
///`parseMaybeAssign` (overridden)
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
pub(super) fn parse_assignment_expr(&mut self) -> PResult<Box<Expr>> {
|
||||
trace_cur!(self, parse_assignment_expr);
|
||||
|
||||
@ -76,7 +76,7 @@ impl<I: Tokens> Parser<I> {
|
||||
/// operators like `+=`.
|
||||
///
|
||||
/// `parseMaybeAssign`
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
fn parse_assignment_expr_base(&mut self) -> PResult<Box<Expr>> {
|
||||
trace_cur!(self, parse_assignment_expr_base);
|
||||
let start = self.input.cur_span();
|
||||
@ -208,7 +208,7 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
|
||||
/// Spec: 'ConditionalExpression'
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
fn parse_cond_expr(&mut self) -> PResult<Box<Expr>> {
|
||||
trace_cur!(self, parse_cond_expr);
|
||||
|
||||
@ -245,7 +245,7 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
|
||||
/// Parse a primary expression or arrow function
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
pub(super) fn parse_primary_expr(&mut self) -> PResult<Box<Expr>> {
|
||||
trace_cur!(self, parse_primary_expr);
|
||||
|
||||
@ -493,7 +493,7 @@ impl<I: Tokens> Parser<I> {
|
||||
syntax_error!(self, self.input.cur_span(), SyntaxError::TS1109)
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
fn parse_array_lit(&mut self) -> PResult<Box<Expr>> {
|
||||
trace_cur!(self, parse_array_lit);
|
||||
|
||||
@ -535,7 +535,7 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
|
||||
/// `is_new_expr`: true iff we are parsing production 'NewExpression'.
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
fn parse_member_expr_or_new_expr(&mut self, is_new_expr: bool) -> PResult<Box<Expr>> {
|
||||
let ctx = Context {
|
||||
should_not_lex_lt_or_gt_as_type: true,
|
||||
@ -678,7 +678,7 @@ impl<I: Tokens> Parser<I> {
|
||||
|
||||
/// Parse `NewExpression`.
|
||||
/// This includes `MemberExpression`.
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
pub(super) fn parse_new_expr(&mut self) -> PResult<Box<Expr>> {
|
||||
trace_cur!(self, parse_new_expr);
|
||||
|
||||
@ -686,7 +686,7 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
|
||||
/// Parse `Arguments[Yield, Await]`
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
pub(super) fn parse_args(&mut self, is_dynamic_import: bool) -> PResult<Vec<ExprOrSpread>> {
|
||||
trace_cur!(self, parse_args);
|
||||
|
||||
@ -759,7 +759,7 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
|
||||
/// Parse paren expression or arrow function expression.
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
fn parse_paren_expr_or_arrow_fn(
|
||||
&mut self,
|
||||
can_be_arrow: bool,
|
||||
@ -1091,7 +1091,7 @@ impl<I: Tokens> Parser<I> {
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
pub(super) fn parse_subscripts(
|
||||
&mut self,
|
||||
mut obj: Callee,
|
||||
@ -1108,7 +1108,7 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
|
||||
/// returned bool is true if this method should be called again.
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
fn parse_subscript(
|
||||
&mut self,
|
||||
start: BytePos,
|
||||
@ -1544,7 +1544,7 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
|
||||
/// Parse call, dot, and `[]`-subscript expressions.
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
pub(super) fn parse_lhs_expr(&mut self) -> PResult<Box<Expr>> {
|
||||
trace_cur!(self, parse_lhs_expr);
|
||||
|
||||
@ -1681,7 +1681,7 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
|
||||
// Returns (args_or_pats, trailing_comma)
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
pub(super) fn parse_args_or_pats(
|
||||
&mut self,
|
||||
) -> PResult<(Vec<AssignTargetOrSpread>, Option<Span>)> {
|
||||
|
@ -570,7 +570,7 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
pub(super) fn try_parse_ts_type_args(&mut self) -> Option<Box<TsTypeParamInstantiation>> {
|
||||
trace_cur!(self, try_parse_ts_type_args);
|
||||
debug_assert!(self.input.syntax().typescript());
|
||||
@ -642,7 +642,7 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
pub(super) fn parse_ts_type_ann(
|
||||
&mut self,
|
||||
eat_colon: bool,
|
||||
@ -1972,7 +1972,7 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
|
||||
/// `tsTryParseTypeAnnotation`
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
|
||||
pub(super) fn try_parse_ts_type_ann(&mut self) -> PResult<Option<Box<TsTypeAnn>>> {
|
||||
if !cfg!(feature = "typescript") {
|
||||
return Ok(None);
|
||||
|
Loading…
Reference in New Issue
Block a user