mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 08:47:28 +01:00
Move cgen's sub-structs to private_data
name old speed new speed delta wuffs_gif_decode_1k_bw/clang5 243MB/s ± 1% 243MB/s ± 1% ~ (p=0.101 n=47+48) wuffs_gif_decode_1k_color/clang5 142MB/s ± 1% 142MB/s ± 1% +0.36% (p=0.000 n=48+47) wuffs_gif_decode_10k_bgra/clang5 734MB/s ± 1% 728MB/s ± 1% -0.78% (p=0.000 n=46+50) wuffs_gif_decode_10k_indexed/clang5 197MB/s ± 0% 196MB/s ± 1% -0.52% (p=0.000 n=47+46) wuffs_gif_decode_20k/clang5 250MB/s ± 1% 249MB/s ± 1% ~ (p=0.189 n=49+46) wuffs_gif_decode_100k_artificial/clang5 556MB/s ± 1% 555MB/s ± 1% -0.23% (p=0.000 n=46+44) wuffs_gif_decode_100k_realistic/clang5 229MB/s ± 1% 229MB/s ± 0% ~ (p=0.055 n=48+48) wuffs_gif_decode_1000k/clang5 233MB/s ± 1% 234MB/s ± 0% +0.30% (p=0.000 n=48+45) wuffs_gif_decode_anim_screencap/clang5 1.11GB/s ± 1% 1.10GB/s ± 0% -0.28% (p=0.000 n=46+47) wuffs_gif_decode_1k_bw/gcc7 257MB/s ± 2% 263MB/s ± 1% +2.67% (p=0.000 n=49+47) wuffs_gif_decode_1k_color/gcc7 142MB/s ± 1% 146MB/s ± 1% +3.25% (p=0.000 n=50+49) wuffs_gif_decode_10k_bgra/gcc7 627MB/s ± 1% 625MB/s ± 1% -0.35% (p=0.000 n=48+49) wuffs_gif_decode_10k_indexed/gcc7 197MB/s ± 1% 196MB/s ± 1% -0.21% (p=0.000 n=48+43) wuffs_gif_decode_20k/gcc7 239MB/s ± 0% 239MB/s ± 1% +0.21% (p=0.000 n=50+47) wuffs_gif_decode_100k_artificial/gcc7 511MB/s ± 0% 512MB/s ± 1% +0.21% (p=0.000 n=49+44) wuffs_gif_decode_100k_realistic/gcc7 211MB/s ± 0% 212MB/s ± 1% +0.39% (p=0.000 n=45+44) wuffs_gif_decode_1000k/gcc7 215MB/s ± 0% 216MB/s ± 1% +0.13% (p=0.002 n=46+48) wuffs_gif_decode_anim_screencap/gcc7 1.06GB/s ± 1% 1.06GB/s ± 1% +0.12% (p=0.007 n=45+48) wuffs_lzw_decode_20k/clang5 271MB/s ± 1% 270MB/s ± 1% -0.34% (p=0.000 n=49+49) wuffs_lzw_decode_100k/clang5 480MB/s ± 1% 478MB/s ± 1% -0.31% (p=0.001 n=48+50) wuffs_lzw_decode_20k/gcc7 263MB/s ± 1% 264MB/s ± 1% +0.38% (p=0.000 n=45+47) wuffs_lzw_decode_100k/gcc7 476MB/s ± 1% 482MB/s ± 2% +1.30% (p=0.000 n=47+50)
This commit is contained in:
1 parent
664c47fe3c
commit
0ab52c6204
6 files changed
+88
-38
No files matched your search
@@ -321,11 +321,12 @@ type gen struct {
|
||||
// generated C code (due to line numbers changing) when editing Wuffs code.
|
||||
genlinenum bool
|
||||
|
||||
scalarConstsMap map[t.QID]*a.Const
|
||||
statusList []status
|
||||
statusMap map[t.QID]status
|
||||
structList []*a.Struct
|
||||
structMap map[t.QID]*a.Struct
|
||||
privateDataFields map[t.QQID]struct{}
|
||||
scalarConstsMap map[t.QID]*a.Const
|
||||
statusList []status
|
||||
statusMap map[t.QID]status
|
||||
structList []*a.Struct
|
||||
structMap map[t.QID]*a.Struct
|
||||
|
||||
currFunk funk
|
||||
funks map[t.QQID]funk
|
||||
@@ -374,8 +375,16 @@ func (g *gen) generate() ([]byte, error) {
|
||||
return nil, fmt.Errorf("cyclical struct definitions")
|
||||
}
|
||||
g.structMap = map[t.QID]*a.Struct{}
|
||||
g.privateDataFields = map[t.QQID]struct{}{}
|
||||
for _, n := range g.structList {
|
||||
g.structMap[n.QID()] = n
|
||||
qid := n.QID()
|
||||
g.structMap[qid] = n
|
||||
for _, f := range n.Fields() {
|
||||
f := f.AsField()
|
||||
if f.PrivateData() {
|
||||
g.privateDataFields[t.QQID{qid[0], qid[1], f.Name()}] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g.funks = map[t.QQID]funk{}
|
||||
@@ -745,7 +754,7 @@ func (g *gen) writeStructPrivateImpl(b *buffer, n *a.Struct) error {
|
||||
|
||||
for _, o := range n.Fields() {
|
||||
o := o.AsField()
|
||||
if o.XType().Eq(typeExprUtility) {
|
||||
if o.PrivateData() || o.XType().Eq(typeExprUtility) {
|
||||
continue
|
||||
}
|
||||
if err := g.writeCTypeName(b, o.XType(), fPrefix, o.Name().Str(g.tm)); err != nil {
|
||||
@@ -782,6 +791,20 @@ func (g *gen) writeStructPrivateImpl(b *buffer, n *a.Struct) error {
|
||||
b.writes("struct {\n")
|
||||
oldOuterLenB1 := len(*b)
|
||||
|
||||
for _, o := range n.Fields() {
|
||||
o := o.AsField()
|
||||
if !o.PrivateData() || o.XType().Eq(typeExprUtility) {
|
||||
continue
|
||||
}
|
||||
if err := g.writeCTypeName(b, o.XType(), fPrefix, o.Name().Str(g.tm)); err != nil {
|
||||
return err
|
||||
}
|
||||
b.writes(";\n")
|
||||
}
|
||||
if oldOuterLenB1 != len(*b) {
|
||||
b.writeb('\n')
|
||||
}
|
||||
|
||||
for _, file := range g.files {
|
||||
for _, tld := range file.TopLevelDecls() {
|
||||
if tld.Kind() != a.KFunc {
|
||||
@@ -1011,7 +1034,7 @@ func (g *gen) writeInitializerImpl(b *buffer, n *a.Struct) error {
|
||||
|
||||
b.printf("{\n")
|
||||
b.printf("wuffs_base__status z = %s%s__initialize("+
|
||||
"&self->private_impl.%s%s, sizeof(self->private_impl.%s%s), WUFFS_VERSION, initialize_flags);\n",
|
||||
"&self->private_data.%s%s, sizeof(self->private_data.%s%s), WUFFS_VERSION, initialize_flags);\n",
|
||||
prefix, qid[1].Str(g.tm), fPrefix, f.Name().Str(g.tm), fPrefix, f.Name().Str(g.tm))
|
||||
b.printf("if (z) { return z; }\n")
|
||||
b.printf("}\n")
|
||||
|
||||
@@ -217,13 +217,29 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, depth uint32) error {
|
||||
} else {
|
||||
b.writes(".")
|
||||
}
|
||||
b.writes("private_impl." + fPrefix)
|
||||
|
||||
b.writes(g.privateImplData(lhs.MType(), n.Ident()))
|
||||
b.writeb('.')
|
||||
b.writes(fPrefix)
|
||||
b.writes(n.Ident().Str(g.tm))
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unrecognized token (0x%X) for writeExprOther", n.Operator())
|
||||
}
|
||||
|
||||
func (g *gen) privateImplData(typ *a.TypeExpr, fieldName t.ID) string {
|
||||
if p := typ.Decorator(); p == t.IDNptr || p == t.IDPtr {
|
||||
typ = typ.Inner()
|
||||
}
|
||||
if s := g.structMap[typ.QID()]; s != nil {
|
||||
qid := s.QID()
|
||||
if _, ok := g.privateDataFields[t.QQID{qid[0], qid[1], fieldName}]; ok {
|
||||
return "private_data"
|
||||
}
|
||||
}
|
||||
return "private_impl"
|
||||
}
|
||||
|
||||
func (g *gen) writeExprUnaryOp(b *buffer, n *a.Expr, depth uint32) error {
|
||||
op := n.Operator()
|
||||
opName := cOpName(op)
|
||||
|
||||
Reference in new issue
Block a user