Ruby 3.5.0dev (2025-09-17 revision 6094cb51136418a7b545baa84b6ede0aaeb2eaac)
yjit.c (6094cb51136418a7b545baa84b6ede0aaeb2eaac)
1// This part of YJIT helps interfacing with the rest of CRuby and with the OS.
2// Sometimes our FFI binding generation tool gives undesirable outputs when it
3// sees C features that Rust doesn't support well. We mitigate that by binding
4// functions which have simple parameter types. The boilerplate C functions for
5// that purpose are in this file.
6// Similarly, we wrap OS facilities we need in simple functions to help with
7// FFI and to avoid the need to use external crates.io Rust libraries.
8
9#include "internal.h"
10#include "internal/sanitizers.h"
11#include "internal/string.h"
12#include "internal/hash.h"
13#include "internal/variable.h"
14#include "internal/compile.h"
15#include "internal/class.h"
16#include "internal/fixnum.h"
17#include "internal/numeric.h"
18#include "internal/gc.h"
19#include "vm_core.h"
20#include "vm_callinfo.h"
21#include "builtin.h"
22#include "insns.inc"
23#include "insns_info.inc"
24#include "yjit.h"
25#include "zjit.h"
26#include "vm_insnhelper.h"
27#include "probes.h"
28#include "probes_helper.h"
29#include "iseq.h"
30#include "ruby/debug.h"
31#include "internal/cont.h"
32
33// For mmapp(), sysconf()
34#ifndef _WIN32
35#include <unistd.h>
36#include <sys/mman.h>
37#endif
38
39#include <errno.h>
40
41// Field offsets for the RString struct
42enum rstring_offsets {
43 RUBY_OFFSET_RSTRING_LEN = offsetof(struct RString, len)
44};
45
46// We need size_t to have a known size to simplify code generation and FFI.
47// TODO(alan): check this in configure.ac to fail fast on 32 bit platforms.
48STATIC_ASSERT(64b_size_t, SIZE_MAX == UINT64_MAX);
49// I don't know any C implementation that has uint64_t and puts padding bits
50// into size_t but the standard seems to allow it.
51STATIC_ASSERT(size_t_no_padding_bits, sizeof(size_t) == sizeof(uint64_t));
52
53// This build config impacts the pointer tagging scheme and we only want to
54// support one scheme for simplicity.
55STATIC_ASSERT(pointer_tagging_scheme, USE_FLONUM);
56
57// NOTE: We can trust that uint8_t has no "padding bits" since the C spec
58// guarantees it. Wording about padding bits is more explicit in C11 compared
59// to C99. See C11 7.20.1.1p2. All this is to say we have _some_ standards backing to
60// use a Rust `*mut u8` to represent a C `uint8_t *`.
61//
62// If we don't want to trust that we can interpreter the C standard correctly, we
63// could outsource that work to the Rust standard library by sticking to fundamental
64// types in C such as int, long, etc. and use `std::os::raw::c_long` and friends on
65// the Rust side.
66//
67// What's up with the long prefix? Even though we build with `-fvisibility=hidden`
68// we are sometimes a static library where the option doesn't prevent name collision.
69// The "_yjit_" part is for trying to be informative. We might want different
70// suffixes for symbols meant for Rust and symbols meant for broader CRuby.
71
72long
73rb_yjit_array_len(VALUE a)
74{
75 return rb_array_len(a);
76}
77
78# define PTR2NUM(x) (rb_int2inum((intptr_t)(void *)(x)))
79
80// For a given raw_sample (frame), set the hash with the caller's
81// name, file, and line number. Return the hash with collected frame_info.
82static void
83rb_yjit_add_frame(VALUE hash, VALUE frame)
84{
85 VALUE frame_id = PTR2NUM(frame);
86
87 if (RTEST(rb_hash_aref(hash, frame_id))) {
88 return;
89 }
90 else {
91 VALUE frame_info = rb_hash_new();
92 // Full label for the frame
94 // Absolute path of the frame from rb_iseq_realpath
96 // Line number of the frame
98
99 // If absolute path isn't available use the rb_iseq_path
100 if (NIL_P(file)) {
101 file = rb_profile_frame_path(frame);
102 }
103
104 rb_hash_aset(frame_info, ID2SYM(rb_intern("name")), name);
105 rb_hash_aset(frame_info, ID2SYM(rb_intern("file")), file);
106 rb_hash_aset(frame_info, ID2SYM(rb_intern("samples")), INT2NUM(0));
107 rb_hash_aset(frame_info, ID2SYM(rb_intern("total_samples")), INT2NUM(0));
108 rb_hash_aset(frame_info, ID2SYM(rb_intern("edges")), rb_hash_new());
109 rb_hash_aset(frame_info, ID2SYM(rb_intern("lines")), rb_hash_new());
110
111 if (line != INT2FIX(0)) {
112 rb_hash_aset(frame_info, ID2SYM(rb_intern("line")), line);
113 }
114
115 rb_hash_aset(hash, frame_id, frame_info);
116 }
117}
118
119// Parses the YjitExitLocations raw_samples and line_samples collected by
120// rb_yjit_record_exit_stack and turns them into 3 hashes (raw, lines, and frames) to
121// be used by RubyVM::YJIT.exit_locations. yjit_raw_samples represents the raw frames information
122// (without name, file, and line), and yjit_line_samples represents the line information
123// of the iseq caller.
124VALUE
125rb_yjit_exit_locations_dict(VALUE *yjit_raw_samples, int *yjit_line_samples, int samples_len)
126{
127 VALUE result = rb_hash_new();
128 VALUE raw_samples = rb_ary_new_capa(samples_len);
129 VALUE line_samples = rb_ary_new_capa(samples_len);
130 VALUE frames = rb_hash_new();
131 int idx = 0;
132
133 // While the index is less than samples_len, parse yjit_raw_samples and
134 // yjit_line_samples, then add casted values to raw_samples and line_samples array.
135 while (idx < samples_len) {
136 int num = (int)yjit_raw_samples[idx];
137 int line_num = (int)yjit_line_samples[idx];
138 idx++;
139
140 // + 1 as we append an additional sample for the insn
141 rb_ary_push(raw_samples, SIZET2NUM(num + 1));
142 rb_ary_push(line_samples, INT2NUM(line_num + 1));
143
144 // Loop through the length of samples_len and add data to the
145 // frames hash. Also push the current value onto the raw_samples
146 // and line_samples array respectively.
147 for (int o = 0; o < num; o++) {
148 rb_yjit_add_frame(frames, yjit_raw_samples[idx]);
149 rb_ary_push(raw_samples, SIZET2NUM(yjit_raw_samples[idx]));
150 rb_ary_push(line_samples, INT2NUM(yjit_line_samples[idx]));
151 idx++;
152 }
153
154 rb_ary_push(raw_samples, SIZET2NUM(yjit_raw_samples[idx]));
155 rb_ary_push(line_samples, INT2NUM(yjit_line_samples[idx]));
156 idx++;
157
158 rb_ary_push(raw_samples, SIZET2NUM(yjit_raw_samples[idx]));
159 rb_ary_push(line_samples, INT2NUM(yjit_line_samples[idx]));
160 idx++;
161 }
162
163 // Set add the raw_samples, line_samples, and frames to the results
164 // hash.
165 rb_hash_aset(result, ID2SYM(rb_intern("raw")), raw_samples);
166 rb_hash_aset(result, ID2SYM(rb_intern("lines")), line_samples);
167 rb_hash_aset(result, ID2SYM(rb_intern("frames")), frames);
168
169 return result;
170}
171
172// Is anyone listening for :c_call and :c_return event currently?
173bool
174rb_c_method_tracing_currently_enabled(const rb_execution_context_t *ec)
175{
176 rb_event_flag_t tracing_events;
177 if (rb_multi_ractor_p()) {
178 tracing_events = ruby_vm_event_enabled_global_flags;
179 }
180 else {
181 // At the time of writing, events are never removed from
182 // ruby_vm_event_enabled_global_flags so always checking using it would
183 // mean we don't compile even after tracing is disabled.
184 tracing_events = rb_ec_ractor_hooks(ec)->events;
185 }
186
187 return tracing_events & (RUBY_EVENT_C_CALL | RUBY_EVENT_C_RETURN);
188}
189
190// The code we generate in gen_send_cfunc() doesn't fire the c_return TracePoint event
191// like the interpreter. When tracing for c_return is enabled, we patch the code after
192// the C method return to call into this to fire the event.
193void
194rb_full_cfunc_return(rb_execution_context_t *ec, VALUE return_value)
195{
196 rb_control_frame_t *cfp = ec->cfp;
197 RUBY_ASSERT_ALWAYS(cfp == GET_EC()->cfp);
198 const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(cfp);
199
200 RUBY_ASSERT_ALWAYS(RUBYVM_CFUNC_FRAME_P(cfp));
201 RUBY_ASSERT_ALWAYS(me->def->type == VM_METHOD_TYPE_CFUNC);
202
203 // CHECK_CFP_CONSISTENCY("full_cfunc_return"); TODO revive this
204
205 // Pop the C func's frame and fire the c_return TracePoint event
206 // Note that this is the same order as vm_call_cfunc_with_frame().
207 rb_vm_pop_frame(ec);
208 EXEC_EVENT_HOOK(ec, RUBY_EVENT_C_RETURN, cfp->self, me->def->original_id, me->called_id, me->owner, return_value);
209 // Note, this deviates from the interpreter in that users need to enable
210 // a c_return TracePoint for this DTrace hook to work. A reasonable change
211 // since the Ruby return event works this way as well.
212 RUBY_DTRACE_CMETHOD_RETURN_HOOK(ec, me->owner, me->def->original_id);
213
214 // Push return value into the caller's stack. We know that it's a frame that
215 // uses cfp->sp because we are patching a call done with gen_send_cfunc().
216 ec->cfp->sp[0] = return_value;
217 ec->cfp->sp++;
218}
219
220// TODO(alan): consider using an opaque pointer for the payload rather than a void pointer
221void *
222rb_iseq_get_yjit_payload(const rb_iseq_t *iseq)
223{
224 RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(iseq, imemo_iseq));
225 if (iseq->body) {
226 return iseq->body->yjit_payload;
227 }
228 else {
229 // Body is NULL when constructing the iseq.
230 return NULL;
231 }
232}
233
234void
235rb_iseq_set_yjit_payload(const rb_iseq_t *iseq, void *payload)
236{
237 RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(iseq, imemo_iseq));
238 RUBY_ASSERT_ALWAYS(iseq->body);
239 RUBY_ASSERT_ALWAYS(NULL == iseq->body->yjit_payload);
240 iseq->body->yjit_payload = payload;
241}
242
243rb_proc_t *
244rb_yjit_get_proc_ptr(VALUE procv)
245{
246 rb_proc_t *proc;
247 GetProcPtr(procv, proc);
248 return proc;
249}
250
251// This is defined only as a named struct inside rb_iseq_constant_body.
252// By giving it a separate typedef, we make it nameable by rust-bindgen.
253// Bindgen's temp/anon name isn't guaranteed stable.
254typedef struct rb_iseq_param_keyword rb_seq_param_keyword_struct;
255
256ID rb_get_symbol_id(VALUE namep);
257
258VALUE
259rb_get_def_bmethod_proc(rb_method_definition_t *def)
260{
261 RUBY_ASSERT(def->type == VM_METHOD_TYPE_BMETHOD);
262 return def->body.bmethod.proc;
263}
264
265VALUE
266rb_optimized_call(VALUE *recv, rb_execution_context_t *ec, int argc, VALUE *argv, int kw_splat, VALUE block_handler)
267{
268 rb_proc_t *proc;
269 GetProcPtr(recv, proc);
270 return rb_vm_invoke_proc(ec, proc, argc, argv, kw_splat, block_handler);
271}
272
273unsigned int
274rb_yjit_iseq_builtin_attrs(const rb_iseq_t *iseq)
275{
276 return iseq->body->builtin_attrs;
277}
278
279// If true, the iseq has only opt_invokebuiltin_delegate(_leave) and leave insns.
280static bool
281invokebuiltin_delegate_leave_p(const rb_iseq_t *iseq)
282{
283 int insn1 = rb_vm_insn_addr2opcode((void *)iseq->body->iseq_encoded[0]);
284 if ((int)iseq->body->iseq_size != insn_len(insn1) + insn_len(BIN(leave))) {
285 return false;
286 }
287 int insn2 = rb_vm_insn_addr2opcode((void *)iseq->body->iseq_encoded[insn_len(insn1)]);
288 return (insn1 == BIN(opt_invokebuiltin_delegate) || insn1 == BIN(opt_invokebuiltin_delegate_leave)) &&
289 insn2 == BIN(leave);
290}
291
292// Return an rb_builtin_function if the iseq contains only that builtin function.
293const struct rb_builtin_function *
294rb_yjit_builtin_function(const rb_iseq_t *iseq)
295{
296 if (invokebuiltin_delegate_leave_p(iseq)) {
297 return (const struct rb_builtin_function *)iseq->body->iseq_encoded[1];
298 }
299 else {
300 return NULL;
301 }
302}
303
304VALUE
305rb_yjit_str_simple_append(VALUE str1, VALUE str2)
306{
307 return rb_str_cat(str1, RSTRING_PTR(str2), RSTRING_LEN(str2));
308}
309
310extern VALUE *rb_vm_base_ptr(struct rb_control_frame_struct *cfp);
311
312// YJIT needs this function to never allocate and never raise
313VALUE
314rb_yarv_str_eql_internal(VALUE str1, VALUE str2)
315{
316 // We wrap this since it's static inline
317 return rb_str_eql_internal(str1, str2);
318}
319
320VALUE
321rb_str_neq_internal(VALUE str1, VALUE str2)
322{
323 return rb_str_eql_internal(str1, str2) == Qtrue ? Qfalse : Qtrue;
324}
325
326extern VALUE rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary);
327
328VALUE
329rb_yjit_rb_ary_subseq_length(VALUE ary, long beg)
330{
331 long len = RARRAY_LEN(ary);
332 return rb_ary_subseq(ary, beg, len);
333}
334
335VALUE
336rb_yjit_fix_div_fix(VALUE recv, VALUE obj)
337{
338 return rb_fix_div_fix(recv, obj);
339}
340
341VALUE
342rb_yjit_fix_mod_fix(VALUE recv, VALUE obj)
343{
344 return rb_fix_mod_fix(recv, obj);
345}
346
347// Return non-zero when `obj` is an array and its last item is a
348// `ruby2_keywords` hash. We don't support this kind of splat.
349size_t
350rb_yjit_ruby2_keywords_splat_p(VALUE obj)
351{
352 if (!RB_TYPE_P(obj, T_ARRAY)) return 0;
353 long len = RARRAY_LEN(obj);
354 if (len == 0) return 0;
355 VALUE last = RARRAY_AREF(obj, len - 1);
356 if (!RB_TYPE_P(last, T_HASH)) return 0;
357 return FL_TEST_RAW(last, RHASH_PASS_AS_KEYWORDS);
358}
359
360// Checks to establish preconditions for rb_yjit_splat_varg_cfunc()
361VALUE
362rb_yjit_splat_varg_checks(VALUE *sp, VALUE splat_array, rb_control_frame_t *cfp)
363{
364 // We inserted a T_ARRAY guard before this call
365 long len = RARRAY_LEN(splat_array);
366
367 // Large splat arrays need a separate allocation
368 if (len < 0 || len > VM_ARGC_STACK_MAX) return Qfalse;
369
370 // Would we overflow if we put the contents of the array onto the stack?
371 if (sp + len > (VALUE *)(cfp - 2)) return Qfalse;
372
373 // Reject keywords hash since that requires duping it sometimes
374 if (len > 0) {
375 VALUE last_hash = RARRAY_AREF(splat_array, len - 1);
376 if (RB_TYPE_P(last_hash, T_HASH) &&
377 FL_TEST_RAW(last_hash, RHASH_PASS_AS_KEYWORDS)) {
378 return Qfalse;
379 }
380 }
381
382 return Qtrue;
383}
384
385// Push array elements to the stack for a C method that has a variable number
386// of parameters. Returns the number of arguments the splat array contributes.
387int
388rb_yjit_splat_varg_cfunc(VALUE *stack_splat_array)
389{
390 VALUE splat_array = *stack_splat_array;
391 int len;
392
393 // We already checked that length fits in `int`
394 RUBY_ASSERT(RB_TYPE_P(splat_array, T_ARRAY));
395 len = (int)RARRAY_LEN(splat_array);
396
397 // Push the contents of the array onto the stack
398 MEMCPY(stack_splat_array, RARRAY_CONST_PTR(splat_array), VALUE, len);
399
400 return len;
401}
402
403// Print the Ruby source location of some ISEQ for debugging purposes
404void
405rb_yjit_dump_iseq_loc(const rb_iseq_t *iseq, uint32_t insn_idx)
406{
407 char *ptr;
408 long len;
409 VALUE path = rb_iseq_path(iseq);
410 RSTRING_GETMEM(path, ptr, len);
411 fprintf(stderr, "%s %.*s:%u\n", __func__, (int)len, ptr, rb_iseq_line_no(iseq, insn_idx));
412}
413
414// Get the number of digits required to print an integer
415static int
416num_digits(int integer)
417{
418 int num = 1;
419 while (integer /= 10) {
420 num++;
421 }
422 return num;
423}
424
425// Allocate a C string that formats an ISEQ label like iseq_inspect()
426char *
427rb_yjit_iseq_inspect(const rb_iseq_t *iseq)
428{
429 const char *label = RSTRING_PTR(iseq->body->location.label);
430 const char *path = RSTRING_PTR(rb_iseq_path(iseq));
431 int lineno = iseq->body->location.code_location.beg_pos.lineno;
432
433 const size_t size = strlen(label) + strlen(path) + num_digits(lineno) + 3;
434 char *buf = ZALLOC_N(char, size);
435 snprintf(buf, size, "%s@%s:%d", label, path, lineno);
436 return buf;
437}
438
439// There are RSTRUCT_SETs in ruby/internal/core/rstruct.h and internal/struct.h
440// with different types (int vs long) for k. Here we use the one from ruby/internal/core/rstruct.h,
441// which takes an int.
442void
443rb_RSTRUCT_SET(VALUE st, int k, VALUE v)
444{
445 RSTRUCT_SET(st, k, v);
446}
447
448// Return the string encoding index
449int
450rb_ENCODING_GET(VALUE obj)
451{
452 return RB_ENCODING_GET(obj);
453}
454
455bool
456rb_yjit_constcache_shareable(const struct iseq_inline_constant_cache_entry *ice)
457{
458 return (ice->flags & IMEMO_CONST_CACHE_SHAREABLE) != 0;
459}
460
461// For running write barriers from Rust. Required when we add a new edge in the
462// object graph from `old` to `young`.
463void
464rb_yjit_obj_written(VALUE old, VALUE young, const char *file, int line)
465{
466 rb_obj_written(old, Qundef, young, file, line);
467}
468
469void
470rb_yjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec, bool jit_exception)
471{
472 RB_VM_LOCKING() {
473 rb_vm_barrier();
474
475 // Compile a block version starting at the current instruction
476 uint8_t *rb_yjit_iseq_gen_entry_point(const rb_iseq_t *iseq, rb_execution_context_t *ec, bool jit_exception); // defined in Rust
477 uintptr_t code_ptr = (uintptr_t)rb_yjit_iseq_gen_entry_point(iseq, ec, jit_exception);
478
479 if (jit_exception) {
480 iseq->body->jit_exception = (rb_jit_func_t)code_ptr;
481 }
482 else {
483 iseq->body->jit_entry = (rb_jit_func_t)code_ptr;
484 }
485 }
486}
487
488// GC root for interacting with the GC
490 bool unused; // empty structs are not legal in C99
491};
492
493// For dealing with refinements
494void
495rb_yjit_invalidate_all_method_lookup_assumptions(void)
496{
497 // It looks like Module#using actually doesn't need to invalidate all the
498 // method caches, so we do nothing here for now.
499}
500
501// Number of object shapes, which might be useful for investigating YJIT exit reasons.
502VALUE
503rb_object_shape_count(void)
504{
505 // next_shape_id starts from 0, so it's the same as the count
506 return ULONG2NUM((unsigned long)rb_shapes_count());
507}
508
509bool
510rb_yjit_shape_obj_too_complex_p(VALUE obj)
511{
512 return rb_shape_obj_too_complex_p(obj);
513}
514
515attr_index_t
516rb_yjit_shape_capacity(shape_id_t shape_id)
517{
518 return RSHAPE_CAPACITY(shape_id);
519}
520
521attr_index_t
522rb_yjit_shape_index(shape_id_t shape_id)
523{
524 return RSHAPE_INDEX(shape_id);
525}
526
527// The number of stack slots that vm_sendish() pops for send and invokesuper.
528size_t
529rb_yjit_sendish_sp_pops(const struct rb_callinfo *ci)
530{
531 return 1 - sp_inc_of_sendish(ci); // + 1 to ignore return value push
532}
533
534// The number of stack slots that vm_sendish() pops for invokeblock.
535size_t
536rb_yjit_invokeblock_sp_pops(const struct rb_callinfo *ci)
537{
538 return 1 - sp_inc_of_invokeblock(ci); // + 1 to ignore return value push
539}
540
541// Setup jit_return to avoid returning a non-Qundef value on a non-FINISH frame.
542// See [jit_compile_exception] for details.
543void
544rb_yjit_set_exception_return(rb_control_frame_t *cfp, void *leave_exit, void *leave_exception)
545{
546 if (VM_FRAME_FINISHED_P(cfp)) {
547 // If it's a FINISH frame, just normally exit with a non-Qundef value.
548 cfp->jit_return = leave_exit;
549 }
550 else if (cfp->jit_return) {
551 while (!VM_FRAME_FINISHED_P(cfp)) {
552 if (cfp->jit_return == leave_exit) {
553 // Unlike jit_exec(), leave_exit is not safe on a non-FINISH frame on
554 // jit_exec_exception(). See [jit_exec] and [jit_exec_exception] for
555 // details. Exit to the interpreter with Qundef to let it keep executing
556 // other Ruby frames.
557 cfp->jit_return = leave_exception;
558 return;
559 }
560 cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
561 }
562 }
563 else {
564 // If the caller was not JIT code, exit to the interpreter with Qundef
565 // to keep executing Ruby frames with the interpreter.
566 cfp->jit_return = leave_exception;
567 }
568}
569
570// Primitives used by yjit.rb
571VALUE rb_yjit_stats_enabled_p(rb_execution_context_t *ec, VALUE self);
572VALUE rb_yjit_print_stats_p(rb_execution_context_t *ec, VALUE self);
573VALUE rb_yjit_log_enabled_p(rb_execution_context_t *c, VALUE self);
574VALUE rb_yjit_print_log_p(rb_execution_context_t *c, VALUE self);
575VALUE rb_yjit_trace_exit_locations_enabled_p(rb_execution_context_t *ec, VALUE self);
576VALUE rb_yjit_get_stats(rb_execution_context_t *ec, VALUE self, VALUE key);
577VALUE rb_yjit_reset_stats_bang(rb_execution_context_t *ec, VALUE self);
578VALUE rb_yjit_get_log(rb_execution_context_t *ec, VALUE self);
579VALUE rb_yjit_disasm_iseq(rb_execution_context_t *ec, VALUE self, VALUE iseq);
580VALUE rb_yjit_insns_compiled(rb_execution_context_t *ec, VALUE self, VALUE iseq);
581VALUE rb_yjit_code_gc(rb_execution_context_t *ec, VALUE self);
582VALUE rb_yjit_simulate_oom_bang(rb_execution_context_t *ec, VALUE self);
583VALUE rb_yjit_get_exit_locations(rb_execution_context_t *ec, VALUE self);
584VALUE rb_yjit_enable(rb_execution_context_t *ec, VALUE self, VALUE gen_stats, VALUE print_stats, VALUE gen_compilation_log, VALUE print_compilation_log, VALUE mem_size, VALUE call_threshold);
585VALUE rb_yjit_c_builtin_p(rb_execution_context_t *ec, VALUE self);
586
587// Allow YJIT_C_BUILTIN macro to force --yjit-c-builtin
588#ifdef YJIT_C_BUILTIN
589static VALUE yjit_c_builtin_p(rb_execution_context_t *ec, VALUE self) { return Qtrue; }
590#else
591#define yjit_c_builtin_p rb_yjit_c_builtin_p
592#endif
593
594// Preprocessed yjit.rb generated during build
595#include "yjit.rbinc"
596
#define RUBY_ASSERT_ALWAYS(expr,...)
A variant of RUBY_ASSERT that does not interface with RUBY_DEBUG.
Definition assert.h:199
#define RUBY_ASSERT(...)
Asserts that the given expression is truthy if and only if RUBY_DEBUG is truthy.
Definition assert.h:219
VALUE rb_profile_frame_full_label(VALUE frame)
Identical to rb_profile_frame_label(), except it returns a qualified result.
VALUE rb_profile_frame_absolute_path(VALUE frame)
Identical to rb_profile_frame_path(), except it tries to expand the returning path.
VALUE rb_profile_frame_path(VALUE frame)
Queries the path of the passed backtrace.
VALUE rb_profile_frame_first_lineno(VALUE frame)
Queries the first line of the method of the passed frame pointer.
#define RUBY_EVENT_C_CALL
A method, written in C, is called.
Definition event.h:43
#define RUBY_EVENT_C_RETURN
Return from a method, written in C.
Definition event.h:44
uint32_t rb_event_flag_t
Represents event(s).
Definition event.h:108
#define Qundef
Old name of RUBY_Qundef.
#define INT2FIX
Old name of RB_INT2FIX.
Definition long.h:48
#define ID2SYM
Old name of RB_ID2SYM.
Definition symbol.h:44
#define ULONG2NUM
Old name of RB_ULONG2NUM.
Definition long.h:60
#define SIZET2NUM
Old name of RB_SIZE2NUM.
Definition size_t.h:62
#define ZALLOC_N
Old name of RB_ZALLOC_N.
Definition memory.h:401
#define T_HASH
Old name of RUBY_T_HASH.
Definition value_type.h:65
#define FL_TEST_RAW
Old name of RB_FL_TEST_RAW.
Definition fl_type.h:131
#define Qtrue
Old name of RUBY_Qtrue.
#define INT2NUM
Old name of RB_INT2NUM.
Definition int.h:43
#define Qfalse
Old name of RUBY_Qfalse.
#define T_ARRAY
Old name of RUBY_T_ARRAY.
Definition value_type.h:56
#define NIL_P
Old name of RB_NIL_P.
static int RB_ENCODING_GET(VALUE obj)
Just another name of rb_enc_get_index.
Definition encoding.h:195
Defines RBIMPL_HAS_BUILTIN.
VALUE rb_ary_new_capa(long capa)
Identical to rb_ary_new(), except it additionally specifies how many rooms of objects it should alloc...
VALUE rb_ary_subseq(VALUE ary, long beg, long len)
Obtains a part of the passed array.
VALUE rb_ary_push(VALUE ary, VALUE elem)
Special case of rb_ary_cat() that it adds only one element.
VALUE rb_str_cat(VALUE dst, const char *src, long srclen)
Destructively appends the passed contents to the string.
Definition string.c:3528
int len
Length of the buffer.
Definition io.h:8
#define MEMCPY(p1, p2, type, n)
Handy macro to call memcpy.
Definition memory.h:372
#define RARRAY_LEN
Just another name of rb_array_len.
Definition rarray.h:51
static long rb_array_len(VALUE a)
Queries the length of the array.
Definition rarray.h:255
#define RARRAY_AREF(a, i)
Definition rarray.h:403
#define RARRAY_CONST_PTR
Just another name of rb_array_const_ptr.
Definition rarray.h:52
#define RSTRING_GETMEM(str, ptrvar, lenvar)
Convenient macro to obtain the contents and length at once.
Definition rstring.h:488
#define RTEST
This is an old name of RB_TEST.
#define USE_FLONUM
Ruby's String.
Definition rstring.h:196
Definition vm_core.h:261
Definition method.h:63
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40
static bool RB_TYPE_P(VALUE obj, enum ruby_value_type t)
Queries if the given object is of given type.
Definition value_type.h:376