Remove short_read_src cgen code path

This commit is contained in:
Nigel Tao committed 2018-08-04 09:45:35 +10:00
1 parent eca5565821
commit f2ee78aa2a
4 files changed
+124 -148

No files matched your search

+3 -4
View File
@@ -429,8 +429,8 @@ func (g *gen) writeBuiltinCallSuspendibles(b *buffer, n *a.Expr, depth uint32) e
temp := g.currFunk.tempW
g.currFunk.tempW++
b.printf("if (WUFFS_BASE__UNLIKELY(ioptr_src == iobounds1_src)) { goto short_read_src; }")
g.currFunk.shortReads = append(g.currFunk.shortReads, "src")
b.printf("if (WUFFS_BASE__UNLIKELY(ioptr_src == iobounds1_src)) {" +
"status = WUFFS_BASE__SUSPENSION_SHORT_READ; goto suspend; }")
// TODO: watch for passing an array type to writeCTypeName? In C, an
// array type can decay into a pointer.
@@ -491,8 +491,7 @@ func (g *gen) writeBuiltinCallSuspendibles(b *buffer, n *a.Expr, depth uint32) e
b.printf("%s -= iobounds1_src - ioptr_src;\n", scratchName)
b.printf("ioptr_src = iobounds1_src;\n")
b.writes("goto short_read_src; }\n")
g.currFunk.shortReads = append(g.currFunk.shortReads, "src")
b.writes("status = WUFFS_BASE__SUSPENSION_SHORT_READ; goto suspend; }\n")
b.printf("ioptr_src += %s;\n", scratchName)
return nil
}
-14
View File
@@ -41,7 +41,6 @@ type funk struct {
suspendible bool // TODO: rename to coroutine.
usesScratch bool
hasGotoOK bool
shortReads []string
}
func (k *funk) jumpTarget(n a.Loop) (uint32, error) {
@@ -344,19 +343,6 @@ func (g *gen) writeFuncImplFooter(b *buffer) error {
b.writes("self->private_impl.status = status;\n")
}
b.writes("return status;\n\n")
shortReadsSeen := map[string]struct{}{}
for _, sr := range g.currFunk.shortReads {
if _, ok := shortReadsSeen[sr]; ok {
continue
}
shortReadsSeen[sr] = struct{}{}
if err := template_short_read(b, template_args_short_read{
name: sr,
}); err != nil {
return err
}
}
}
return nil
}
+3 -3
View File
@@ -570,9 +570,9 @@ func (g *gen) writeReadUXX(b *buffer, n *a.Expr, name string, size uint32, endia
}
b.printf("while (true) {")
b.printf("if (WUFFS_BASE__UNLIKELY(ioptr_%s == iobounds1_%s)) { goto short_read_%s; }",
name, name, name)
g.currFunk.shortReads = append(g.currFunk.shortReads, name)
b.printf("if (WUFFS_BASE__UNLIKELY(ioptr_%s == iobounds1_%s)) {"+
"status = WUFFS_BASE__SUSPENSION_SHORT_READ; goto suspend; }",
name, name)
b.printf("uint64_t *scratch = &%s;", scratchName)
b.printf("uint32_t %s%d = *scratch", tPrefix, temp0)