Ruby  2.7.1p83(2020-03-31revisiona0c7c23c9cec0d0ffcba012279cd652d28ad5bf3)
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
compile.c File Reference
#include "ruby/encoding.h"
#include "ruby/re.h"
#include "ruby/util.h"
#include "internal.h"
#include "encindex.h"
#include <math.h>
#include "vm_core.h"
#include "vm_debug.h"
#include "builtin.h"
#include "iseq.h"
#include "insns.inc"
#include "insns_info.inc"
#include "id_table.h"
#include "gc.h"
#include "optinsn.inc"

Go to the source code of this file.

Data Structures

struct  iseq_link_element
 
struct  iseq_link_anchor
 
struct  iseq_label_data
 
struct  iseq_insn_data
 
struct  iseq_adjust_data
 
struct  iseq_trace_data
 
struct  ensure_range
 
struct  iseq_compile_data_ensure_node_stack
 
struct  cdhash_set_label_struct
 
struct  accessor_args
 
struct  ibf_header
 
struct  ibf_dump_buffer
 
struct  ibf_dump
 
struct  ibf_load_buffer
 
struct  ibf_load
 
struct  ibf_object_header
 
struct  ibf_object_regexp
 
struct  ibf_object_hash
 
struct  ibf_object_struct_range
 
struct  ibf_object_bignum
 
struct  ibf_object_complex_rational
 
struct  ibf_object_symbol
 

Macros

#define RUBY_UNTYPED_DATA_WARNING   0
 
#define FIXNUM_INC(n, i)   ((n)+(INT2FIX(i)&~FIXNUM_FLAG))
 
#define FIXNUM_OR(n, i)   ((n)|INT2FIX(i))
 
#define CPDEBUG   0
 debug function(macro) interface depend on CPDEBUG if it is less than 0, runtime option is in effect. More...
 
#define compile_debug   CPDEBUG
 
#define debugi(header, id)   ((void)0)
 
#define debugp(header, value)   ((void)0)
 
#define debugp_verbose(header, value)   ((void)0)
 
#define debugp_verbose_node(header, value)   ((void)0)
 
#define debugp_param(header, value)   ((void)0)
 
#define debug_node_start(node)   ((void)0)
 
#define debug_node_end()   ((void)0)
 
#define debugs   if(0)printf
 
#define debug_compile(msg, v)   (v)
 
#define LVAR_ERRINFO   (1)
 
#define NEW_LABEL(l)   new_label_body(iseq, (l))
 
#define LABEL_FORMAT   "<L%03d>"
 
#define NEW_ISEQ(node, name, type, line_no)   new_child_iseq(iseq, (node), rb_fstring(name), 0, (type), (line_no))
 
#define NEW_CHILD_ISEQ(node, name, type, line_no)   new_child_iseq(iseq, (node), rb_fstring(name), iseq, (type), (line_no))
 
#define ADD_SEQ(seq1, seq2)   APPEND_LIST((seq1), (seq2))
 
#define ADD_INSN(seq, line, insn)   ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))
 
#define INSERT_BEFORE_INSN(next, line, insn)   ELEM_INSERT_PREV(&(next)->link, (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))
 
#define INSERT_AFTER_INSN(prev, line, insn)   ELEM_INSERT_NEXT(&(prev)->link, (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))
 
#define ADD_INSN1(seq, line, insn, op1)
 
#define INSERT_BEFORE_INSN1(next, line, insn, op1)
 
#define INSERT_AFTER_INSN1(prev, line, insn, op1)
 
#define LABEL_REF(label)   ((label)->refcnt++)
 
#define ADD_INSNL(seq, line, insn, label)   (ADD_INSN1(seq, line, insn, label), LABEL_REF(label))
 
#define ADD_INSN2(seq, line, insn, op1, op2)
 
#define ADD_INSN3(seq, line, insn, op1, op2, op3)
 
#define ADD_SEND(seq, line, id, argc)   ADD_SEND_R((seq), (line), (id), (argc), NULL, (VALUE)INT2FIX(0), NULL)
 
#define ADD_SEND_WITH_FLAG(seq, line, id, argc, flag)   ADD_SEND_R((seq), (line), (id), (argc), NULL, (VALUE)(flag), NULL)
 
#define ADD_SEND_WITH_BLOCK(seq, line, id, argc, block)   ADD_SEND_R((seq), (line), (id), (argc), (block), (VALUE)INT2FIX(0), NULL)
 
#define ADD_CALL_RECEIVER(seq, line)   ADD_INSN((seq), (line), putself)
 
#define ADD_CALL(seq, line, id, argc)   ADD_SEND_R((seq), (line), (id), (argc), NULL, (VALUE)INT2FIX(VM_CALL_FCALL), NULL)
 
#define ADD_CALL_WITH_BLOCK(seq, line, id, argc, block)   ADD_SEND_R((seq), (line), (id), (argc), (block), (VALUE)INT2FIX(VM_CALL_FCALL), NULL)
 
#define ADD_SEND_R(seq, line, id, argc, block, flag, keywords)   ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_send(iseq, (line), (id), (VALUE)(argc), (block), (VALUE)(flag), (keywords)))
 
#define ADD_TRACE(seq, event)   ADD_ELEM((seq), (LINK_ELEMENT *)new_trace_body(iseq, (event), 0))
 
#define ADD_TRACE_WITH_DATA(seq, event, data)   ADD_ELEM((seq), (LINK_ELEMENT *)new_trace_body(iseq, (event), (data)))
 
#define DECL_BRANCH_BASE(branches, first_line, first_column, last_line, last_column, type)
 
#define ADD_TRACE_BRANCH_COVERAGE(seq, first_line, first_column, last_line, last_column, type, branches)
 
#define ADD_GETLOCAL(seq, line, idx, level)   iseq_add_getlocal(iseq, (seq), (line), (idx), (level))
 
#define ADD_SETLOCAL(seq, line, idx, level)   iseq_add_setlocal(iseq, (seq), (line), (idx), (level))
 
#define ADD_LABEL(seq, label)   ADD_ELEM((seq), (LINK_ELEMENT *) (label))
 
#define APPEND_LABEL(seq, before, label)   APPEND_ELEM((seq), (before), (LINK_ELEMENT *) (label))
 
#define ADD_ADJUST(seq, line, label)   ADD_ELEM((seq), (LINK_ELEMENT *) new_adjust_body(iseq, (label), (line)))
 
#define ADD_ADJUST_RESTORE(seq, label)   ADD_ELEM((seq), (LINK_ELEMENT *) new_adjust_body(iseq, (label), -1))
 
#define LABEL_UNREMOVABLE(label)   ((label) ? (LABEL_REF(label), (label)->unremovable=1) : 0)
 
#define ADD_CATCH_ENTRY(type, ls, le, iseqv, lc)
 
#define COMPILE(anchor, desc, node)
 
#define COMPILE_POPPED(anchor, desc, node)
 
#define COMPILE_(anchor, desc, node, popped)
 
#define COMPILE_RECV(anchor, desc, node)
 
#define OPERAND_AT(insn, idx)   (((INSN*)(insn))->operands[(idx)])
 
#define INSN_OF(insn)   (((INSN*)(insn))->insn_id)
 
#define IS_INSN(link)   ((link)->type == ISEQ_ELEMENT_INSN)
 
#define IS_LABEL(link)   ((link)->type == ISEQ_ELEMENT_LABEL)
 
#define IS_ADJUST(link)   ((link)->type == ISEQ_ELEMENT_ADJUST)
 
#define IS_TRACE(link)   ((link)->type == ISEQ_ELEMENT_TRACE)
 
#define IS_INSN_ID(iobj, insn)   (INSN_OF(iobj) == BIN(insn))
 
#define IS_NEXT_INSN_ID(link, insn)   ((link)->next && IS_INSN((link)->next) && IS_INSN_ID((link)->next, insn))
 
#define COMPILE_ERROR   append_compile_error
 
#define ERROR_ARGS_AT(n)   iseq, nd_line(n),
 
#define ERROR_ARGS   ERROR_ARGS_AT(node)
 
#define EXPECT_NODE(prefix, node, ndtype, errval)
 
#define EXPECT_NODE_NONULL(prefix, parent, ndtype, errval)
 
#define UNKNOWN_NODE(prefix, node, errval)
 
#define COMPILE_OK   1
 
#define COMPILE_NG   0
 
#define CHECK(sub)   if (!(sub)) {BEFORE_RETURN;return COMPILE_NG;}
 
#define NO_CHECK(sub)   (void)(sub)
 
#define BEFORE_RETURN
 
#define DECL_ANCHOR(name)   LINK_ANCHOR name[1] = {{{ISEQ_ELEMENT_ANCHOR,},}}
 
#define INIT_ANCHOR(name)   (name->last = &name->anchor)
 
#define ISEQ_ARG
 
#define ISEQ_ARG_DECLARE
 
#define ISEQ_LAST_LINE(iseq)   (ISEQ_COMPILE_DATA(iseq)->last_line)
 
#define INVALID_ISEQ_TYPE(type)   ISEQ_TYPE_##type: m = #type; goto invalid_iseq_type
 
#define PADDING_SIZE_MAX   0
 
#define debug_list(anc)   ((void)0)
 
#define BADINSN_DUMP(anchor, list, dest)   dump_disasm_list_with_cursor(FIRST_ELEMENT(anchor), list, dest)
 
#define BADINSN_ERROR
 
#define SP_INSN(opt)   insn_set_specialized_instruction(iseq, iobj, BIN(opt_##opt))
 
#define FLUSH_CHUNK(newarrayinsn)
 
#define FLUSH_CHUNK()
 
#define MEMORY(v)
 
#define BEFORE_RETURN   debug_node_end()
 
#define rb_intern(str)   rb_intern_const(str)
 
#define CHECK_EVENT(ev)   if (sym == ID2SYM(rb_intern(#ev))) return ev;
 
#define CHECK_ARRAY(v)   rb_to_array_type(v)
 
#define CHECK_SYMBOL(v)   rb_to_symbol_type(v)
 
#define SYM(s)   ID2SYM(rb_intern(#s))
 
#define SYM(s)   ID2SYM(rb_intern(#s))
 
#define INT_PARAM(F)   int_param(&iseq->body->param.F, params, SYM(F))
 
#define INT_PARAM(F)   F = (int_param(&x, misc, SYM(F)) ? (unsigned int)x : 0)
 
#define IBF_ISEQ_DEBUG   0
 
#define IBF_ISEQ_ENABLE_LOCAL_BUFFER   0
 
#define IBF_OFFSET(ptr)   ((ibf_offset_t)(VALUE)(ptr))
 
#define IBF_MAJOR_VERSION   ISEQ_MAJOR_VERSION
 
#define IBF_MINOR_VERSION   ISEQ_MINOR_VERSION
 
#define IBF_W_ALIGN(type)   (RUBY_ALIGNOF(type) > 1 ? ibf_dump_align(dump, RUBY_ALIGNOF(type)) : (void)0)
 
#define IBF_W(b, type, n)   (IBF_W_ALIGN(type), (type *)(VALUE)IBF_WP(b, type, n))
 
#define IBF_WV(variable)   ibf_dump_write(dump, &(variable), sizeof(variable))
 
#define IBF_WP(b, type, n)   ibf_dump_write(dump, (b), sizeof(type) * (n))
 
#define IBF_R(val, type, n)   (type *)ibf_load_alloc(load, IBF_OFFSET(val), sizeof(type), (n))
 
#define IBF_ZERO(variable)   memset(&(variable), 0, sizeof(variable))
 
#define IBF_BODY_OFFSET(x)   (body_offset - (x))
 
#define IBF_BODY_OFFSET(x)   (offset - (x))
 
#define IBF_OBJECT_INTERNAL   FL_PROMOTED0
 
#define IBF_ALIGNED_OFFSET(align, offset)
 
#define IBF_OBJBODY(type, offset)
 

Typedefs

typedef struct iseq_link_element LINK_ELEMENT
 
typedef struct iseq_link_anchor LINK_ANCHOR
 
typedef struct iseq_label_data LABEL
 
typedef struct iseq_insn_data INSN
 
typedef struct iseq_adjust_data ADJUST
 
typedef struct iseq_trace_data TRACE
 
typedef unsigned int ibf_offset_t
 
typedef void(* ibf_dump_object_function) (struct ibf_dump *dump, VALUE obj)
 
typedef VALUE(* ibf_load_object_function) (const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
 

Enumerations

enum  LABEL_RESCUE_TYPE { LABEL_RESCUE_NONE, LABEL_RESCUE_BEG, LABEL_RESCUE_END, LABEL_RESCUE_TYPE_MAX }
 
enum  ibf_object_class_index {
  IBF_OBJECT_CLASS_OBJECT, IBF_OBJECT_CLASS_ARRAY, IBF_OBJECT_CLASS_STANDARD_ERROR, IBF_OBJECT_CLASS_NO_MATCHING_PATTERN_ERROR,
  IBF_OBJECT_CLASS_TYPE_ERROR
}
 
enum  ibf_object_data_type { IBF_OBJECT_DATA_ENCODING }
 

Functions

VALUE rb_iseq_compile_callback (rb_iseq_t *iseq, const struct rb_iseq_new_with_callback_callback_func *ifunc)
 
VALUE rb_iseq_compile_node (rb_iseq_t *iseq, const NODE *node)
 
VALUErb_iseq_original_iseq (const rb_iseq_t *iseq)
 
VALUE rb_node_case_when_optimizable_literal (const NODE *const node)
 
const charrb_insns_name (int i)
 
VALUE rb_insns_name_array (void)
 
void rb_iseq_mark_insn_storage (struct iseq_compile_data_storage *storage)
 
void rb_iseq_build_from_ary (rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params, VALUE exception, VALUE body)
 
int rb_dvar_defined (ID id, const rb_iseq_t *iseq)
 
int rb_local_defined (ID id, const rb_iseq_t *iseq)
 
const rb_iseq_trb_method_for_self_aref (VALUE name, VALUE arg, rb_insn_func_t func)
 
const rb_iseq_trb_method_for_self_aset (VALUE name, VALUE arg, rb_insn_func_t func)
 
rb_iseq_tiseq_alloc (void)
 
 NORETURN (static void ibf_dump_object_unsupported(struct ibf_dump *dump, VALUE obj))
 
VALUE rb_iseq_ibf_dump (const rb_iseq_t *iseq, VALUE opt)
 
void rb_ibf_load_iseq_complete (rb_iseq_t *iseq)
 
const rb_iseq_trb_iseq_ibf_load (VALUE str)
 
const rb_iseq_trb_iseq_ibf_load_bytes (const char *bytes, size_t size)
 
VALUE rb_iseq_ibf_load_extra_data (VALUE str)
 

Variables

const ID rb_iseq_shared_exc_local_tbl [] = {idERROR_INFO}
 

Macro Definition Documentation

◆ ADD_ADJUST

#define ADD_ADJUST (   seq,
  line,
  label 
)    ADD_ELEM((seq), (LINK_ELEMENT *) new_adjust_body(iseq, (label), (line)))

Definition at line 318 of file compile.c.

◆ ADD_ADJUST_RESTORE

#define ADD_ADJUST_RESTORE (   seq,
  label 
)    ADD_ELEM((seq), (LINK_ELEMENT *) new_adjust_body(iseq, (label), -1))

Definition at line 321 of file compile.c.

◆ ADD_CALL

#define ADD_CALL (   seq,
  line,
  id,
  argc 
)    ADD_SEND_R((seq), (line), (id), (argc), NULL, (VALUE)INT2FIX(VM_CALL_FCALL), NULL)

Definition at line 256 of file compile.c.

◆ ADD_CALL_RECEIVER

#define ADD_CALL_RECEIVER (   seq,
  line 
)    ADD_INSN((seq), (line), putself)

Definition at line 253 of file compile.c.

◆ ADD_CALL_WITH_BLOCK

#define ADD_CALL_WITH_BLOCK (   seq,
  line,
  id,
  argc,
  block 
)    ADD_SEND_R((seq), (line), (id), (argc), (block), (VALUE)INT2FIX(VM_CALL_FCALL), NULL)

Definition at line 259 of file compile.c.

◆ ADD_CATCH_ENTRY

#define ADD_CATCH_ENTRY (   type,
  ls,
  le,
  iseqv,
  lc 
)
Value:
do { \
VALUE _e = rb_ary_new3(5, (type), \
(VALUE)(ls) | 1, (VALUE)(le) | 1, \
(VALUE)(iseqv), (VALUE)(lc) | 1); \
LABEL_UNREMOVABLE(ls); \
LABEL_REF(le); \
LABEL_REF(lc); \
if (NIL_P(ISEQ_COMPILE_DATA(iseq)->catch_table_ary)) \
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, rb_ary_tmp_new(3)); \
rb_ary_push(ISEQ_COMPILE_DATA(iseq)->catch_table_ary, freeze_hide_obj(_e)); \
} while (0)

Definition at line 326 of file compile.c.

◆ ADD_GETLOCAL

#define ADD_GETLOCAL (   seq,
  line,
  idx,
  level 
)    iseq_add_getlocal(iseq, (seq), (line), (idx), (level))

Definition at line 308 of file compile.c.

◆ ADD_INSN

#define ADD_INSN (   seq,
  line,
  insn 
)    ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))

Definition at line 204 of file compile.c.

◆ ADD_INSN1

#define ADD_INSN1 (   seq,
  line,
  insn,
  op1 
)
Value:
ADD_ELEM((seq), (LINK_ELEMENT *) \
new_insn_body(iseq, (line), BIN(insn), 1, (VALUE)(op1)))

Definition at line 216 of file compile.c.

◆ ADD_INSN2

#define ADD_INSN2 (   seq,
  line,
  insn,
  op1,
  op2 
)
Value:
ADD_ELEM((seq), (LINK_ELEMENT *) \
new_insn_body(iseq, (line), BIN(insn), 2, (VALUE)(op1), (VALUE)(op2)))

Definition at line 235 of file compile.c.

◆ ADD_INSN3

#define ADD_INSN3 (   seq,
  line,
  insn,
  op1,
  op2,
  op3 
)
Value:
ADD_ELEM((seq), (LINK_ELEMENT *) \
new_insn_body(iseq, (line), BIN(insn), 3, (VALUE)(op1), (VALUE)(op2), (VALUE)(op3)))

Definition at line 239 of file compile.c.

◆ ADD_INSNL

#define ADD_INSNL (   seq,
  line,
  insn,
  label 
)    (ADD_INSN1(seq, line, insn, label), LABEL_REF(label))

Definition at line 233 of file compile.c.

◆ ADD_LABEL

#define ADD_LABEL (   seq,
  label 
)    ADD_ELEM((seq), (LINK_ELEMENT *) (label))

Definition at line 312 of file compile.c.

◆ ADD_SEND

#define ADD_SEND (   seq,
  line,
  id,
  argc 
)    ADD_SEND_R((seq), (line), (id), (argc), NULL, (VALUE)INT2FIX(0), NULL)

Definition at line 244 of file compile.c.

◆ ADD_SEND_R

#define ADD_SEND_R (   seq,
  line,
  id,
  argc,
  block,
  flag,
  keywords 
)    ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_send(iseq, (line), (id), (VALUE)(argc), (block), (VALUE)(flag), (keywords)))

Definition at line 262 of file compile.c.

◆ ADD_SEND_WITH_BLOCK

#define ADD_SEND_WITH_BLOCK (   seq,
  line,
  id,
  argc,
  block 
)    ADD_SEND_R((seq), (line), (id), (argc), (block), (VALUE)INT2FIX(0), NULL)

Definition at line 250 of file compile.c.

◆ ADD_SEND_WITH_FLAG

#define ADD_SEND_WITH_FLAG (   seq,
  line,
  id,
  argc,
  flag 
)    ADD_SEND_R((seq), (line), (id), (argc), NULL, (VALUE)(flag), NULL)

Definition at line 247 of file compile.c.

◆ ADD_SEQ

#define ADD_SEQ (   seq1,
  seq2 
)    APPEND_LIST((seq1), (seq2))

Definition at line 200 of file compile.c.

◆ ADD_SETLOCAL

#define ADD_SETLOCAL (   seq,
  line,
  idx,
  level 
)    iseq_add_setlocal(iseq, (seq), (line), (idx), (level))

Definition at line 309 of file compile.c.

◆ ADD_TRACE

#define ADD_TRACE (   seq,
  event 
)    ADD_ELEM((seq), (LINK_ELEMENT *)new_trace_body(iseq, (event), 0))

Definition at line 265 of file compile.c.

◆ ADD_TRACE_BRANCH_COVERAGE

#define ADD_TRACE_BRANCH_COVERAGE (   seq,
  first_line,
  first_column,
  last_line,
  last_column,
  type,
  branches 
)
Value:
do { \
if (ISEQ_COVERAGE(iseq) && \
(first_line) > 0) { \
VALUE counters = RARRAY_AREF(ISEQ_BRANCH_COVERAGE(iseq), 1); \
long counter_idx = RARRAY_LEN(counters); \
rb_ary_push(counters, INT2FIX(0)); \
rb_ary_push(branches, ID2SYM(rb_intern(type))); \
rb_ary_push(branches, INT2FIX(first_line)); \
rb_ary_push(branches, INT2FIX(first_column)); \
rb_ary_push(branches, INT2FIX(last_line)); \
rb_ary_push(branches, INT2FIX(last_column)); \
rb_ary_push(branches, INT2FIX(counter_idx)); \
ADD_TRACE_WITH_DATA(seq, RUBY_EVENT_COVERAGE_BRANCH, counter_idx); \
ADD_INSN(seq, last_line, nop); \
} \
} while (0)

Definition at line 286 of file compile.c.

◆ ADD_TRACE_WITH_DATA

#define ADD_TRACE_WITH_DATA (   seq,
  event,
  data 
)    ADD_ELEM((seq), (LINK_ELEMENT *)new_trace_body(iseq, (event), (data)))

Definition at line 267 of file compile.c.

◆ APPEND_LABEL

#define APPEND_LABEL (   seq,
  before,
  label 
)    APPEND_ELEM((seq), (before), (LINK_ELEMENT *) (label))

Definition at line 315 of file compile.c.

◆ BADINSN_DUMP

#define BADINSN_DUMP (   anchor,
  list,
  dest 
)    dump_disasm_list_with_cursor(FIRST_ELEMENT(anchor), list, dest)

Definition at line 1885 of file compile.c.

◆ BADINSN_ERROR

#define BADINSN_ERROR
Value:
(xfree(generated_iseq), \
xfree(insns_info), \
BADINSN_DUMP(anchor, list, NULL), \
COMPILE_ERROR)

Definition at line 1888 of file compile.c.

◆ BEFORE_RETURN [1/2]

#define BEFORE_RETURN

Definition at line 450 of file compile.c.

◆ BEFORE_RETURN [2/2]

#define BEFORE_RETURN   debug_node_end()

Definition at line 450 of file compile.c.

◆ CHECK

#define CHECK (   sub)    if (!(sub)) {BEFORE_RETURN;return COMPILE_NG;}

Definition at line 448 of file compile.c.

◆ CHECK_ARRAY

#define CHECK_ARRAY (   v)    rb_to_array_type(v)

Definition at line 9109 of file compile.c.

◆ CHECK_EVENT

#define CHECK_EVENT (   ev)    if (sym == ID2SYM(rb_intern(#ev))) return ev;

◆ CHECK_SYMBOL

#define CHECK_SYMBOL (   v)    rb_to_symbol_type(v)

Definition at line 9110 of file compile.c.

◆ COMPILE

#define COMPILE (   anchor,
  desc,
  node 
)
Value:
(debug_compile("== " desc "\n", \
iseq_compile_each(iseq, (anchor), (node), 0)))

Definition at line 339 of file compile.c.

◆ COMPILE_

#define COMPILE_ (   anchor,
  desc,
  node,
  popped 
)
Value:
(debug_compile("== " desc "\n", \
iseq_compile_each(iseq, (anchor), (node), (popped))))

Definition at line 349 of file compile.c.

◆ compile_debug

#define compile_debug   CPDEBUG

Definition at line 130 of file compile.c.

◆ COMPILE_ERROR

#define COMPILE_ERROR   append_compile_error

Definition at line 413 of file compile.c.

◆ COMPILE_NG

#define COMPILE_NG   0

Definition at line 446 of file compile.c.

◆ COMPILE_OK

#define COMPILE_OK   1

Definition at line 445 of file compile.c.

◆ COMPILE_POPPED

#define COMPILE_POPPED (   anchor,
  desc,
  node 
)
Value:
(debug_compile("== " desc "\n", \
iseq_compile_each(iseq, (anchor), (node), 1)))

Definition at line 344 of file compile.c.

◆ COMPILE_RECV

#define COMPILE_RECV (   anchor,
  desc,
  node 
)
Value:
(private_recv_p(node) ? \
(ADD_INSN(anchor, nd_line(node), putself), VM_CALL_FCALL) : \
COMPILE(anchor, desc, node->nd_recv) ? 0 : -1)

Definition at line 353 of file compile.c.

◆ CPDEBUG

#define CPDEBUG   0

debug function(macro) interface depend on CPDEBUG if it is less than 0, runtime option is in effect.

debug level: 0: no debug output 1: show node type 2: show node important parameters ... 5: show other parameters 10: show every AST array

Definition at line 126 of file compile.c.

◆ debug_compile

#define debug_compile (   msg,
  v 
)    (v)

Definition at line 184 of file compile.c.

◆ debug_list

#define debug_list (   anc)    ((void)0)

Definition at line 1093 of file compile.c.

◆ debug_node_end

#define debug_node_end ( )    ((void)0)

Definition at line 175 of file compile.c.

◆ debug_node_start

#define debug_node_start (   node)    ((void)0)

Definition at line 174 of file compile.c.

◆ debugi

#define debugi (   header,
  id 
)    ((void)0)

Definition at line 169 of file compile.c.

◆ debugp

#define debugp (   header,
  value 
)    ((void)0)

Definition at line 170 of file compile.c.

◆ debugp_param

#define debugp_param (   header,
  value 
)    ((void)0)

Definition at line 173 of file compile.c.

◆ debugp_verbose

#define debugp_verbose (   header,
  value 
)    ((void)0)

Definition at line 171 of file compile.c.

◆ debugp_verbose_node

#define debugp_verbose_node (   header,
  value 
)    ((void)0)

Definition at line 172 of file compile.c.

◆ debugs

#define debugs   if(0)printf

Definition at line 183 of file compile.c.

◆ DECL_ANCHOR

#define DECL_ANCHOR (   name)    LINK_ANCHOR name[1] = {{{ISEQ_ELEMENT_ANCHOR,},}}

Definition at line 454 of file compile.c.

◆ DECL_BRANCH_BASE

#define DECL_BRANCH_BASE (   branches,
  first_line,
  first_column,
  last_line,
  last_column,
  type 
)
Value:
do { \
if (ISEQ_COVERAGE(iseq) && \
(first_line) > 0) { \
VALUE structure = RARRAY_AREF(ISEQ_BRANCH_COVERAGE(iseq), 0); \
branches = rb_ary_tmp_new(5); \
rb_ary_push(structure, branches); \
rb_ary_push(branches, ID2SYM(rb_intern(type))); \
rb_ary_push(branches, INT2FIX(first_line)); \
rb_ary_push(branches, INT2FIX(first_column)); \
rb_ary_push(branches, INT2FIX(last_line)); \
rb_ary_push(branches, INT2FIX(last_column)); \
} \
} while (0)

Definition at line 271 of file compile.c.

◆ ERROR_ARGS

#define ERROR_ARGS   ERROR_ARGS_AT(node)

Definition at line 416 of file compile.c.

◆ ERROR_ARGS_AT

#define ERROR_ARGS_AT (   n)    iseq, nd_line(n),

Definition at line 415 of file compile.c.

◆ EXPECT_NODE

#define EXPECT_NODE (   prefix,
  node,
  ndtype,
  errval 
)
Value:
do { \
const NODE *error_node = (node); \
enum node_type error_type = nd_type(error_node); \
if (error_type != (ndtype)) { \
COMPILE_ERROR(ERROR_ARGS_AT(error_node) \
prefix ": " #ndtype " is expected, but %s", \
ruby_node_name(error_type)); \
return errval; \
} \
} while (0)

Definition at line 418 of file compile.c.

◆ EXPECT_NODE_NONULL

#define EXPECT_NODE_NONULL (   prefix,
  parent,
  ndtype,
  errval 
)
Value:
do { \
COMPILE_ERROR(ERROR_ARGS_AT(parent) \
prefix ": must be " #ndtype ", but 0"); \
return errval; \
} while (0)

Definition at line 430 of file compile.c.

◆ FIXNUM_INC

#define FIXNUM_INC (   n,
  i 
)    ((n)+(INT2FIX(i)&~FIXNUM_FLAG))

Definition at line 35 of file compile.c.

◆ FIXNUM_OR

#define FIXNUM_OR (   n,
  i 
)    ((n)|INT2FIX(i))

Definition at line 36 of file compile.c.

◆ FLUSH_CHUNK [1/2]

#define FLUSH_CHUNK ( )
Value:
if (stack_len) { \
if (first_chunk) { \
APPEND_LIST(ret, anchor); \
ADD_INSN1(ret, line, newhash, INT2FIX(stack_len)); \
} \
else { \
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE)); \
ADD_INSN(ret, line, swap); \
APPEND_LIST(ret, anchor); \
ADD_SEND(ret, line, id_core_hash_merge_ptr, INT2FIX(stack_len + 1)); \
} \
INIT_ANCHOR(anchor); \
first_chunk = stack_len = 0; \
}

◆ FLUSH_CHUNK [2/2]

#define FLUSH_CHUNK (   newarrayinsn)
Value:
if (stack_len) { \
ADD_INSN1(ret, line, newarrayinsn, INT2FIX(stack_len)); \
if (!first_chunk) ADD_INSN(ret, line, concatarray); \
first_chunk = stack_len = 0; \
}

◆ IBF_ALIGNED_OFFSET

#define IBF_ALIGNED_OFFSET (   align,
  offset 
)
Value:
/* offset > 0 */ \
((((offset) - 1) / (align) + 1) * (align))

Definition at line 10751 of file compile.c.

◆ IBF_BODY_OFFSET [1/2]

#define IBF_BODY_OFFSET (   x)    (body_offset - (x))

◆ IBF_BODY_OFFSET [2/2]

#define IBF_BODY_OFFSET (   x)    (offset - (x))

◆ IBF_ISEQ_DEBUG

#define IBF_ISEQ_DEBUG   0

Definition at line 9493 of file compile.c.

◆ IBF_ISEQ_ENABLE_LOCAL_BUFFER

#define IBF_ISEQ_ENABLE_LOCAL_BUFFER   0

Definition at line 9497 of file compile.c.

◆ IBF_MAJOR_VERSION

#define IBF_MAJOR_VERSION   ISEQ_MAJOR_VERSION

Definition at line 9503 of file compile.c.

◆ IBF_MINOR_VERSION

#define IBF_MINOR_VERSION   ISEQ_MINOR_VERSION

Definition at line 9508 of file compile.c.

◆ IBF_OBJBODY

#define IBF_OBJBODY (   type,
  offset 
)
Value:
(const type *)\
ibf_load_check_offset(load, IBF_ALIGNED_OFFSET(RUBY_ALIGNOF(type), offset))

Definition at line 10753 of file compile.c.

◆ IBF_OBJECT_INTERNAL

#define IBF_OBJECT_INTERNAL   FL_PROMOTED0

Definition at line 10693 of file compile.c.

◆ IBF_OFFSET

#define IBF_OFFSET (   ptr)    ((ibf_offset_t)(VALUE)(ptr))

Definition at line 9501 of file compile.c.

◆ IBF_R

#define IBF_R (   val,
  type,
  n 
)    (type *)ibf_load_alloc(load, IBF_OFFSET(val), sizeof(type), (n))

Definition at line 9635 of file compile.c.

◆ IBF_W

#define IBF_W (   b,
  type,
  n 
)    (IBF_W_ALIGN(type), (type *)(VALUE)IBF_WP(b, type, n))

Definition at line 9632 of file compile.c.

◆ IBF_W_ALIGN

#define IBF_W_ALIGN (   type)    (RUBY_ALIGNOF(type) > 1 ? ibf_dump_align(dump, RUBY_ALIGNOF(type)) : (void)0)

Definition at line 9630 of file compile.c.

◆ IBF_WP

#define IBF_WP (   b,
  type,
  n 
)    ibf_dump_write(dump, (b), sizeof(type) * (n))

Definition at line 9634 of file compile.c.

◆ IBF_WV

#define IBF_WV (   variable)    ibf_dump_write(dump, &(variable), sizeof(variable))

Definition at line 9633 of file compile.c.

◆ IBF_ZERO

#define IBF_ZERO (   variable)    memset(&(variable), 0, sizeof(variable))

Definition at line 9636 of file compile.c.

◆ INIT_ANCHOR

#define INIT_ANCHOR (   name)    (name->last = &name->anchor)

Definition at line 456 of file compile.c.

◆ INSERT_AFTER_INSN

#define INSERT_AFTER_INSN (   prev,
  line,
  insn 
)    ELEM_INSERT_NEXT(&(prev)->link, (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))

Definition at line 212 of file compile.c.

◆ INSERT_AFTER_INSN1

#define INSERT_AFTER_INSN1 (   prev,
  line,
  insn,
  op1 
)
Value:
ELEM_INSERT_NEXT(&(prev)->link, (LINK_ELEMENT *) \
new_insn_body(iseq, (line), BIN(insn), 1, (VALUE)(op1)))

Definition at line 226 of file compile.c.

◆ INSERT_BEFORE_INSN

#define INSERT_BEFORE_INSN (   next,
  line,
  insn 
)    ELEM_INSERT_PREV(&(next)->link, (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))

Definition at line 208 of file compile.c.

◆ INSERT_BEFORE_INSN1

#define INSERT_BEFORE_INSN1 (   next,
  line,
  insn,
  op1 
)
Value:
ELEM_INSERT_PREV(&(next)->link, (LINK_ELEMENT *) \
new_insn_body(iseq, (line), BIN(insn), 1, (VALUE)(op1)))

Definition at line 221 of file compile.c.

◆ INSN_OF

#define INSN_OF (   insn)    (((INSN*)(insn))->insn_id)

Definition at line 361 of file compile.c.

◆ INT_PARAM [1/2]

#define INT_PARAM (   F)    int_param(&iseq->body->param.F, params, SYM(F))

◆ INT_PARAM [2/2]

#define INT_PARAM (   F)    F = (int_param(&x, misc, SYM(F)) ? (unsigned int)x : 0)

◆ INVALID_ISEQ_TYPE

#define INVALID_ISEQ_TYPE (   type)    ISEQ_TYPE_##type: m = #type; goto invalid_iseq_type

◆ IS_ADJUST

#define IS_ADJUST (   link)    ((link)->type == ISEQ_ELEMENT_ADJUST)

Definition at line 366 of file compile.c.

◆ IS_INSN

#define IS_INSN (   link)    ((link)->type == ISEQ_ELEMENT_INSN)

Definition at line 364 of file compile.c.

◆ IS_INSN_ID

#define IS_INSN_ID (   iobj,
  insn 
)    (INSN_OF(iobj) == BIN(insn))

Definition at line 368 of file compile.c.

◆ IS_LABEL

#define IS_LABEL (   link)    ((link)->type == ISEQ_ELEMENT_LABEL)

Definition at line 365 of file compile.c.

◆ IS_NEXT_INSN_ID

#define IS_NEXT_INSN_ID (   link,
  insn 
)    ((link)->next && IS_INSN((link)->next) && IS_INSN_ID((link)->next, insn))

Definition at line 369 of file compile.c.

◆ IS_TRACE

#define IS_TRACE (   link)    ((link)->type == ISEQ_ELEMENT_TRACE)

Definition at line 367 of file compile.c.

◆ ISEQ_ARG

#define ISEQ_ARG

Definition at line 477 of file compile.c.

◆ ISEQ_ARG_DECLARE

#define ISEQ_ARG_DECLARE

Definition at line 478 of file compile.c.

◆ ISEQ_LAST_LINE

#define ISEQ_LAST_LINE (   iseq)    (ISEQ_COMPILE_DATA(iseq)->last_line)

Definition at line 605 of file compile.c.

◆ LABEL_FORMAT

#define LABEL_FORMAT   "<L%03d>"

Definition at line 191 of file compile.c.

◆ LABEL_REF

#define LABEL_REF (   label)    ((label)->refcnt++)

Definition at line 230 of file compile.c.

◆ LABEL_UNREMOVABLE

#define LABEL_UNREMOVABLE (   label)    ((label) ? (LABEL_REF(label), (label)->unremovable=1) : 0)

Definition at line 324 of file compile.c.

◆ LVAR_ERRINFO

#define LVAR_ERRINFO   (1)

Definition at line 187 of file compile.c.

◆ MEMORY

#define MEMORY (   v)
Value:
{ \
int i; \
if (memindex == memsize) return 0; \
for (i=0; i<memindex; i++) { \
if (mem[i] == (v)) return 0; \
} \
mem[memindex++] = (v); \
}

◆ NEW_CHILD_ISEQ

#define NEW_CHILD_ISEQ (   node,
  name,
  type,
  line_no 
)    new_child_iseq(iseq, (node), rb_fstring(name), iseq, (type), (line_no))

Definition at line 196 of file compile.c.

◆ NEW_ISEQ

#define NEW_ISEQ (   node,
  name,
  type,
  line_no 
)    new_child_iseq(iseq, (node), rb_fstring(name), 0, (type), (line_no))

Definition at line 193 of file compile.c.

◆ NEW_LABEL

#define NEW_LABEL (   l)    new_label_body(iseq, (l))

Definition at line 190 of file compile.c.

◆ NO_CHECK

#define NO_CHECK (   sub)    (void)(sub)

Definition at line 449 of file compile.c.

◆ OPERAND_AT

#define OPERAND_AT (   insn,
  idx 
)    (((INSN*)(insn))->operands[(idx)])

Definition at line 358 of file compile.c.

◆ PADDING_SIZE_MAX

#define PADDING_SIZE_MAX   0

Definition at line 826 of file compile.c.

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

◆ RUBY_UNTYPED_DATA_WARNING

#define RUBY_UNTYPED_DATA_WARNING   0

Definition at line 33 of file compile.c.

◆ SP_INSN

#define SP_INSN (   opt)    insn_set_specialized_instruction(iseq, iobj, BIN(opt_##opt))

◆ SYM [1/2]

#define SYM (   s)    ID2SYM(rb_intern(#s))

◆ SYM [2/2]

#define SYM (   s)    ID2SYM(rb_intern(#s))

◆ UNKNOWN_NODE

#define UNKNOWN_NODE (   prefix,
  node,
  errval 
)
Value:
do { \
const NODE *error_node = (node); \
COMPILE_ERROR(ERROR_ARGS_AT(error_node) prefix ": unknown node (%s)", \
ruby_node_name(nd_type(error_node))); \
return errval; \
} while (0)

Definition at line 437 of file compile.c.

Typedef Documentation

◆ ADJUST

typedef struct iseq_adjust_data ADJUST

◆ ibf_dump_object_function

typedef void(* ibf_dump_object_function) (struct ibf_dump *dump, VALUE obj)

Definition at line 11129 of file compile.c.

◆ ibf_load_object_function

typedef VALUE(* ibf_load_object_function) (const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)

Definition at line 11226 of file compile.c.

◆ ibf_offset_t

Definition at line 9500 of file compile.c.

◆ INSN

typedef struct iseq_insn_data INSN

◆ LABEL

typedef struct iseq_label_data LABEL

◆ LINK_ANCHOR

typedef struct iseq_link_anchor LINK_ANCHOR

◆ LINK_ELEMENT

◆ TRACE

typedef struct iseq_trace_data TRACE

Enumeration Type Documentation

◆ ibf_object_class_index

Enumerator
IBF_OBJECT_CLASS_OBJECT 
IBF_OBJECT_CLASS_ARRAY 
IBF_OBJECT_CLASS_STANDARD_ERROR 
IBF_OBJECT_CLASS_NO_MATCHING_PATTERN_ERROR 
IBF_OBJECT_CLASS_TYPE_ERROR 

Definition at line 10708 of file compile.c.

◆ ibf_object_data_type

Enumerator
IBF_OBJECT_DATA_ENCODING 

Definition at line 10739 of file compile.c.

◆ LABEL_RESCUE_TYPE

Enumerator
LABEL_RESCUE_NONE 
LABEL_RESCUE_BEG 
LABEL_RESCUE_END 
LABEL_RESCUE_TYPE_MAX 

Definition at line 55 of file compile.c.

Function Documentation

◆ iseq_alloc()

rb_iseq_t* iseq_alloc ( void  )

◆ NORETURN()

NORETURN ( static void   ibf_dump_object_unsupportedstruct ibf_dump *dump, VALUE obj)

◆ rb_dvar_defined()

int rb_dvar_defined ( ID  id,
const rb_iseq_t iseq 
)

◆ rb_ibf_load_iseq_complete()

void rb_ibf_load_iseq_complete ( rb_iseq_t iseq)

◆ rb_insns_name()

const char* rb_insns_name ( int  i)

Definition at line 8761 of file compile.c.

References i.

◆ rb_insns_name_array()

VALUE rb_insns_name_array ( void  )

◆ rb_iseq_build_from_ary()

void rb_iseq_build_from_ary ( rb_iseq_t iseq,
VALUE  misc,
VALUE  locals,
VALUE  params,
VALUE  exception,
VALUE  body 
)

◆ rb_iseq_compile_callback()

VALUE rb_iseq_compile_callback ( rb_iseq_t iseq,
const struct rb_iseq_new_with_callback_callback_func ifunc 
)

◆ rb_iseq_compile_node()

VALUE rb_iseq_compile_node ( rb_iseq_t iseq,
const NODE node 
)

Definition at line 644 of file compile.c.

References DECL_ANCHOR, and INIT_ANCHOR.

◆ rb_iseq_ibf_dump()

VALUE rb_iseq_ibf_dump ( const rb_iseq_t iseq,
VALUE  opt 
)

◆ rb_iseq_ibf_load()

const rb_iseq_t* rb_iseq_ibf_load ( VALUE  str)

Definition at line 11602 of file compile.c.

References iseq, ibf_load::loader_obj, and TypedData_Make_Struct.

◆ rb_iseq_ibf_load_bytes()

const rb_iseq_t* rb_iseq_ibf_load_bytes ( const char bytes,
size_t  size 
)

Definition at line 11616 of file compile.c.

References iseq, ibf_load::loader_obj, and TypedData_Make_Struct.

◆ rb_iseq_ibf_load_extra_data()

VALUE rb_iseq_ibf_load_extra_data ( VALUE  str)

Definition at line 11630 of file compile.c.

References ibf_load::loader_obj, and TypedData_Make_Struct.

◆ rb_iseq_mark_insn_storage()

void rb_iseq_mark_insn_storage ( struct iseq_compile_data_storage storage)

◆ rb_iseq_original_iseq()

VALUE* rb_iseq_original_iseq ( const rb_iseq_t iseq)

Definition at line 778 of file compile.c.

Referenced by rb_vmdebug_debug_print_pre().

◆ rb_local_defined()

int rb_local_defined ( ID  id,
const rb_iseq_t iseq 
)

◆ rb_method_for_self_aref()

const rb_iseq_t* rb_method_for_self_aref ( VALUE  name,
VALUE  arg,
rb_insn_func_t  func 
)

Definition at line 9476 of file compile.c.

◆ rb_method_for_self_aset()

const rb_iseq_t* rb_method_for_self_aset ( VALUE  name,
VALUE  arg,
rb_insn_func_t  func 
)

Definition at line 9485 of file compile.c.

◆ rb_node_case_when_optimizable_literal()

VALUE rb_node_case_when_optimizable_literal ( const NODE *const  node)

Variable Documentation

◆ rb_iseq_shared_exc_local_tbl

const ID rb_iseq_shared_exc_local_tbl[] = {idERROR_INFO}

Definition at line 110 of file compile.c.

Referenced by rb_iseq_free().

i
uint32_t i
Definition: rb_mjit_min_header-2.7.1.h:5425
ruby_node_name
const char * ruby_node_name(int node)
Definition: iseq.c:2534
INT2FIX
#define INT2FIX(i)
Definition: ruby.h:263
VALUE
unsigned long VALUE
Definition: ruby.h:102
iseq
const rb_iseq_t * iseq
Definition: rb_mjit_min_header-2.7.1.h:13426
ERROR_ARGS_AT
#define ERROR_ARGS_AT(n)
Definition: compile.c:415
RUBY_ALIGNOF
#define RUBY_ALIGNOF(type)
Definition: defines.h:517
rb_ary_new3
#define rb_ary_new3
Definition: intern.h:104
NULL
#define NULL
Definition: _sdbm.c:101
ID2SYM
#define ID2SYM(x)
Definition: ruby.h:414
debug_compile
#define debug_compile(msg, v)
Definition: compile.c:184
rb_intern
#define rb_intern(str)
ISEQ_BRANCH_COVERAGE
#define ISEQ_BRANCH_COVERAGE(iseq)
Definition: iseq.h:37
rb_ary_tmp_new
VALUE rb_ary_tmp_new(long capa)
Definition: array.c:768
COMPILE
#define COMPILE(anchor, desc, node)
Definition: compile.c:339
node_type
node_type
Definition: node.h:22
VM_SPECIAL_OBJECT_VMCORE
@ VM_SPECIAL_OBJECT_VMCORE
Definition: vm_core.h:1115
RARRAY_AREF
#define RARRAY_AREF(a, i)
Definition: ruby.h:1101
list
struct rb_encoding_entry * list
Definition: encoding.c:56
BIN
#define BIN(n)
Definition: rb_mjit_min_header-2.7.1.h:11893
link
int link(const char *, const char *)
Definition: win32.c:4931
le
#define le(x, y)
Definition: time.c:85
RARRAY_LEN
#define RARRAY_LEN(a)
Definition: ruby.h:1070
VM_CALL_FCALL
#define VM_CALL_FCALL
Definition: vm_core.h:1103
NIL_P
#define NIL_P(v)
Definition: ruby.h:482
id_core_hash_merge_ptr
@ id_core_hash_merge_ptr
Definition: id.h:126
ISEQ_COVERAGE
#define ISEQ_COVERAGE(iseq)
Definition: iseq.h:34
ADD_INSN
#define ADD_INSN(seq, line, insn)
Definition: compile.c:204
xfree
#define xfree
Definition: defines.h:216
v
int VALUE v
Definition: rb_mjit_min_header-2.7.1.h:12257
nd_line
#define nd_line(n)
Definition: node.h:194
IBF_ALIGNED_OFFSET
#define IBF_ALIGNED_OFFSET(align, offset)
Definition: compile.c:10751
nd_type
#define nd_type(n)
Definition: node.h:188
RUBY_EVENT_COVERAGE_BRANCH
#define RUBY_EVENT_COVERAGE_BRANCH
Definition: vm_core.h:1957
ruby::backward::cxxanyargs::type
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:39
RNode
Definition: node.h:149