Commit graph

23 commits

Author SHA1 Message Date
Boshen
9b38119ec9 refactor(ast)!: replace Modifiers with declare on VariableDeclaration (#3839)
part of #2958
2024-06-23 10:34:52 +00:00
Don Isaac
d5f6aeb1ca
feat(semantic): check for illegal symbol modifiers (#3838) 2024-06-23 12:36:09 +08:00
Boshen
445603444f feat(ast)!: add IdentifierReference to ExportSpecifier (#3820)
closes #3795
closes #3796
2024-06-22 11:43:41 +00:00
overlookmotel
4f7ff7e3ad perf: do not pass &Atom to functions (#3818)
`Atom` is just a wrapper around `&str`, so better not to pass `&Atom` to functions, as that's a double-reference. Prefer `Atom` or `&str` instead to avoid indirection.
2024-06-22 04:48:00 +00:00
Boshen
45b0d1147e chore(semantic): regenerate snapshot (#3757) 2024-06-19 09:28:31 +00:00
Boshen
051ceb6539
chore: improve some format by running cargo +nightly fmt 2024-06-19 00:48:30 +08:00
rzvxa
256acc949b
chore(semantic)!: no longer generate CFG by default. (#3738)
related but won't close #3641
2024-06-19 00:13:29 +08:00
rzvxa
d8ad321687 refactor(semantic): make control flow generation optional. (#3737)
For maximum backward compatibility, we generate CFG by default.

Note: It can't be done with a simple method since lifetimes make it impossible(at least without unsafe trickery) I've tried to do it without a macro but it was just unintuitive.
2024-06-18 15:59:38 +00:00
rzvxa
0537d298db refactor(cfg)!: move control flow to its own crate. (#3728) 2024-06-18 15:59:29 +00:00
Ali Rezvani
e148a32ce3
fix(semantic/cfg): correct unreachability propagation in try-finally. (#3667)
closes #3663


[oxlint-ecosystem-ci](https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9511509383/job/26217870705)

From this:

![Screenshot 2024-06-14
092916](https://github.com/oxc-project/oxc/assets/3788964/9e6a9a01-984a-4a19-8a73-abc3b71fb9c2)

To this:

![Screenshot 2024-06-14
092852](https://github.com/oxc-project/oxc/assets/3788964/46483bc2-a227-4416-b8da-07b11ab96990)

Since try-finally (without a catch) wouldn't join after finalization.
2024-06-14 14:39:20 +08:00
rzvxa
9c31ed9178 feat(semantic/cfg): propagate unreachable edges through subgraphs. (#3648)
From this:

![Screenshot 2024-06-12 230152](https://github.com/oxc-project/oxc/assets/3788964/b489cee8-62ec-4483-9c9b-6e3d9858fec2)

To this:

![Screenshot 2024-06-12 230031](https://github.com/oxc-project/oxc/assets/3788964/674a6e42-5311-4ca6-940b-65d8e3ccc0f4)
2024-06-13 08:34:12 +00:00
Ali Rezvani
d9c5b33394
feat(semantic/cfg): add Condition instruction. (#3567) 2024-06-13 16:17:24 +08:00
rzvxa
f2dfd667df feat(semantic/cfg): add iteration instructions. (#3566) 2024-06-13 07:36:20 +00:00
rzvxa
defef057e1 improvement(semantic/cfg): better control flow for switch statements. (#3547)
There was an issue similar to the one in loops see #3451 to #3453
2024-06-13 07:36:18 +00:00
rzvxa
9b3097147e improvement(semantic/cfg): rework error path. (#3519)
This PR aims to provide a more accurate error/finalization flow, I've nuked the old error path approach and rewrote it with more versatility in mind.

We used to visit the finalizer block twice and create 2 sets of AstNodes/Basic Blocks for them, This was there to differentiate between the error path finalizer and success path one. There is no longer a need for having 2 separate sets of nodes to do this differentiation.

As for the error path now we have 2 kinds of them, Everything is attached to an error block - even if it is not in a try-catch statement - this results in a lot of extra edges to keep track of these "Implicit" error blocks but I believe in future it can help us to track cross block error paths, For example, we can dynamically attach and cache the implicit error block of a function to its call site error path (either implicit or explicit).
2024-06-13 07:36:16 +00:00
Boshen
f6752b482f
feat!(ast): make Trivias clonable by adding Arc (#3638)
This makes `Trivias` cloneable and stops us from using `Rc::new` and
`Rc::clone` everywhere.

`Trivias` is rarely cloned so an `Arc` should suffice.
2024-06-12 13:16:10 +08:00
Dunqing
5793ff1986
refactor(transformer): replace &’a Trivias with Rc<Trivias> (#3580)
`Transformer` needs to borrow `Trivias`.
8be1cc8052 (r1630711060)
2024-06-11 13:23:41 +08:00
rzvxa
3c7ee85ce4 improvement(semantic/cfg): better break and continue flow. (#3462)
This PR adds a new edge type called `Jump` to distinguish between normal edges and jumps.
There is also a control flow context which is used to keep track of cfg scopes and labels. It replaces the old `preserve_state` and `restore_state`.
It corrects some mistakes - such as labeled blocks especially labeled continue which wasn't easy to implement with the old approach - in the old control flow but other than that it is mostly refactored to have a more declarative API instead of a procedural approach.
2024-06-06 07:55:31 +00:00
rzvxa
91c999546c improvement(semantic/cfg): better control flow for DoWhileStatements. (#3452)
similar to #3451
2024-06-06 05:41:06 +00:00
rzvxa
0012094188 improvement(semantic/cfg): better control flow for WhileStatements. (#3451)
Fixes a simple cfg issue, previously it wouldn't follow the body subgraph correctly.
2024-06-06 05:41:04 +00:00
rzvxa
209a99d49f improvement(semantic/cfg): rework basic blocks. (#3381)
I've replaced the `BasicBlockElement` with an `Instruction` type which would keep both the instruction kind and its associated AstNodeId.
I also removed the register scheme in the control flow in favor of a simpler approach using explicit enums.

https://github.com/oxc-project/oxc/pull/3381#issuecomment-2126622774
2024-06-06 05:41:01 +00:00
mysteryven
5e06298ec2 fix(linter): memorize visited block id in neighbors_filtered_by_edge_weight (#3407)
closes: #3396

we visit the same node too many times, I picked some result from run require-render-return rule on [timeserieseexploere.js](https://github.com/elastic/kibana/blob/main/x-pack/plugins/ml/public/application/timeseriesexplorer/timeseriesexplorer.js)

```bash
    NodeIndex(64): 368640,
    NodeIndex(67): 737280,
    NodeIndex(70): 2949120,
    NodeIndex(73): 5971968,
    NodeIndex(76): 11943936,
    NodeIndex(43): 184320,
    NodeIndex(71): 2985984,
    NodeIndex(65): 368640,
    NodeIndex(68): 1474560,
    NodeIndex(74): 5971968,
    NodeIndex(77): 23887872,
    NodeIndex(44): 184320,
    NodeIndex(41): 73728,
    NodeIndex(35): 36864,
    NodeIndex(66): 737280,
    NodeIndex(69): 1474560,
    NodeIndex(72): 2985984,
    NodeIndex(75): 11943936,
```
2024-05-26 08:11:48 +00:00
Boshen
de75fb2942 refactor: compile less test binaries to speed up CI (#3414)
The semantic crate currently compiles 5 binaries for integration test, this PR merges them into one.
2024-05-26 07:21:44 +00:00