vcc: Repurpose (struct proc).called and add info to struct vcl_sub

The .called attribute was not used.

We now increment it only for custom subs which are actually called
statically (with "call"), that is, not for the builtin subs. This is
to simplify and clarify the use case in the next commits.

The increment happens for each VCC walk of the SUBs.

We also add the number of symbolic references and calls to (struct
vcl_sub) of the VGC to facilitate reviews and debugging.
parent e0bca94e
......@@ -92,4 +92,6 @@ struct vcl_sub {
const struct VCL_conf *vcl_conf;
vcl_func_f *func;
unsigned n;
unsigned nref;
unsigned called;
};
......@@ -176,6 +176,7 @@ vcc_EmitProc(struct vcc *tl, struct proc *p)
AZ(VSB_finish(p->cname));
AZ(VSB_finish(p->prologue));
AZ(VSB_finish(p->body));
AN(p->sym);
Fh(tl, 1, "vcl_func_f %s;\n", VSB_data(p->cname));
Fh(tl, 1, "const struct vcl_sub sub_%s[1] = {{\n",
......@@ -185,7 +186,9 @@ vcc_EmitProc(struct vcc *tl, struct proc *p)
Fh(tl, 1, "\t.name\t\t= \"%.*s\",\n", PF(p->name));
Fh(tl, 1, "\t.vcl_conf\t= &VCL_conf,\n");
Fh(tl, 1, "\t.func\t\t= %s,\n", VSB_data(p->cname));
Fh(tl, 1, "\t.n\t\t= %d\n", tl->nsub++);
Fh(tl, 1, "\t.n\t\t= %d,\n", tl->nsub++);
Fh(tl, 1, "\t.nref\t\t= %d,\n", p->sym->nref);
Fh(tl, 1, "\t.called\t\t= %d\n", p->called);
Fh(tl, 1, "}};\n");
/*
* TODO: v_dont_optimize for custom subs called from vcl_init/fini only
......
......@@ -203,6 +203,7 @@ vcc_CheckActionRecurse(struct vcc *tl, struct proc *p, unsigned bitmap)
vcc_ErrWhere(tl, pc->t);
return (1);
}
pc->sym->proc->called++;
if (vcc_CheckActionRecurse(tl, pc->sym->proc, bitmap)) {
VSB_printf(tl->sb, "\n...called from \"%.*s\"\n",
PF(p->name));
......@@ -212,7 +213,6 @@ vcc_CheckActionRecurse(struct vcc *tl, struct proc *p, unsigned bitmap)
p->okmask &= pc->sym->proc->okmask;
}
p->active = 0;
p->called++;
return (0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment