Skip to content

Conversation

quininer
Copy link
Contributor

Description:

Following our previous discussion, I am trying to introduce a self-describing serialization encoding for ast to replace #11069 .

Since serde is currently used for json serialization, it is hard to modify serde to support both json and binary encodings (due to the untagged and flatten attr). So I made our own Encode and Decode proc macro, which also facilitate unknown variant support.

benchmark

I've done some simple benchmarks with a modified swc ast, and I believe we don't have an unacceptable performance loss relative to rkyv.
I'm using cbor4ii here, which I developed, so I'd prefer it if there's no performance difference. but it's easy to migrate to bincode or other scheme.

This also introduces an unknown feature for ecma_ast crate, which should only be enabled by the wasm plugin to ensure that old plugins can decode new AST.

BREAKING CHANGE:

This PR itself only introduces new encoding and will not cause any breakage. However, it may cause breakage when switch the wasm plugin communication scheme in future.

Related issue (if exists):

Copy link

changeset-bot bot commented Sep 18, 2025

⚠️ No Changeset found

Latest commit: 041a36d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@quininer quininer force-pushed the r/self-desc-encode branch 2 times, most recently from c9d0a01 to de8261b Compare September 18, 2025 12:27
Copy link

codspeed-hq bot commented Sep 18, 2025

CodSpeed Performance Report

Merging #11100 will not alter performance

Comparing quininer:r/self-desc-encode (041a36d) with main (101c3b7)1

Summary

✅ 140 untouched

Footnotes

  1. No successful run was found on main (3ef7ce0) during the generation of this report, so 101c3b7 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link

socket-security bot commented Sep 19, 2025

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn Critical
@babel/[email protected] has a Critical CVE.

CVE: GHSA-67hx-6x53-jw92 Babel vulnerable to arbitrary code execution when compiling specifically crafted malicious code (CRITICAL)

Affected versions: < 7.23.2; >= 8.0.0-alpha.0 < 8.0.0-alpha.4

Patched version: 7.23.2

From: crates/swc_ecma_minifier/yarn.locknpm/@babel/[email protected]

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at [email protected].

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@babel/[email protected]. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@quininer quininer force-pushed the r/self-desc-encode branch 12 times, most recently from 1b60f1d to c5fab18 Compare September 22, 2025 12:10
@quininer quininer force-pushed the r/self-desc-encode branch 5 times, most recently from 4da0e40 to 815343f Compare September 23, 2025 09:47
kdy1 pushed a commit that referenced this pull request Oct 12, 2025
**Description:**

This is the split of #11100.
Since we need to add unknown variants to the ast enum, this requires a
lot of code changes to handle non-exhaustive matches. I'm doing this in a
separate PR for review.
@quininer
Copy link
Contributor Author

This also requires a serialization test, include unknown variants.

Since I'm busy with other work, it will be a little slower.

@quininer quininer force-pushed the r/self-desc-encode branch 2 times, most recently from c736814 to 46b5ab6 Compare October 15, 2025 10:35
@quininer quininer closed this Oct 20, 2025
@quininer quininer deleted the r/self-desc-encode branch October 20, 2025 02:59
@quininer quininer restored the r/self-desc-encode branch October 20, 2025 03:01
@quininer quininer reopened this Oct 20, 2025
move to ast_node

make encoding-impl optional

fix fmt

make css_ast

fix tuple

fix unknown

fix fmt

make html_ast

make xml_ast

make jsdoc

fix fmt

fix unit tag

update visit

fix parser

make regexp_ast

no unknown

fix snap

fix arbitrary

encoding: ignore unknown field

fix cfg
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​babel/​traverse@​7.22.1100257995100
Added@​types/​terser@​3.12.0661003977100
Addedhas@​1.0.3671006252100
Added@​swc/​counter@​0.1.31001004277100
Addednode-releases@​2.0.131001004490100
Addedhasown@​2.0.2671007253100
Addedpath-parse@​1.0.7671007952100
Addedis-core-module@​2.12.1671008253100
Addedfunction-bind@​1.1.2671008353100
Added@​swc/​plugin-jest@​1.5.117801005594100
Added@​types/​parse-json@​4.0.01001005878100
Addedis-arrayish@​0.2.11001005881100
Addedaxios@​0.21.4996010095100
Added@​babel/​plugin-transform-react-jsx-development@​7.18.61001006189100
Updatedjest-regex-util@​25.2.6 ⏵ 29.6.31001006286100
Updatedjest-get-type@​25.2.6 ⏵ 29.6.310010063 +184100
Updatedescape-string-regexp@​2.0.0 ⏵ 1.0.510010063 -577100
Updated@​jest/​globals@​25.5.2 ⏵ 29.7.010010063 +195100
Added@​babel/​plugin-transform-dotall-regex@​7.18.61001006389100
Added@​babel/​plugin-transform-unicode-regex@​7.18.61001006389100
Updated@​jest/​source-map@​25.5.0 ⏵ 29.6.31001006488100
Added@​babel/​plugin-transform-unicode-sets-regex@​7.22.31001006589100
Added@​babel/​plugin-transform-exponentiation-operator@​7.18.61001006589100
Added@​babel/​plugin-transform-reserved-words@​7.18.61001006589100
Added@​babel/​plugin-transform-class-properties@​7.22.31001006589100
Added@​babel/​plugin-transform-private-methods@​7.22.31001006589100
Added@​babel/​plugin-transform-sticky-regex@​7.18.61001006589100
Updatedcore-util-is@​1.0.2 ⏵ 1.0.310010065 -177100
Addedcollect-v8-coverage@​1.0.11001006685100
Added@​babel/​plugin-transform-named-capturing-groups-regex@​7.22.31001006689100
Updatedjest-resolve-dependencies@​25.5.4 ⏵ 29.7.0100 +110066 +196100
Added@​babel/​plugin-transform-property-literals@​7.18.61001006689100
Added@​babel/​plugin-transform-optional-catch-binding@​7.22.31001006689100
See 403 more rows in the dashboard

View full report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant