Skip to content

Commit

Permalink
Rename maxvals -> maxcells
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Jan 17, 2023
1 parent 06651a5 commit a49e8c6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ frame_enter(struct exec_context *ctx, struct instance *inst, uint32_t funcidx,
* As we've copied "params" above, now it's safe to resize
* stack.
*/
ret = stack_prealloc(ctx, ei->maxvals);
ret = stack_prealloc(ctx, ei->maxcells);
if (ret != 0) {
return ret;
}
#else
const bool params_on_stack = params == &VEC_NEXTELEM(ctx->stack);

ret = stack_prealloc(ctx, nlocals + ei->maxvals);
ret = stack_prealloc(ctx, nlocals + ei->maxcells);
if (ret != 0) {
return ret;
}
Expand All @@ -311,8 +311,8 @@ frame_enter(struct exec_context *ctx, struct instance *inst, uint32_t funcidx,
#endif
cells_zero(locals + nparams, nlocals - nparams);

xlog_trace_insn("frame enter: maxlabels %u maxvals %u", ei->maxlabels,
ei->maxvals);
xlog_trace_insn("frame enter: maxlabels %u maxcells %u", ei->maxlabels,
ei->maxcells);
uint32_t i;
for (i = 0; i < nlocals; i++) {
if (i == nparams) {
Expand All @@ -335,7 +335,7 @@ frame_enter(struct exec_context *ctx, struct instance *inst, uint32_t funcidx,
assert(ctx->locals.lsize + nlocals <= ctx->locals.psize);
ctx->locals.lsize += nlocals;
#else
assert(ctx->stack.lsize + nlocals + ei->maxvals <= ctx->stack.psize);
assert(ctx->stack.lsize + nlocals + ei->maxcells <= ctx->stack.psize);
ctx->stack.lsize += nlocals;
#endif
set_current_frame(ctx, frame, ei);
Expand Down
4 changes: 2 additions & 2 deletions lib/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ read_expr_common(const uint8_t **pp, const uint8_t *ep, struct expr *expr,
*pp = p;
expr->end = p;
xlog_trace("code size %zu, jump table size %zu, max labels %" PRIu32
", vals %" PRIu32,
", cells %" PRIu32,
expr->end - expr->start, ei->njumps * sizeof(*ei->jumps),
ei->maxlabels, ei->maxvals);
ei->maxlabels, ei->maxcells);
validation_context_clear(vctx);
return 0;
fail:
Expand Down
2 changes: 1 addition & 1 deletion lib/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct expr_exec_info {
struct jump *jumps;

uint32_t maxlabels; /* max labels (including the implicit one) */
uint32_t maxvals; /* max vals on stack */
uint32_t maxcells; /* max cells on stack */

#if defined(TOYWASM_USE_SMALL_CELLS)
/*
Expand Down
4 changes: 2 additions & 2 deletions lib/validation.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ push_valtype(enum valtype type, struct validation_context *ctx)
const struct ctrlframe *cframe = &ctx->cframes[ctx->ncframes - 1];
if (!cframe->unreachable) {
ctx->ncells += valtype_cellsize(type);
if (ctx->ncells > ctx->ei->maxvals) {
ctx->ei->maxvals = ctx->ncells;
if (ctx->ncells > ctx->ei->maxcells) {
ctx->ei->maxcells = ctx->ncells;
}
}
return 0;
Expand Down

0 comments on commit a49e8c6

Please sign in to comment.