From 957182fde7e499a55b5e2de3b93afaf26f7c216b Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 9 Feb 2019 11:15:56 +1100 Subject: [PATCH] Re-arrange coro_susp_point's and coro stacks --- cmd/wuffs-c/internal/cgen/cgen.go | 29 ++++++++++++++++------ release/c/wuffs-unsupported-snapshot.c | 33 +++++++++++++++----------- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/cmd/wuffs-c/internal/cgen/cgen.go b/cmd/wuffs-c/internal/cgen/cgen.go index bddb69be..902f3d57 100644 --- a/cmd/wuffs-c/internal/cgen/cgen.go +++ b/cmd/wuffs-c/internal/cgen/cgen.go @@ -747,6 +747,28 @@ func (g *gen) writeStructPrivateImpl(b *buffer, n *a.Struct) error { } if n.Classy() { + // TODO: allow max depth > 1 for recursive coroutines. + const maxDepth = 1 + + b.writeb('\n') + for _, file := range g.files { + for _, tld := range file.TopLevelDecls() { + if tld.Kind() != a.KFunc { + continue + } + o := tld.AsFunc() + if o.Receiver() != n.QID() || !o.Effect().Coroutine() { + continue + } + k := g.funks[o.QQID()] + if k.coroSuspPoint == 0 { + continue + } + + b.printf("uint32_t %s%s[%d];\n", pPrefix, o.FuncName().Str(g.tm), maxDepth) + } + } + b.writeb('\n') for _, file := range g.files { for _, tld := range file.TopLevelDecls() { @@ -762,13 +784,6 @@ func (g *gen) writeStructPrivateImpl(b *buffer, n *a.Struct) error { continue } - // TODO: allow max depth > 1 for recursive coroutines. - const maxDepth = 1 - - if k.coroSuspPoint != 0 { - b.printf("uint32_t %s%s[%d];\n", pPrefix, o.FuncName().Str(g.tm), maxDepth) - } - oldLenB0 := len(*b) b.writes("struct {\n") oldLenB1 := len(*b) diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 4f3d28f7..0076cd55 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -2708,15 +2708,17 @@ struct wuffs_deflate__decoder__struct { uint32_t p_decode_io_writer[1]; uint32_t p_decode_blocks[1]; + uint32_t p_decode_uncompressed[1]; + uint32_t p_init_dynamic_huffman[1]; + uint32_t p_decode_huffman_slow[1]; + struct { uint32_t v_final; } s_decode_blocks[1]; - uint32_t p_decode_uncompressed[1]; struct { uint32_t v_length; uint64_t scratch; } s_decode_uncompressed[1]; - uint32_t p_init_dynamic_huffman[1]; struct { uint32_t v_bits; uint32_t v_n_bits; @@ -2730,7 +2732,6 @@ struct wuffs_deflate__decoder__struct { uint8_t v_rep_symbol; uint32_t v_rep_count; } s_init_dynamic_huffman[1]; - uint32_t p_decode_huffman_slow[1]; struct { uint32_t v_bits; uint32_t v_n_bits; @@ -2901,6 +2902,7 @@ struct wuffs_lzw__decoder__struct { uint32_t p_decode_io_writer[1]; uint32_t p_write_to[1]; + } private_impl; #else // WUFFS_IMPLEMENTATION @@ -3110,50 +3112,51 @@ struct wuffs_gif__decoder__struct { uint32_t p_decode_image_config[1]; uint32_t p_decode_frame_config[1]; uint32_t p_skip_frame[1]; - struct { - uint64_t scratch; - } s_skip_frame[1]; uint32_t p_decode_frame[1]; uint32_t p_decode_up_to_id_part1[1]; uint32_t p_decode_header[1]; + uint32_t p_decode_lsd[1]; + uint32_t p_decode_extension[1]; + uint32_t p_skip_blocks[1]; + uint32_t p_decode_ae[1]; + uint32_t p_decode_gc[1]; + uint32_t p_decode_id_part0[1]; + uint32_t p_decode_id_part1[1]; + uint32_t p_decode_id_part2[1]; + + struct { + uint64_t scratch; + } s_skip_frame[1]; struct { uint8_t v_c[6]; uint32_t v_i; } s_decode_header[1]; - uint32_t p_decode_lsd[1]; struct { uint8_t v_flags; uint32_t v_num_palette_entries; uint32_t v_i; uint64_t scratch; } s_decode_lsd[1]; - uint32_t p_decode_extension[1]; - uint32_t p_skip_blocks[1]; struct { uint64_t scratch; } s_skip_blocks[1]; - uint32_t p_decode_ae[1]; struct { uint8_t v_block_size; bool v_not_animexts; bool v_not_netscape; uint64_t scratch; } s_decode_ae[1]; - uint32_t p_decode_gc[1]; struct { uint64_t scratch; } s_decode_gc[1]; - uint32_t p_decode_id_part0[1]; struct { uint64_t scratch; } s_decode_id_part0[1]; - uint32_t p_decode_id_part1[1]; struct { uint32_t v_num_palette_entries; uint32_t v_i; uint64_t scratch; } s_decode_id_part1[1]; - uint32_t p_decode_id_part2[1]; struct { uint64_t v_block_size; bool v_need_block_size; @@ -3339,6 +3342,7 @@ struct wuffs_gzip__decoder__struct { wuffs_deflate__decoder f_flate; uint32_t p_decode_io_writer[1]; + struct { uint8_t v_flags; uint32_t v_checksum_got; @@ -3491,6 +3495,7 @@ struct wuffs_zlib__decoder__struct { wuffs_deflate__decoder f_flate; uint32_t p_decode_io_writer[1]; + struct { uint32_t v_checksum_got; uint64_t scratch;