MJIT: Make it parsable by Solargraph (#6827)
* Revert "Revert "MJIT: Make it parsable by Solargraph"" This reverts commit 8e18761da1932df88bfb6505acbda4740e1b2930. * Call rb_gc_register_mark_object
This commit is contained in:
parent
acb76663ba
commit
9c13fc614c
Notes:
git
2022-11-29 05:34:14 +00:00
Merged-By: k0kubun <takashikkbn@gmail.com>
1788
lib/mjit/compiler.rb
1788
lib/mjit/compiler.rb
File diff suppressed because it is too large
Load Diff
5
mjit.c
5
mjit.c
@ -1324,7 +1324,7 @@ static VALUE rb_mMJIT = 0;
|
|||||||
// RubyVM::MJIT::C
|
// RubyVM::MJIT::C
|
||||||
VALUE rb_mMJITC = 0;
|
VALUE rb_mMJITC = 0;
|
||||||
// RubyVM::MJIT::Compiler
|
// RubyVM::MJIT::Compiler
|
||||||
VALUE rb_mMJITCompiler = 0;
|
VALUE rb_cMJITCompiler = 0;
|
||||||
|
|
||||||
// [experimental] Call custom RubyVM::MJIT.compile if defined
|
// [experimental] Call custom RubyVM::MJIT.compile if defined
|
||||||
static void
|
static void
|
||||||
@ -1765,8 +1765,9 @@ mjit_init(const struct mjit_options *opts)
|
|||||||
mjit_enabled = false;
|
mjit_enabled = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rb_mMJITCompiler = rb_const_get(rb_mMJIT, rb_intern("Compiler"));
|
|
||||||
rb_mMJITC = rb_const_get(rb_mMJIT, rb_intern("C"));
|
rb_mMJITC = rb_const_get(rb_mMJIT, rb_intern("C"));
|
||||||
|
rb_cMJITCompiler = rb_funcall(rb_const_get(rb_mMJIT, rb_intern("Compiler")), rb_intern("new"), 0);
|
||||||
|
rb_gc_register_mark_object(rb_cMJITCompiler);
|
||||||
|
|
||||||
mjit_call_p = true;
|
mjit_call_p = true;
|
||||||
mjit_pid = getpid();
|
mjit_pid = getpid();
|
||||||
|
1
mjit.rb
1
mjit.rb
@ -20,6 +20,7 @@ if RubyVM::MJIT.enabled?
|
|||||||
return # miniruby doesn't support MJIT
|
return # miniruby doesn't support MJIT
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RubyVM::MJIT::C = Object.new # forward declaration for mjit/compiler
|
||||||
require "mjit/c_type"
|
require "mjit/c_type"
|
||||||
require "mjit/instruction"
|
require "mjit/instruction"
|
||||||
require "mjit/compiler"
|
require "mjit/compiler"
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
# Part of this file is generated by tool/mjit/bindgen.rb.
|
# Part of this file is generated by tool/mjit/bindgen.rb.
|
||||||
# Run `make mjit-bindgen` to update code between "MJIT bindgen begin" and "MJIT bindgen end".
|
# Run `make mjit-bindgen` to update code between "MJIT bindgen begin" and "MJIT bindgen end".
|
||||||
module RubyVM::MJIT
|
module RubyVM::MJIT
|
||||||
C = Object.new
|
|
||||||
|
|
||||||
# This `class << C` section is for calling C functions. For importing variables
|
# This `class << C` section is for calling C functions. For importing variables
|
||||||
# or macros as is, please consider using tool/mjit/bindgen.rb instead.
|
# or macros as is, please consider using tool/mjit/bindgen.rb instead.
|
||||||
class << C
|
class << C
|
||||||
@ -769,4 +767,4 @@ module RubyVM::MJIT
|
|||||||
end
|
end
|
||||||
|
|
||||||
### MJIT bindgen end ###
|
### MJIT bindgen end ###
|
||||||
end if RubyVM::MJIT.enabled?
|
end if RubyVM::MJIT.enabled? && RubyVM::MJIT.const_defined?(:C) # not defined for miniruby
|
||||||
|
@ -122,8 +122,8 @@ mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname, int id)
|
|||||||
bool original_call_p = mjit_call_p;
|
bool original_call_p = mjit_call_p;
|
||||||
mjit_call_p = false; // Avoid impacting JIT metrics by itself
|
mjit_call_p = false; // Avoid impacting JIT metrics by itself
|
||||||
|
|
||||||
extern VALUE rb_mMJITCompiler;
|
extern VALUE rb_cMJITCompiler;
|
||||||
VALUE src = rb_funcall(rb_mMJITCompiler, rb_intern("compile"), 3,
|
VALUE src = rb_funcall(rb_cMJITCompiler, rb_intern("compile"), 3,
|
||||||
rb_ptr("rb_iseq_t", iseq), rb_str_new_cstr(funcname), INT2NUM(id));
|
rb_ptr("rb_iseq_t", iseq), rb_str_new_cstr(funcname), INT2NUM(id));
|
||||||
if (!NIL_P(src)) {
|
if (!NIL_P(src)) {
|
||||||
fprintf(f, "%s", RSTRING_PTR(src));
|
fprintf(f, "%s", RSTRING_PTR(src));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user