Don't suspend/resume unnecessary local variables

name                                    old speed      new speed      delta

wuffs_adler32_10k/clang                 2.42GB/s ± 1%  2.41GB/s ± 0%  -0.43%  (p=0.000 n=49+10)
wuffs_adler32_100k/clang                2.42GB/s ± 1%  2.41GB/s ± 1%  -0.56%  (p=0.000 n=48+10)

wuffs_adler32_10k/gcc                   3.22GB/s ± 1%  3.21GB/s ± 0%  -0.35%  (p=0.000 n=48+10)
wuffs_adler32_100k/gcc                  3.22GB/s ± 0%  3.20GB/s ± 0%  -0.69%  (p=0.000 n=48+10)

wuffs_crc32_ieee_10k/clang              2.86GB/s ± 0%  2.85GB/s ± 0%  -0.44%  (p=0.000 n=48+9)
wuffs_crc32_ieee_100k/clang             2.88GB/s ± 1%  2.87GB/s ± 0%  -0.45%  (p=0.000 n=49+10)

wuffs_crc32_ieee_10k/gcc                3.35GB/s ± 1%  3.35GB/s ± 0%    ~     (p=0.094 n=48+9)
wuffs_crc32_ieee_100k/gcc               3.38GB/s ± 1%  3.38GB/s ± 1%    ~     (p=0.371 n=45+10)

wuffs_deflate_decode_1k/clang            147MB/s ± 1%   137MB/s ± 1%  -6.84%  (p=0.000 n=50+10)
wuffs_deflate_decode_10k/clang           241MB/s ± 0%   227MB/s ± 0%  -5.74%  (p=0.000 n=48+9)
wuffs_deflate_decode_100k/clang          269MB/s ± 0%   258MB/s ± 0%  -3.92%  (p=0.000 n=49+9)

wuffs_deflate_decode_1k/gcc              159MB/s ± 0%   161MB/s ± 1%  +1.51%  (p=0.000 n=49+10)
wuffs_deflate_decode_10k/gcc             269MB/s ± 0%   276MB/s ± 0%  +2.51%  (p=0.000 n=49+10)
wuffs_deflate_decode_100k/gcc            320MB/s ± 0%   316MB/s ± 0%  -1.29%  (p=0.000 n=46+10)

wuffs_gif_decode_1k_bw/clang             252MB/s ± 1%   264MB/s ± 0%  +4.56%  (p=0.000 n=49+10)
wuffs_gif_decode_1k_color/clang          127MB/s ± 1%   122MB/s ± 1%  -3.84%  (p=0.000 n=47+10)
wuffs_gif_decode_10k/clang               152MB/s ± 0%   148MB/s ± 0%  -3.12%  (p=0.000 n=47+9)
wuffs_gif_decode_100k_artificial/clang   431MB/s ± 0%   443MB/s ± 1%  +2.95%  (p=0.000 n=42+10)
wuffs_gif_decode_100k_realistic/clang    170MB/s ± 0%   173MB/s ± 0%  +1.39%  (p=0.000 n=48+10)
wuffs_gif_decode_1000k/clang             172MB/s ± 0%   174MB/s ± 0%  +1.27%  (p=0.000 n=48+10)
wuffs_gif_decode_anim_screencap/clang    917MB/s ± 1%   949MB/s ± 0%  +3.44%  (p=0.000 n=47+9)

wuffs_gif_decode_1k_bw/gcc               265MB/s ± 1%   278MB/s ± 2%  +4.87%  (p=0.000 n=48+10)
wuffs_gif_decode_1k_color/gcc            135MB/s ± 0%   140MB/s ± 2%  +4.10%  (p=0.000 n=46+10)
wuffs_gif_decode_10k/gcc                 157MB/s ± 1%   166MB/s ± 0%  +5.84%  (p=0.000 n=48+8)
wuffs_gif_decode_100k_artificial/gcc     446MB/s ± 1%   459MB/s ± 1%  +2.89%  (p=0.000 n=48+10)
wuffs_gif_decode_100k_realistic/gcc      176MB/s ± 0%   186MB/s ± 2%  +5.82%  (p=0.000 n=46+10)
wuffs_gif_decode_1000k/gcc               178MB/s ± 0%   189MB/s ± 1%  +6.11%  (p=0.000 n=45+9)
wuffs_gif_decode_anim_screencap/gcc      962MB/s ± 1%   989MB/s ± 1%  +2.83%  (p=0.000 n=48+9)

wuffs_gzip_decode_10k/clang              212MB/s ± 0%   208MB/s ± 0%  -1.67%  (p=0.000 n=47+10)
wuffs_gzip_decode_100k/clang             240MB/s ± 0%   236MB/s ± 0%  -1.68%  (p=0.000 n=47+10)

wuffs_gzip_decode_10k/gcc                252MB/s ± 0%   246MB/s ± 0%  -2.41%  (p=0.000 n=47+10)
wuffs_gzip_decode_100k/gcc               290MB/s ± 0%   288MB/s ± 0%  -0.70%  (p=0.000 n=44+10)

wuffs_lzw_decode_20k/clang               202MB/s ± 0%   202MB/s ± 0%    ~     (p=0.069 n=48+8)
wuffs_lzw_decode_100k/clang              332MB/s ± 1%   334MB/s ± 1%  +0.54%  (p=0.000 n=46+10)

wuffs_lzw_decode_20k/gcc                 215MB/s ± 1%   223MB/s ± 0%  +3.60%  (p=0.000 n=49+9)
wuffs_lzw_decode_100k/gcc                361MB/s ± 1%   368MB/s ± 0%  +2.05%  (p=0.000 n=47+10)

wuffs_zlib_decode_10k/clang              218MB/s ± 0%   206MB/s ± 0%  -5.53%  (p=0.000 n=48+9)
wuffs_zlib_decode_100k/clang             244MB/s ± 0%   234MB/s ± 0%  -4.14%  (p=0.000 n=45+10)

wuffs_zlib_decode_10k/gcc                252MB/s ± 0%   252MB/s ± 0%    ~     (p=0.960 n=49+10)
wuffs_zlib_decode_100k/gcc               290MB/s ± 0%   292MB/s ± 0%  +0.52%  (p=0.000 n=49+10)
This commit is contained in:
Nigel Tao committed 2018-11-10 17:04:40 +11:00
1 parent 808d5c1e6c
commit 6ebe99ced9
6 files changed
+507 -125

No files matched your search

+1 -1
View File
@@ -689,7 +689,7 @@ func (g *gen) writeStruct(b *buffer, n *a.Struct) error {
b.writes("struct {\n")
if k.coroSuspPoint != 0 {
b.writes("uint32_t coro_susp_point;\n")
if err := g.writeVars(b, o.Body(), true, true); err != nil {
if err := g.writeVars(b, &k, true, true, true); err != nil {
return err
}
}
+10 -4
View File
@@ -31,6 +31,8 @@ type funk struct {
astFunc *a.Func
cName string
varList []*a.Var
varResumables map[t.ID]bool
derivedVars map[t.ID]struct{}
jumpTargets map[a.Loop]uint32
coroSuspPoint uint32
@@ -180,6 +182,10 @@ func (g *gen) gatherFuncImpl(_ *buffer, n *a.Func) error {
suspendible: n.Effect().Coroutine(),
}
if err := g.findVars(); err != nil {
return err
}
if err := g.writeFuncImplHeader(&g.currFunk.bHeader); err != nil {
return err
}
@@ -259,7 +265,7 @@ func (g *gen) writeFuncImplHeader(b *buffer) error {
b.writes("\n")
// Generate the local variables.
if err := g.writeVars(b, g.currFunk.astFunc.Body(), false, true); err != nil {
if err := g.writeVars(b, &g.currFunk, false, true, false); err != nil {
return err
}
b.writes("\n")
@@ -283,11 +289,11 @@ func (g *gen) writeFuncImplBodyResume(b *buffer) error {
b.printf("uint32_t coro_susp_point = self->private_impl.%s%s[0].coro_susp_point;\n",
cPrefix, g.currFunk.astFunc.FuncName().Str(g.tm))
b.printf("if (coro_susp_point) {\n")
if err := g.writeResumeSuspend(b, g.currFunk.astFunc.Body(), false, false); err != nil {
if err := g.writeResumeSuspend(b, &g.currFunk, false, false); err != nil {
return err
}
b.writes("} else {\n")
if err := g.writeResumeSuspend(b, g.currFunk.astFunc.Body(), false, true); err != nil {
if err := g.writeResumeSuspend(b, &g.currFunk, false, true); err != nil {
return err
}
b.writes("}\n")
@@ -323,7 +329,7 @@ func (g *gen) writeFuncImplBodySuspend(b *buffer) error {
b.printf("self->private_impl.%s%s[0].coro_susp_point = coro_susp_point;\n",
cPrefix, g.currFunk.astFunc.FuncName().Str(g.tm))
if err := g.writeResumeSuspend(b, g.currFunk.astFunc.Body(), true, false); err != nil {
if err := g.writeResumeSuspend(b, &g.currFunk, true, false); err != nil {
return err
}
b.writes("\n")
+427
View File
@@ -0,0 +1,427 @@
// Copyright 2018 The Wuffs Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package cgen
import (
"fmt"
a "github.com/google/wuffs/lang/ast"
t "github.com/google/wuffs/lang/token"
)
type subExprFilter uint32
const (
subExprFilterNone = subExprFilter(0)
subExprFilterBeforeCoroutine = subExprFilter(1)
subExprFilterDuringCoroutine = subExprFilter(2)
subExprFilterAfterCoroutine = subExprFilter(3)
)
type resumability uint32
const (
resumabilityNone = resumability(0)
resumabilityWeak = resumability(1)
resumabilityStrong = resumability(2)
)
type resumabilities []resumability
func (r resumabilities) clone() resumabilities {
return append(resumabilities(nil), r...)
}
func (r resumabilities) merge(s resumabilities) (changed bool) {
if len(r) != len(s) {
panic("resumabilities have different length")
}
for i := range r {
if r[i] < s[i] {
r[i] = s[i]
changed = true
}
}
return changed
}
func (r resumabilities) lowerWeakToNone(i int) {
if r[i] == resumabilityWeak {
r[i] = resumabilityNone
}
}
func (r resumabilities) raiseWeakToStrong(i int) {
if r[i] == resumabilityWeak {
r[i] = resumabilityStrong
}
}
func (r resumabilities) raiseNoneToWeak() {
for i, x := range r {
if x == resumabilityNone {
r[i] = resumabilityWeak
}
}
}
type loopResumable struct {
before resumabilities
after resumabilities
changed bool
}
type resumabilityHelper struct {
tm *t.Map
vars map[t.ID]int
loops map[a.Loop]*loopResumable
}
func (g *gen) findVars() error {
h := resumabilityHelper{
tm: g.tm,
vars: map[t.ID]int{},
loops: map[a.Loop]*loopResumable{},
}
f := g.currFunk.astFunc
if err := g.visitVars(nil, f.Body(), 0, func(g *gen, b *buffer, n *a.Var) error {
name := n.Name()
if _, ok := h.vars[name]; !ok {
g.currFunk.varList = append(g.currFunk.varList, n)
h.vars[name] = len(h.vars)
}
return nil
}); err != nil {
return err
}
if f.Effect().Coroutine() {
r := make(resumabilities, len(h.vars))
if err := h.doBlock(r, f.Body(), 0); err != nil {
return err
}
g.currFunk.varResumables = map[t.ID]bool{}
for i, v := range g.currFunk.varList {
g.currFunk.varResumables[v.Name()] = r[i] == resumabilityStrong
}
}
return nil
}
func (h *resumabilityHelper) doBlock(r resumabilities, block []*a.Node, depth uint32) error {
if depth > a.MaxBodyDepth {
return fmt.Errorf("body recursion depth too large")
}
depth++
loop:
for _, o := range block {
switch o.Kind() {
case a.KAssign:
if err := h.doAssign(r, o.AsAssign(), depth); err != nil {
return err
}
case a.KExpr:
if err := h.doExpr(r, o.AsExpr()); err != nil {
return err
}
case a.KIOBind:
if err := h.doIOBind(r, o.AsIOBind(), depth); err != nil {
return err
}
case a.KIf:
if err := h.doIf(r, o.AsIf(), depth); err != nil {
return err
}
case a.KIterate:
if err := h.doIterate(r, o.AsIterate(), depth); err != nil {
return err
}
case a.KJump:
if err := h.doJump(r, o.AsJump(), depth); err != nil {
return err
}
break loop
case a.KRet:
if err := h.doRet(r, o.AsRet(), depth); err != nil {
return err
}
if o.AsRet().Keyword() == t.IDReturn {
break loop
}
case a.KVar:
if err := h.doVar(r, o.AsVar(), depth); err != nil {
return err
}
case a.KWhile:
if err := h.doWhile(r, o.AsWhile(), depth); err != nil {
return err
}
}
}
return nil
}
func (h *resumabilityHelper) doAssign(r resumabilities, n *a.Assign, depth uint32) error {
if err := h.doExpr(r, n.RHS()); err != nil {
return err
}
// If the LHS is not a local variable (e.g. "this.foo[bar] = etc", or if
// the LHS is implicitly also on the RHS (e.g. for a += or *= operator),
// walk the LHS Expr.
if n.LHS().Operator() != 0 || n.Operator() != t.IDEq {
if err := h.doExpr(r, n.LHS()); err != nil {
return err
}
}
// If the LHS is just a local variable, then call lowerWeakToNone.
if lhs := n.LHS(); lhs.Operator() == 0 {
if i, ok := h.vars[lhs.Ident()]; !ok {
return fmt.Errorf("unrecognized variable %q", lhs.Ident().Str(h.tm))
} else {
r.lowerWeakToNone(i)
}
}
return nil
}
func (h *resumabilityHelper) doExpr(r resumabilities, n *a.Expr) error {
if n.Effect()&a.EffectCoroutine == 0 {
return h.doExpr1(r, n, subExprFilterNone, 0)
}
for sef := subExprFilterBeforeCoroutine; sef <= subExprFilterAfterCoroutine; sef++ {
if err := h.doExpr1(r, n, sef, 0); err != nil {
return err
}
}
return nil
}
func (h *resumabilityHelper) doExpr1(r resumabilities, n *a.Expr, sef subExprFilter, depth uint32) error {
if depth > a.MaxBodyDepth {
return fmt.Errorf("body recursion depth too large")
}
depth++
processOnlySubExprs := false
if sef != subExprFilterNone {
const mask = a.EffectCoroutine | a.EffectRootCause
switch sef {
case subExprFilterBeforeCoroutine:
switch n.Effect() & mask {
case a.EffectCoroutine | a.EffectRootCause:
sef = subExprFilterNone
case a.EffectCoroutine:
// No-op.
default:
return nil
}
processOnlySubExprs = true
case subExprFilterDuringCoroutine:
if n.Effect()&mask == mask {
switch n.Operator() {
case t.IDOpenParen:
r.raiseNoneToWeak()
case t.IDTry:
// No-op.
default:
return fmt.Errorf("unrecognized ast.Expr coroutine operator")
}
return nil
}
processOnlySubExprs = true
case subExprFilterAfterCoroutine:
if n.Effect()&mask == mask {
return nil
}
}
}
for _, o := range n.AsNode().AsRaw().SubNodes() {
if o != nil && o.Kind() == a.KExpr {
if err := h.doExpr1(r, o.AsExpr(), sef, depth); err != nil {
return err
}
}
}
for _, o := range n.Args() {
e := (*a.Expr)(nil)
switch o.Kind() {
case a.KArg:
e = o.AsArg().Value()
case a.KExpr:
e = o.AsExpr()
default:
return fmt.Errorf("unrecognized arg kind")
}
if err := h.doExpr1(r, e, sef, depth); err != nil {
return err
}
}
if !processOnlySubExprs && n.Operator() == 0 {
if i, ok := h.vars[n.Ident()]; ok {
r.raiseWeakToStrong(i)
}
}
return nil
}
func (h *resumabilityHelper) doIOBind(r resumabilities, n *a.IOBind, depth uint32) error {
// Ignore the IOBind fields, as they should be I/O types and therefore not
// resumable.
return h.doBlock(r, n.Body(), depth)
}
func (h *resumabilityHelper) doIf(r resumabilities, n *a.If, depth uint32) error {
scratch := make(resumabilities, len(r))
result := make(resumabilities, len(r))
for ; n != nil; n = n.ElseIf() {
if err := h.doExpr(r, n.Condition()); err != nil {
return err
}
copy(scratch, r)
if err := h.doBlock(scratch, n.BodyIfTrue(), depth); err != nil {
return err
}
result.merge(scratch)
copy(scratch, r)
if err := h.doBlock(scratch, n.BodyIfFalse(), depth); err != nil {
return err
}
result.merge(scratch)
}
copy(r, result)
return nil
}
func (h *resumabilityHelper) doIterate(r resumabilities, n *a.Iterate, depth uint32) error {
// TODO: ban jumps, rets and coroutine calls inside an iterate. Also ensure
// that the iterate variable values are all pure expressions.
for _, v := range n.Variables() {
v := v.AsVar()
if err := h.doExpr(r, v.Value()); err != nil {
return err
}
if i, ok := h.vars[v.Name()]; !ok {
return fmt.Errorf("unrecognized variable %q", v.Name().Str(h.tm))
} else {
r.lowerWeakToNone(i)
}
}
return h.doBlock(r, n.Body(), depth)
}
func (h *resumabilityHelper) doJump(r resumabilities, n *a.Jump, depth uint32) error {
l := h.loops[n.JumpTarget()]
switch n.Keyword() {
case t.IDBreak:
l.changed = l.before.merge(r) || l.changed
case t.IDContinue:
l.changed = l.after.merge(r) || l.changed
default:
return fmt.Errorf("unrecognized ast.Jump keyword")
}
return nil
}
func (h *resumabilityHelper) doRet(r resumabilities, n *a.Ret, depth uint32) error {
if n.Value() != nil {
if err := h.doExpr(r, n.Value()); err != nil {
return err
}
}
switch n.Keyword() {
case t.IDReturn:
// No-op.
case t.IDYield:
r.raiseNoneToWeak()
default:
return fmt.Errorf("unrecognized ast.Ret keyword")
}
return nil
}
func (h *resumabilityHelper) doVar(r resumabilities, n *a.Var, depth uint32) error {
if n.Value() != nil {
if err := h.doExpr(r, n.Value()); err != nil {
return err
}
}
name := n.Name()
if i, ok := h.vars[name]; !ok {
return fmt.Errorf("unrecognized variable %q", name.Str(h.tm))
} else {
r.lowerWeakToNone(i)
}
return nil
}
func (h *resumabilityHelper) doWhile(r resumabilities, n *a.While, depth uint32) error {
l := &loopResumable{
before: make(resumabilities, len(r)),
after: make(resumabilities, len(r)),
changed: false,
}
h.loops[n] = l
copy(l.before, r)
if err := h.doExpr(r, n.Condition()); err != nil {
return err
}
copy(l.after, r)
for {
copy(r, l.after)
if err := h.doBlock(r, n.Body(), depth); err != nil {
return err
}
l.changed = l.before.merge(r) || l.changed
copy(r, l.before)
if err := h.doExpr(r, n.Condition()); err != nil {
return err
}
l.changed = l.after.merge(r) || l.changed
if !l.changed {
break
}
l.changed = false
}
copy(r, l.after)
return nil
}
+28 -6
View File
@@ -271,7 +271,7 @@ func (g *gen) visitVars(b *buffer, block []*a.Node, depth uint32, f func(*gen, *
return nil
}
func (g *gen) writeResumeSuspend1(b *buffer, n *a.Var, suspend bool, initBoolTypedVars bool) error {
func (g *gen) writeResumeSuspend1(b *buffer, f *funk, n *a.Var, suspend bool, initBoolTypedVars bool) error {
local := fmt.Sprintf("%s%s", vPrefix, n.Name().Str(g.tm))
if typ := n.XType(); typ.HasPointers() {
@@ -300,6 +300,25 @@ func (g *gen) writeResumeSuspend1(b *buffer, n *a.Var, suspend bool, initBoolTyp
return nil
}
} else if f.varResumables == nil || !f.varResumables[n.Name()] {
if !suspend {
if initBoolTypedVars && typ.QID() == (t.QID{t.IDBase, t.IDBool}) {
b.printf("%s = false;\n", local)
return nil
}
// TODO: drop this (after we stop emitting unnecessary
// WUFFS_BASE__COROUTINE_SUSPENSION_POINT lines); we shouldn't need
// to zero-initialize these variables.
if !initBoolTypedVars {
zero := "0"
if typ.QID() == (t.QID{t.IDBase, t.IDBool}) {
zero = "false"
}
b.printf("%s = %s;\n", local, zero)
}
}
return nil
} else {
lhs := local
rhs := ""
@@ -363,14 +382,14 @@ fail:
n.Name().Str(g.tm), n.XType().Str(g.tm))
}
func (g *gen) writeResumeSuspend(b *buffer, block []*a.Node, suspend bool, initBoolTypedVars bool) error {
return g.visitVars(b, block, 0, func(g *gen, b *buffer, n *a.Var) error {
return g.writeResumeSuspend1(b, n, suspend, initBoolTypedVars)
func (g *gen) writeResumeSuspend(b *buffer, f *funk, suspend bool, initBoolTypedVars bool) error {
return g.visitVars(b, f.astFunc.Body(), 0, func(g *gen, b *buffer, n *a.Var) error {
return g.writeResumeSuspend1(b, f, n, suspend, initBoolTypedVars)
})
}
func (g *gen) writeVars(b *buffer, block []*a.Node, skipPointerTypes bool, skipIterateVariables bool) error {
return g.visitVars(b, block, 0, func(g *gen, b *buffer, n *a.Var) error {
func (g *gen) writeVars(b *buffer, f *funk, skipPointerTypes bool, skipIterateVariables bool, skipNonresumable bool) error {
return g.visitVars(b, f.astFunc.Body(), 0, func(g *gen, b *buffer, n *a.Var) error {
typ := n.XType()
if skipPointerTypes && typ.HasPointers() {
return nil
@@ -378,6 +397,9 @@ func (g *gen) writeVars(b *buffer, block []*a.Node, skipPointerTypes bool, skipI
if skipIterateVariables && n.IterateVariable() {
return nil
}
if skipNonresumable && (f.varResumables == nil || !f.varResumables[n.Name()]) {
return nil
}
name := n.Name().Str(g.tm)
if err := g.writeCTypeName(b, typ, vPrefix, name); err != nil {
return err
+39 -114
View File
@@ -2358,24 +2358,18 @@ struct wuffs_deflate__decoder__struct {
struct {
uint32_t coro_susp_point;
wuffs_base__status v_z;
uint64_t v_n_copied;
uint32_t v_already_full;
} c_decode[1];
struct {
uint32_t coro_susp_point;
uint32_t v_final;
uint32_t v_type;
} c_decode_blocks[1];
struct {
uint32_t coro_susp_point;
uint32_t v_length;
uint32_t v_n_copied;
uint64_t scratch;
} c_decode_uncompressed[1];
struct {
uint32_t coro_susp_point;
uint32_t v_i;
} c_init_fixed_huffman[1];
struct {
uint32_t coro_susp_point;
@@ -2387,7 +2381,6 @@ struct wuffs_deflate__decoder__struct {
uint32_t v_i;
uint32_t v_mask;
uint32_t v_table_entry;
uint32_t v_table_entry_n_bits;
uint32_t v_n_extra_bits;
uint8_t v_rep_symbol;
uint32_t v_rep_count;
@@ -2404,7 +2397,6 @@ struct wuffs_deflate__decoder__struct {
uint32_t v_redir_mask;
uint32_t v_length;
uint32_t v_dist_minus_1;
uint32_t v_n_copied;
uint32_t v_hlen;
uint32_t v_hdist;
} c_decode_huffman_slow[1];
@@ -2510,19 +2502,11 @@ struct wuffs_lzw__decoder__struct {
uint32_t v_j;
uint32_t v_bits;
uint32_t v_n_bits;
uint32_t v_code;
uint16_t v_lm1_a;
uint32_t v_c;
uint32_t v_o;
uint32_t v_steps;
uint8_t v_first_byte;
uint16_t v_lm1_b;
} c_decode[1];
struct {
uint32_t coro_susp_point;
uint32_t v_i;
uint32_t v_j;
uint64_t v_n;
} c_flush[1];
} private_impl;
@@ -2678,16 +2662,12 @@ struct wuffs_gif__decoder__struct {
struct {
uint32_t coro_susp_point;
bool v_ffio;
} c_decode_image_config[1];
struct {
uint32_t coro_susp_point;
uint8_t v_blend;
} c_decode_frame_config[1];
struct {
uint32_t coro_susp_point;
uint8_t v_flags;
uint8_t v_lw;
uint64_t scratch;
} c_skip_frame[1];
struct {
@@ -2695,7 +2675,6 @@ struct wuffs_gif__decoder__struct {
} c_decode_frame[1];
struct {
uint32_t coro_susp_point;
uint8_t v_block_type;
} c_decode_up_to_id_part1[1];
struct {
uint32_t coro_susp_point;
@@ -2707,21 +2686,17 @@ struct wuffs_gif__decoder__struct {
uint8_t v_flags;
uint32_t v_num_palette_entries;
uint32_t v_i;
uint32_t v_argb;
uint64_t scratch;
} c_decode_lsd[1];
struct {
uint32_t coro_susp_point;
uint8_t v_label;
} c_decode_extension[1];
struct {
uint32_t coro_susp_point;
uint8_t v_block_size;
uint64_t scratch;
} c_skip_blocks[1];
struct {
uint32_t coro_susp_point;
uint8_t v_c;
uint8_t v_block_size;
bool v_not_animexts;
bool v_not_netscape;
@@ -2729,8 +2704,6 @@ struct wuffs_gif__decoder__struct {
} c_decode_ae[1];
struct {
uint32_t coro_susp_point;
uint8_t v_c;
uint8_t v_flags;
uint64_t scratch;
} c_decode_gc[1];
struct {
@@ -2739,11 +2712,8 @@ struct wuffs_gif__decoder__struct {
} c_decode_id_part0[1];
struct {
uint32_t coro_susp_point;
uint8_t v_flags;
uint32_t v_num_palette_entries;
uint32_t v_i;
uint32_t v_argb;
uint8_t v_lw;
uint64_t v_block_size;
wuffs_base__status v_z;
uint64_t scratch;
@@ -2882,14 +2852,10 @@ struct wuffs_gzip__decoder__struct {
struct {
uint32_t coro_susp_point;
uint8_t v_c;
uint8_t v_flags;
uint16_t v_xlen;
uint32_t v_checksum_got;
uint32_t v_decoded_length_got;
wuffs_base__status v_z;
uint32_t v_checksum_want;
uint32_t v_decoded_length_want;
uint64_t scratch;
} c_decode[1];
} private_impl;
@@ -2990,10 +2956,7 @@ struct wuffs_zlib__decoder__struct {
struct {
uint32_t coro_susp_point;
uint16_t v_x;
uint32_t v_checksum_got;
wuffs_base__status v_z;
uint32_t v_checksum_want;
uint64_t scratch;
} c_decode[1];
} private_impl;
@@ -4997,10 +4960,10 @@ wuffs_deflate__decoder__decode(wuffs_deflate__decoder* self,
uint32_t coro_susp_point = self->private_impl.c_decode[0].coro_susp_point;
if (coro_susp_point) {
v_z = self->private_impl.c_decode[0].v_z;
v_z = 0;
v_written = ((wuffs_base__slice_u8){});
v_n_copied = self->private_impl.c_decode[0].v_n_copied;
v_already_full = self->private_impl.c_decode[0].v_already_full;
v_n_copied = 0;
v_already_full = 0;
} else {
v_written = ((wuffs_base__slice_u8){});
}
@@ -5087,9 +5050,6 @@ wuffs_deflate__decoder__decode(wuffs_deflate__decoder* self,
goto suspend;
suspend:
self->private_impl.c_decode[0].coro_susp_point = coro_susp_point;
self->private_impl.c_decode[0].v_z = v_z;
self->private_impl.c_decode[0].v_n_copied = v_n_copied;
self->private_impl.c_decode[0].v_already_full = v_already_full;
goto exit;
exit:
@@ -5136,7 +5096,7 @@ wuffs_deflate__decoder__decode_blocks(wuffs_deflate__decoder* self,
self->private_impl.c_decode_blocks[0].coro_susp_point;
if (coro_susp_point) {
v_final = self->private_impl.c_decode_blocks[0].v_final;
v_type = self->private_impl.c_decode_blocks[0].v_type;
v_type = 0;
} else {
}
switch (coro_susp_point) {
@@ -5250,7 +5210,6 @@ wuffs_deflate__decoder__decode_blocks(wuffs_deflate__decoder* self,
suspend:
self->private_impl.c_decode_blocks[0].coro_susp_point = coro_susp_point;
self->private_impl.c_decode_blocks[0].v_final = v_final;
self->private_impl.c_decode_blocks[0].v_type = v_type;
goto exit;
exit:
@@ -5313,7 +5272,7 @@ wuffs_deflate__decoder__decode_uncompressed(wuffs_deflate__decoder* self,
self->private_impl.c_decode_uncompressed[0].coro_susp_point;
if (coro_susp_point) {
v_length = self->private_impl.c_decode_uncompressed[0].v_length;
v_n_copied = self->private_impl.c_decode_uncompressed[0].v_n_copied;
v_n_copied = 0;
} else {
}
switch (coro_susp_point) {
@@ -5388,7 +5347,6 @@ wuffs_deflate__decoder__decode_uncompressed(wuffs_deflate__decoder* self,
suspend:
self->private_impl.c_decode_uncompressed[0].coro_susp_point = coro_susp_point;
self->private_impl.c_decode_uncompressed[0].v_length = v_length;
self->private_impl.c_decode_uncompressed[0].v_n_copied = v_n_copied;
goto exit;
exit:
@@ -5415,7 +5373,7 @@ wuffs_deflate__decoder__init_fixed_huffman(wuffs_deflate__decoder* self) {
uint32_t coro_susp_point =
self->private_impl.c_init_fixed_huffman[0].coro_susp_point;
if (coro_susp_point) {
v_i = self->private_impl.c_init_fixed_huffman[0].v_i;
v_i = 0;
} else {
}
switch (coro_susp_point) {
@@ -5462,7 +5420,6 @@ wuffs_deflate__decoder__init_fixed_huffman(wuffs_deflate__decoder* self) {
goto suspend;
suspend:
self->private_impl.c_init_fixed_huffman[0].coro_susp_point = coro_susp_point;
self->private_impl.c_init_fixed_huffman[0].v_i = v_i;
goto exit;
exit:
@@ -5517,8 +5474,7 @@ wuffs_deflate__decoder__init_dynamic_huffman(wuffs_deflate__decoder* self,
v_i = self->private_impl.c_init_dynamic_huffman[0].v_i;
v_mask = self->private_impl.c_init_dynamic_huffman[0].v_mask;
v_table_entry = self->private_impl.c_init_dynamic_huffman[0].v_table_entry;
v_table_entry_n_bits =
self->private_impl.c_init_dynamic_huffman[0].v_table_entry_n_bits;
v_table_entry_n_bits = 0;
v_n_extra_bits =
self->private_impl.c_init_dynamic_huffman[0].v_n_extra_bits;
v_rep_symbol = self->private_impl.c_init_dynamic_huffman[0].v_rep_symbol;
@@ -5711,8 +5667,6 @@ suspend:
self->private_impl.c_init_dynamic_huffman[0].v_i = v_i;
self->private_impl.c_init_dynamic_huffman[0].v_mask = v_mask;
self->private_impl.c_init_dynamic_huffman[0].v_table_entry = v_table_entry;
self->private_impl.c_init_dynamic_huffman[0].v_table_entry_n_bits =
v_table_entry_n_bits;
self->private_impl.c_init_dynamic_huffman[0].v_n_extra_bits = v_n_extra_bits;
self->private_impl.c_init_dynamic_huffman[0].v_rep_symbol = v_rep_symbol;
self->private_impl.c_init_dynamic_huffman[0].v_rep_count = v_rep_count;
@@ -6420,7 +6374,7 @@ wuffs_deflate__decoder__decode_huffman_slow(wuffs_deflate__decoder* self,
v_redir_mask = self->private_impl.c_decode_huffman_slow[0].v_redir_mask;
v_length = self->private_impl.c_decode_huffman_slow[0].v_length;
v_dist_minus_1 = self->private_impl.c_decode_huffman_slow[0].v_dist_minus_1;
v_n_copied = self->private_impl.c_decode_huffman_slow[0].v_n_copied;
v_n_copied = 0;
v_hlen = self->private_impl.c_decode_huffman_slow[0].v_hlen;
v_hdist = self->private_impl.c_decode_huffman_slow[0].v_hdist;
} else {
@@ -6760,7 +6714,6 @@ suspend:
self->private_impl.c_decode_huffman_slow[0].v_redir_mask = v_redir_mask;
self->private_impl.c_decode_huffman_slow[0].v_length = v_length;
self->private_impl.c_decode_huffman_slow[0].v_dist_minus_1 = v_dist_minus_1;
self->private_impl.c_decode_huffman_slow[0].v_n_copied = v_n_copied;
self->private_impl.c_decode_huffman_slow[0].v_hlen = v_hlen;
self->private_impl.c_decode_huffman_slow[0].v_hdist = v_hdist;
@@ -6908,13 +6861,13 @@ wuffs_lzw__decoder__decode(wuffs_lzw__decoder* self,
v_j = self->private_impl.c_decode[0].v_j;
v_bits = self->private_impl.c_decode[0].v_bits;
v_n_bits = self->private_impl.c_decode[0].v_n_bits;
v_code = self->private_impl.c_decode[0].v_code;
v_lm1_a = self->private_impl.c_decode[0].v_lm1_a;
v_c = self->private_impl.c_decode[0].v_c;
v_o = self->private_impl.c_decode[0].v_o;
v_steps = self->private_impl.c_decode[0].v_steps;
v_first_byte = self->private_impl.c_decode[0].v_first_byte;
v_lm1_b = self->private_impl.c_decode[0].v_lm1_b;
v_code = 0;
v_lm1_a = 0;
v_c = 0;
v_o = 0;
v_steps = 0;
v_first_byte = 0;
v_lm1_b = 0;
} else {
}
switch (coro_susp_point) {
@@ -7116,13 +7069,6 @@ suspend:
self->private_impl.c_decode[0].v_j = v_j;
self->private_impl.c_decode[0].v_bits = v_bits;
self->private_impl.c_decode[0].v_n_bits = v_n_bits;
self->private_impl.c_decode[0].v_code = v_code;
self->private_impl.c_decode[0].v_lm1_a = v_lm1_a;
self->private_impl.c_decode[0].v_c = v_c;
self->private_impl.c_decode[0].v_o = v_o;
self->private_impl.c_decode[0].v_steps = v_steps;
self->private_impl.c_decode[0].v_first_byte = v_first_byte;
self->private_impl.c_decode[0].v_lm1_b = v_lm1_b;
goto exit;
exit:
@@ -7174,7 +7120,7 @@ wuffs_lzw__decoder__flush(wuffs_lzw__decoder* self,
v_i = self->private_impl.c_flush[0].v_i;
v_j = self->private_impl.c_flush[0].v_j;
v_s = ((wuffs_base__slice_u8){});
v_n = self->private_impl.c_flush[0].v_n;
v_n = 0;
} else {
v_s = ((wuffs_base__slice_u8){});
}
@@ -7215,7 +7161,6 @@ suspend:
self->private_impl.c_flush[0].coro_susp_point = coro_susp_point;
self->private_impl.c_flush[0].v_i = v_i;
self->private_impl.c_flush[0].v_j = v_j;
self->private_impl.c_flush[0].v_n = v_n;
goto exit;
exit:
@@ -7373,7 +7318,7 @@ wuffs_gif__decoder__decode_image_config(wuffs_gif__decoder* self,
uint32_t coro_susp_point =
self->private_impl.c_decode_image_config[0].coro_susp_point;
if (coro_susp_point) {
v_ffio = self->private_impl.c_decode_image_config[0].v_ffio;
v_ffio = false;
} else {
v_ffio = false;
}
@@ -7423,7 +7368,6 @@ wuffs_gif__decoder__decode_image_config(wuffs_gif__decoder* self,
goto suspend;
suspend:
self->private_impl.c_decode_image_config[0].coro_susp_point = coro_susp_point;
self->private_impl.c_decode_image_config[0].v_ffio = v_ffio;
goto exit;
exit:
@@ -7548,7 +7492,7 @@ wuffs_gif__decoder__decode_frame_config(wuffs_gif__decoder* self,
uint32_t coro_susp_point =
self->private_impl.c_decode_frame_config[0].coro_susp_point;
if (coro_susp_point) {
v_blend = self->private_impl.c_decode_frame_config[0].v_blend;
v_blend = 0;
} else {
}
switch (coro_susp_point) {
@@ -7615,7 +7559,6 @@ wuffs_gif__decoder__decode_frame_config(wuffs_gif__decoder* self,
goto suspend;
suspend:
self->private_impl.c_decode_frame_config[0].coro_susp_point = coro_susp_point;
self->private_impl.c_decode_frame_config[0].v_blend = v_blend;
goto exit;
exit:
@@ -7654,8 +7597,8 @@ wuffs_gif__decoder__skip_frame(wuffs_gif__decoder* self,
uint32_t coro_susp_point = self->private_impl.c_skip_frame[0].coro_susp_point;
if (coro_susp_point) {
v_flags = self->private_impl.c_skip_frame[0].v_flags;
v_lw = self->private_impl.c_skip_frame[0].v_lw;
v_flags = 0;
v_lw = 0;
} else {
}
switch (coro_susp_point) {
@@ -7693,6 +7636,8 @@ wuffs_gif__decoder__skip_frame(wuffs_gif__decoder* self,
uint8_t t_1 = *iop_a_src++;
v_lw = t_1;
}
if (v_lw != 0) {
}
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
if (a_src.private_impl.buf) {
a_src.private_impl.buf->meta.ri =
@@ -7719,8 +7664,6 @@ wuffs_gif__decoder__skip_frame(wuffs_gif__decoder* self,
goto suspend;
suspend:
self->private_impl.c_skip_frame[0].coro_susp_point = coro_susp_point;
self->private_impl.c_skip_frame[0].v_flags = v_flags;
self->private_impl.c_skip_frame[0].v_lw = v_lw;
goto exit;
exit:
@@ -7842,7 +7785,7 @@ wuffs_gif__decoder__decode_up_to_id_part1(wuffs_gif__decoder* self,
uint32_t coro_susp_point =
self->private_impl.c_decode_up_to_id_part1[0].coro_susp_point;
if (coro_susp_point) {
v_block_type = self->private_impl.c_decode_up_to_id_part1[0].v_block_type;
v_block_type = 0;
} else {
}
switch (coro_susp_point) {
@@ -7925,7 +7868,6 @@ wuffs_gif__decoder__decode_up_to_id_part1(wuffs_gif__decoder* self,
suspend:
self->private_impl.c_decode_up_to_id_part1[0].coro_susp_point =
coro_susp_point;
self->private_impl.c_decode_up_to_id_part1[0].v_block_type = v_block_type;
goto exit;
exit:
@@ -8051,7 +7993,7 @@ wuffs_gif__decoder__decode_lsd(wuffs_gif__decoder* self,
v_num_palette_entries =
self->private_impl.c_decode_lsd[0].v_num_palette_entries;
v_i = self->private_impl.c_decode_lsd[0].v_i;
v_argb = self->private_impl.c_decode_lsd[0].v_argb;
v_argb = 0;
} else {
}
switch (coro_susp_point) {
@@ -8200,7 +8142,6 @@ suspend:
self->private_impl.c_decode_lsd[0].v_num_palette_entries =
v_num_palette_entries;
self->private_impl.c_decode_lsd[0].v_i = v_i;
self->private_impl.c_decode_lsd[0].v_argb = v_argb;
goto exit;
exit:
@@ -8241,7 +8182,7 @@ wuffs_gif__decoder__decode_extension(wuffs_gif__decoder* self,
uint32_t coro_susp_point =
self->private_impl.c_decode_extension[0].coro_susp_point;
if (coro_susp_point) {
v_label = self->private_impl.c_decode_extension[0].v_label;
v_label = 0;
} else {
}
switch (coro_susp_point) {
@@ -8312,7 +8253,6 @@ wuffs_gif__decoder__decode_extension(wuffs_gif__decoder* self,
goto suspend;
suspend:
self->private_impl.c_decode_extension[0].coro_susp_point = coro_susp_point;
self->private_impl.c_decode_extension[0].v_label = v_label;
goto exit;
exit:
@@ -8353,7 +8293,7 @@ wuffs_gif__decoder__skip_blocks(wuffs_gif__decoder* self,
uint32_t coro_susp_point =
self->private_impl.c_skip_blocks[0].coro_susp_point;
if (coro_susp_point) {
v_block_size = self->private_impl.c_skip_blocks[0].v_block_size;
v_block_size = 0;
} else {
}
switch (coro_susp_point) {
@@ -8395,7 +8335,6 @@ wuffs_gif__decoder__skip_blocks(wuffs_gif__decoder* self,
goto suspend;
suspend:
self->private_impl.c_skip_blocks[0].coro_susp_point = coro_susp_point;
self->private_impl.c_skip_blocks[0].v_block_size = v_block_size;
goto exit;
exit:
@@ -8438,7 +8377,7 @@ wuffs_gif__decoder__decode_ae(wuffs_gif__decoder* self,
uint32_t coro_susp_point = self->private_impl.c_decode_ae[0].coro_susp_point;
if (coro_susp_point) {
v_c = self->private_impl.c_decode_ae[0].v_c;
v_c = 0;
v_block_size = self->private_impl.c_decode_ae[0].v_block_size;
v_not_animexts = self->private_impl.c_decode_ae[0].v_not_animexts;
v_not_netscape = self->private_impl.c_decode_ae[0].v_not_netscape;
@@ -8606,7 +8545,6 @@ wuffs_gif__decoder__decode_ae(wuffs_gif__decoder* self,
goto suspend;
suspend:
self->private_impl.c_decode_ae[0].coro_susp_point = coro_susp_point;
self->private_impl.c_decode_ae[0].v_c = v_c;
self->private_impl.c_decode_ae[0].v_block_size = v_block_size;
self->private_impl.c_decode_ae[0].v_not_animexts = v_not_animexts;
self->private_impl.c_decode_ae[0].v_not_netscape = v_not_netscape;
@@ -8650,8 +8588,8 @@ wuffs_gif__decoder__decode_gc(wuffs_gif__decoder* self,
uint32_t coro_susp_point = self->private_impl.c_decode_gc[0].coro_susp_point;
if (coro_susp_point) {
v_c = self->private_impl.c_decode_gc[0].v_c;
v_flags = self->private_impl.c_decode_gc[0].v_flags;
v_c = 0;
v_flags = 0;
} else {
}
switch (coro_susp_point) {
@@ -8754,8 +8692,6 @@ wuffs_gif__decoder__decode_gc(wuffs_gif__decoder* self,
goto suspend;
suspend:
self->private_impl.c_decode_gc[0].coro_susp_point = coro_susp_point;
self->private_impl.c_decode_gc[0].v_c = v_c;
self->private_impl.c_decode_gc[0].v_flags = v_flags;
goto exit;
exit:
@@ -8989,12 +8925,12 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
uint32_t coro_susp_point =
self->private_impl.c_decode_id_part1[0].coro_susp_point;
if (coro_susp_point) {
v_flags = self->private_impl.c_decode_id_part1[0].v_flags;
v_flags = 0;
v_num_palette_entries =
self->private_impl.c_decode_id_part1[0].v_num_palette_entries;
v_i = self->private_impl.c_decode_id_part1[0].v_i;
v_argb = self->private_impl.c_decode_id_part1[0].v_argb;
v_lw = self->private_impl.c_decode_id_part1[0].v_lw;
v_argb = 0;
v_lw = 0;
v_block_size = self->private_impl.c_decode_id_part1[0].v_block_size;
v_w = ((wuffs_base__io_writer){});
v_z = self->private_impl.c_decode_id_part1[0].v_z;
@@ -9232,12 +9168,9 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
goto suspend;
suspend:
self->private_impl.c_decode_id_part1[0].coro_susp_point = coro_susp_point;
self->private_impl.c_decode_id_part1[0].v_flags = v_flags;
self->private_impl.c_decode_id_part1[0].v_num_palette_entries =
v_num_palette_entries;
self->private_impl.c_decode_id_part1[0].v_i = v_i;
self->private_impl.c_decode_id_part1[0].v_argb = v_argb;
self->private_impl.c_decode_id_part1[0].v_lw = v_lw;
self->private_impl.c_decode_id_part1[0].v_block_size = v_block_size;
self->private_impl.c_decode_id_part1[0].v_z = v_z;
@@ -9507,15 +9440,14 @@ wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self,
uint32_t coro_susp_point = self->private_impl.c_decode[0].coro_susp_point;
if (coro_susp_point) {
v_c = self->private_impl.c_decode[0].v_c;
v_c = 0;
v_flags = self->private_impl.c_decode[0].v_flags;
v_xlen = self->private_impl.c_decode[0].v_xlen;
v_xlen = 0;
v_checksum_got = self->private_impl.c_decode[0].v_checksum_got;
v_decoded_length_got = self->private_impl.c_decode[0].v_decoded_length_got;
v_z = self->private_impl.c_decode[0].v_z;
v_z = 0;
v_checksum_want = self->private_impl.c_decode[0].v_checksum_want;
v_decoded_length_want =
self->private_impl.c_decode[0].v_decoded_length_want;
v_decoded_length_want = 0;
} else {
}
switch (coro_susp_point) {
@@ -9795,14 +9727,10 @@ wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self,
goto suspend;
suspend:
self->private_impl.c_decode[0].coro_susp_point = coro_susp_point;
self->private_impl.c_decode[0].v_c = v_c;
self->private_impl.c_decode[0].v_flags = v_flags;
self->private_impl.c_decode[0].v_xlen = v_xlen;
self->private_impl.c_decode[0].v_checksum_got = v_checksum_got;
self->private_impl.c_decode[0].v_decoded_length_got = v_decoded_length_got;
self->private_impl.c_decode[0].v_z = v_z;
self->private_impl.c_decode[0].v_checksum_want = v_checksum_want;
self->private_impl.c_decode[0].v_decoded_length_want = v_decoded_length_want;
goto exit;
exit:
@@ -9962,10 +9890,10 @@ wuffs_zlib__decoder__decode(wuffs_zlib__decoder* self,
uint32_t coro_susp_point = self->private_impl.c_decode[0].coro_susp_point;
if (coro_susp_point) {
v_x = self->private_impl.c_decode[0].v_x;
v_x = 0;
v_checksum_got = self->private_impl.c_decode[0].v_checksum_got;
v_z = self->private_impl.c_decode[0].v_z;
v_checksum_want = self->private_impl.c_decode[0].v_checksum_want;
v_z = 0;
v_checksum_want = 0;
} else {
}
switch (coro_susp_point) {
@@ -10099,10 +10027,7 @@ wuffs_zlib__decoder__decode(wuffs_zlib__decoder* self,
goto suspend;
suspend:
self->private_impl.c_decode[0].coro_susp_point = coro_susp_point;
self->private_impl.c_decode[0].v_x = v_x;
self->private_impl.c_decode[0].v_checksum_got = v_checksum_got;
self->private_impl.c_decode[0].v_z = v_z;
self->private_impl.c_decode[0].v_checksum_want = v_checksum_want;
goto exit;
exit:
+2
View File
@@ -230,6 +230,8 @@ pri func decoder.skip_frame!??(src base.io_reader) {
args.src.skip!??(n:(3 as base.u32) << (1 + (flags & 0x07)))
}
var lw base.u8 = args.src.read_u8!??()
if lw != 0 { // TODO: delete the lw variable.
}
this.skip_blocks!??(src:args.src)
this.num_decoded_frames_value ~sat+= 1