vm: more use of ctx->replace().