Ruby: yjit.h Source File

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

yjit.h
1#ifndef YJIT_H
2#define YJIT_H 1
3//
4// This file contains definitions YJIT exposes to the CRuby codebase
5//
6
7#include "ruby/internal/config.h"
8#include "ruby_assert.h" // for RUBY_DEBUG
9#include "vm_core.h"
10#include "method.h"
11
12// YJIT_STATS controls whether to support runtime counters in generated code
13// and in the interpreter.
14#ifndef YJIT_STATS
15# define YJIT_STATS RUBY_DEBUG
16#endif
17
18#if USE_YJIT && !defined(MJIT_HEADER) // MJIT and YJIT can't be enabled simultaneously
19
20// We generate x86 or arm64 assembly
21#if defined(_WIN32) ? defined(_M_AMD64) : (defined(__x86_64__) || defined(__aarch64__))
22// x86_64 platforms without mingw/msys or x64-mswin
23#else
24# error YJIT unsupported platform
25#endif
26
27// Expose these as declarations since we are building YJIT.
28bool rb_yjit_enabled_p(void);
29unsigned rb_yjit_call_threshold(void);
30void rb_yjit_invalidate_all_method_lookup_assumptions(void);
31void rb_yjit_cme_invalidate(rb_callable_method_entry_t *cme);
32void rb_yjit_collect_vm_usage_insn(int insn);
33void rb_yjit_collect_binding_alloc(void);
34void rb_yjit_collect_binding_set(void);
35bool rb_yjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec);
36void rb_yjit_init(void);
37void rb_yjit_bop_redefined(int redefined_flag, enum ruby_basic_operators bop);
38void rb_yjit_constant_state_changed(ID id);
39void rb_yjit_iseq_mark(void *payload);
40void rb_yjit_iseq_update_references(void *payload);
41void rb_yjit_iseq_free(void *payload);
42void rb_yjit_before_ractor_spawn(void);
43void rb_yjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic, unsigned insn_idx);
44void rb_yjit_tracing_invalidate_all(void);
45
46#else
47// !USE_YJIT
48// In these builds, YJIT could never be turned on. Provide dummy implementations.
49
50static inline bool rb_yjit_enabled_p(void) { return false; }
51static inline unsigned rb_yjit_call_threshold(void) { return UINT_MAX; }
52static inline void rb_yjit_invalidate_all_method_lookup_assumptions(void) {}
53static inline void rb_yjit_cme_invalidate(rb_callable_method_entry_t *cme) {}
54static inline void rb_yjit_collect_vm_usage_insn(int insn) {}
55static inline void rb_yjit_collect_binding_alloc(void) {}
56static inline void rb_yjit_collect_binding_set(void) {}
57static inline bool rb_yjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec) { return false; }
58static inline void rb_yjit_init(void) {}
59static inline void rb_yjit_bop_redefined(int redefined_flag, enum ruby_basic_operators bop) {}
60static inline void rb_yjit_constant_state_changed(ID id) {}
61static inline void rb_yjit_iseq_mark(void *payload) {}
62static inline void rb_yjit_iseq_update_references(void *payload) {}
63static inline void rb_yjit_iseq_free(void *payload) {}
64static inline void rb_yjit_before_ractor_spawn(void) {}
65static inline void rb_yjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic, unsigned insn_idx) {}
66static inline void rb_yjit_tracing_invalidate_all(void) {}
67
68#endif // #if USE_YJIT
69
70#endif // #ifndef YJIT_H
iseq_inline_constant_cache
Definition vm_core.h:259
rb_callable_method_entry_struct
Definition method.h:62
rb_execution_context_struct
Definition vm_core.h:899
rb_iseq_struct
Definition vm_core.h:526
ID
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52