Commit Graph

13 Commits

Author SHA1 Message Date
overlookmotel f78e09650e test(minifier): simplify ArenaVec builder args to array (#24625)
Pure refactor. Just shorten code.

Replace pattern of creating a `Vec` and pushing to it repeatedly with just passing an array to the AST builder method.

This is shorter and more performant - though perf doesn't matter, because it's just in a test.
2026-07-17 13:49:40 +00:00
overlookmotel c1a074cdc8 refactor(all): pass [] for empty ArenaVec args to AST builder methods (#24622)
Pure refactor. Just shorten code.

#24621 made AST builder methods take arrays as params.

Replace `ArenaVec::new_in(...)` arguments written inline at AST builder method call sites with the empty array literal `[]`.

```rs
let block = Statement::new_block_statement(SPAN, ArenaVec::new_in(ctx), ctx);
```

\->

```rs
let block = Statement::new_block_statement(SPAN, [], ctx);
```
2026-07-17 13:49:39 +00:00
overlookmotel b7cd88dcd6 refactor(minifier): switch to new AstBuilder (#23832)
Part of #23043. Migrate `oxc_minifier` over to new `AstBuilder`.
2026-06-26 18:17:30 +00:00
overlookmotel 3855f0c0d1 perf(minifier): allocate AST nodes in arena directly (#23710)
Same as #23709.

Small perf optimizations around AST builder calls.

- AST nodes which end up in `Box`es, allocate into the `Box` as early as possible, to increase chance compiler sees the type can be built directly in arena, rather than built on the stack, and then copied from stack into arena.
- Functions return `Box<T>` rather than `T` where the value needs to be boxed anyway. If function is not inlined, this avoids stack allocation + copy.

Also, shorten code where possible by using more specific `AstBuilder` methods.
2026-06-23 01:00:15 +00:00
overlookmotel c9cd809e50 refactor(str)!: rename Atom to Str (#20835)
Pure refactor.

Rename `Atom` to `Str`. The name "Atom" is a leftover from when we used to intern strings (years ago), and is misleading now.

Just call it `Str`. This follows the naming convention we have for arena-allocated versions of other types e.g. `Box`, `Vec`, `HashMap` - which we name the same as the native equivalents but with a lifetime (`Box<'a>` not `ArenaBox<'a>`, so `Str<'a>` not `ArenaStr<'a>`).

Rename all variables that contained "atom", and methods which relate to `Str`s to match the new type name.

Rename `as_atom` methods to `as_arena_str`. The longer name is required here to disambiguate from `as_str` methods which return a `&str`.

Some variables called "atom" still exist in `oxc_regular_expression` crate - that's a different meaning of "atom" - the meaning defined in regexp spec.

The diff of this PR is large but it's 100% renaming. No substantive or unrelated changes whatsoever.
2026-03-30 02:40:33 +00:00
Boshen 0c5bffc052 refactor(ecmascript): change IsGlobalReference to GlobalContext (#12952) 2025-08-10 06:57:13 +00:00
overlookmotel f3eaefbf1b feat(ast)!: add value field to BigIntLiteral (#11564)
Add `value` field to `BigIntLiteral`, same as the other literal types.

Once upon a time, we stored the value as a `BigInt` which normalized the representation (removing `_`s, and converting e.g. `0xFF` to `255`). But we had to remove it because `BigInt` owns a heap allocation, and this caused a memory leak.

https://github.com/oxc-project/oxc/commit/50fe0fef73027f10740e68a65a78216933b5d8a0

This PR brings back the `value` field, but avoids memory leak by storing the normalized value as a string (`Atom`).

This has effects in various places in the codebase:

* Brings our JS-side AST into line with ESTree (fixing the test cases broken by #11563).
* Fixes edge cases in a couple of lint rules.
* Codegen now prints bigints in normalized form e.g. `0xFFn` is printed as `255n`.
* Changes behavior of 1 function in `oxc_ecmascript`.

I've made comments below on the parts I'm not so sure about. Review would be very welcome!
2025-06-09 02:28:46 +00:00
Boshen 7284135135 refactor(ast)!: remove trailing_commas from ArrayExpression and ObjectExpression (#10431)
closes #10419

This change reduces the size of these AST nodes, saving a bit of memory.

`ArrayExpression`: 56 -> 40
`ObjectExpression`: 56 -> 40
`ArrayAssignmentTarget`: 80 -> 64

Also removes the annoying `None` argument from these AST node builders.
2025-04-16 04:04:12 +00:00
Boshen 1d81adac48 Rust Edition 2024 (#9289)
closes #9271

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-02-22 11:56:25 +08:00
sapphi-red cfc71f9581 fix(ecmascript): to_string for shadowed undefined (#9103)
`to_string` was returning `"undefined"` for shadowed `undefined` as well.
2025-02-14 08:58:33 +00:00
Boshen 1d6e84dd33 fix(minifier): fix incorrect null.toString() and 1n.toString() (#8464) 2025-01-13 15:08:49 +00:00
Song Gao ebc80f6749 refactor(ast)!: change 'raw' from &str to Option<Atom> (#7547)
Fix #7254 

Changed all "raw" properties of literal types (if they have this property) to `Option<Atom>`.

---------

Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2024-12-05 00:34:45 +00:00
Boshen 9d6e14bb67 test(ecmascript): move tests to oxc_minifier due to cyclic dependency with oxc_parser (#7542) 2024-11-29 09:18:45 +00:00