Ruby 4.0.7p0 (2026-09-15 revision 229531a6cfbf07e3caef30dbac24a2a3f3fed482)
jit.c
1// Glue code shared between YJIT and ZJIT for use from Rust.
2// For FFI safety and bindgen compatibility reasons, certain types of C
3// functions require wrapping before they can be called from Rust. Those show
4// up here.
5//
6// Code specific to YJIT and ZJIT should go to yjit.c and zjit.c respectively.
7
8#include "internal.h"
9#include "vm_core.h"
10#include "vm_callinfo.h"
11#include "builtin.h"
12#include "insns.inc"
13#include "insns_info.inc"
14#include "iseq.h"
15#include "internal/gc.h"
16#include "vm_sync.h"
17#include "internal/fixnum.h"
18#include "internal/string.h"
19
20enum jit_bindgen_constants {
21 // Field offsets for the RObject struct
22 ROBJECT_OFFSET_AS_HEAP_FIELDS = offsetof(struct RObject, as.heap.fields),
23 ROBJECT_OFFSET_AS_ARY = offsetof(struct RObject, as.ary),
24
25 // Field offsets for the RString struct
26 RUBY_OFFSET_RSTRING_LEN = offsetof(struct RString, len),
27
28 // Field offsets for rb_execution_context_t
29 RUBY_OFFSET_EC_CFP = offsetof(rb_execution_context_t, cfp),
30 RUBY_OFFSET_EC_INTERRUPT_FLAG = offsetof(rb_execution_context_t, interrupt_flag),
31 RUBY_OFFSET_EC_INTERRUPT_MASK = offsetof(rb_execution_context_t, interrupt_mask),
32 RUBY_OFFSET_EC_THREAD_PTR = offsetof(rb_execution_context_t, thread_ptr),
33 RUBY_OFFSET_EC_RACTOR_ID = offsetof(rb_execution_context_t, ractor_id),
34};
35
36// Manually bound in rust since this is out-of-range of `int`,
37// so this can't be in a `enum`, and we avoid `static const`
38// to avoid allocating storage for the constant.
39const shape_id_t rb_invalid_shape_id = INVALID_SHAPE_ID;
40
41unsigned int
42rb_iseq_encoded_size(const rb_iseq_t *iseq)
43{
44 return iseq->body->iseq_size;
45}
46
47// Get the PC for a given index in an iseq
48VALUE *
49rb_iseq_pc_at_idx(const rb_iseq_t *iseq, uint32_t insn_idx)
50{
51 RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(iseq, imemo_iseq));
52 RUBY_ASSERT_ALWAYS(insn_idx < iseq->body->iseq_size);
53 VALUE *encoded = iseq->body->iseq_encoded;
54 VALUE *pc = &encoded[insn_idx];
55 return pc;
56}
57
58// Get the opcode given a program counter. Can return trace opcode variants.
59int
60rb_iseq_opcode_at_pc(const rb_iseq_t *iseq, const VALUE *pc)
61{
62 // YJIT should only use iseqs after AST to bytecode compilation.
63 // (Certain non-default interpreter configurations never set ISEQ_TRANSLATED)
64 if (OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE) {
65 RUBY_ASSERT_ALWAYS(FL_TEST_RAW((VALUE)iseq, ISEQ_TRANSLATED));
66 }
67
68 const VALUE at_pc = *pc;
69 return rb_vm_insn_addr2opcode((const void *)at_pc);
70}
71
72unsigned long
73rb_RSTRING_LEN(VALUE str)
74{
75 return RSTRING_LEN(str);
76}
77
78char *
79rb_RSTRING_PTR(VALUE str)
80{
81 return RSTRING_PTR(str);
82}
83
84const char *
85rb_insn_name(VALUE insn)
86{
87 return insn_name(insn);
88}
89
90unsigned int
91rb_vm_ci_argc(const struct rb_callinfo *ci)
92{
93 return vm_ci_argc(ci);
94}
95
96ID
97rb_vm_ci_mid(const struct rb_callinfo *ci)
98{
99 return vm_ci_mid(ci);
100}
101
102unsigned int
103rb_vm_ci_flag(const struct rb_callinfo *ci)
104{
105 return vm_ci_flag(ci);
106}
107
108const struct rb_callinfo_kwarg *
109rb_vm_ci_kwarg(const struct rb_callinfo *ci)
110{
111 return vm_ci_kwarg(ci);
112}
113
114int
115rb_get_cikw_keyword_len(const struct rb_callinfo_kwarg *cikw)
116{
117 return cikw->keyword_len;
118}
119
120VALUE
121rb_get_cikw_keywords_idx(const struct rb_callinfo_kwarg *cikw, int idx)
122{
123 return cikw->keywords[idx];
124}
125
126rb_method_visibility_t
127rb_METHOD_ENTRY_VISI(const rb_callable_method_entry_t *me)
128{
129 return METHOD_ENTRY_VISI(me);
130}
131
132rb_method_type_t
133rb_get_cme_def_type(const rb_callable_method_entry_t *cme)
134{
135 if (UNDEFINED_METHOD_ENTRY_P(cme)) {
136 return VM_METHOD_TYPE_UNDEF;
137 }
138 else {
139 return cme->def->type;
140 }
141}
142
143ID
144rb_get_cme_def_body_attr_id(const rb_callable_method_entry_t *cme)
145{
146 return cme->def->body.attr.id;
147}
148
149enum method_optimized_type
150rb_get_cme_def_body_optimized_type(const rb_callable_method_entry_t *cme)
151{
152 return cme->def->body.optimized.type;
153}
154
155unsigned int
156rb_get_cme_def_body_optimized_index(const rb_callable_method_entry_t *cme)
157{
158 return cme->def->body.optimized.index;
159}
160
161rb_method_cfunc_t *
162rb_get_cme_def_body_cfunc(const rb_callable_method_entry_t *cme)
163{
164 return UNALIGNED_MEMBER_PTR(cme->def, body.cfunc);
165}
166
167uintptr_t
168rb_get_def_method_serial(const rb_method_definition_t *def)
169{
170 return def->method_serial;
171}
172
173ID
174rb_get_def_original_id(const rb_method_definition_t *def)
175{
176 return def->original_id;
177}
178
179VALUE
180rb_get_def_bmethod_proc(rb_method_definition_t *def)
181{
182 RUBY_ASSERT(def->type == VM_METHOD_TYPE_BMETHOD);
183 return def->body.bmethod.proc;
184}
185
186rb_proc_t *
187rb_jit_get_proc_ptr(VALUE procv)
188{
189 rb_proc_t *proc;
190 GetProcPtr(procv, proc);
191 return proc;
192}
193
194unsigned int
195rb_jit_iseq_builtin_attrs(const rb_iseq_t *iseq)
196{
197 return iseq->body->builtin_attrs;
198}
199
200// Relaxed memory ordering, but called by the JIT with VM lock and barrier.
201void
202rb_jit_iseq_mark_ep_escape_recorded(const rb_iseq_t *iseq)
203{
204 rbimpl_atomic_store(&iseq->body->jit_ep_escape_recorded, 1, RBIMPL_ATOMIC_RELAXED);
205}
206
207// Whether an EP escape of this iseq has been reported to the enabled JIT.
208bool
209rb_jit_iseq_ep_escape_recorded_p(const rb_iseq_t *iseq)
210{
211 return rbimpl_atomic_load(&iseq->body->jit_ep_escape_recorded, RBIMPL_ATOMIC_RELAXED) != 0;
212}
213
214int
215rb_get_mct_argc(const rb_method_cfunc_t *mct)
216{
217 return mct->argc;
218}
219
220void *
221rb_get_mct_func(const rb_method_cfunc_t *mct)
222{
223 return (void*)(uintptr_t)mct->func; // this field is defined as type VALUE (*func)(ANYARGS)
224}
225
226const rb_iseq_t *
227rb_get_def_iseq_ptr(rb_method_definition_t *def)
228{
229 return def_iseq_ptr(def);
230}
231
232const rb_iseq_t *
233rb_get_iseq_body_local_iseq(const rb_iseq_t *iseq)
234{
235 return iseq->body->local_iseq;
236}
237
238const rb_iseq_t *
239rb_get_iseq_body_parent_iseq(const rb_iseq_t *iseq)
240{
241 return iseq->body->parent_iseq;
242}
243
244unsigned int
245rb_get_iseq_body_local_table_size(const rb_iseq_t *iseq)
246{
247 return iseq->body->local_table_size;
248}
249
250VALUE *
251rb_get_iseq_body_iseq_encoded(const rb_iseq_t *iseq)
252{
253 return iseq->body->iseq_encoded;
254}
255
256unsigned
257rb_get_iseq_body_stack_max(const rb_iseq_t *iseq)
258{
259 return iseq->body->stack_max;
260}
261
262enum rb_iseq_type
263rb_get_iseq_body_type(const rb_iseq_t *iseq)
264{
265 return iseq->body->type;
266}
267
268bool
269rb_get_iseq_flags_has_lead(const rb_iseq_t *iseq)
270{
271 return iseq->body->param.flags.has_lead;
272}
273
274bool
275rb_get_iseq_flags_has_opt(const rb_iseq_t *iseq)
276{
277 return iseq->body->param.flags.has_opt;
278}
279
280bool
281rb_get_iseq_flags_has_kw(const rb_iseq_t *iseq)
282{
283 return iseq->body->param.flags.has_kw;
284}
285
286bool
287rb_get_iseq_flags_has_post(const rb_iseq_t *iseq)
288{
289 return iseq->body->param.flags.has_post;
290}
291
292bool
293rb_get_iseq_flags_has_kwrest(const rb_iseq_t *iseq)
294{
295 return iseq->body->param.flags.has_kwrest;
296}
297
298bool
299rb_get_iseq_flags_anon_kwrest(const rb_iseq_t *iseq)
300{
301 return iseq->body->param.flags.anon_kwrest;
302}
303
304bool
305rb_get_iseq_flags_has_rest(const rb_iseq_t *iseq)
306{
307 return iseq->body->param.flags.has_rest;
308}
309
310bool
311rb_get_iseq_flags_ruby2_keywords(const rb_iseq_t *iseq)
312{
313 return iseq->body->param.flags.ruby2_keywords;
314}
315
316bool
317rb_get_iseq_flags_has_block(const rb_iseq_t *iseq)
318{
319 return iseq->body->param.flags.has_block;
320}
321
322bool
323rb_get_iseq_flags_ambiguous_param0(const rb_iseq_t *iseq)
324{
325 return iseq->body->param.flags.ambiguous_param0;
326}
327
328bool
329rb_get_iseq_flags_accepts_no_kwarg(const rb_iseq_t *iseq)
330{
331 return iseq->body->param.flags.accepts_no_kwarg;
332}
333
334bool
335rb_get_iseq_flags_forwardable(const rb_iseq_t *iseq)
336{
337 return iseq->body->param.flags.forwardable;
338}
339
340// This is defined only as a named struct inside rb_iseq_constant_body.
341// By giving it a separate typedef, we make it nameable by rust-bindgen.
342// Bindgen's temp/anon name isn't guaranteed stable.
343typedef struct rb_iseq_param_keyword rb_iseq_param_keyword_struct;
344
345const rb_iseq_param_keyword_struct *
346rb_get_iseq_body_param_keyword(const rb_iseq_t *iseq)
347{
348 return iseq->body->param.keyword;
349}
350
351unsigned
352rb_get_iseq_body_param_size(const rb_iseq_t *iseq)
353{
354 return iseq->body->param.size;
355}
356
357int
358rb_get_iseq_body_param_lead_num(const rb_iseq_t *iseq)
359{
360 return iseq->body->param.lead_num;
361}
362
363int
364rb_get_iseq_body_param_opt_num(const rb_iseq_t *iseq)
365{
366 return iseq->body->param.opt_num;
367}
368
369const VALUE *
370rb_get_iseq_body_param_opt_table(const rb_iseq_t *iseq)
371{
372 return iseq->body->param.opt_table;
373}
374
376rb_get_ec_cfp(const rb_execution_context_t *ec)
377{
378 return ec->cfp;
379}
380
381const rb_iseq_t *
382rb_get_cfp_iseq(struct rb_control_frame_struct *cfp)
383{
384 return cfp->iseq;
385}
386
387VALUE *
388rb_get_cfp_pc(struct rb_control_frame_struct *cfp)
389{
390 return (VALUE*)cfp->pc;
391}
392
393VALUE *
394rb_get_cfp_sp(struct rb_control_frame_struct *cfp)
395{
396 return cfp->sp;
397}
398
399VALUE
400rb_get_cfp_self(struct rb_control_frame_struct *cfp)
401{
402 return cfp->self;
403}
404
405VALUE *
406rb_get_cfp_ep(struct rb_control_frame_struct *cfp)
407{
408 return (VALUE*)cfp->ep;
409}
410
411const VALUE *
412rb_get_cfp_ep_level(struct rb_control_frame_struct *cfp, uint32_t lv)
413{
414 uint32_t i;
415 const VALUE *ep = (VALUE*)cfp->ep;
416 for (i = 0; i < lv; i++) {
417 ep = VM_ENV_PREV_EP(ep);
418 }
419 return ep;
420}
421
422VALUE
423rb_yarv_class_of(VALUE obj)
424{
425 return rb_class_of(obj);
426}
427
428// The FL_TEST() macro
429VALUE
430rb_FL_TEST(VALUE obj, VALUE flags)
431{
432 return RB_FL_TEST(obj, flags);
433}
434
435// The FL_TEST_RAW() macro, normally an internal implementation detail
436VALUE
437rb_FL_TEST_RAW(VALUE obj, VALUE flags)
438{
439 return FL_TEST_RAW(obj, flags);
440}
441
442// The RB_TYPE_P macro
443bool
444rb_RB_TYPE_P(VALUE obj, enum ruby_value_type t)
445{
446 return RB_TYPE_P(obj, t);
447}
448
449long
450rb_RSTRUCT_LEN(VALUE st)
451{
452 return RSTRUCT_LEN(st);
453}
454
455const struct rb_callinfo *
456rb_get_call_data_ci(const struct rb_call_data *cd)
457{
458 return cd->ci;
459}
460
461bool
462rb_BASIC_OP_UNREDEFINED_P(enum ruby_basic_operators bop, uint32_t klass)
463{
464 return BASIC_OP_UNREDEFINED_P(bop, klass);
465}
466
467VALUE
468rb_RCLASS_ORIGIN(VALUE c)
469{
470 return RCLASS_ORIGIN(c);
471}
472
473// For debug builds
474void
475rb_assert_iseq_handle(VALUE handle)
476{
477 RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(handle, imemo_iseq));
478}
479
480// Assert that we have the VM lock. Relevant mostly for multi ractor situations.
481// The GC takes the lock before calling us, and this asserts that it indeed happens.
482void
483rb_assert_holding_vm_lock(void)
484{
485 ASSERT_vm_locking();
486}
487
488int
489rb_IMEMO_TYPE_P(VALUE imemo, enum imemo_type imemo_type)
490{
491 return IMEMO_TYPE_P(imemo, imemo_type);
492}
493
494void
495rb_assert_cme_handle(VALUE handle)
496{
497 RUBY_ASSERT_ALWAYS(!rb_objspace_garbage_object_p(handle));
498 RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(handle, imemo_ment));
499}
500
501// YJIT and ZJIT need this function to never allocate and never raise
502VALUE
503rb_yarv_ary_entry_internal(VALUE ary, long offset)
504{
505 return rb_ary_entry_internal(ary, offset);
506}
507
508long
509rb_jit_array_len(VALUE a)
510{
511 return rb_array_len(a);
512}
513
514void
515rb_set_cfp_pc(struct rb_control_frame_struct *cfp, const VALUE *pc)
516{
517 cfp->pc = pc;
518}
519
520void
521rb_set_cfp_sp(struct rb_control_frame_struct *cfp, VALUE *sp)
522{
523 cfp->sp = sp;
524}
525
526bool
527rb_jit_shape_too_complex_p(shape_id_t shape_id)
528{
529 return rb_shape_too_complex_p(shape_id);
530}
531
532bool
533rb_jit_multi_ractor_p(void)
534{
535 return rb_multi_ractor_p();
536}
537
538// Acquire the VM lock and then signal all other Ruby threads (ractors) to
539// contend for the VM lock, putting them to sleep. ZJIT and YJIT use this to
540// evict threads running inside generated code so among other things, it can
541// safely change memory protection of regions housing generated code.
542void
543rb_jit_vm_lock_then_barrier(unsigned int *recursive_lock_level, const char *file, int line)
544{
545 rb_vm_lock_enter(recursive_lock_level, file, line);
546 rb_vm_barrier();
547}
548
549// Release the VM lock. The lock level must point to the same integer used to
550// acquire the lock.
551void
552rb_jit_vm_unlock(unsigned int *recursive_lock_level, const char *file, int line)
553{
554 rb_vm_lock_leave(recursive_lock_level, file, line);
555}
556
557void
558rb_iseq_reset_jit_func(const rb_iseq_t *iseq)
559{
560 RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(iseq, imemo_iseq));
561 iseq->body->jit_entry = NULL;
562 iseq->body->jit_exception = NULL;
563 // Enable re-compiling this ISEQ. Event when it's invalidated for TracePoint,
564 // we'd like to re-compile ISEQs that haven't been converted to trace_* insns.
565 iseq->body->jit_entry_calls = 0;
566 iseq->body->jit_exception_calls = 0;
567}
568
569// Callback data for rb_jit_for_each_iseq
571 rb_iseq_callback callback;
572 void *data;
573};
574
575// Heap-walking callback for rb_jit_for_each_iseq
576static int
577for_each_iseq_i(void *vstart, void *vend, size_t stride, void *data)
578{
579 const struct iseq_callback_data *callback_data = (struct iseq_callback_data *)data;
580 VALUE v = (VALUE)vstart;
581 for (; v != (VALUE)vend; v += stride) {
582 void *ptr = rb_asan_poisoned_object_p(v);
583 rb_asan_unpoison_object(v, false);
584
585 if (rb_obj_is_iseq(v)) {
586 rb_iseq_t *iseq = (rb_iseq_t *)v;
587 callback_data->callback(iseq, callback_data->data);
588 }
589
590 if (ptr) {
591 rb_asan_poison_object(v);
592 }
593 }
594 return 0;
595}
596
597uint32_t
598rb_jit_get_page_size(void)
599{
600#if defined(_SC_PAGESIZE)
601 long page_size = sysconf(_SC_PAGESIZE);
602 if (page_size <= 0) rb_bug("jit: failed to get page size");
603
604 // 1 GiB limit. x86 CPUs with PDPE1GB can do this and anything larger is unexpected.
605 // Though our design sort of assume we have fine grained control over memory protection
606 // which require small page sizes.
607 if (page_size > 0x40000000l) rb_bug("jit page size too large");
608
609 return (uint32_t)page_size;
610#else
611#error "JIT supports POSIX only for now"
612#endif
613}
614
615#if defined(MAP_FIXED_NOREPLACE) && defined(_SC_PAGESIZE)
616// Align the current write position to a multiple of bytes
617static uint8_t *
618align_ptr(uint8_t *ptr, uint32_t multiple)
619{
620 // Compute the pointer modulo the given alignment boundary
621 uint32_t rem = ((uint32_t)(uintptr_t)ptr) % multiple;
622
623 // If the pointer is already aligned, stop
624 if (rem == 0)
625 return ptr;
626
627 // Pad the pointer by the necessary amount to align it
628 uint32_t pad = multiple - rem;
629
630 return ptr + pad;
631}
632#endif
633
634// Address space reservation. Memory pages are mapped on an as needed basis.
635// See the Rust mm module for details.
636uint8_t *
637rb_jit_reserve_addr_space(uint32_t mem_size)
638{
639#ifndef _WIN32
640 uint8_t *mem_block;
641
642 // On Linux
643 #if defined(MAP_FIXED_NOREPLACE) && defined(_SC_PAGESIZE)
644 uint32_t const page_size = (uint32_t)sysconf(_SC_PAGESIZE);
645 uint8_t *const cfunc_sample_addr = (void *)(uintptr_t)&rb_jit_reserve_addr_space;
646 uint8_t *const probe_region_end = cfunc_sample_addr + INT32_MAX;
647 // Align the requested address to page size
648 uint8_t *req_addr = align_ptr(cfunc_sample_addr, page_size);
649
650 // Probe for addresses close to this function using MAP_FIXED_NOREPLACE
651 // to improve odds of being in range for 32-bit relative call instructions.
652 do {
653 mem_block = mmap(
654 req_addr,
655 mem_size,
656 PROT_NONE,
657 MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED_NOREPLACE,
658 -1,
659 0
660 );
661
662 // If we succeeded, stop
663 if (mem_block != MAP_FAILED) {
664 ruby_annotate_mmap(mem_block, mem_size, "Ruby:rb_jit_reserve_addr_space");
665 break;
666 }
667
668 // -4MiB. Downwards to probe away from the heap. (On x86/A64 Linux
669 // main_code_addr < heap_addr, and in case we are in a shared
670 // library mapped higher than the heap, downwards is still better
671 // since it's towards the end of the heap rather than the stack.)
672 req_addr -= 4 * 1024 * 1024;
673 } while (req_addr < probe_region_end);
674
675 // On MacOS and other platforms
676 #else
677 // Try to map a chunk of memory as executable
678 mem_block = mmap(
679 (void *)rb_jit_reserve_addr_space,
680 mem_size,
681 PROT_NONE,
682 MAP_PRIVATE | MAP_ANONYMOUS,
683 -1,
684 0
685 );
686 #endif
687
688 // Fallback
689 if (mem_block == MAP_FAILED) {
690 // Try again without the address hint (e.g., valgrind)
691 mem_block = mmap(
692 NULL,
693 mem_size,
694 PROT_NONE,
695 MAP_PRIVATE | MAP_ANONYMOUS,
696 -1,
697 0
698 );
699
700 if (mem_block != MAP_FAILED) {
701 ruby_annotate_mmap(mem_block, mem_size, "Ruby:rb_jit_reserve_addr_space:fallback");
702 }
703 }
704
705 // Check that the memory mapping was successful
706 if (mem_block == MAP_FAILED) {
707 perror("ruby: jit: mmap:");
708 if(errno == ENOMEM) {
709 // No crash report if it's only insufficient memory
710 exit(EXIT_FAILURE);
711 }
712 rb_bug("mmap failed");
713 }
714
715 return mem_block;
716#else
717 // Windows not supported for now
718 return NULL;
719#endif
720}
721
722// Walk all ISEQs in the heap and invoke the callback - shared between YJIT and ZJIT
723void
724rb_jit_for_each_iseq(rb_iseq_callback callback, void *data)
725{
726 struct iseq_callback_data callback_data = { .callback = callback, .data = data };
727 rb_objspace_each_objects(for_each_iseq_i, (void *)&callback_data);
728}
729
730bool
731rb_jit_mark_writable(void *mem_block, uint32_t mem_size)
732{
733 return mprotect(mem_block, mem_size, PROT_READ | PROT_WRITE) == 0;
734}
735
736void
737rb_jit_mark_executable(void *mem_block, uint32_t mem_size)
738{
739 // Do not call mprotect when mem_size is zero. Some platforms may return
740 // an error for it. https://github.com/Shopify/ruby/issues/450
741 if (mem_size == 0) {
742 return;
743 }
744 if (mprotect(mem_block, mem_size, PROT_READ | PROT_EXEC)) {
745 rb_bug("Couldn't make JIT page (%p, %lu bytes) executable, errno: %s",
746 mem_block, (unsigned long)mem_size, strerror(errno));
747 }
748}
749
750// Free the specified memory block.
751bool
752rb_jit_mark_unused(void *mem_block, uint32_t mem_size)
753{
754 // On Linux, you need to use madvise MADV_DONTNEED to free memory.
755 // We might not need to call this on macOS, but it's not really documented.
756 // We generally prefer to do the same thing on both to ease testing too.
757 madvise(mem_block, mem_size, MADV_DONTNEED);
758
759 // On macOS, mprotect PROT_NONE seems to reduce RSS.
760 // We also call this on Linux to avoid executing unused pages.
761 return mprotect(mem_block, mem_size, PROT_NONE) == 0;
762}
763
764// Invalidate icache for arm64.
765// `start` is inclusive and `end` is exclusive.
766void
767rb_jit_icache_invalidate(void *start, void *end)
768{
769 // Clear/invalidate the instruction cache. Compiles to nothing on x86_64
770 // but required on ARM before running freshly written code.
771 // On Darwin it's the same as calling sys_icache_invalidate().
772#ifdef __GNUC__
773 __builtin___clear_cache(start, end);
774#elif defined(__aarch64__)
775#error No instruction cache clear available with this compiler on Aarch64!
776#endif
777}
778
779VALUE
780rb_jit_fix_mod_fix(VALUE recv, VALUE obj)
781{
782 return rb_fix_mod_fix(recv, obj);
783}
784
785VALUE
786rb_jit_fix_div_fix(VALUE recv, VALUE obj)
787{
788 return rb_fix_div_fix(recv, obj);
789}
790
791// YJIT/ZJIT need this function to never allocate and never raise
792VALUE
793rb_yarv_str_eql_internal(VALUE str1, VALUE str2)
794{
795 // We wrap this since it's static inline
796 return rb_str_eql_internal(str1, str2);
797}
798
799void rb_jit_str_concat_codepoint(VALUE str, VALUE codepoint);
800
801attr_index_t
802rb_jit_shape_capacity(shape_id_t shape_id)
803{
804 return RSHAPE_CAPACITY(shape_id);
805}
#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
#define FL_TEST_RAW
Old name of RB_FL_TEST_RAW.
Definition fl_type.h:131
char * ptr
Pointer to the underlying memory region, of at least capa bytes.
Definition io.h:2
int len
Length of the buffer.
Definition io.h:8
#define errno
Ractor-aware version of errno.
Definition ruby.h:388
Ruby's ordinal objects.
Definition robject.h:85
Ruby's String.
Definition rstring.h:196
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
ruby_value_type
C-level type of an object.
Definition value_type.h:113