23#ifdef HAVE_SYS_PRCTL_H
39#define id_cause ruby_static_id_cause
41#define exception_error GET_VM()->special_exceptions[ruby_error_reenter]
46#define CLASS_OR_MODULE_P(obj) \
47 (!SPECIAL_CONST_P(obj) && \
48 (BUILTIN_TYPE(obj) == T_CLASS || BUILTIN_TYPE(obj) == T_MODULE))
69#if defined(__linux__) && defined(PR_SET_THP_DISABLE)
70 prctl(PR_SET_THP_DISABLE, 1, 0, 0, 0);
119 void *
volatile iseq = 0;
128 state = error_handle(ec, state);
143 rb_ec_exec_end_proc(ec);
183 return rb_ec_cleanup(
GET_EC(), ex);
195 volatile int step = 0;
225 if (ex == 0) ex = state;
229 sysex = error_handle(ec, ex);
232 for (nerr = 0; nerr <
numberof(errs); ++nerr) {
241 sysex = sysexit_status(
err);
318 if (status) *status = s;
332 rb_ec_cleanup(ec, 0);
336 return rb_ec_cleanup(ec, rb_ec_exec_node(ec,
n));
344 return rb_ec_exec_node(
GET_EC(),
n);
368 while (cref && CREF_NEXT(cref)) {
370 if (!CREF_PUSHED_BY_EVAL(cref) &&
374 cref = CREF_NEXT(cref);
414 klass = CREF_CLASS(cref);
415 if (!CREF_PUSHED_BY_EVAL(cref) &&
422 cref = CREF_NEXT(cref);
480static VALUE get_errinfo(
void);
481#define get_ec_errinfo(ec) rb_ec_get_errinfo(ec)
489 CONST_ID(id_true_cause,
"true_cause");
500 if (!
NIL_P(cause) && cause !=
exc) {
541 if (!nocircular && !
NIL_P(*cause) && *cause !=
Qundef && *cause != mesg) {
558 const char *
const volatile file0 = file;
561 volatile int state = 0;
572 exc_setup_cause(mesg, cause);
577 set_backtrace(mesg, at);
583 if (state)
goto fatal;
652 mesg = exc_setup_message(ec, mesg, &cause);
653 setup_exception(ec, tag, mesg, cause);
671 mesg = make_exception(1, &mesg,
FALSE);
687 mesg = make_exception(1, &mesg,
FALSE);
824 set_backtrace(mesg,
argv[2]);
990 result = (*b_proc) (data1);
1019 result = (*r_proc) (data2, ec->
errinfo);
1096 if (pstate !=
NULL) *pstate = state;
1129 result = (*b_proc) (data1);
1217prev_frame_callee(
void)
1220 if (!prev_cfp)
return 0;
1221 return frame_called_id(prev_cfp);
1225prev_frame_func(
void)
1228 if (!prev_cfp)
return 0;
1229 return frame_func_id(prev_cfp);
1245 while (!(mid = frame_func_id(
cfp)) &&
1247 !RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(ec,
cfp)));
1264rb_mod_append_features(
VALUE module,
VALUE include)
1285 ID id_append_features, id_included;
1287 CONST_ID(id_append_features,
"append_features");
1313rb_mod_prepend_features(
VALUE module,
VALUE prepend)
1334 ID id_prepend_features, id_prepended;
1336 CONST_ID(id_prepend_features,
"prepend_features");
1337 CONST_ID(id_prepended,
"prepended");
1354 "wrong argument type %"PRIsVALUE" (expected Class or Module)",
1360hidden_identity_hash_new(
void)
1369refinement_superclass(
VALUE superclass)
1389 ensure_class_or_module(
klass);
1391 if (
NIL_P(CREF_REFINEMENTS(cref))) {
1392 CREF_REFINEMENTS_SET(cref, hidden_identity_hash_new());
1395 if (CREF_OMOD_SHARED(cref)) {
1396 CREF_REFINEMENTS_SET(cref,
rb_hash_dup(CREF_REFINEMENTS(cref)));
1397 CREF_OMOD_SHARED_UNSET(cref);
1411 superclass = refinement_superclass(superclass);
1419 while (module && module !=
klass) {
1433 rb_using_refinement(cref,
klass, module);
1441 VALUE super, module, refinements;
1445 using_module_recursive(cref, super);
1461 CONST_ID(id_refinements,
"__refinements__");
1462 refinements =
rb_attr_get(module, id_refinements);
1463 if (
NIL_P(refinements))
return;
1475 using_module_recursive(cref, module);
1483 ID id_refined_class;
1485 CONST_ID(id_refined_class,
"__refined_class__");
1490add_activated_refinement(
VALUE activated_refinements,
1506 superclass = refinement_superclass(superclass);
1510 while (refinement && refinement !=
klass) {
1532 ID id_refinements, id_activated_refinements,
1533 id_refined_class, id_defined_at;
1534 VALUE refinements, activated_refinements;
1545 ensure_class_or_module(
klass);
1549 CONST_ID(id_refinements,
"__refinements__");
1550 refinements =
rb_attr_get(module, id_refinements);
1551 if (
NIL_P(refinements)) {
1552 refinements = hidden_identity_hash_new();
1555 CONST_ID(id_activated_refinements,
"__activated_refinements__");
1556 activated_refinements =
rb_attr_get(module, id_activated_refinements);
1557 if (
NIL_P(activated_refinements)) {
1558 activated_refinements = hidden_identity_hash_new();
1560 activated_refinements);
1563 if (
NIL_P(refinement)) {
1564 VALUE superclass = refinement_superclass(
klass);
1566 RCLASS_SET_SUPER(refinement, superclass);
1568 CONST_ID(id_refined_class,
"__refined_class__");
1570 CONST_ID(id_defined_at,
"__defined_at__");
1573 add_activated_refinement(activated_refinements,
klass, refinement);
1580ignored_block(
VALUE module,
const char *
klass)
1582 const char *anon =
"";
1585 anon =
", maybe for Module.new";
1587 rb_warn(
"%s""using doesn't call the given block""%s.",
klass, anon);
1603 if (prev_frame_func()) {
1605 "Module#using is not permitted in methods");
1607 if (prev_cfp && prev_cfp->
self !=
self) {
1611 ignored_block(module,
"Module#");
1621 CONST_ID(id_defined_at,
"__defined_at__");
1655rb_mod_s_used_modules(
VALUE _)
1661 if (!
NIL_P(CREF_REFINEMENTS(cref))) {
1664 cref = CREF_NEXT(cref);
1769 ID id_extend_object, id_extended;
1771 CONST_ID(id_extend_object,
"extend_object");
1799 rb_warning(
"main.include in the wrapped load is effective only in wrapper module");
1823 ignored_block(module,
"main.");
1836 if (VM_FRAME_RUBYFRAME_P(
cfp)) {
1854 const VALUE *
ptr = errinfo_place(ec);
1872 return get_errinfo();
1884 return GET_EC()->errinfo;
1923 set_backtrace(
err, val);
1939 ID fname = prev_frame_func();
1961 ID fname = prev_frame_callee();
1982f_current_dirname(
VALUE _)
2002f_global_variables(
VALUE _)
2076 rb_mod_s_used_modules, 0);
2088 "include", top_include, -1);
2090 "using", top_using, 1);
void rb_obj_call_init_kw(VALUE obj, int argc, const VALUE *argv, int kw_splat)
int rb_vm_cframe_empty_keyword_p(const rb_control_frame_t *cfp)
void ruby_stop(int ex)
Calls ruby_cleanup() and exits the process.
VALUE rb_ec_get_errinfo(const rb_execution_context_t *ec)
#define get_ec_errinfo(ec)
void rb_ec_clear_all_trace_func(const rb_execution_context_t *ec)
VALUE rb_f_raise(int argc, VALUE *argv)
void rb_ec_clear_current_thread_trace_func(const rb_execution_context_t *ec)
#define CLASS_OR_MODULE_P(obj)
int rb_vm_cframe_keyword_p(const rb_control_frame_t *cfp)
NORETURN(void rb_raise_jump(VALUE, VALUE))
#define warn_print_str(x)
#define unknown_longjmp_status(status)
void rb_include_module(VALUE, VALUE)
void rb_extend_object(VALUE obj, VALUE module)
Extend the object with the module.
void rb_prepend_module(VALUE, VALUE)
VALUE rb_singleton_class(VALUE)
Returns the singleton class of obj.
VALUE rb_include_class_new(VALUE, VALUE)
VALUE rb_module_new(void)
void rb_class_modify_check(VALUE klass)
Asserts that klass is not a frozen class.
ID rb_frame_callee(void)
The name of the current method.
ID rb_frame_this_func(void)
The original name of the current method.
void rb_need_block(void)
Declares that the current method needs a block.
ID rb_frame_last_func(void)
Returns the ID of the last method in the call stack.
void rb_undef_method(VALUE, const char *)
int rb_block_given_p(void)
Determines if the current method is given a block.
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *)
int rb_empty_keyword_given_p(void)
VALUE rb_mKernel
Kernel module.
VALUE rb_vrescue2(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*r_proc)(VALUE, VALUE), VALUE data2, va_list args)
An equivalent of rescue clause.
VALUE rb_cClass
Class class.
VALUE rb_cBasicObject
BasicObject class.
VALUE rb_cObject
Object class.
VALUE rb_cModule
Module class.
int rb_keyword_given_p(void)
int ruby_exec_node(void *n)
Runs the given compiled source.
int ruby_setup(void)
Initializes the VM and builtin libraries.
void ruby_finalize(void)
Runs the VM finalization processes.
int ruby_cleanup(volatile int ex)
Destructs the VM.
VALUE rb_get_backtrace(VALUE info)
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_rescue2(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*r_proc)(VALUE, VALUE), VALUE data2,...)
An equivalent of rescue clause.
void rb_exc_raise(VALUE mesg)
Raises an exception in the current thread.
void rb_set_errinfo(VALUE err)
Sets the current exception ($!) to the given value.
void rb_interrupt(void)
Raises an Interrupt exception.
void rb_frozen_error_raise(VALUE frozen_obj, const char *fmt,...)
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *pstate)
Protects a function call from potential global escapes from the function.
VALUE rb_make_exception(int argc, const VALUE *argv)
Make an Exception object from the list of arguments in a manner similar to Kernel#raise.
void rb_exc_fatal(VALUE mesg)
Raises a fatal error in the current thread.
void rb_warn(const char *fmt,...)
VALUE rb_exc_new(VALUE, const char *, long)
VALUE rb_rescue(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*r_proc)(VALUE, VALUE), VALUE data2)
An equivalent of rescue clause.
VALUE rb_ensure(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*e_proc)(VALUE), VALUE data2)
An equivalent to ensure clause.
VALUE rb_errinfo(void)
The current exception in the current thread.
void rb_jump_tag(int tag)
Continues the exception caught by rb_protect() and rb_eval_string_protect().
void rb_obj_call_init(VALUE obj, int argc, const VALUE *argv)
Calls #initialize method of obj with the given arguments.
VALUE rb_obj_class(VALUE)
Equivalent to Object#class in Ruby.
VALUE rb_obj_dup(VALUE)
Equivalent to Object#dup in Ruby.
VALUE rb_obj_is_kind_of(VALUE, VALUE)
Determines if obj is a kind of c.
int ruby_run_node(void *n)
Runs the given compiled source and exits this process.
void ruby_init(void)
Calls ruby_setup() and check error.
void * ruby_options(int argc, char **argv)
Processes command line arguments and compiles the Ruby source to execute.
int ruby_executable_node(void *n, int *status)
Checks the return value of ruby_options().
struct rb_method_definition_struct *const def
struct rb_ensure_entry entry
struct rb_ensure_list * next
rb_ensure_list_t * ensure_list
struct rb_vm_protect_tag * protect_tag
enum rb_iseq_constant_body::iseq_type type
struct rb_iseq_constant_body * body
rb_execution_context_t * ec
enum rb_thread_status status
struct rb_vm_protect_tag * prev
VALUE rb_vm_frame_block_handler(const rb_control_frame_t *cfp)
VALUE rb_vm_top_self(void)
MJIT_FUNC_EXPORTED void rb_vm_localjump_error(const char *mesg, VALUE value, int reason)
MJIT_STATIC void rb_vm_pop_frame(rb_execution_context_t *ec)
MJIT_STATIC const rb_callable_method_entry_t * rb_vm_frame_method_entry(const rb_control_frame_t *cfp)
MJIT_STATIC void rb_error_arity(int argc, int min, int max)