Skip to content

docs(oxc_parser): add header symbol for parser.unexpected's doc comment#24

Merged
Boshen merged 1 commit into
oxc-project:mainfrom
jason89521:docs/parser/markdown-header
Feb 18, 2023
Merged

docs(oxc_parser): add header symbol for parser.unexpected's doc comment#24
Boshen merged 1 commit into
oxc-project:mainfrom
jason89521:docs/parser/markdown-header

Conversation

@jason89521

Copy link
Copy Markdown
Contributor

Description

It seems that there should exist a # symbol to make Panics be an title when user see the document comment.

Additional Information

I'm highly interested in this project, but I'm a newbie in Rust and compiler. Currently trying to understand the compiler concepts from the guide you wrote and trying to understand this great project :)

I'm also not good at english writing, so if I have written anything that offend you, please accept my apologies.

@jason89521 jason89521 marked this pull request as ready for review February 17, 2023 11:44
@Boshen Boshen closed this Feb 18, 2023
@Boshen Boshen reopened this Feb 18, 2023
@Boshen Boshen merged commit 362c02f into oxc-project:main Feb 18, 2023
@Boshen

Boshen commented Feb 18, 2023

Copy link
Copy Markdown
Member

(github on mobile is not easy to use so I accidentally closed this and then reopened again.)

Keep on learning, and we will see more contributions from you.

@jason89521 jason89521 deleted the docs/parser/markdown-header branch February 18, 2023 02:31
graphite-app Bot pushed a commit that referenced this pull request Jun 25, 2026
This avoids calling `Expression::span()` when wrapping an expression-bodied arrow function in a synthetic `ExpressionStatement`.

The parser already knows the expression body starts at the current token before parsing and ends at `prev_token_end` afterwards, so this can use `start_span()` / `end_span()` directly. That keeps the returned `Expression` in registers instead of materializing it on the stack just to call the generated `GetSpan` impl.

Before, the optimized parser assembly spilled the returned expression and called `Expression::span()`:

```asm
bl      parse_assignment_expression_or_higher_impl
mov     x20, x0
mov     x22, x1
strh    w21, [x19, #1196]
strb    w0, [sp, #16]
str     x1, [sp, #24]
add     x0, sp, #16
bl      GetSpan_for_Expression_span
...
str     x0, [x21]       ; ExpressionStatement span
strb    w20, [x21, #16] ; Expression tag
str     x22, [x21, #24] ; Expression payload
```

After, the span is built from parser token state and the expression result is written directly into the arena allocation:

```asm
ldr     x20, [x0, #816]  ; current token span before parse
...
bl      parse_assignment_expression_or_higher_impl
strh    w21, [x19, #1196]
ldr     w8, [x19, #1192] ; previous token end after parse
bfi     x20, x8, #32, #32
...
str     x20, [x21]      ; ExpressionStatement span
strb    w0, [x21, #16]  ; Expression tag
str     x1, [x21, #24]  ; Expression payload
```

This also reduced the first monomorphized parse_arrow_function_expression_body stack frame from 432 bytes to 416 bytes in my local release assembly.
camc314 added a commit that referenced this pull request Jul 3, 2026
This avoids calling `Expression::span()` when wrapping an expression-bodied arrow function in a synthetic `ExpressionStatement`.

The parser already knows the expression body starts at the current token before parsing and ends at `prev_token_end` afterwards, so this can use `start_span()` / `end_span()` directly. That keeps the returned `Expression` in registers instead of materializing it on the stack just to call the generated `GetSpan` impl.

Before, the optimized parser assembly spilled the returned expression and called `Expression::span()`:

```asm
bl      parse_assignment_expression_or_higher_impl
mov     x20, x0
mov     x22, x1
strh    w21, [x19, #1196]
strb    w0, [sp, #16]
str     x1, [sp, #24]
add     x0, sp, #16
bl      GetSpan_for_Expression_span
...
str     x0, [x21]       ; ExpressionStatement span
strb    w20, [x21, #16] ; Expression tag
str     x22, [x21, #24] ; Expression payload
```

After, the span is built from parser token state and the expression result is written directly into the arena allocation:

```asm
ldr     x20, [x0, #816]  ; current token span before parse
...
bl      parse_assignment_expression_or_higher_impl
strh    w21, [x19, #1196]
ldr     w8, [x19, #1192] ; previous token end after parse
bfi     x20, x8, #32, #32
...
str     x20, [x21]      ; ExpressionStatement span
strb    w0, [x21, #16]  ; Expression tag
str     x1, [x21, #24]  ; Expression payload
```

This also reduced the first monomorphized parse_arrow_function_expression_body stack frame from 432 bytes to 416 bytes in my local release assembly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants