From 5f10bd634fb6ae8f74a4ea730176233b0ca96954 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 23 Mar 2022 15:19:48 -0400 Subject: Add ISEQ_BODY macro Use ISEQ_BODY macro to get the rb_iseq_constant_body of the ISeq. Using this macro will make it easier for us to change the allocation strategy of rb_iseq_constant_body when using Variable Width Allocation. --- iseq.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'iseq.h') diff --git a/iseq.h b/iseq.h index fc61d03b76..f90b0be7ab 100644 --- a/iseq.h +++ b/iseq.h @@ -28,35 +28,35 @@ typedef struct rb_iseq_struct rb_iseq_t; extern const ID rb_iseq_shared_exc_local_tbl[]; -#define ISEQ_COVERAGE(iseq) iseq->body->variable.coverage -#define ISEQ_COVERAGE_SET(iseq, cov) RB_OBJ_WRITE(iseq, &iseq->body->variable.coverage, cov) +#define ISEQ_COVERAGE(iseq) ISEQ_BODY(iseq)->variable.coverage +#define ISEQ_COVERAGE_SET(iseq, cov) RB_OBJ_WRITE(iseq, &ISEQ_BODY(iseq)->variable.coverage, cov) #define ISEQ_LINE_COVERAGE(iseq) RARRAY_AREF(ISEQ_COVERAGE(iseq), COVERAGE_INDEX_LINES) #define ISEQ_BRANCH_COVERAGE(iseq) RARRAY_AREF(ISEQ_COVERAGE(iseq), COVERAGE_INDEX_BRANCHES) -#define ISEQ_PC2BRANCHINDEX(iseq) iseq->body->variable.pc2branchindex -#define ISEQ_PC2BRANCHINDEX_SET(iseq, h) RB_OBJ_WRITE(iseq, &iseq->body->variable.pc2branchindex, h) +#define ISEQ_PC2BRANCHINDEX(iseq) ISEQ_BODY(iseq)->variable.pc2branchindex +#define ISEQ_PC2BRANCHINDEX_SET(iseq, h) RB_OBJ_WRITE(iseq, &ISEQ_BODY(iseq)->variable.pc2branchindex, h) -#define ISEQ_FLIP_CNT(iseq) (iseq)->body->variable.flip_count +#define ISEQ_FLIP_CNT(iseq) ISEQ_BODY(iseq)->variable.flip_count static inline rb_snum_t ISEQ_FLIP_CNT_INCREMENT(const rb_iseq_t *iseq) { - rb_snum_t cnt = iseq->body->variable.flip_count; - iseq->body->variable.flip_count += 1; + rb_snum_t cnt = ISEQ_BODY(iseq)->variable.flip_count; + ISEQ_BODY(iseq)->variable.flip_count += 1; return cnt; } static inline VALUE * ISEQ_ORIGINAL_ISEQ(const rb_iseq_t *iseq) { - return iseq->body->variable.original_iseq; + return ISEQ_BODY(iseq)->variable.original_iseq; } static inline void ISEQ_ORIGINAL_ISEQ_CLEAR(const rb_iseq_t *iseq) { - void *ptr = iseq->body->variable.original_iseq; - iseq->body->variable.original_iseq = NULL; + void *ptr = ISEQ_BODY(iseq)->variable.original_iseq; + ISEQ_BODY(iseq)->variable.original_iseq = NULL; if (ptr) { ruby_xfree(ptr); } @@ -65,7 +65,7 @@ ISEQ_ORIGINAL_ISEQ_CLEAR(const rb_iseq_t *iseq) static inline VALUE * ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size) { - return iseq->body->variable.original_iseq = + return ISEQ_BODY(iseq)->variable.original_iseq = ALLOC_N(VALUE, size); } -- cgit v1.2.1