13#include "internal/gc.h"
17#define ISEQ_MAJOR_VERSION ((unsigned int)ruby_api_version[0])
18#define ISEQ_MINOR_VERSION ((unsigned int)ruby_api_version[1])
20#define ISEQ_MBITS_SIZE sizeof(iseq_bits_t)
21#define ISEQ_MBITS_BITLENGTH (ISEQ_MBITS_SIZE * CHAR_BIT)
22#define ISEQ_MBITS_SET(buf, i) (buf[(i) / ISEQ_MBITS_BITLENGTH] |= ((iseq_bits_t)1 << ((i) % ISEQ_MBITS_BITLENGTH)))
23#define ISEQ_MBITS_SET_P(buf, i) ((buf[(i) / ISEQ_MBITS_BITLENGTH] >> ((i) % ISEQ_MBITS_BITLENGTH)) & 0x1)
24#define ISEQ_MBITS_BUFLEN(size) roomof(size, ISEQ_MBITS_BITLENGTH)
26#ifndef USE_ISEQ_NODE_ID
27#define USE_ISEQ_NODE_ID 1
32#define rb_iseq_t rb_iseq_t
34typedef void (*rb_iseq_callback)(
const rb_iseq_t *,
void *);
36extern const ID rb_iseq_shared_exc_local_tbl[];
38#define ISEQ_COVERAGE(iseq) ISEQ_BODY(iseq)->variable.coverage
39#define ISEQ_COVERAGE_SET(iseq, cov) RB_OBJ_WRITE(iseq, &ISEQ_BODY(iseq)->variable.coverage, cov)
40#define ISEQ_LINE_COVERAGE(iseq) RARRAY_AREF(ISEQ_COVERAGE(iseq), COVERAGE_INDEX_LINES)
41#define ISEQ_BRANCH_COVERAGE(iseq) RARRAY_AREF(ISEQ_COVERAGE(iseq), COVERAGE_INDEX_BRANCHES)
43#define ISEQ_PC2BRANCHINDEX(iseq) ISEQ_BODY(iseq)->variable.pc2branchindex
44#define ISEQ_PC2BRANCHINDEX_SET(iseq, h) RB_OBJ_WRITE(iseq, &ISEQ_BODY(iseq)->variable.pc2branchindex, h)
46#define ISEQ_FLIP_CNT(iseq) ISEQ_BODY(iseq)->variable.flip_count
48static inline rb_snum_t
49ISEQ_FLIP_CNT_INCREMENT(
const rb_iseq_t *iseq)
51 rb_snum_t cnt = ISEQ_BODY(iseq)->variable.flip_count;
52 ISEQ_BODY(iseq)->variable.flip_count += 1;
59 return ISEQ_BODY(iseq)->variable.original_iseq;
63ISEQ_ORIGINAL_ISEQ_CLEAR(
const rb_iseq_t *iseq)
65 void *ptr = ISEQ_BODY(iseq)->variable.original_iseq;
66 ISEQ_BODY(iseq)->variable.original_iseq = NULL;
73ISEQ_ORIGINAL_ISEQ_ALLOC(
const rb_iseq_t *iseq,
long size)
75 return ISEQ_BODY(iseq)->variable.original_iseq =
79#define ISEQ_TRACE_EVENTS (RUBY_EVENT_LINE | \
85 RUBY_EVENT_C_RETURN| \
87 RUBY_EVENT_B_RETURN| \
88 RUBY_EVENT_COVERAGE_LINE| \
89 RUBY_EVENT_COVERAGE_BRANCH)
91#define ISEQ_NOT_LOADED_YET IMEMO_FL_USER1
92#define ISEQ_USE_COMPILE_DATA IMEMO_FL_USER2
93#define ISEQ_TRANSLATED IMEMO_FL_USER3
95#define ISEQ_EXECUTABLE_P(iseq) (FL_TEST_RAW(((VALUE)iseq), ISEQ_NOT_LOADED_YET | ISEQ_USE_COMPILE_DATA) == 0)
100 const VALUE catch_table_ary;
122 unsigned int ci_index;
123 unsigned int ic_index;
127 const NODE *root_node;
136 if (iseq->flags & ISEQ_USE_COMPILE_DATA) {
137 return iseq->aux.compile_data;
148 iseq->flags |= ISEQ_USE_COMPILE_DATA;
154 iseq->flags &= ~ISEQ_USE_COMPILE_DATA;
155 iseq->aux.compile_data = NULL;
159iseq_imemo_alloc(
void)
161 return (
rb_iseq_t *)rb_imemo_new(imemo_iseq, 0, 0, 0, 0);
165void rb_ibf_load_iseq_complete(
rb_iseq_t *iseq);
167const rb_iseq_t *rb_iseq_ibf_load_bytes(
const char *cstr,
size_t);
170int rb_iseq_add_local_tracepoint_recursively(
const rb_iseq_t *iseq,
rb_event_flag_t turnon_events,
VALUE tpval,
unsigned int target_line,
bool target_bmethod);
171int rb_iseq_remove_local_tracepoint_recursively(
const rb_iseq_t *iseq,
VALUE tpval);
174#if VM_INSN_INFO_TABLE_IMPL == 2
178int rb_vm_insn_addr2opcode(
const void *addr);
180RUBY_SYMBOL_EXPORT_BEGIN
193unsigned int rb_iseq_line_no(
const rb_iseq_t *iseq,
size_t pos);
194#ifdef USE_ISEQ_NODE_ID
195int rb_iseq_node_id(
const rb_iseq_t *iseq,
size_t pos);
199void rb_iseq_insns_info_encode_positions(
const rb_iseq_t *iseq);
206int rb_iseq_from_eval_p(
const rb_iseq_t *iseq);
212void rb_iseq_code_location(
const rb_iseq_t *iseq,
int *first_lineno,
int *first_column,
int *last_lineno,
int *last_column);
214void rb_iseq_remove_coverage_all(
void);
221 unsigned int inline_const_cache: 1;
222 unsigned int peephole_optimization: 1;
223 unsigned int tailcall_optimization: 1;
224 unsigned int specialized_instruction: 1;
225 unsigned int operands_unification: 1;
226 unsigned int instructions_unification: 1;
227 unsigned int stack_caching: 1;
228 unsigned int frozen_string_literal: 1;
229 unsigned int debug_frozen_string_literal: 1;
230 unsigned int coverage_enabled: 1;
236#ifdef USE_ISEQ_NODE_ID
239 rb_event_flag_t events;
255 CATCH_TYPE_RESCUE =
INT2FIX(1),
256 CATCH_TYPE_ENSURE =
INT2FIX(2),
264 enum rb_catch_type type;
279iseq_catch_table_bytes(
int n)
283 catch_table_entries_max = (INT_MAX - offsetof(
struct iseq_catch_table, entries)) / catch_table_entry_size
285 if (n > catch_table_entries_max)
rb_fatal(
"too large iseq_catch_table - %d", n);
287 n * catch_table_entry_size);
290#define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
296 char buff[FLEX_ARY_LEN];
322VALUE rb_iseq_defined_string(
enum defined_type
type);
327RUBY_SYMBOL_EXPORT_END
#define RUBY_EXTERN
Declaration of externally visible global variables.
uint32_t rb_event_flag_t
Represents event(s).
#define INT2FIX
Old name of RB_INT2FIX.
#define ZALLOC
Old name of RB_ZALLOC.
#define ALLOC_N
Old name of RB_ALLOC_N.
void rb_fatal(const char *fmt,...)
Raises the unsung "fatal" exception.
const int ruby_api_version[3]
API versions, in { major, minor, teeny } order.
VALUE type(ANYARGS)
ANYARGS-ed function type.
uintptr_t VALUE
Type that represents a Ruby object.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.