eval_intern.h File Reference
`#include "ruby/ruby.h"`
`#include "vm_core.h"`
`#include <stdio.h>`
`#include <setjmp.h>`
`#include <sys/types.h>`
`#include <signal.h>`
`#include <errno.h>`
`#include <sys/stat.h>`

Go to the source code of this file.

## Macros

#define | PASS_PASSED_BLOCK_TH(th)
#define | PASS_PASSED_BLOCK()
#define | EXIT_SUCCESS 0
#define | EXIT_FAILURE 1
#define | ruby_setjmp(env) RUBY_SETJMP(env)
#define | ruby_longjmp(env, val) RUBY_LONGJMP((env),(val))
#define | SAVE_ROOT_JMPBUF(th, stmt)
#define | TH_PUSH_TAG(th)
#define | TH_POP_TAG()
#define | TH_POP_TAG2() _th->tag = _tag.prev
#define | PUSH_TAG() TH_PUSH_TAG(GET_THREAD())
#define | POP_TAG() TH_POP_TAG()
#define | TH_EXEC_TAG() ruby_setjmp(_th->tag->buf)
#define | EXEC_TAG() TH_EXEC_TAG()
#define | TH_JUMP_TAG(th, st)
#define | JUMP_TAG(st) TH_JUMP_TAG(GET_THREAD(), (st))
#define | INTERNAL_EXCEPTION_P(exc) FIXNUM_P(exc)
#define | TAG_RETURN RUBY_TAG_RETURN
#define | TAG_BREAK RUBY_TAG_BREAK
#define | TAG_NEXT RUBY_TAG_NEXT
#define | TAG_RETRY RUBY_TAG_RETRY
#define | TAG_REDO RUBY_TAG_REDO
#define | TAG_RAISE RUBY_TAG_RAISE
#define | TAG_THROW RUBY_TAG_THROW
#define | TAG_FATAL RUBY_TAG_FATAL
#define | TAG_MASK RUBY_TAG_MASK
#define | NEW_THROW_OBJECT(val, pt, st) ((VALUE)rb_node_newnode(NODE_LIT, (VALUE)(val), (VALUE)(pt), (VALUE)(st)))
#define | SET_THROWOBJ_CATCH_POINT(obj, val) (RNODE((obj))->u2.value = (val))
#define | SET_THROWOBJ_STATE(obj, val) (RNODE((obj))->u3.value = (val))
#define | GET_THROWOBJ_VAL(obj) ((VALUE)RNODE((obj))->u1.value)
#define | GET_THROWOBJ_CATCH_POINT(obj) ((VALUE*)RNODE((obj))->u2.value)
#define | GET_THROWOBJ_STATE(obj) ((int)RNODE((obj))->u3.value)
#define | SCOPE_TEST(f) (rb_vm_cref()->nd_visi & (f))
#define | SCOPE_CHECK(f) (rb_vm_cref()->nd_visi == (f))
#define | SCOPE_SET(f) (rb_vm_cref()->nd_visi = (f))
#define | CHECK_STACK_OVERFLOW(cfp, margin)
#define | rb_thread_raised_set(th, f) ((th)->raised_flag |= (f))
#define | rb_thread_raised_reset(th, f) ((th)->raised_flag &= ~(f))
#define | rb_thread_raised_p(th, f) (((th)->raised_flag & (f)) != 0)
#define | rb_thread_raised_clear(th) ((th)->raised_flag = 0)
#define | CharNext(p) ((p) + mblen((p), RUBY_MBCHAR_MAXSIZE))

## Enumerations

enum | ruby_tag_type { RUBY_TAG_RETURN = 0x1, RUBY_TAG_BREAK = 0x2, RUBY_TAG_NEXT = 0x3, RUBY_TAG_RETRY = 0x4, RUBY_TAG_REDO = 0x5, RUBY_TAG_RAISE = 0x6, RUBY_TAG_THROW = 0x7, RUBY_TAG_FATAL = 0x8, RUBY_TAG_MASK = 0xf }
enum | { RAISED_EXCEPTION = 1, RAISED_STACKOVERFLOW = 2, RAISED_NOMEMORY = 4 }

## Functions

void * | alloca ()
char * | strrchr (const char *, const char)
void | rb_thread_cleanup (void)
void | rb_thread_wait_other_threads (void)
int | rb_threadptr_set_raised (rb_thread_t *th)
int | rb_threadptr_reset_raised (rb_thread_t *th)
VALUE | rb_f_eval (int argc, VALUE *argv, VALUE self)
VALUE | rb_make_exception (int argc, VALUE *argv)
| NORETURN (void rb_fiber_start(void))
| NORETURN (void rb_print_undef(VALUE, ID, int))
| NORETURN (void rb_vm_localjump_error(const char *, VALUE, int))
| NORETURN (void rb_vm_jump_tag_but_local_jump(int, VALUE))
| NORETURN (void rb_raise_method_missing(rb_thread_t *th, int argc, VALUE *argv, VALUE obj, int call_status))
VALUE | rb_vm_make_jump_tag_but_local_jump (int state, VALUE val)
NODE * | rb_vm_cref (void)
VALUE | rb_vm_call_cfunc (VALUE recv, VALUE(*func)(VALUE), VALUE arg, const rb_block_t *blockptr, VALUE filename)
void | rb_vm_set_progname (VALUE filename)
void | rb_thread_terminate_all (void)
VALUE | rb_vm_top_self ()
VALUE | rb_vm_cbase (void)
void | rb_trap_restore_mask (void)

## Macro Definition Documentation

#define CharNext | ( |  | p | ) | ((p) + mblen((p), RUBY_MBCHAR_MAXSIZE))

Definition at line 219 of file eval_intern.h.

Referenced by cmdglob(), dln_find_1(), has_redirection(), join_argv(), push_include(), rb_w32_cmdvector(), rb_w32_spawn(), and translate_char().

#define CHECK_STACK_OVERFLOW | ( |  | cfp,
|  |  | margin
| ) |  |

Value:
do \
if ((VALUE *)((char *)(((VALUE *)(cfp)->sp) + (margin)) + sizeof(rb_control_frame_t)) >= ((VALUE *)(cfp))) { \
rb_exc_raise(sysstack_error); \
} \
while (0)

Definition at line 177 of file eval_intern.h.

Referenced by caller_setup_args(), eval_string_with_cref(), invoke_block_from_c(), vm_call0(), vm_invoke_block(), vm_set_eval_stack(), vm_set_main_stack(), vm_set_top_stack(), vm_setup_method(), and vm_yield_setup_block_args().

#define EXEC_TAG | ( |  | ) | TH_EXEC_TAG()

Definition at line 130 of file eval_intern.h.

Referenced by error_print(), eval_string_with_cref(), exec_recursive_i(), rb_catch_obj(), rb_ensure(), rb_eval_cmd(), rb_exec_end_proc(), rb_fiber_start(), rb_load_internal(), rb_load_protect(), rb_method_call(), rb_protect(), rb_require_safe(), rb_rescue2(), rb_thread_terminate_all(), rb_vm_invoke_proc(), ruby_cleanup(), ruby_exec_internal(), ruby_finalize_0(), ruby_init(), ruby_options(), setup_exception(), thread_start_func_2(), thread_suppress_tracing(), and vm_exec().

#define EXIT_FAILURE 1

Definition at line 24 of file eval_intern.h.

Referenced by error_handle(), garbage_collect_with_gvl(), goruby_run_node(), Init_BareVM(), negative_size_allocation_error(), nkf_buf_push(), nkf_xmalloc(), nkf_xrealloc(), no_connection2(), rb_memerror(), rb_thread_call_with_gvl(), ruby_cleanup(), ruby_executable_node(), ruby_init(), and ruby_memerror().

#define EXIT_SUCCESS 0

Definition at line 21 of file eval_intern.h.

#define GET_THROWOBJ_CATCH_POINT | ( |  | obj | ) | ((VALUE*)RNODE((obj))->u2.value)

Definition at line 170 of file eval_intern.h.

Referenced by rb_iterate(), rb_vm_rewrite_dfp_in_errinfo(), and vm_exec().

#define GET_THROWOBJ_STATE | ( |  | obj | ) | ((int)RNODE((obj))->u3.value)

Definition at line 171 of file eval_intern.h.

Referenced by thread_join(), and vm_throw().

#define GET_THROWOBJ_VAL | ( |  | obj | ) | ((VALUE)RNODE((obj))->u1.value)

Definition at line 169 of file eval_intern.h.

Referenced by thread_join(), and vm_exec().

#define INTERNAL_EXCEPTION_P | ( |  | exc | ) | FIXNUM_P(exc)

Definition at line 139 of file eval_intern.h.

Referenced by setup_exception().

#define JUMP_TAG | ( |  | st | ) | TH_JUMP_TAG(GET_THREAD(), (st))

Definition at line 137 of file eval_intern.h.

Referenced by eval_string_with_cref(), exec_recursive_i(), rb_catch_obj(), rb_ensure(), rb_eval_cmd(), rb_eval_string_wrap(), rb_jump_tag(), rb_longjmp(), rb_memerror(), rb_method_call(), rb_raise_jump(), rb_require_safe(), rb_rescue2(), rb_throw_obj(), rb_vm_invoke_proc(), rb_vm_jump_tag_but_local_jump(), setup_exception(), thread_suppress_tracing(), and vm_exec().

#define NEW_THROW_OBJECT | ( |  | val,
|  |  | pt,
|  |  | st
| ) |  | ((VALUE)rb_node_newnode(NODE_LIT, (VALUE)(val), (VALUE)(pt), (VALUE)(st)))

Definition at line 162 of file eval_intern.h.

Referenced by rb_throw_obj(), vm_iter_break(), and vm_throw().

#define PASS_PASSED_BLOCK | ( |  | ) |

Value:
do { \
rb_thread_t * const __th__ = GET_THREAD(); \
PASS_PASSED_BLOCK_TH(__th__); \
} while (0)

Definition at line 12 of file eval_intern.h.

Referenced by rb_call_super(), and rb_obj_call_init().

#define PASS_PASSED_BLOCK_TH | ( |  | th | ) |

Value:
do { \
(th)->passed_block = GC_GUARDED_PTR_REF((rb_block_t *)(th)->cfp->lfp[0]); \
(th)->cfp->flag |= VM_FRAME_FLAG_PASSED; \
} while (0)

Definition at line 7 of file eval_intern.h.

Referenced by rb_funcall_passing_block(), rb_method_call(), and send_internal().

#define POP_TAG | ( |  | ) | TH_POP_TAG()

Definition at line 126 of file eval_intern.h.

Referenced by error_print(), eval_string_with_cref(), exec_recursive_i(), rb_catch_obj(), rb_ensure(), rb_eval_cmd(), rb_exec_end_proc(), rb_load_internal(), rb_load_protect(), rb_method_call(), rb_protect(), rb_require_safe(), rb_rescue2(), rb_thread_terminate_all(), ruby_cleanup(), ruby_exec_internal(), ruby_finalize_0(), ruby_init(), ruby_options(), setup_exception(), and thread_suppress_tracing().

#define PUSH_TAG | ( |  | ) | TH_PUSH_TAG(GET_THREAD())

Definition at line 125 of file eval_intern.h.

Referenced by error_print(), eval_string_with_cref(), exec_recursive_i(), rb_catch_obj(), rb_ensure(), rb_eval_cmd(), rb_exec_end_proc(), rb_load_internal(), rb_load_protect(), rb_method_call(), rb_protect(), rb_require_safe(), rb_rescue2(), rb_thread_terminate_all(), ruby_cleanup(), ruby_exec_internal(), ruby_finalize_0(), ruby_init(), ruby_options(), setup_exception(), and thread_suppress_tracing().

#define rb_thread_raised_clear | ( |  | th | ) | ((th)->raised_flag = 0)

Definition at line 196 of file eval_intern.h.

Referenced by error_print(), rb_longjmp(), rb_memerror(), and rb_raise_jump().

#define rb_thread_raised_p | ( |  | th,
|  |  | f
| ) |  | (((th)->raised_flag & (f)) != 0)

Definition at line 195 of file eval_intern.h.

Referenced by rb_memerror(), and stack_check().

#define rb_thread_raised_reset | ( |  | th,
|  |  | f
| ) |  | ((th)->raised_flag &= ~(f))

Definition at line 194 of file eval_intern.h.

#define rb_thread_raised_set | ( |  | th,
|  |  | f
| ) |  | ((th)->raised_flag |= (f))

Definition at line 193 of file eval_intern.h.

Referenced by error_print(), rb_memerror(), and stack_check().

#define ruby_longjmp | ( |  | env,
|  |  | val
| ) |  | RUBY_LONGJMP((env),(val))

Definition at line 68 of file eval_intern.h.

Referenced by cont_restore_1().

#define ruby_setjmp | ( |  | env | ) | RUBY_SETJMP(env)

Definition at line 67 of file eval_intern.h.

Referenced by cont_capture(), and fiber_store().

#define SAVE_ROOT_JMPBUF | ( |  | th,
|  |  | stmt
| ) |  |

Value:
do \
if (ruby_setjmp((th)->root_jmpbuf) == 0) { \
stmt; \
} \
else { \
rb_fiber_start(); \
} while (0)

Definition at line 103 of file eval_intern.h.

Referenced by rb_protect(), ruby_cleanup(), ruby_exec_internal(), ruby_options(), and thread_start_func_2().

#define SCOPE_CHECK | ( |  | f | ) | (rb_vm_cref()->nd_visi == (f))

Definition at line 174 of file eval_intern.h.

Referenced by rb_attr().

#define SCOPE_SET | ( |  | f | ) | (rb_vm_cref()->nd_visi = (f))

Definition at line 175 of file eval_intern.h.

Referenced by init_ext_call(), load_ext(), rb_mod_modfunc(), rb_mod_private(), rb_mod_protected(), and rb_mod_public().

#define SCOPE_TEST | ( |  | f | ) | (rb_vm_cref()->nd_visi & (f))

Definition at line 173 of file eval_intern.h.

Referenced by rb_attr().

#define SET_THROWOBJ_CATCH_POINT | ( |  | obj,
|  |  | val
| ) |  | (RNODE((obj))->u2.value = (val))

Definition at line 164 of file eval_intern.h.

Referenced by rb_vm_rewrite_dfp_in_errinfo(), and vm_exec().

#define SET_THROWOBJ_STATE | ( |  | obj,
|  |  | val
| ) |  | (RNODE((obj))->u3.value = (val))

Definition at line 166 of file eval_intern.h.

Referenced by vm_exec().

#define TAG_BREAK RUBY_TAG_BREAK

Definition at line 153 of file eval_intern.h.

Referenced by error_handle(), make_localjump_error(), rb_iterate(), rb_vm_make_jump_tag_but_local_jump(), vm_exec(), vm_iter_break(), and vm_throw().

#define TAG_FATAL RUBY_TAG_FATAL

Definition at line 159 of file eval_intern.h.

Referenced by error_handle(), rb_exc_fatal(), rb_threadptr_execute_interrupts_common(), setup_exception(), and thread_start_func_2().

#define TAG_MASK RUBY_TAG_MASK

Definition at line 160 of file eval_intern.h.

Referenced by error_handle().

#define TAG_NEXT RUBY_TAG_NEXT

Definition at line 154 of file eval_intern.h.

Referenced by error_handle(), make_localjump_error(), rb_vm_make_jump_tag_but_local_jump(), and vm_exec().

#define TAG_RAISE RUBY_TAG_RAISE

Definition at line 157 of file eval_intern.h.

Referenced by error_handle(), eval_string_with_cref(), rb_exc_raise(), rb_fiber_start(), rb_memerror(), rb_raise_jump(), rb_rescue2(), ruby_thread_stack_overflow(), vm_exec(), and vm_throw().

#define TAG_REDO RUBY_TAG_REDO

Definition at line 156 of file eval_intern.h.

Referenced by error_handle(), make_localjump_error(), rb_vm_make_jump_tag_but_local_jump(), and vm_exec().

#define TAG_RETRY RUBY_TAG_RETRY

Definition at line 155 of file eval_intern.h.

Referenced by error_handle(), make_localjump_error(), rb_iterate(), rb_rescue2(), rb_vm_make_jump_tag_but_local_jump(), vm_exec(), and vm_throw().

#define TAG_RETURN RUBY_TAG_RETURN

Definition at line 152 of file eval_intern.h.

Referenced by error_handle(), make_localjump_error(), rb_vm_make_jump_tag_but_local_jump(), vm_exec(), and vm_throw().

#define TAG_THROW RUBY_TAG_THROW

Definition at line 158 of file eval_intern.h.

Referenced by error_handle(), rb_catch_obj(), rb_throw_obj(), and vm_throw().

#define TH_EXEC_TAG | ( |  | ) | ruby_setjmp(_th->tag->buf)

Definition at line 128 of file eval_intern.h.

Referenced by rb_iterate().

#define TH_JUMP_TAG | ( |  | th,
|  |  | st
| ) |  |

Value:
do { \
ruby_longjmp((th)->tag->buf,(st)); \
} while (0)

Definition at line 133 of file eval_intern.h.

Referenced by rb_iterate(), rb_threadptr_execute_interrupts_common(), ruby_thread_stack_overflow(), and vm_iter_break().

#define TH_POP_TAG | ( |  | ) |

Value:
_th->tag = _tag.prev; \
} while (0)

Definition at line 118 of file eval_intern.h.

Referenced by rb_fiber_start(), rb_iterate(), rb_vm_invoke_proc(), thread_start_func_2(), and vm_exec().

#define TH_POP_TAG2 | ( |  | ) | _th->tag = _tag.prev

Definition at line 122 of file eval_intern.h.

Referenced by vm_exec().

#define TH_PUSH_TAG | ( |  | th | ) |

Value:
do { \
rb_thread_t * const _th = (th); \
struct rb_vm_tag _tag; \
_tag.tag = 0; \
_tag.prev = _th->tag; \
_th->tag = &_tag;

Definition at line 111 of file eval_intern.h.

Referenced by rb_fiber_start(), rb_iterate(), rb_vm_invoke_proc(), thread_start_func_2(), and vm_exec().

## Enumeration Type Documentation

anonymous enum

Enumerator
RAISED_EXCEPTION |
RAISED_STACKOVERFLOW |
RAISED_NOMEMORY |

Definition at line 186 of file eval_intern.h.

enum ruby_tag_type

Enumerator
RUBY_TAG_RETURN |
RUBY_TAG_BREAK |
RUBY_TAG_NEXT |
RUBY_TAG_RETRY |
RUBY_TAG_REDO |
RUBY_TAG_RAISE |
RUBY_TAG_THROW |
RUBY_TAG_FATAL |
RUBY_TAG_MASK |

Definition at line 141 of file eval_intern.h.

## Function Documentation

void* alloca | ( |  | ) |

NORETURN | ( | void | rb_fiber_startvoid | ) |

NORETURN | ( | void | rb_print_undefVALUE, ID, int | ) |

NORETURN | ( | void | rb_vm_localjump_errorconst char *, VALUE, int | ) |

NORETURN | ( | void | rb_vm_jump_tag_but_local_jumpint, VALUE | ) |

NORETURN | ( | void | rb_raise_method_missingrb_thread_t *th, int argc, VALUE *argv, VALUE obj, int call_status | ) |

VALUE rb_f_eval | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |

Definition at line 1113 of file vm_eval.c.

References eval_string(), NIL_P, NUM2INT, OBJ_TAINTED, rb_eSecurityError, rb_raise(), rb_safe_level, rb_scan_args(), RSTRING_PTR, SafeStringValue, and StringValue.

Referenced by bind_eval(), and Init_vm_eval().

VALUE rb_make_exception | ( | int | argc,
|  | VALUE * | argv
| ) |  |

Definition at line 574 of file eval.c.

void rb_thread_cleanup | ( | void |  | ) |

void rb_thread_terminate_all | ( | void |  | ) |

Definition at line 355 of file thread.c.

References EXEC_TAG, GET_THREAD, rb_vm_struct::inhibit_thread_creation, rb_vm_struct::living_threads, rb_vm_struct::main_thread, POP_TAG, PUSH_TAG, rb_bug(), rb_thread_alone(), rb_thread_schedule(), rb_threadptr_unlock_all_locking_mutexes(), st_foreach, terminate_i(), rb_mutex_struct::th, thread_debug, and rb_thread_struct::vm.

Referenced by ruby_cleanup().

void rb_thread_wait_other_threads | ( | void |  | ) |

int rb_threadptr_reset_raised | ( | rb_thread_t * | th | ) |

Definition at line 1428 of file thread.c.

References RAISED_EXCEPTION, and rb_thread_struct::raised_flag.

Referenced by error_handle(), setup_exception(), and thread_suppress_tracing().

int rb_threadptr_set_raised | ( | rb_thread_t * | th | ) |

Definition at line 1418 of file thread.c.

References RAISED_EXCEPTION, and rb_thread_struct::raised_flag.

Referenced by error_handle(), setup_exception(), and thread_suppress_tracing().

void rb_trap_restore_mask | ( | void |  | ) |

Definition at line 874 of file signal.c.

References NULL, and pthread_sigmask().

Referenced by rb_throw_obj(), and setup_exception().

VALUE rb_vm_call_cfunc | ( | VALUE | recv,
|  | VALUE(*)(VALUE) | func,
|  | VALUE | arg,
|  | const rb_block_t * | blockptr,
|  | VALUE | filename
| ) |  |

Definition at line 1527 of file vm.c.

References arg, rb_thread_struct::cfp, DATA_PTR, GET_THREAD, Qnil, rb_iseq_new(), rb_control_frame_t::sp, VM_FRAME_MAGIC_TOP, vm_pop_frame(), and vm_push_frame().

Referenced by rb_require_safe(), and ruby_init_ext().

VALUE rb_vm_cbase | ( | void |  | ) |

Definition at line 910 of file vm.c.

References rb_thread_struct::cfp, rb_control_frame_t::dfp, GET_THREAD, rb_control_frame_t::iseq, rb_control_frame_t::lfp, rb_eRuntimeError, rb_raise(), rb_vm_get_ruby_level_next_cfp(), and vm_get_cbase().

Referenced by rb_f_autoload(), rb_f_autoload_p(), and rb_undef().

NODE* rb_vm_cref | ( | void |  | ) |

Definition at line 886 of file vm.c.

References rb_thread_struct::cfp, rb_control_frame_t::dfp, GET_THREAD, rb_control_frame_t::iseq, rb_control_frame_t::lfp, rb_eRuntimeError, rb_raise(), rb_vm_get_ruby_level_next_cfp(), and vm_get_cref().

Referenced by m_core_define_method(), m_core_define_singleton_method(), rb_mod_nesting(), and rb_mod_s_constants().

VALUE rb_vm_make_jump_tag_but_local_jump | ( | int | state,
|  | VALUE | val
| ) |  |

Definition at line 963 of file vm.c.

References GET_THREAD, make_localjump_error(), Qnil, Qundef, result, TAG_BREAK, TAG_NEXT, TAG_REDO, TAG_RETRY, and TAG_RETURN.

Referenced by rb_fiber_start(), rb_vm_jump_tag_but_local_jump(), and thread_join().

void rb_vm_set_progname | ( | VALUE | filename | ) |

Definition at line 2189 of file vm.c.

References rb_iseq_struct::filename, GET_VM, rb_control_frame_t::iseq, rb_thread_struct::stack, and rb_thread_struct::stack_size.

Referenced by load_file_internal(), process_options(), and ruby_script().

VALUE rb_vm_top_self | ( |  | ) |

Definition at line 2236 of file vm.c.

Referenced by Init_eval(), Init_eval_method(), Init_top_self(), Init_VM(), rb_eval_cmd(), rb_eval_string(), rb_eval_string_wrap(), rb_load_internal(), rb_require_safe(), require_libraries(), ruby_init_ext(), and ruby_thread_init().

char* strrchr | ( | const char * | ,
|  | const char |
| ) |  |

Referenced by load_file_internal(), parse_mode_enc(), proc_exec_v(), rb_feature_provided(), ruby_init_loadpath_safe(), and search_required().