Fix broken rebase
This commit is contained in:
parent
9f8f1afba2
commit
e4a824f769
@ -1,4 +1,4 @@
|
|||||||
module RubyVM::MJIT # :nodoc: all
|
module RubyVM::MJIT
|
||||||
# Every class under this namespace is a pointer. Even if the type is
|
# Every class under this namespace is a pointer. Even if the type is
|
||||||
# immediate, it shouldn't be dereferenced until `*` is called.
|
# immediate, it shouldn't be dereferenced until `*` is called.
|
||||||
module CPointer
|
module CPointer
|
||||||
@ -293,12 +293,12 @@ module RubyVM::MJIT # :nodoc: all
|
|||||||
|
|
||||||
# Dereference
|
# Dereference
|
||||||
def *
|
def *
|
||||||
byte = Fiddle::Pointer.new(@addr)[0, Fiddle::SIZEOF_CHAR].unpack1('c')
|
byte = Fiddle::Pointer.new(@addr)[0, Fiddle::SIZEOF_CHAR].unpack('c').first
|
||||||
if @width == 1
|
if @width == 1
|
||||||
bit = (1 & (byte >> @offset))
|
bit = (1 & (byte >> @offset))
|
||||||
bit == 1
|
bit == 1
|
||||||
elsif @width <= 8 && @offset == 0
|
elsif @width <= 8 && @offset == 0
|
||||||
bitmask = @width.times.sum { |i| 1 << i }
|
bitmask = @width.times.map { |i| 1 << i }.sum
|
||||||
byte & bitmask
|
byte & bitmask
|
||||||
else
|
else
|
||||||
raise NotImplementedError.new("not-implemented bit field access: width=#{@width} offset=#{@offset}")
|
raise NotImplementedError.new("not-implemented bit field access: width=#{@width} offset=#{@offset}")
|
||||||
|
@ -2,7 +2,7 @@ require 'fiddle'
|
|||||||
require 'fiddle/pack'
|
require 'fiddle/pack'
|
||||||
require_relative 'c_pointer'
|
require_relative 'c_pointer'
|
||||||
|
|
||||||
module RubyVM::MJIT # :nodoc: all
|
module RubyVM::MJIT
|
||||||
module CType
|
module CType
|
||||||
module Struct
|
module Struct
|
||||||
# @param name [String]
|
# @param name [String]
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
require 'mjit/context'
|
require 'ruby_vm/mjit/context'
|
||||||
require 'mjit/insn_compiler'
|
require 'ruby_vm/mjit/insn_compiler'
|
||||||
require 'mjit/instruction'
|
require 'ruby_vm/mjit/instruction'
|
||||||
require 'mjit/jit_state'
|
require 'ruby_vm/mjit/jit_state'
|
||||||
require 'mjit/x86_assembler'
|
require 'ruby_vm/mjit/x86_assembler'
|
||||||
|
|
||||||
module RubyVM::MJIT
|
module RubyVM::MJIT
|
||||||
# Compilation status
|
# Compilation status
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
module RubyVM::MJIT::Hooks # :nodoc: all
|
|
||||||
C = RubyVM::MJIT.const_get(:C, false)
|
|
||||||
|
|
||||||
def self.on_bop_redefined(_redefined_flag, _bop)
|
|
||||||
C.mjit_cancel_all("BOP is redefined")
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.on_cme_invalidate(_cme)
|
|
||||||
# to be used later
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.on_ractor_spawn
|
|
||||||
C.mjit_cancel_all("Ractor is spawned")
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.on_constant_state_changed(_id)
|
|
||||||
# to be used later
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.on_constant_ic_update(_iseq, _ic, _insn_idx)
|
|
||||||
# to be used later
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.on_tracing_invalidate_all(new_iseq_events)
|
|
||||||
# Stop calling all JIT-ed code. We can't rewrite existing JIT-ed code to trace_ insns for now.
|
|
||||||
# :class events are triggered only in ISEQ_TYPE_CLASS, but mjit_target_iseq_p ignores such iseqs.
|
|
||||||
# Thus we don't need to cancel JIT-ed code for :class events.
|
|
||||||
if new_iseq_events != C.RUBY_EVENT_CLASS
|
|
||||||
C.mjit_cancel_all("TracePoint is enabled")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
86
mjit.c
86
mjit.c
@ -129,92 +129,6 @@ static VALUE rb_mMJITC = 0;
|
|||||||
static VALUE rb_MJITCompiler = 0;
|
static VALUE rb_MJITCompiler = 0;
|
||||||
// RubyVM::MJIT::CPointer::Struct_rb_iseq_t
|
// RubyVM::MJIT::CPointer::Struct_rb_iseq_t
|
||||||
static VALUE rb_cMJITIseqPtr = 0;
|
static VALUE rb_cMJITIseqPtr = 0;
|
||||||
// RubyVM::MJIT::CPointer::Struct_IC
|
|
||||||
static VALUE rb_cMJITICPtr = 0;
|
|
||||||
// RubyVM::MJIT::Compiler
|
|
||||||
static VALUE rb_mMJITHooks = 0;
|
|
||||||
|
|
||||||
#define WITH_MJIT_DISABLED(stmt) do { \
|
|
||||||
bool original_call_p = mjit_call_p; \
|
|
||||||
mjit_call_p = false; \
|
|
||||||
stmt; \
|
|
||||||
mjit_call_p = original_call_p; \
|
|
||||||
if (mjit_cancel_p) mjit_call_p = false; \
|
|
||||||
} while (0);
|
|
||||||
|
|
||||||
// Hook MJIT when BOP is redefined.
|
|
||||||
MJIT_FUNC_EXPORTED void
|
|
||||||
rb_mjit_bop_redefined(int redefined_flag, enum ruby_basic_operators bop)
|
|
||||||
{
|
|
||||||
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return;
|
|
||||||
WITH_MJIT_DISABLED({
|
|
||||||
rb_funcall(rb_mMJITHooks, rb_intern("on_bop_redefined"), 2, INT2NUM(redefined_flag), INT2NUM((int)bop));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hook MJIT when CME is invalidated.
|
|
||||||
MJIT_FUNC_EXPORTED void
|
|
||||||
rb_mjit_cme_invalidate(rb_callable_method_entry_t *cme)
|
|
||||||
{
|
|
||||||
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return;
|
|
||||||
WITH_MJIT_DISABLED({
|
|
||||||
VALUE cme_klass = rb_funcall(rb_mMJITC, rb_intern("rb_callable_method_entry_struct"), 0);
|
|
||||||
VALUE cme_ptr = rb_funcall(cme_klass, rb_intern("new"), 1, SIZET2NUM((size_t)cme));
|
|
||||||
rb_funcall(rb_mMJITHooks, rb_intern("on_cme_invalidate"), 1, cme_ptr);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hook MJIT when Ractor is spawned.
|
|
||||||
void
|
|
||||||
rb_mjit_before_ractor_spawn(void)
|
|
||||||
{
|
|
||||||
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return;
|
|
||||||
WITH_MJIT_DISABLED({
|
|
||||||
rb_funcall(rb_mMJITHooks, rb_intern("on_ractor_spawn"), 0);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
mjit_constant_state_changed(void *data)
|
|
||||||
{
|
|
||||||
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return;
|
|
||||||
ID id = (ID)data;
|
|
||||||
WITH_MJIT_DISABLED({
|
|
||||||
rb_funcall(rb_mMJITHooks, rb_intern("on_constant_state_changed"), 1, ID2SYM(id));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hook MJIT when constant state is changed.
|
|
||||||
MJIT_FUNC_EXPORTED void
|
|
||||||
rb_mjit_constant_state_changed(ID id)
|
|
||||||
{
|
|
||||||
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return;
|
|
||||||
// Asynchronously hook the Ruby code since this is hooked during a "Ruby critical section".
|
|
||||||
extern int rb_workqueue_register(unsigned flags, rb_postponed_job_func_t func, void *data);
|
|
||||||
rb_workqueue_register(0, mjit_constant_state_changed, (void *)id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hook MJIT when constant IC is updated.
|
|
||||||
MJIT_FUNC_EXPORTED void
|
|
||||||
rb_mjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic, unsigned insn_idx)
|
|
||||||
{
|
|
||||||
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return;
|
|
||||||
WITH_MJIT_DISABLED({
|
|
||||||
VALUE iseq_ptr = rb_funcall(rb_cMJITIseqPtr, rb_intern("new"), 1, SIZET2NUM((size_t)iseq));
|
|
||||||
VALUE ic_ptr = rb_funcall(rb_cMJITICPtr, rb_intern("new"), 1, SIZET2NUM((size_t)ic));
|
|
||||||
rb_funcall(rb_mMJITHooks, rb_intern("on_constant_ic_update"), 3, iseq_ptr, ic_ptr, UINT2NUM(insn_idx));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hook MJIT when TracePoint is enabled.
|
|
||||||
MJIT_FUNC_EXPORTED void
|
|
||||||
rb_mjit_tracing_invalidate_all(rb_event_flag_t new_iseq_events)
|
|
||||||
{
|
|
||||||
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return;
|
|
||||||
WITH_MJIT_DISABLED({
|
|
||||||
rb_funcall(rb_mMJITHooks, rb_intern("on_tracing_invalidate_all"), 1, UINT2NUM(new_iseq_events));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_mjit_add_iseq_to_process(const rb_iseq_t *iseq)
|
rb_mjit_add_iseq_to_process(const rb_iseq_t *iseq)
|
||||||
|
6
mjit.rb
6
mjit.rb
@ -23,7 +23,7 @@ if RubyVM::MJIT.enabled?
|
|||||||
return # miniruby doesn't support MJIT
|
return # miniruby doesn't support MJIT
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'mjit/c_type'
|
require 'ruby_vm/mjit/c_type'
|
||||||
require 'mjit/compiler'
|
require 'ruby_vm/mjit/compiler'
|
||||||
require 'mjit/stats'
|
require 'ruby_vm/mjit/stats'
|
||||||
end
|
end
|
||||||
|
@ -5530,7 +5530,6 @@ vm_ic_update(const rb_iseq_t *iseq, IC ic, VALUE val, const VALUE *reg_ep, const
|
|||||||
RUBY_ASSERT(pc >= ISEQ_BODY(iseq)->iseq_encoded);
|
RUBY_ASSERT(pc >= ISEQ_BODY(iseq)->iseq_encoded);
|
||||||
unsigned pos = (unsigned)(pc - ISEQ_BODY(iseq)->iseq_encoded);
|
unsigned pos = (unsigned)(pc - ISEQ_BODY(iseq)->iseq_encoded);
|
||||||
rb_yjit_constant_ic_update(iseq, ic, pos);
|
rb_yjit_constant_ic_update(iseq, ic, pos);
|
||||||
rb_mjit_constant_ic_update(iseq, ic, pos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -124,7 +124,6 @@ vm_cme_invalidate(rb_callable_method_entry_t *cme)
|
|||||||
RB_DEBUG_COUNTER_INC(cc_cme_invalidate);
|
RB_DEBUG_COUNTER_INC(cc_cme_invalidate);
|
||||||
|
|
||||||
rb_yjit_cme_invalidate(cme);
|
rb_yjit_cme_invalidate(cme);
|
||||||
rb_mjit_cme_invalidate(cme);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -150,7 +149,6 @@ rb_clear_constant_cache_for_id(ID id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rb_yjit_constant_state_changed(id);
|
rb_yjit_constant_state_changed(id);
|
||||||
rb_mjit_constant_state_changed(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -190,7 +188,6 @@ clear_method_cache_by_id_in_class(VALUE klass, ID mid)
|
|||||||
if (cc_tbl && rb_id_table_lookup(cc_tbl, mid, &ccs_data)) {
|
if (cc_tbl && rb_id_table_lookup(cc_tbl, mid, &ccs_data)) {
|
||||||
struct rb_class_cc_entries *ccs = (struct rb_class_cc_entries *)ccs_data;
|
struct rb_class_cc_entries *ccs = (struct rb_class_cc_entries *)ccs_data;
|
||||||
rb_yjit_cme_invalidate((rb_callable_method_entry_t *)ccs->cme);
|
rb_yjit_cme_invalidate((rb_callable_method_entry_t *)ccs->cme);
|
||||||
rb_mjit_cme_invalidate((rb_callable_method_entry_t *)ccs->cme);
|
|
||||||
if (NIL_P(ccs->cme->owner)) invalidate_negative_cache(mid);
|
if (NIL_P(ccs->cme->owner)) invalidate_negative_cache(mid);
|
||||||
rb_vm_ccs_free(ccs);
|
rb_vm_ccs_free(ccs);
|
||||||
rb_id_table_delete(cc_tbl, mid);
|
rb_id_table_delete(cc_tbl, mid);
|
||||||
@ -203,7 +200,6 @@ clear_method_cache_by_id_in_class(VALUE klass, ID mid)
|
|||||||
VALUE cme;
|
VALUE cme;
|
||||||
if (rb_yjit_enabled_p() && rb_id_table_lookup(cm_tbl, mid, &cme)) {
|
if (rb_yjit_enabled_p() && rb_id_table_lookup(cm_tbl, mid, &cme)) {
|
||||||
rb_yjit_cme_invalidate((rb_callable_method_entry_t *)cme);
|
rb_yjit_cme_invalidate((rb_callable_method_entry_t *)cme);
|
||||||
rb_mjit_cme_invalidate((rb_callable_method_entry_t *)cme);
|
|
||||||
}
|
}
|
||||||
rb_id_table_delete(cm_tbl, mid);
|
rb_id_table_delete(cm_tbl, mid);
|
||||||
RB_DEBUG_COUNTER_INC(cc_invalidate_leaf_callable);
|
RB_DEBUG_COUNTER_INC(cc_invalidate_leaf_callable);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user