Commit graph

6256 commits

Author SHA1 Message Date
Will Lillis 2a8a17cf03 revert raw pointer hoisting to get_unchecked 2026-03-01 17:31:32 -05:00
Will Lillis 72718ca566 use bitset for coincident tokens 2026-03-01 15:41:46 -05:00
Will Lillis fd90c6e974 use simple bitvecs in TokenConflictMap, yields ~6% gain in tree-sitter-bash 2026-03-01 15:41:24 -05:00
Will Lillis 8982547112 use simple bitset for coincident token map, ~8% gain for tree-sitter bash 2026-03-01 15:39:08 -05:00
Will Lillis 7b3b9da95b more nfa stuff 2026-03-01 15:39:08 -05:00
Will Lillis 8f1ee0f13f optimize allocations around NfaStates 2026-03-01 15:39:08 -05:00
Will Lillis cf7d9e4d68 hashing trick, eliminate the expensive clone. Some pre-allocs as well 2026-03-01 15:39:08 -05:00
Will Lillis 3f353a21f9 more precompute, small gains 2026-03-01 15:39:08 -05:00
Will Lillis f50c7d9e64 perf: Use FxHasher over default hash implementation 2026-03-01 15:39:08 -05:00
Will Lillis b9f40095d7 cleanup symbol key using newtype method 2026-03-01 15:39:08 -05:00
Will Lillis bbd57f95d4 perf(generate): optimize variable_index_for_nfa_state 2026-03-01 15:39:08 -05:00
Will Lillis 45ad716e86 states conflict smart matrix accesses, small perf win 2026-03-01 15:39:08 -05:00
Will Lillis 4fd554f6af prealloc followup 2026-03-01 15:39:08 -05:00
Will Lillis 58d153efdb use bitflags for tokenconflictstatus 2026-03-01 15:39:08 -05:00
Will Lillis e5b6b40bb9 unchecked array accesses 2026-03-01 15:39:08 -05:00
Will Lillis d61d9e3715 pointers to map, small perf gain, scales w grammar 2026-03-01 15:39:08 -05:00
Will Lillis 58c7177277 Use symbol key for symbol, big boost for larger grammars 2026-03-01 15:39:08 -05:00
Will Lillis 62eb93fb0f nonterminal index, basically no change 2026-03-01 15:39:08 -05:00
Will Lillis afcc08c75e yet another precompute, also small/zero gains 2026-03-01 15:39:08 -05:00
Will Lillis e661efecee another precompute, much smaller/zero gains 2026-03-01 15:39:08 -05:00
Will Lillis f5df7c1a6f precompute some stuff, looks promising 2026-03-01 15:39:08 -05:00
Will Lillis 27035f6608
WIP: use u16 2026-03-01 15:38:18 -05:00
Will Lillis 0b269f537b
WIP: use linear Vec 2026-03-01 15:38:09 -05:00
Riley Bruins 4ae90615d1 chore(parser): return NULL, not false, for incomplete parse
Small nit; `NULL` is returned everywhere else in this function for an
incomplete parse.
2026-03-01 03:41:27 -05:00
Will Lillis 5fa7514fee perf(generate): several small optimizations
* reduce inner loop range in `CoincidentTokenIndex::new`

The indices computed from `a, b` and `b, a` are identical, so there's
no reason to iterate over the entire set of terminal indices in the
inner loop.

* remove redundant check for `does_match_same_string` in
  `token_conflicts`

`does_match_same_string` is already covered within `does_conflict`, so
OR-ing the result of the two together is wasteful.

* mark several functions available for `inline`

Reduces walltime by 0-3% depending on the grammar.

* don't continually reserve space in render buffer

Reserving space up front for containers is great. Doing this in a loop
can lead to _more_ allocations, hurting performance.

* pre-collect terminal indices in `CoincidentTokenIndex`

In `CoincidentTokenIndex::new`, the inner loop re-iterates the
`IndexMap` keys and re-checks is_terminal() for every outer iteration.
This information can be collected once per state, avoiding redundant
calculations.
2026-02-28 18:41:29 +01:00
Will Lillis 83fafba7f0 perf(generate): add basic free list to BitVec's arena allocator
In the naive implementation, the backing arena for `BitVec` frees no
memory, resulting in an increase of ~8-15% in peak rss. To mitigate
against this, the arena manages a simple free list, keyed by block
sizes. This keeps the reduction in wall time within 3% in the worst case
(on par for most grammars) with the naive implementation, and caps the
increase in peak rss to <1% over the current master branch.
2026-02-28 18:41:29 +01:00
Will Lillis 4d787db0b1 perf(generate): iterate set bits only in merge_token_set 2026-02-28 18:41:29 +01:00
Will Lillis 34706d3ef1 perf(generate): back BitVec with a custom arena allocator. 2026-02-28 18:41:29 +01:00
Will Lillis 8e6dea673b perf(generate): pre-alloc some BitVec sizes
We don't pre-allocate _all_ `BitVec`s, as this causes a ~20% increase in
peak rss with little to no performance gain. Certain `TokenSet`s are
guaranteed to be filled out to a fixed size, and so reserving the
space (and thus avoiding the arena waste) is safe.
2026-02-28 18:41:29 +01:00
Will Lillis 603c61fcb9 perf(generate): replace SmallBitVec with word-level BitVec for TokenSet
`TokenSet` operations (insert_all_terminals, insert_all, etc.) are called
_many_ times during parser generation. `SmallBitVec` performs these
bit-by-bit, which is incredibly slow compared to word-level operations.

Replace `SmallBitVec` with a custom `BitVec` backed by Vec<u64> that
operates at the word level.
2026-02-28 18:41:29 +01:00
dependabot[bot] f9bcce2e01 build(deps): bump rollup from 4.49.0 to 4.59.0 in /lib/binding_web
Bumps [rollup](https://github.com/rollup/rollup) from 4.49.0 to 4.59.0.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v4.49.0...v4.59.0)

---
updated-dependencies:
- dependency-name: rollup
  dependency-version: 4.59.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-28 15:11:12 +01:00
dependabot[bot] 3a295c7493 build(deps): bump minimatch in /lib/binding_web
Bumps  and [minimatch](https://github.com/isaacs/minimatch). These dependencies needed to be updated together.

Updates `minimatch` from 9.0.5 to 9.0.9
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/minimatch/compare/v9.0.5...v9.0.9)

Updates `minimatch` from 3.1.2 to 3.1.5
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/minimatch/compare/v9.0.5...v9.0.9)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-version: 9.0.9
  dependency-type: indirect
- dependency-name: minimatch
  dependency-version: 3.1.5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-28 15:08:24 +01:00
dependabot[bot] 6cefea704e build(deps): bump minimatch from 10.2.2 to 10.2.4 in /crates/cli/eslint
Bumps [minimatch](https://github.com/isaacs/minimatch) from 10.2.2 to 10.2.4.
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/minimatch/compare/v10.2.2...v10.2.4)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-version: 10.2.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-28 15:05:37 +01:00
Marian Buschsieweke a3bca3bc45
fix(wasm): pass target triple to clang (#5385)
Problem: The `clang` binary contained in the WASI-SDK releases downloaded from Github does not work on all platforms (e.g., Alpine/MUSL), but a custom (LLVM) `clang` built for the platform will default to that target, making it impossible to build wasm parsers.

Solution: Always pass `wasm32` target triple when calling clang to compile to wasm.

Notes:
* This assumes the custom `clang` is (installed or linked) to `$TREE_SITTER_WASI_SDK_PATH/bin`.
* This requires a full LLVM clang; Apple clang does not support `wasm` targets. 
* Tree-sitter expects a specified version of WASI-SDK, including a specific `clang` version. Other versions may but are not guaranteed to work.
2026-02-28 10:59:56 +01:00
MFS-code 146ea6e12b fix: skip missing Makefile in version command 2026-02-27 10:01:59 +01:00
Amaan Qureshi 0561079b6e cli(init): extract per-binding generators and named update functions
This commit just refactors the init command's update code, as it's quite messy. The main changes are that most bindings now go through their own generate_{lang} function.
2026-02-27 02:13:03 -05:00
Christian Clason 4d7d35818b build(deps): bump wasmtime to v36.0.6 2026-02-24 14:29:07 -05:00
dependabot[bot] b75abfff09 build(deps): bump anyhow from 1.0.101 to 1.0.102 in the cargo group
Bumps the cargo group with 1 update: [anyhow](https://github.com/dtolnay/anyhow).


Updates `anyhow` from 1.0.101 to 1.0.102
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.101...1.0.102)

---
updated-dependencies:
- dependency-name: anyhow
  dependency-version: 1.0.102
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-24 09:03:07 +01:00
Will Lillis 6ae37120b3 fix(cli): correct condition to perform __init__.py replacement for
`tree-sitter init -u` command
2026-02-23 22:53:06 -05:00
Will Lillis 5210ca0b51 fix(cli): update tree-sitter init -u for recent Package.swift
changes
2026-02-23 22:53:06 -05:00
Will Lillis f1f493e59e fix(cli): actually write updated Package.swift file 2026-02-23 22:53:06 -05:00
Amaan Qureshi 67f848cac9 loader: invalidate cached wasm toolchains on version mismatch
Previously, `get_existing_tool` checked only for the existence of
binaries in the cache directory without verifying their version, meaning bumping the version files had no effect until users manually deleted the cache directories. This commit writes a `.version` marker file after downloading and checks it on subsequent runs, removing stale caches automatically when the expected version changes.
2026-02-23 22:50:20 -05:00
Christian Clason 9b4577c6f2 feat(wasm): bump binaryen to v126 2026-02-22 17:21:20 +01:00
Christian Clason eeebf706cb feat(wasm): bump wasi-sdk to v30 2026-02-22 17:21:20 +01:00
Amaan Qureshi 787800dda6 cli(init): fix Package.swift scanner detection when used as a dependency
The template used `FileManager.default.fileExists(atPath: "src/scanner.c")` with a relative path, which resolves against the process cwd. When SwiftPM evaluates a dependency's manifest, the cwd is the consumer's directory, so the check returns `false` even when `scanner.c` exists, causing undefined symbol linker errors.

This commit uses `Context.packageDirectory`, which is available since `swift-tools-version:5.6`, to resolve the path against the package root. This does bump the minimum tools version from 5.3 to 5.6.
2026-02-22 10:55:16 -05:00
Christian Clason e62bf4ee5f ci: retrigger crates check on PR updates 2026-02-22 15:29:39 +01:00
dependabot[bot] 224598586c build(deps): bump minimatch, eslint and eslint-plugin-jsdoc
Bumps [minimatch](https://github.com/isaacs/minimatch) to 10.2.2 and updates ancestor dependencies [minimatch](https://github.com/isaacs/minimatch), [eslint](https://github.com/eslint/eslint) and [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc). These dependencies need to be updated together.


Updates `minimatch` from 3.1.2 to 10.2.2
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.1.2...v10.2.2)

Updates `eslint` from 9.39.2 to 10.0.1
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v9.39.2...v10.0.1)

Updates `eslint-plugin-jsdoc` from 50.2.4 to 62.7.0
- [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases)
- [Commits](https://github.com/gajus/eslint-plugin-jsdoc/compare/v50.2.4...v62.7.0)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-version: 10.2.2
  dependency-type: indirect
- dependency-name: eslint
  dependency-version: 10.0.1
  dependency-type: indirect
- dependency-name: eslint-plugin-jsdoc
  dependency-version: 62.7.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-21 16:48:12 +01:00
dependabot[bot] 8e330c7f24 build(deps): bump ajv from 6.12.6 to 6.14.0 in /crates/cli/eslint
Bumps [ajv](https://github.com/ajv-validator/ajv) from 6.12.6 to 6.14.0.
- [Release notes](https://github.com/ajv-validator/ajv/releases)
- [Commits](https://github.com/ajv-validator/ajv/compare/v6.12.6...v6.14.0)

---
updated-dependencies:
- dependency-name: ajv
  dependency-version: 6.14.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-21 16:43:21 +01:00
Will Lillis d0714e0828 docs: add basic information about creating releases 2026-02-21 15:59:32 +01:00
Will Lillis cf98b9b61e ci: add a dry-run workflow to test rust releases 2026-02-21 15:59:32 +01:00