Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9daced2
speedup
mcy Mar 4, 2026
bca6388
comments
mcy Mar 4, 2026
437c66c
lint
mcy Mar 5, 2026
b32958f
get value to inline
mcy Mar 5, 2026
785c902
wip
mcy Mar 5, 2026
07fa3df
wip
mcy Mar 5, 2026
744163e
use an atomic-ish log
mcy Mar 6, 2026
4683a8f
fixes
mcy Mar 6, 2026
d6d38c8
better benchmark
mcy Mar 6, 2026
54dc3f8
lint
mcy Mar 6, 2026
b1eed0e
add instrumentation
mcy Mar 6, 2026
8d6a168
fix
mcy Mar 6, 2026
cd6ba22
benchmarks
mcy Mar 6, 2026
6b4241c
add an inlining test
mcy Mar 7, 2026
184427c
Merge remote-tracking branch 'origin/main' into mcy/intern-amortize
mcy Mar 7, 2026
926f422
lockless
mcy Mar 7, 2026
05899ca
fix spurious -race failure
mcy Mar 7, 2026
cb4a02f
cleanup
mcy Mar 9, 2026
a1a2fdf
lint
mcy Mar 9, 2026
d68bb4a
lint
mcy Mar 9, 2026
1a7baa1
make misuse of log impossible
mcy Mar 9, 2026
9a313c4
remove data race
mcy Mar 9, 2026
a1048db
unbreak
mcy Mar 9, 2026
9eb9d65
ensure exit
mcy Mar 10, 2026
2cd2bd1
add benchmarks
mcy Mar 24, 2026
777c887
speedups
mcy Mar 25, 2026
deaf2f3
Merge remote-tracking branch 'origin/main' into mcy/intern-amortize
mcy Mar 25, 2026
3c50318
Merge branch 'mcy/intern-amortize' into mcy/benchmarks
mcy Mar 25, 2026
948704d
more opts
mcy Mar 25, 2026
559c317
Merge remote-tracking branch 'origin/main' into mcy/benchmarks
mcy Mar 25, 2026
9cfad5e
fix
mcy Mar 25, 2026
284a826
lint
mcy Mar 25, 2026
79909e3
add benchmarks to ci
mcy Mar 25, 2026
a79ddaf
hide googleapis in benchmark from public api
mcy Mar 25, 2026
0dbd05f
oops
mcy Mar 25, 2026
a729153
bytes = 0
mcy Mar 27, 2026
7489f35
lint
mcy Mar 27, 2026
4950a0f
check in googleapis test data
mcy Mar 27, 2026
7e81b87
check-it-in
mcy Mar 27, 2026
776a422
cf
mcy Mar 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ clean: ## Delete intermediate build artifacts
test: build ## Run unit tests
$(GO) test -race -cover ./...
$(GO) test -tags protolegacy ./...
cd internal/benchmarks && SKIP_DOWNLOAD_GOOGLEAPIS=true $(GO) test -race -cover ./...

.PHONY: benchmarks
benchmarks: build ## Run benchmarks
$(GO) test -bench -benchmem -v ./experimental/benchmark
cd internal/benchmarks && $(GO) test -bench=. -benchmem -v ./...

.PHONY: build
Expand Down
4 changes: 2 additions & 2 deletions experimental/ast/commas.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ func (c commas[T, _]) AppendComma(value T, comma token.Token) {
}

func (c commas[T, _]) InsertComma(n int, value T, comma token.Token) {
c.file.Nodes().panicIfNotOurs(comma)
c.file.Nodes().panicIfNotOurs(comma.Context())
v := c.SliceInserter.Unwrap(n, value)
v.Comma = comma.ID()

*c.Slice = slices.Insert(*c.Slice, n, v)
}

func (c commas[T, _]) SetComma(n int, comma token.Token) {
c.file.Nodes().panicIfNotOurs(comma)
c.file.Nodes().panicIfNotOurs(comma.Context())
(*c.SliceInserter.Slice)[n].Comma = comma.ID()
}
30 changes: 18 additions & 12 deletions experimental/ast/decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,24 @@ func (d DeclAny) AsRange() DeclRange {

// Span implements [source.Spanner].
func (d DeclAny) Span() source.Span {
// At most one of the below will produce a non-zero decl, and that will be
// the span selected by source.Join. If all of them are zero, this produces
// the zero span.
return source.Join(
d.AsEmpty(),
d.AsSyntax(),
d.AsPackage(),
d.AsImport(),
d.AsDef(),
d.AsBody(),
d.AsRange(),
)
switch d.Kind() {
case DeclKindBody:
return d.AsBody().Span()
case DeclKindDef:
return d.AsDef().Span()
case DeclKindEmpty:
return d.AsEmpty().Span()
case DeclKindImport:
return d.AsImport().Span()
case DeclKindPackage:
return d.AsPackage().Span()
case DeclKindRange:
return d.AsRange().Span()
case DeclKindSyntax:
return d.AsSyntax().Span()
default:
return source.Span{}
}
}

func (DeclKind) DecodeDynID(lo, _ int32) DeclKind {
Expand Down
2 changes: 1 addition & 1 deletion experimental/ast/decl_body.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (d DeclBody) Decls() seq.Inserter[DeclAny] {
return id.WrapDyn(d.Context(), id.NewDyn(k, p))
},
func(_ int, d DeclAny) (DeclKind, id.ID[DeclAny]) {
d.Context().Nodes().panicIfNotOurs(d)
d.Context().Nodes().panicIfNotOurs(d.Context())
return d.ID().Kind(), d.ID().Value()
},
)
Expand Down
18 changes: 9 additions & 9 deletions experimental/ast/decl_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,15 +520,15 @@ func (d DeclDef) Span() source.Span {
return source.Span{}
}

return source.Join(
d.Type(),
d.Name(),
d.Signature(),
d.Equals(),
d.Value(),
d.Options(),
d.Body(),
d.Semicolon(),
return source.JoinSpans(
d.Type().Span(),
d.Name().Span(),
d.Signature().Span(),
d.Equals().Span(),
d.Value().Span(),
d.Options().Span(),
d.Body().Span(),
d.Semicolon().Span(),
)
}

Expand Down
2 changes: 1 addition & 1 deletion experimental/ast/decl_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func (d DeclImport) ModifierTokens() seq.Inserter[token.Token] {
return seq.NewSliceInserter(&d.Raw().modifiers,
func(_ int, e token.ID) token.Token { return id.Wrap(d.Context().Stream(), e) },
func(_ int, t token.Token) token.ID {
d.Context().Nodes().panicIfNotOurs(t)
d.Context().Nodes().panicIfNotOurs(t.Context())
return t.ID()
},
)
Expand Down
2 changes: 1 addition & 1 deletion experimental/ast/decl_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (d DeclRange) Ranges() Commas[ExprAny] {
return id.WrapDyn(d.Context(), c.Value)
},
func(_ int, e ExprAny) withComma[id.Dyn[ExprAny, ExprKind]] {
d.Context().Nodes().panicIfNotOurs(e)
d.Context().Nodes().panicIfNotOurs(e.Context())
return withComma[id.Dyn[ExprAny, ExprKind]]{Value: e.ID()}
},
),
Expand Down
32 changes: 20 additions & 12 deletions experimental/ast/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,26 @@ func (e ExprAny) AsField() ExprField {

// Span implements [source.Spanner].
func (e ExprAny) Span() source.Span {
// At most one of the below will produce a non-nil type, and that will be
// the span selected by source.Join. If all of them are nil, this produces
// the nil span.
return source.Join(
e.AsLiteral(),
e.AsPath(),
e.AsPrefixed(),
e.AsRange(),
e.AsArray(),
e.AsDict(),
e.AsField(),
)
switch e.Kind() {
case ExprKindArray:
return e.AsArray().Span()
case ExprKindDict:
return e.AsDict().Span()
case ExprKindError:
return e.AsError().Span()
case ExprKindField:
return e.AsField().Span()
case ExprKindLiteral:
return e.AsLiteral().Span()
case ExprKindPath:
return e.AsPath().Span()
case ExprKindPrefixed:
return e.AsPrefixed().Span()
case ExprKindRange:
return e.AsRange().Span()
default:
return source.Span{}
}
}

// ExprError represents an unrecoverable parsing error in an expression context.
Expand Down
2 changes: 1 addition & 1 deletion experimental/ast/expr_array.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (e ExprArray) Elements() Commas[ExprAny] {
return id.WrapDyn(e.Context(), c.Value)
},
func(_ int, e ExprAny) withComma[id.Dyn[ExprAny, ExprKind]] {
e.Context().Nodes().panicIfNotOurs(e)
e.Context().Nodes().panicIfNotOurs(e.Context())
return withComma[id.Dyn[ExprAny, ExprKind]]{Value: e.ID()}
},
),
Expand Down
2 changes: 1 addition & 1 deletion experimental/ast/expr_dict.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (e ExprDict) Elements() Commas[ExprField] {
return id.Wrap(e.Context(), c.Value)
},
func(_ int, e ExprField) withComma[id.ID[ExprField]] {
e.Context().Nodes().panicIfNotOurs(e)
e.Context().Nodes().panicIfNotOurs(e.Context())
return withComma[id.ID[ExprField]]{Value: e.ID()}
},
),
Expand Down
Loading
Loading