211 Commits

Author SHA1 Message Date
Andrew Kelley
84df1d4f3d stage2 parser: elide memcpy of large initialization lists
throughput: 71.4 MiB/s => 72.9 MiB/s
2020-05-20 22:41:18 -04:00
Andrew Kelley
897f23f20f stage2 parser: split off some SuffixOp AST nodes into separate tags
These SuffixOp nodes have their own ast.Node tags now:
 * ArrayInitializer
 * ArrayInitializerDot
 * StructInitializer
 * StructInitializerDot

Their sub-expression lists are general-purpose-allocator allocated
and then copied into the arena after completion of parsing.

throughput: 72.9 MiB/s => 74.4 MiB/s
maxrss: 68 KB => 72 KB

The API is also nicer since the sub expression lists are now flat arrays
instead of singly linked lists.
2020-05-20 19:18:14 -04:00
Andrew Kelley
7c2c0e36f8 stage2 parser: different memory layout of ParamDecl
Instead of being its own node, it's a struct inside FnProto.
Instead of FnProto having a SinglyLinkedList of ParamDecl nodes,
ParamDecls are appended directly in memory after the FnProto.

throughput: 72.2 MiB/s => 72.9 MiB/s
maxrss: 70 KB => 68 KB

Importantly, the API is improved as well since the data is arranged
linearly in memory.
2020-05-20 17:39:54 -04:00
Andrew Kelley
64c149ca19 fields and decls: ArrayList appending, memcpy to ast arena
This makes fields and decl ast nodes part of the Root and ContainerDecl
AST nodes.

Surprisingly, it's a performance regression from using a singly-linked
list for these nodes:

throughput: 76.5 MiB/s => 69.4 MiB/s

However it has much better memory usage:

maxrss: 392 KB => 77 KB

It's also better API for consumers of the parser, since it is a flat
list in memory.
2020-05-20 16:13:02 -04:00
Andrew Kelley
4617c5907a fix zig fmt test regressions 2020-05-20 00:19:00 -04:00
Andrew Kelley
93384f7428 use singly linked lists for std.zig.parse
std.ast uses a singly linked list for lists of things. This is a
breaking change to the self-hosted parser API.

std.ast.Tree has been separated into a private "Parser" type which
represents in-progress parsing, and std.ast.Tree which has only
"output" data. This means cleaner, but breaking, API for parse results.
Specifically, `tokens` and `errors` are no longer SegmentedList but a
slice.

The way to iterate over AST nodes has necessarily changed since lists of
nodes are now singly linked lists rather than SegmentedList.

From these changes, I observe the following on the
self-hosted-parser benchmark from ziglang/gotta-go-fast:

throughput: 45.6 MiB/s => 55.6 MiB/s
maxrss: 359 KB => 342 KB

This commit breaks the build; more updates are necessary to fix API
usage of the self-hosted parser.
2020-05-19 21:22:52 -04:00
Vexu
28d449b38d
fix zig fmt regression 2020-05-17 15:13:19 +03:00
Vexu
081ffe24cf
fix infinite loop with invalid comptime 2020-05-16 19:23:59 +03:00
Vexu
a05011d403
move ParamType to Node.ParamDecl 2020-05-16 12:54:51 +03:00
Vexu
ed62081d38
recover from missing semicolon after if stmt 2020-05-16 12:29:01 +03:00
Vexu
6ca0def499
recover from invalid global error set access 2020-05-16 12:09:34 +03:00
Vexu
b2f16d4484
fix infinite loop with mismatced bracket 2020-05-15 23:50:47 +03:00
Vexu
a00fd6e254
properly handle extra closing braces at top level 2020-05-15 14:30:49 +03:00
Vexu
440189a04a
cleanup* remove unecessary error* properly handle ReturnTypeInvalid in ast.zig functions* assert that the tree is clean in render.zig* simplify parser recovery with top level decls 2020-05-15 11:35:37 +03:00
Vexu
c77fee0344
fix infinite loop
findToken wasn't as generic as I thought it was
2020-05-14 19:56:55 +03:00
Vexu
c4552ee8ed
store rparen in ReturnType.Invalid
This is useful for getting a partial function signature
2020-05-14 17:18:14 +03:00
Vexu
a32e240540
improve recovery from invalid container members
Instead of trying to find the end of the block or the next comma/semicolon
we no try to find the next token that can start a container member.
2020-05-14 12:09:40 +03:00
Vexu
89f2923a8a
recover from missing semicolon 2020-05-14 11:19:50 +03:00
Vexu
ac319b2734
remove useless nosuspend parsing
nosuspend cannot be used in a type expression and
all other use casesare covered by PrimaryExpr
2020-05-14 11:19:14 +03:00
Vexu
c3b76d0913
recover from invalid builtin/async call 2020-05-14 00:16:56 +03:00
Vexu
1f81887a78
recover after invalid inline/extern 2020-05-13 23:35:58 +03:00
Vexu
ad71d959d7
correctly recover from invalid top level declarations 2020-05-13 23:28:04 +03:00
Vexu
23c5ff94e9
improve recovery on top level declarations 2020-05-13 20:42:18 +03:00
Vexu
cefc04348e
continue parsing on invalid and token 2020-05-13 17:36:06 +03:00
Vexu
be392777b7
continue parsing after missing commas and invalid statements 2020-05-13 17:21:27 +03:00
Vexu
91358f3092
continue parsing on extra qualifier errors 2020-05-13 16:51:23 +03:00
Vexu
df22c7dfef
std.zig attempt to continue parsing on error 2020-05-12 22:37:39 +03:00
Tadeo Kondrak
d0e996405b
add zig fmt fix for async/extern fn 2020-05-05 09:37:59 -06:00
Tadeo Kondrak
7ada59f873
remove nakedcc/stdcallcc/async fn/extern fn fnproto 2020-05-05 09:37:28 -06:00
Tadeo Kondrak
8d5636ebe4
Rename noasync to nosuspend in self-hosted, add rewriter 2020-05-05 05:17:33 -06:00
Vexu
b6fe839248
update std lib to decls being disallowed between fields 2020-04-18 23:56:05 +03:00
LemonBoy
128e70ff3a ir: Allow errdefer with payload
Closes #1265
2020-03-21 09:54:49 +01:00
Vexu
57f9f07558
use anon literals in ast.zig and parse.zig 2020-03-15 01:11:58 +02:00
Vexu
5e5dee829d
remove .Cancel correct merge err set parsing 2020-03-15 01:02:33 +02:00
Vexu
03c1431f9c
disallow resume and suspend in noasync scopes 2020-03-09 15:51:51 +02:00
Vexu
6f8d732599
update parsers to new noasync syntax 2020-03-09 12:23:30 +02:00
Andrew Kelley
cb3a818699
zig fmt: support noasync await 2020-02-16 01:44:52 -05:00
Vexu
0ea96c11ef disallow multiline strings in test and library names 2020-01-15 14:20:48 -05:00
Vexu
af2ede4d96 fix crash on multiline library name 2020-01-14 13:10:52 -05:00
xackus
5880eb3a75 stage2 parser: document undefined and clean up 2020-01-10 22:48:51 +01:00
xackus
f81529fab1 stage2 parser: fix segfault on extern block 2020-01-10 22:35:41 +01:00
LemonBoy
563d9ebfe5 Implement the callconv() annotation 2020-01-02 18:53:16 +01:00
Andrew Kelley
28dbdba37e
Merge pull request #3935 from Vexu/translate-c-2
Translate-c-2 the rest
2019-12-22 16:12:56 -05:00
Andrew Kelley
290dc5d95b
zig fmt support for slice sentinel syntax 2019-12-21 14:03:36 -05:00
Vexu
d172a7335c
translate-c-2 copy parametrs to stack 2019-12-20 00:12:08 +02:00
Vexu
61482be153
translate-c-2 improve macro fn ptr caller 2019-12-19 20:58:48 +02:00
Vexu
f837c7c9cd
translate-c-2 compound assign 2019-12-19 16:13:28 +02:00
Vexu
1a967db083
add default initializers to all ast.Node base values 2019-12-14 20:40:56 +02:00
Andrew Kelley
64d700bfa6
zig fmt: support comptime fields 2019-12-08 12:26:20 -05:00
Vexu
10cc8cad86
fix zig fmt of c pointers 2019-12-05 14:50:46 +02:00