2021-10-06 16:34:16 -04:00
|
|
|
#ifndef YJIT_H
|
|
|
|
#define YJIT_H 1
|
2021-03-06 18:46:56 -05:00
|
|
|
//
|
|
|
|
// This file contains definitions YJIT exposes to the CRuby codebase
|
|
|
|
//
|
|
|
|
|
2021-09-08 12:01:39 -04:00
|
|
|
#include "ruby/internal/config.h"
|
|
|
|
#include "ruby_assert.h" // for RUBY_DEBUG
|
2021-03-24 18:07:26 -04:00
|
|
|
#include "vm_core.h"
|
2021-03-06 18:46:56 -05:00
|
|
|
#include "method.h"
|
|
|
|
|
2021-10-06 16:34:16 -04:00
|
|
|
// YJIT_STATS controls whether to support runtime counters in generated code
|
|
|
|
// and in the interpreter.
|
2021-09-08 12:01:39 -04:00
|
|
|
#ifndef YJIT_STATS
|
|
|
|
# define YJIT_STATS RUBY_DEBUG
|
2021-03-06 18:46:56 -05:00
|
|
|
#endif
|
|
|
|
|
2021-12-27 22:57:04 -05:00
|
|
|
// We generate x86 assembly
|
2021-12-31 06:13:11 -05:00
|
|
|
#if (defined(__x86_64__) && !defined(_WIN32)) || (defined(_WIN32) && defined(_M_AMD64)) // x64 platforms without mingw/msys
|
2021-12-13 19:08:01 -05:00
|
|
|
# define YJIT_SUPPORTED_P 1
|
|
|
|
#else
|
|
|
|
# define YJIT_SUPPORTED_P 0
|
|
|
|
#endif
|
|
|
|
|
2021-03-06 18:46:56 -05:00
|
|
|
struct rb_yjit_options {
|
2021-04-24 00:16:48 -04:00
|
|
|
// Enable compilation with YJIT
|
2021-03-06 18:46:56 -05:00
|
|
|
bool yjit_enabled;
|
|
|
|
|
2021-05-26 15:25:50 -04:00
|
|
|
// Size of the executable memory block to allocate in MiB
|
|
|
|
unsigned exec_mem_size;
|
|
|
|
|
2021-03-06 18:46:56 -05:00
|
|
|
// Number of method calls after which to start generating code
|
|
|
|
// Threshold==1 means compile on first execution
|
|
|
|
unsigned call_threshold;
|
|
|
|
|
2021-04-24 00:16:48 -04:00
|
|
|
// Generate versions greedily until the limit is hit
|
|
|
|
bool greedy_versioning;
|
|
|
|
|
2021-11-18 10:44:31 -05:00
|
|
|
// Disable the propagation of type information
|
|
|
|
bool no_type_prop;
|
|
|
|
|
2021-04-24 00:16:48 -04:00
|
|
|
// Maximum number of versions per block
|
|
|
|
// 1 means always create generic versions
|
2021-06-23 13:55:34 -04:00
|
|
|
unsigned max_versions;
|
2021-04-24 00:16:48 -04:00
|
|
|
|
2021-03-06 18:46:56 -05:00
|
|
|
// Capture and print out stats
|
|
|
|
bool gen_stats;
|
2021-10-01 07:17:09 -04:00
|
|
|
|
|
|
|
// Run backend tests
|
|
|
|
bool test_backend;
|
2021-03-06 18:46:56 -05:00
|
|
|
};
|
|
|
|
|
2021-10-25 14:53:22 -04:00
|
|
|
bool rb_yjit_enabled_p(void);
|
2021-03-06 18:46:56 -05:00
|
|
|
unsigned rb_yjit_call_threshold(void);
|
|
|
|
|
2021-03-17 19:07:20 -04:00
|
|
|
void rb_yjit_invalidate_all_method_lookup_assumptions(void);
|
|
|
|
void rb_yjit_method_lookup_change(VALUE klass, ID mid);
|
|
|
|
void rb_yjit_cme_invalidate(VALUE cme);
|
2021-03-06 18:46:56 -05:00
|
|
|
void rb_yjit_collect_vm_usage_insn(int insn);
|
2021-04-07 15:51:50 -04:00
|
|
|
void rb_yjit_collect_binding_alloc(void);
|
|
|
|
void rb_yjit_collect_binding_set(void);
|
2021-07-07 14:15:40 -04:00
|
|
|
bool rb_yjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec);
|
2021-03-06 18:46:56 -05:00
|
|
|
void rb_yjit_init(struct rb_yjit_options *options);
|
|
|
|
void rb_yjit_bop_redefined(VALUE klass, const rb_method_entry_t *me, enum ruby_basic_operators bop);
|
|
|
|
void rb_yjit_constant_state_changed(void);
|
|
|
|
void rb_yjit_iseq_mark(const struct rb_iseq_constant_body *body);
|
|
|
|
void rb_yjit_iseq_update_references(const struct rb_iseq_constant_body *body);
|
|
|
|
void rb_yjit_iseq_free(const struct rb_iseq_constant_body *body);
|
|
|
|
void rb_yjit_before_ractor_spawn(void);
|
2021-12-06 17:09:52 -05:00
|
|
|
void rb_yjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic);
|
2021-10-01 18:38:39 -04:00
|
|
|
void rb_yjit_tracing_invalidate_all(void);
|
2021-03-06 18:46:56 -05:00
|
|
|
|
|
|
|
#endif // #ifndef YJIT_H
|