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#ifndef USE_ISEQ_NODE_ID
21#define USE_ISEQ_NODE_ID 1
26#define rb_iseq_t rb_iseq_t
29extern const ID rb_iseq_shared_exc_local_tbl[];
31#define ISEQ_COVERAGE(iseq) iseq->body->variable.coverage
32#define ISEQ_COVERAGE_SET(iseq, cov) RB_OBJ_WRITE(iseq, &iseq->body->variable.coverage, cov)
33#define ISEQ_LINE_COVERAGE(iseq) RARRAY_AREF(ISEQ_COVERAGE(iseq), COVERAGE_INDEX_LINES)
34#define ISEQ_BRANCH_COVERAGE(iseq) RARRAY_AREF(ISEQ_COVERAGE(iseq), COVERAGE_INDEX_BRANCHES)
36#define ISEQ_PC2BRANCHINDEX(iseq) iseq->body->variable.pc2branchindex
37#define ISEQ_PC2BRANCHINDEX_SET(iseq, h) RB_OBJ_WRITE(iseq, &iseq->body->variable.pc2branchindex, h)
39#define ISEQ_FLIP_CNT(iseq) (iseq)->body->variable.flip_count
41static inline rb_snum_t
42ISEQ_FLIP_CNT_INCREMENT(
const rb_iseq_t *iseq)
44 rb_snum_t cnt = iseq->body->variable.flip_count;
45 iseq->body->variable.flip_count += 1;
52 return iseq->body->variable.original_iseq;
56ISEQ_ORIGINAL_ISEQ_CLEAR(
const rb_iseq_t *iseq)
58 void *ptr = iseq->body->variable.original_iseq;
59 iseq->body->variable.original_iseq = NULL;
66ISEQ_ORIGINAL_ISEQ_ALLOC(
const rb_iseq_t *iseq,
long size)
68 return iseq->body->variable.original_iseq =
72#define ISEQ_TRACE_EVENTS (RUBY_EVENT_LINE | \
78 RUBY_EVENT_C_RETURN| \
80 RUBY_EVENT_B_RETURN| \
81 RUBY_EVENT_COVERAGE_LINE| \
82 RUBY_EVENT_COVERAGE_BRANCH)
84#define ISEQ_NOT_LOADED_YET IMEMO_FL_USER1
85#define ISEQ_USE_COMPILE_DATA IMEMO_FL_USER2
86#define ISEQ_TRANSLATED IMEMO_FL_USER3
87#define ISEQ_MARKABLE_ISEQ IMEMO_FL_USER4
89#define ISEQ_EXECUTABLE_P(iseq) (FL_TEST_RAW(((VALUE)iseq), ISEQ_NOT_LOADED_YET | ISEQ_USE_COMPILE_DATA) == 0)
94 const VALUE catch_table_ary;
116 unsigned int ci_index;
120 const NODE *root_node;
129 if (iseq->flags & ISEQ_USE_COMPILE_DATA) {
130 return iseq->aux.compile_data;
141 iseq->flags |= ISEQ_USE_COMPILE_DATA;
147 iseq->flags &= ~ISEQ_USE_COMPILE_DATA;
148 iseq->aux.compile_data = NULL;
152iseq_imemo_alloc(
void)
154 return (
rb_iseq_t *)rb_imemo_new(imemo_iseq, 0, 0, 0, 0);
157VALUE rb_iseq_ibf_dump(
const rb_iseq_t *iseq, VALUE opt);
158void rb_ibf_load_iseq_complete(
rb_iseq_t *iseq);
159const rb_iseq_t *rb_iseq_ibf_load(VALUE str);
160const rb_iseq_t *rb_iseq_ibf_load_bytes(
const char *cstr,
size_t);
161VALUE rb_iseq_ibf_load_extra_data(VALUE str);
163int 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);
164int rb_iseq_remove_local_tracepoint_recursively(
const rb_iseq_t *iseq, VALUE tpval);
165const rb_iseq_t *rb_iseq_load_iseq(VALUE fname);
167#if VM_INSN_INFO_TABLE_IMPL == 2
171int rb_vm_insn_addr2opcode(
const void *addr);
173RUBY_SYMBOL_EXPORT_BEGIN
176VALUE rb_iseq_compile_node(
rb_iseq_t *iseq,
const NODE *node);
178VALUE *rb_iseq_original_iseq(
const rb_iseq_t *iseq);
179void rb_iseq_build_from_ary(
rb_iseq_t *iseq, VALUE misc,
180 VALUE locals, VALUE args,
181 VALUE exception, VALUE body);
185VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
186VALUE rb_iseq_parameters(
const rb_iseq_t *iseq,
int is_proc);
187unsigned int rb_iseq_line_no(
const rb_iseq_t *iseq,
size_t pos);
188#ifdef USE_ISEQ_NODE_ID
189int rb_iseq_node_id(
const rb_iseq_t *iseq,
size_t pos);
191void rb_iseq_trace_set(
const rb_iseq_t *iseq, rb_event_flag_t turnon_events);
192void rb_iseq_trace_set_all(rb_event_flag_t turnon_events);
193void rb_iseq_insns_info_encode_positions(
const rb_iseq_t *iseq);
196VALUE rb_iseqw_new(
const rb_iseq_t *iseq);
197const rb_iseq_t *rb_iseqw_to_iseq(VALUE iseqw);
199VALUE rb_iseq_absolute_path(
const rb_iseq_t *iseq);
200int rb_iseq_from_eval_p(
const rb_iseq_t *iseq);
201VALUE rb_iseq_type(
const rb_iseq_t *iseq);
202VALUE rb_iseq_label(
const rb_iseq_t *iseq);
203VALUE rb_iseq_base_label(
const rb_iseq_t *iseq);
204VALUE rb_iseq_first_lineno(
const rb_iseq_t *iseq);
205VALUE rb_iseq_method_name(
const rb_iseq_t *iseq);
206void rb_iseq_code_location(
const rb_iseq_t *iseq,
int *first_lineno,
int *first_column,
int *last_lineno,
int *last_column);
208void rb_iseq_remove_coverage_all(
void);
211const rb_iseq_t *rb_method_iseq(VALUE body);
212const rb_iseq_t *rb_proc_get_iseq(VALUE proc,
int *is_proc);
215 unsigned int inline_const_cache: 1;
216 unsigned int peephole_optimization: 1;
217 unsigned int tailcall_optimization: 1;
218 unsigned int specialized_instruction: 1;
219 unsigned int operands_unification: 1;
220 unsigned int instructions_unification: 1;
221 unsigned int stack_caching: 1;
222 unsigned int frozen_string_literal: 1;
223 unsigned int debug_frozen_string_literal: 1;
224 unsigned int coverage_enabled: 1;
230#ifdef USE_ISEQ_NODE_ID
233 rb_event_flag_t events;
238 CATCH_TYPE_RESCUE =
INT2FIX(1),
239 CATCH_TYPE_ENSURE =
INT2FIX(2),
272iseq_catch_table_bytes(
int n)
276 catch_table_entries_max = (INT_MAX - offsetof(
struct iseq_catch_table, entries)) / catch_table_entry_size
278 if (n > catch_table_entries_max)
rb_fatal(
"too large iseq_catch_table - %d", n);
280 n * catch_table_entry_size);
283#define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
289 char buff[FLEX_ARY_LEN];
315VALUE rb_iseq_defined_string(
enum defined_type
type);
318VALUE rb_iseq_local_variables(
const rb_iseq_t *iseq);
320RUBY_SYMBOL_EXPORT_END
#define RUBY_EXTERN
Declaration of externally visible global variables.
#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.
void ruby_xfree(void *ptr)
Deallocates a storage instance.