Ruby: yjit.h Source File

Ruby 3.3.4p94 (2024-07-09 revision be1089c8ec5ba40e09b1553e36b3174bf4014d9d)

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
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.
28extern uint64_t rb_yjit_call_threshold;
29extern uint64_t rb_yjit_cold_threshold;
30extern uint64_t rb_yjit_live_iseq_count;
31extern bool rb_yjit_enabled_p;
32void rb_yjit_incr_counter(const char *counter_name);
33void rb_yjit_invalidate_all_method_lookup_assumptions(void);
34void rb_yjit_cme_invalidate(rb_callable_method_entry_t *cme);
35void rb_yjit_collect_binding_alloc(void);
36void rb_yjit_collect_binding_set(void);
37void rb_yjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec, bool jit_exception);
38void rb_yjit_init(bool yjit_enabled);
39void rb_yjit_bop_redefined(int redefined_flag, enum ruby_basic_operators bop);
40void rb_yjit_constant_state_changed(ID id);
41void rb_yjit_iseq_mark(void *payload);
42void rb_yjit_iseq_update_references(void *payload);
43void rb_yjit_iseq_free(void *payload);
44void rb_yjit_before_ractor_spawn(void);
45void rb_yjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic, unsigned insn_idx);
46void rb_yjit_tracing_invalidate_all(void);
47void rb_yjit_show_usage(int help, int highlight, unsigned int width, int columns);
48
49#else
50// !USE_YJIT
51// In these builds, YJIT could never be turned on. Provide dummy implementations.
52
53#define rb_yjit_enabled_p false
54static inline void rb_yjit_incr_counter(const char *counter_name) {}
55static inline void rb_yjit_invalidate_all_method_lookup_assumptions(void) {}
56static inline void rb_yjit_cme_invalidate(rb_callable_method_entry_t *cme) {}
57static inline void rb_yjit_collect_binding_alloc(void) {}
58static inline void rb_yjit_collect_binding_set(void) {}
59static inline void rb_yjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec, bool jit_exception) {}
60static inline void rb_yjit_init(bool yjit_enabled) {}
61static inline void rb_yjit_bop_redefined(int redefined_flag, enum ruby_basic_operators bop) {}
62static inline void rb_yjit_constant_state_changed(ID id) {}
63static inline void rb_yjit_iseq_mark(void *payload) {}
64static inline void rb_yjit_iseq_update_references(void *payload) {}
65static inline void rb_yjit_iseq_free(void *payload) {}
66static inline void rb_yjit_before_ractor_spawn(void) {}
67static inline void rb_yjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic, unsigned insn_idx) {}
68static inline void rb_yjit_tracing_invalidate_all(void) {}
69
70#endif // #if USE_YJIT
71
72#endif // #ifndef YJIT_H
iseq_inline_constant_cache
Definition vm_core.h:245
rb_callable_method_entry_struct
Definition method.h:62
rb_execution_context_struct
Definition vm_core.h:986
rb_iseq_struct
Definition vm_core.h:534
ID
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52