Skip to content

Commit

Permalink
vm_push_frame: move assertions out of the function
Browse files Browse the repository at this point in the history
These assertions are purely static.  Ned not be checked on-the-fly.
  • Loading branch information
shyouhei committed Jul 10, 2020
1 parent 1d93705 commit 4b8170c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions vm_insnhelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ vm_push_frame_debug_counter_inc(
#define vm_push_frame_debug_counter_inc(ec, cfp, t) /* void */
#endif

STATIC_ASSERT(VM_ENV_DATA_INDEX_ME_CREF, VM_ENV_DATA_INDEX_ME_CREF == -2);
STATIC_ASSERT(VM_ENV_DATA_INDEX_SPECVAL, VM_ENV_DATA_INDEX_SPECVAL == -1);
STATIC_ASSERT(VM_ENV_DATA_INDEX_FLAGS, VM_ENV_DATA_INDEX_FLAGS == -0);

static void
vm_push_frame(rb_execution_context_t *ec,
const rb_iseq_t *iseq,
Expand Down Expand Up @@ -364,9 +368,6 @@ vm_push_frame(rb_execution_context_t *ec,
}

/* setup ep with managing data */
VM_ASSERT(VM_ENV_DATA_INDEX_ME_CREF == -2);
VM_ASSERT(VM_ENV_DATA_INDEX_SPECVAL == -1);
VM_ASSERT(VM_ENV_DATA_INDEX_FLAGS == -0);
*sp++ = cref_or_me; /* ep[-2] / Qnil or T_IMEMO(cref) or T_IMEMO(ment) */
*sp++ = specval /* ep[-1] / block handler or prev env ptr */;
*sp = type; /* ep[-0] / ENV_FLAGS */
Expand Down

0 comments on commit 4b8170c

Please sign in to comment.