зеркало из https://github.com/github/ruby.git
RJIT: Remove unused code from headers
This commit is contained in:
Родитель
c364e0745d
Коммит
cdece5cf36
|
@ -39,7 +39,6 @@ module RubyVM::RJIT
|
|||
INSNS.fetch(C.rb_vm_insn_decode(encoded))
|
||||
end
|
||||
|
||||
# @param mem_size [Integer] JIT buffer size
|
||||
def initialize
|
||||
mem_size = C.rjit_opts.exec_mem_size * 1024 * 1024
|
||||
mem_block = C.mmap(mem_size)
|
||||
|
|
56
rjit.h
56
rjit.h
|
@ -21,71 +21,21 @@
|
|||
#include "ruby.h"
|
||||
#include "vm_core.h"
|
||||
|
||||
// Special address values of a function generated from the
|
||||
// corresponding iseq by RJIT:
|
||||
enum rb_rjit_func_state {
|
||||
// ISEQ has not been compiled yet
|
||||
RJIT_FUNC_NOT_COMPILED = 0,
|
||||
// ISEQ is already queued for the machine code generation but the
|
||||
// code is not ready yet for the execution
|
||||
RJIT_FUNC_COMPILING = 1,
|
||||
// ISEQ included not compilable insn, some internal assertion failed
|
||||
// or the unit is unloaded
|
||||
RJIT_FUNC_FAILED = 2,
|
||||
};
|
||||
// Return true if jit_func is part of enum rb_rjit_func_state
|
||||
#define RJIT_FUNC_STATE_P(jit_func) ((uintptr_t)(jit_func) <= (uintptr_t)RJIT_FUNC_FAILED)
|
||||
|
||||
// RJIT options which can be defined on the MRI command line.
|
||||
struct rjit_options {
|
||||
// Converted from "jit" feature flag to tell the enablement
|
||||
// Converted from "rjit" feature flag to tell the enablement
|
||||
// information to ruby_show_version().
|
||||
bool on;
|
||||
// Save temporary files after MRI finish. The temporary files
|
||||
// include the pre-compiled header, C code file generated for ISEQ,
|
||||
// and the corresponding object file.
|
||||
bool save_temps;
|
||||
// Print RJIT warnings to stderr.
|
||||
bool warnings;
|
||||
// Disable compiler optimization and add debug symbols. It can be
|
||||
// very slow.
|
||||
bool debug;
|
||||
// Add arbitrary cflags.
|
||||
char* debug_flags;
|
||||
// If true, all ISeqs are synchronously compiled. For testing.
|
||||
bool wait;
|
||||
// Number of calls to trigger JIT compilation.
|
||||
unsigned int call_threshold;
|
||||
// Size of executable memory block in MiB
|
||||
unsigned int exec_mem_size;
|
||||
// Collect RJIT statistics
|
||||
bool stats;
|
||||
// Force printing info about RJIT work of level VERBOSE or
|
||||
// less. 0=silence, 1=medium, 2=verbose.
|
||||
int verbose;
|
||||
// Maximal permitted number of iseq JIT codes in a RJIT memory
|
||||
// cache.
|
||||
int max_cache_size;
|
||||
// [experimental] Do not start RJIT until RJIT.resume is called.
|
||||
bool pause;
|
||||
// [experimental] Call custom RubyVM::RJIT.compile instead of RJIT.
|
||||
bool custom;
|
||||
// Enable disasm of all JIT code
|
||||
bool dump_disasm;
|
||||
};
|
||||
|
||||
// State of optimization switches
|
||||
struct rb_rjit_compile_info {
|
||||
// Disable getinstancevariable/setinstancevariable optimizations based on inline cache (T_OBJECT)
|
||||
bool disable_ivar_cache;
|
||||
// Disable getinstancevariable/setinstancevariable optimizations based on inline cache (FL_EXIVAR)
|
||||
bool disable_exivar_cache;
|
||||
// Disable send/opt_send_without_block optimizations based on inline cache
|
||||
bool disable_send_cache;
|
||||
// Disable method inlining
|
||||
bool disable_inlining;
|
||||
// Disable opt_getinlinecache inlining
|
||||
bool disable_const_cache;
|
||||
// [experimental] Do not start RJIT until RJIT.resume is called.
|
||||
bool pause;
|
||||
};
|
||||
|
||||
RUBY_SYMBOL_EXPORT_BEGIN
|
||||
|
|
89
rjit_c.h
89
rjit_c.h
|
@ -13,95 +13,6 @@
|
|||
#include "rjit.h"
|
||||
#include "shape.h"
|
||||
|
||||
// Macros to check if a position is already compiled using compile_status.stack_size_for_pos
|
||||
#define NOT_COMPILED_STACK_SIZE -1
|
||||
#define ALREADY_COMPILED_P(status, pos) (status->stack_size_for_pos[pos] != NOT_COMPILED_STACK_SIZE)
|
||||
|
||||
// Linked list of struct rb_rjit_unit.
|
||||
struct rb_rjit_unit_list {
|
||||
struct ccan_list_head head;
|
||||
int length; // the list length
|
||||
};
|
||||
|
||||
enum rb_rjit_unit_type {
|
||||
// Single-ISEQ unit for unit_queue
|
||||
RJIT_UNIT_ISEQ = 0,
|
||||
// Multi-ISEQ unit for rjit_batch
|
||||
RJIT_UNIT_BATCH = 1,
|
||||
// All-ISEQ unit for rjit_compact
|
||||
RJIT_UNIT_COMPACT = 2,
|
||||
};
|
||||
|
||||
// The unit structure that holds metadata of ISeq for RJIT.
|
||||
// TODO: Use different structs for ISEQ and BATCH/COMPACT
|
||||
struct rb_rjit_unit {
|
||||
struct ccan_list_node unode;
|
||||
// Unique order number of unit.
|
||||
int id;
|
||||
// Type of this unit
|
||||
enum rb_rjit_unit_type type;
|
||||
|
||||
/* RJIT_UNIT_ISEQ */
|
||||
// ISEQ for a non-batch unit
|
||||
rb_iseq_t *iseq;
|
||||
// Only used by unload_units. Flag to check this unit is currently on stack or not.
|
||||
bool used_code_p;
|
||||
// rjit_compile's optimization switches
|
||||
struct rb_rjit_compile_info compile_info;
|
||||
// captured CC values, they should be marked with iseq.
|
||||
const struct rb_callcache **cc_entries;
|
||||
// ISEQ_BODY(iseq)->ci_size + ones of inlined iseqs
|
||||
unsigned int cc_entries_size;
|
||||
|
||||
/* RJIT_UNIT_BATCH, RJIT_UNIT_COMPACT */
|
||||
// Dlopen handle of the loaded object file.
|
||||
void *handle;
|
||||
// Units compacted by this batch
|
||||
struct rb_rjit_unit_list units; // RJIT_UNIT_BATCH only
|
||||
};
|
||||
|
||||
// Storage to keep data which is consistent in each conditional branch.
|
||||
// This is created and used for one `compile_insns` call and its values
|
||||
// should be copied for extra `compile_insns` call.
|
||||
struct compile_branch {
|
||||
unsigned int stack_size; // this simulates sp (stack pointer) of YARV
|
||||
bool finish_p; // if true, compilation in this branch should stop and let another branch to be compiled
|
||||
};
|
||||
|
||||
// For propagating information needed for lazily pushing a frame.
|
||||
struct inlined_call_context {
|
||||
int orig_argc; // ci->orig_argc
|
||||
VALUE me; // vm_cc_cme(cc)
|
||||
int param_size; // def_iseq_ptr(vm_cc_cme(cc)->def)->body->param.size
|
||||
int local_size; // def_iseq_ptr(vm_cc_cme(cc)->def)->body->local_table_size
|
||||
};
|
||||
|
||||
// Storage to keep compiler's status. This should have information
|
||||
// which is global during one `rjit_compile` call. Ones conditional
|
||||
// in each branch should be stored in `compile_branch`.
|
||||
struct compile_status {
|
||||
bool success; // has true if compilation has had no issue
|
||||
int *stack_size_for_pos; // stack_size_for_pos[pos] has stack size for the position (otherwise -1)
|
||||
// If true, JIT-ed code will use local variables to store pushed values instead of
|
||||
// using VM's stack and moving stack pointer.
|
||||
bool local_stack_p;
|
||||
// Index of call cache entries captured to compiled_iseq to be marked on GC
|
||||
int cc_entries_index;
|
||||
// A pointer to root (i.e. not inlined) iseq being compiled.
|
||||
const struct rb_iseq_constant_body *compiled_iseq;
|
||||
int compiled_id; // Just a copy of compiled_iseq->jit_unit->id
|
||||
// Mutated optimization levels
|
||||
struct rb_rjit_compile_info *compile_info;
|
||||
// If `inlined_iseqs[pos]` is not NULL, `rjit_compile_body` tries to inline ISeq there.
|
||||
const struct rb_iseq_constant_body **inlined_iseqs;
|
||||
struct inlined_call_context inline_context;
|
||||
};
|
||||
|
||||
//================================================================================
|
||||
//
|
||||
// New stuff from here
|
||||
//
|
||||
|
||||
extern uint8_t *rb_rjit_mem_block;
|
||||
|
||||
#define RJIT_RUNTIME_COUNTERS(...) struct rb_rjit_runtime_counters { size_t __VA_ARGS__; };
|
||||
|
|
90
rjit_c.rb
90
rjit_c.rb
|
@ -496,10 +496,6 @@ module RubyVM::RJIT # :nodoc: all
|
|||
Primitive.cexpr! %q{ RBOOL(USE_LAZY_LOAD != 0) }
|
||||
end
|
||||
|
||||
def C.NOT_COMPILED_STACK_SIZE
|
||||
Primitive.cexpr! %q{ INT2NUM(NOT_COMPILED_STACK_SIZE) }
|
||||
end
|
||||
|
||||
def C.VM_ENV_DATA_INDEX_ME_CREF
|
||||
Primitive.cexpr! %q{ INT2NUM(VM_ENV_DATA_INDEX_ME_CREF) }
|
||||
end
|
||||
|
@ -989,39 +985,6 @@ module RubyVM::RJIT # :nodoc: all
|
|||
@attr_index_t ||= CType::Immediate.parse("uint32_t")
|
||||
end
|
||||
|
||||
def C.compile_branch
|
||||
@compile_branch ||= CType::Struct.new(
|
||||
"compile_branch", Primitive.cexpr!("SIZEOF(struct compile_branch)"),
|
||||
stack_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct compile_branch *)NULL)), stack_size)")],
|
||||
finish_p: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct compile_branch *)NULL)), finish_p)")],
|
||||
)
|
||||
end
|
||||
|
||||
def C.compile_status
|
||||
@compile_status ||= CType::Struct.new(
|
||||
"compile_status", Primitive.cexpr!("SIZEOF(struct compile_status)"),
|
||||
success: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct compile_status *)NULL)), success)")],
|
||||
stack_size_for_pos: [CType::Pointer.new { CType::Immediate.parse("int") }, Primitive.cexpr!("OFFSETOF((*((struct compile_status *)NULL)), stack_size_for_pos)")],
|
||||
local_stack_p: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct compile_status *)NULL)), local_stack_p)")],
|
||||
cc_entries_index: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct compile_status *)NULL)), cc_entries_index)")],
|
||||
compiled_iseq: [CType::Pointer.new { self.rb_iseq_constant_body }, Primitive.cexpr!("OFFSETOF((*((struct compile_status *)NULL)), compiled_iseq)")],
|
||||
compiled_id: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct compile_status *)NULL)), compiled_id)")],
|
||||
compile_info: [CType::Pointer.new { self.rb_rjit_compile_info }, Primitive.cexpr!("OFFSETOF((*((struct compile_status *)NULL)), compile_info)")],
|
||||
inlined_iseqs: [CType::Pointer.new { CType::Pointer.new { self.rb_iseq_constant_body } }, Primitive.cexpr!("OFFSETOF((*((struct compile_status *)NULL)), inlined_iseqs)")],
|
||||
inline_context: [self.inlined_call_context, Primitive.cexpr!("OFFSETOF((*((struct compile_status *)NULL)), inline_context)")],
|
||||
)
|
||||
end
|
||||
|
||||
def C.inlined_call_context
|
||||
@inlined_call_context ||= CType::Struct.new(
|
||||
"inlined_call_context", Primitive.cexpr!("SIZEOF(struct inlined_call_context)"),
|
||||
orig_argc: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct inlined_call_context *)NULL)), orig_argc)")],
|
||||
me: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct inlined_call_context *)NULL)), me)")],
|
||||
param_size: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct inlined_call_context *)NULL)), param_size)")],
|
||||
local_size: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct inlined_call_context *)NULL)), local_size)")],
|
||||
)
|
||||
end
|
||||
|
||||
def C.iseq_inline_constant_cache
|
||||
@iseq_inline_constant_cache ||= CType::Struct.new(
|
||||
"iseq_inline_constant_cache", Primitive.cexpr!("SIZEOF(struct iseq_inline_constant_cache)"),
|
||||
|
@ -1423,17 +1386,6 @@ module RubyVM::RJIT # :nodoc: all
|
|||
)
|
||||
end
|
||||
|
||||
def C.rb_rjit_compile_info
|
||||
@rb_rjit_compile_info ||= CType::Struct.new(
|
||||
"rb_rjit_compile_info", Primitive.cexpr!("SIZEOF(struct rb_rjit_compile_info)"),
|
||||
disable_ivar_cache: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_compile_info *)NULL)), disable_ivar_cache)")],
|
||||
disable_exivar_cache: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_compile_info *)NULL)), disable_exivar_cache)")],
|
||||
disable_send_cache: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_compile_info *)NULL)), disable_send_cache)")],
|
||||
disable_inlining: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_compile_info *)NULL)), disable_inlining)")],
|
||||
disable_const_cache: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_compile_info *)NULL)), disable_const_cache)")],
|
||||
)
|
||||
end
|
||||
|
||||
def C.rb_rjit_runtime_counters
|
||||
@rb_rjit_runtime_counters ||= CType::Struct.new(
|
||||
"rb_rjit_runtime_counters", Primitive.cexpr!("SIZEOF(struct rb_rjit_runtime_counters)"),
|
||||
|
@ -1521,22 +1473,6 @@ module RubyVM::RJIT # :nodoc: all
|
|||
)
|
||||
end
|
||||
|
||||
def C.rb_rjit_unit
|
||||
@rb_rjit_unit ||= CType::Struct.new(
|
||||
"rb_rjit_unit", Primitive.cexpr!("SIZEOF(struct rb_rjit_unit)"),
|
||||
unode: [self.ccan_list_node, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_unit *)NULL)), unode)")],
|
||||
id: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_unit *)NULL)), id)")],
|
||||
type: [self.rb_rjit_unit_type, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_unit *)NULL)), type)")],
|
||||
iseq: [CType::Pointer.new { self.rb_iseq_t }, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_unit *)NULL)), iseq)")],
|
||||
used_code_p: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_unit *)NULL)), used_code_p)")],
|
||||
compile_info: [self.rb_rjit_compile_info, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_unit *)NULL)), compile_info)")],
|
||||
cc_entries: [CType::Pointer.new { CType::Pointer.new { self.rb_callcache } }, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_unit *)NULL)), cc_entries)")],
|
||||
cc_entries_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_unit *)NULL)), cc_entries_size)")],
|
||||
handle: [CType::Pointer.new { CType::Immediate.parse("void") }, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_unit *)NULL)), handle)")],
|
||||
units: [self.rb_rjit_unit_list, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_unit *)NULL)), units)")],
|
||||
)
|
||||
end
|
||||
|
||||
def C.rb_serial_t
|
||||
@rb_serial_t ||= CType::Immediate.parse("unsigned long long")
|
||||
end
|
||||
|
@ -1613,19 +1549,11 @@ module RubyVM::RJIT # :nodoc: all
|
|||
@rjit_options ||= CType::Struct.new(
|
||||
"rjit_options", Primitive.cexpr!("SIZEOF(struct rjit_options)"),
|
||||
on: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), on)")],
|
||||
save_temps: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), save_temps)")],
|
||||
warnings: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), warnings)")],
|
||||
debug: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), debug)")],
|
||||
debug_flags: [CType::Pointer.new { CType::Immediate.parse("char") }, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), debug_flags)")],
|
||||
wait: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), wait)")],
|
||||
call_threshold: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), call_threshold)")],
|
||||
exec_mem_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), exec_mem_size)")],
|
||||
stats: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), stats)")],
|
||||
verbose: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), verbose)")],
|
||||
max_cache_size: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), max_cache_size)")],
|
||||
pause: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), pause)")],
|
||||
custom: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), custom)")],
|
||||
dump_disasm: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), dump_disasm)")],
|
||||
pause: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), pause)")],
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -1641,10 +1569,6 @@ module RubyVM::RJIT # :nodoc: all
|
|||
CType::Stub.new(:rb_id_table)
|
||||
end
|
||||
|
||||
def C._Bool
|
||||
CType::Bool.new
|
||||
end
|
||||
|
||||
def C.vm_call_handler
|
||||
CType::Stub.new(:vm_call_handler)
|
||||
end
|
||||
|
@ -1709,6 +1633,10 @@ module RubyVM::RJIT # :nodoc: all
|
|||
CType::Stub.new(:rb_snum_t)
|
||||
end
|
||||
|
||||
def C._Bool
|
||||
CType::Bool.new
|
||||
end
|
||||
|
||||
def C.iseq_bits_t
|
||||
CType::Stub.new(:iseq_bits_t)
|
||||
end
|
||||
|
@ -1741,14 +1669,6 @@ module RubyVM::RJIT # :nodoc: all
|
|||
CType::Stub.new(:ccan_list_node)
|
||||
end
|
||||
|
||||
def C.rb_rjit_unit_type
|
||||
CType::Stub.new(:rb_rjit_unit_type)
|
||||
end
|
||||
|
||||
def C.rb_rjit_unit_list
|
||||
CType::Stub.new(:rb_rjit_unit_list)
|
||||
end
|
||||
|
||||
def C.rb_ractor_t
|
||||
CType::Stub.new(:rb_ractor_t)
|
||||
end
|
||||
|
|
|
@ -357,7 +357,6 @@ generator = BindingGenerator.new(
|
|||
],
|
||||
values: {
|
||||
INT: %w[
|
||||
NOT_COMPILED_STACK_SIZE
|
||||
VM_ENV_DATA_INDEX_SPECVAL
|
||||
VM_ENV_DATA_INDEX_ME_CREF
|
||||
],
|
||||
|
@ -478,9 +477,6 @@ generator = BindingGenerator.new(
|
|||
RObject
|
||||
RStruct
|
||||
attr_index_t
|
||||
compile_branch
|
||||
compile_status
|
||||
inlined_call_context
|
||||
iseq_inline_constant_cache
|
||||
iseq_inline_constant_cache_entry
|
||||
iseq_inline_iv_cache_entry
|
||||
|
@ -505,9 +501,7 @@ generator = BindingGenerator.new(
|
|||
rb_method_iseq_t
|
||||
rb_method_type_t
|
||||
rb_method_bmethod_t
|
||||
rb_rjit_compile_info
|
||||
rb_rjit_runtime_counters
|
||||
rb_rjit_unit
|
||||
rb_serial_t
|
||||
rb_shape
|
||||
rb_shape_t
|
||||
|
|
Загрузка…
Ссылка в новой задаче