Skip to content

Commit

Permalink
Implement OP_JUMP_FWD to jump forward
Browse files Browse the repository at this point in the history
  • Loading branch information
peterzhu2118 committed Oct 15, 2020
1 parent 3f36c75 commit afae410
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ext/liquid_c/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -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--;
}
}
Expand Down
4 changes: 2 additions & 2 deletions ext/liquid_c/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ext/liquid_c/vm_assembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit afae410

Please sign in to comment.