mirror of
https://github.com/ruby/ruby.git
synced 2025-09-18 18:13:58 +02:00
MJIT: Self-contain extern declarations
I'm trying to get rid of mjit_compiler.c, and this helps that migration.
This commit is contained in:
parent
8a0acbea4c
commit
27f34eeb5a
2 changed files with 8 additions and 7 deletions
10
mjit_c.rb
10
mjit_c.rb
|
@ -51,7 +51,10 @@ module RubyVM::MJIT
|
||||||
|
|
||||||
def rb_splat_or_kwargs_p(ci)
|
def rb_splat_or_kwargs_p(ci)
|
||||||
_ci_addr = ci.to_i
|
_ci_addr = ci.to_i
|
||||||
Primitive.cexpr! 'RBOOL(rb_splat_or_kwargs_p((CALL_INFO)NUM2PTR(_ci_addr)))'
|
Primitive.cstmt! %{
|
||||||
|
extern bool rb_splat_or_kwargs_p(const struct rb_callinfo *restrict ci);
|
||||||
|
return RBOOL(rb_splat_or_kwargs_p((CALL_INFO)NUM2PTR(_ci_addr)));
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def fastpath_applied_iseq_p(ci, cc, iseq)
|
def fastpath_applied_iseq_p(ci, cc, iseq)
|
||||||
|
@ -74,7 +77,10 @@ module RubyVM::MJIT
|
||||||
def mjit_capture_cc_entries(compiled_body, captured_body)
|
def mjit_capture_cc_entries(compiled_body, captured_body)
|
||||||
_compiled_body_addr = compiled_body.to_i
|
_compiled_body_addr = compiled_body.to_i
|
||||||
_captured_body_addr = captured_body.to_i
|
_captured_body_addr = captured_body.to_i
|
||||||
Primitive.cexpr! 'INT2NUM(mjit_capture_cc_entries((struct rb_iseq_constant_body *)NUM2PTR(_compiled_body_addr), (struct rb_iseq_constant_body *)NUM2PTR(_captured_body_addr)))'
|
Primitive.cstmt! %{
|
||||||
|
extern int mjit_capture_cc_entries(const struct rb_iseq_constant_body *compiled_iseq, const struct rb_iseq_constant_body *captured_iseq);
|
||||||
|
return INT2NUM(mjit_capture_cc_entries((struct rb_iseq_constant_body *)NUM2PTR(_compiled_body_addr), (struct rb_iseq_constant_body *)NUM2PTR(_captured_body_addr)));
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Convert encoded VM pointers to insn BINs.
|
# Convert encoded VM pointers to insn BINs.
|
||||||
|
|
|
@ -56,9 +56,6 @@ fastpath_applied_iseq_p(const CALL_INFO ci, const CALL_CACHE cc, const rb_iseq_t
|
||||||
#define PTR2NUM(x) ULL2NUM(x)
|
#define PTR2NUM(x) ULL2NUM(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int
|
|
||||||
mjit_capture_cc_entries(const struct rb_iseq_constant_body *compiled_iseq, const struct rb_iseq_constant_body *captured_iseq);
|
|
||||||
|
|
||||||
// Compile ISeq to C code in `f`. It returns true if it succeeds to compile.
|
// Compile ISeq to C code in `f`. It returns true if it succeeds to compile.
|
||||||
bool
|
bool
|
||||||
mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname, int id)
|
mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname, int id)
|
||||||
|
@ -103,8 +100,6 @@ has_cache_for_send(rb_execution_context_t *ec, VALUE self, VALUE cc_addr, VALUE
|
||||||
return RBOOL(has_cache);
|
return RBOOL(has_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern bool rb_splat_or_kwargs_p(const struct rb_callinfo *restrict ci);
|
|
||||||
|
|
||||||
// An offsetof implementation that works for unnamed struct and union.
|
// An offsetof implementation that works for unnamed struct and union.
|
||||||
// Multiplying 8 for compatibility with libclang's offsetof.
|
// Multiplying 8 for compatibility with libclang's offsetof.
|
||||||
#define OFFSETOF(ptr, member) RB_SIZE2NUM(((char *)&ptr.member - (char*)&ptr) * 8)
|
#define OFFSETOF(ptr, member) RB_SIZE2NUM(((char *)&ptr.member - (char*)&ptr) * 8)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue