From afae410b0dd7c4c181e9cc3f1e3dc1fd5e5ce216 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Thu, 15 Oct 2020 11:56:28 -0400 Subject: [PATCH] Implement OP_JUMP_FWD to jump forward --- ext/liquid_c/block.c | 2 +- ext/liquid_c/vm.c | 4 ++-- ext/liquid_c/vm_assembler.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/liquid_c/block.c b/ext/liquid_c/block.c index 9a8e5c93..ec2de30c 100644 --- a/ext/liquid_c/block.c +++ b/ext/liquid_c/block.c @@ -280,7 +280,7 @@ static VALUE block_body_remove_blank_strings(VALUE self) while (*ip != OP_LEAVE) { if (*ip == OP_WRITE_RAW) { if (ip[1] || ip[2] || ip[3]) { // if (size != 0) - ip[0] = OP_WRITE_RAW_SKIP; // effectively a no-op + ip[0] = OP_JUMP_FWD; // effectively a no-op body->render_score--; } } diff --git a/ext/liquid_c/vm.c b/ext/liquid_c/vm.c index 20615683..12ed6649 100644 --- a/ext/liquid_c/vm.c +++ b/ext/liquid_c/vm.c @@ -286,7 +286,7 @@ static VALUE vm_render_until_error(VALUE uncast_args) ip += 3 + size; break; } - case OP_WRITE_RAW_SKIP: + case OP_JUMP_FWD: { size_t size = bytes_to_uint24(ip); ip += 3 + size; @@ -355,7 +355,7 @@ void liquid_vm_next_instruction(const uint8_t **ip_ptr, const size_t **const_ptr break; case OP_WRITE_RAW: - case OP_WRITE_RAW_SKIP: + case OP_JUMP_FWD: { size_t size = bytes_to_uint24(ip); ip += 3 + size; diff --git a/ext/liquid_c/vm_assembler.h b/ext/liquid_c/vm_assembler.h index 1112c91a..48421ad2 100644 --- a/ext/liquid_c/vm_assembler.h +++ b/ext/liquid_c/vm_assembler.h @@ -10,13 +10,13 @@ enum opcode { OP_LEAVE = 0, OP_WRITE_RAW = 1, OP_WRITE_NODE = 2, - OP_WRITE_RAW_SKIP, OP_POP_WRITE_VARIABLE, OP_PUSH_CONST, OP_HASH_NEW, // rb_hash_new & rb_hash_bulk_insert OP_FILTER, OP_PUSH_EVAL_EXPR, OP_RENDER_VARIABLE_RESCUE, // setup state to rescue variable rendering + OP_JUMP_FWD, }; typedef struct vm_assembler {