зеркало из https://github.com/github/ruby.git
Implement the --disable-ujit command line option
This commit is contained in:
Родитель
f3c961f273
Коммит
e8c914c250
|
@ -869,7 +869,7 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
|
|||
unsigned int next_ujit_idx = 0;
|
||||
unsigned int translated_len = 0;
|
||||
|
||||
bool ujit_disabled = false /*get_cmdline_flag()*/;
|
||||
bool ujit_enabled = rb_ujit_enabled_p();
|
||||
|
||||
VALUE *translated_insns = ALLOCV_N(VALUE, translated_insns_buf, iseq->body->iseq_size);
|
||||
for (insn_idx = 0; insn_idx < iseq->body->iseq_size; /* */) {
|
||||
|
@ -880,7 +880,7 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
|
|||
uint8_t* native_code_ptr = NULL;
|
||||
|
||||
// If ujit is enabled and hasn't already compiled this instruction
|
||||
if (!ujit_disabled && insn_idx >= next_ujit_idx)
|
||||
if (ujit_enabled && insn_idx >= next_ujit_idx)
|
||||
native_code_ptr = ujit_compile_insn(iseq, insn_idx, &next_ujit_idx);
|
||||
|
||||
if (native_code_ptr)
|
||||
|
|
10
ruby.c
10
ruby.c
|
@ -59,6 +59,7 @@
|
|||
#include "internal/process.h"
|
||||
#include "internal/variable.h"
|
||||
#include "mjit.h"
|
||||
#include "ujit_compile.h"
|
||||
#include "ruby/encoding.h"
|
||||
#include "ruby/thread.h"
|
||||
#include "ruby/util.h"
|
||||
|
@ -103,6 +104,8 @@ void rb_warning_category_update(unsigned int mask, unsigned int bits);
|
|||
X(frozen_string_literal) \
|
||||
SEP \
|
||||
X(jit) \
|
||||
SEP \
|
||||
X(ujit)
|
||||
/* END OF FEATURES */
|
||||
#define EACH_DEBUG_FEATURES(X, SEP) \
|
||||
X(frozen_string_literal) \
|
||||
|
@ -229,6 +232,7 @@ cmdline_options_init(ruby_cmdline_options_t *opt)
|
|||
#ifdef MJIT_FORCE_ENABLE /* to use with: ./configure cppflags="-DMJIT_FORCE_ENABLE" */
|
||||
opt->features.set |= FEATURE_BIT(jit);
|
||||
#endif
|
||||
opt->features.set |= FEATURE_BIT(ujit);
|
||||
return opt;
|
||||
}
|
||||
|
||||
|
@ -327,6 +331,7 @@ usage(const char *name, int help, int highlight, int columns)
|
|||
M("rubyopt", "", "RUBYOPT environment variable (default: enabled)"),
|
||||
M("frozen-string-literal", "", "freeze all string literals (default: disabled)"),
|
||||
M("jit", "", "JIT compiler (default: disabled)"),
|
||||
M("ujit", "", "in-process JIT compiler (default: enabled)"),
|
||||
};
|
||||
static const struct message warn_categories[] = {
|
||||
M("deprecated", "", "deprecated features"),
|
||||
|
@ -1435,6 +1440,9 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
|
|||
rb_warn("MJIT support is disabled.");
|
||||
#endif
|
||||
}
|
||||
else if (strncmp("ujit", s, 4) == 0) {
|
||||
FEATURE_SET(opt->features, FEATURE_BIT(jit));
|
||||
}
|
||||
else if (strcmp("yydebug", s) == 0) {
|
||||
if (envopt) goto noenvopt_long;
|
||||
opt->dump |= DUMP_BIT(yydebug);
|
||||
|
@ -1861,6 +1869,8 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
|||
/* Using TMP_RUBY_PREFIX created by ruby_init_loadpath(). */
|
||||
mjit_init(&opt->mjit);
|
||||
#endif
|
||||
if (opt->features.set & FEATURE_BIT(ujit))
|
||||
rb_ujit_init();
|
||||
|
||||
Init_ruby_description();
|
||||
Init_enc();
|
||||
|
|
|
@ -182,10 +182,8 @@ https://wiki.osdev.org/System_V_ABI#x86-64
|
|||
uint8_t *
|
||||
ujit_compile_insn(rb_iseq_t *iseq, unsigned int insn_idx, unsigned int* next_ujit_idx)
|
||||
{
|
||||
// If not previously done, initialize ujit
|
||||
if (!cb)
|
||||
{
|
||||
ujit_init();
|
||||
if (!cb) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// NOTE: if we are ever deployed in production, we
|
||||
|
@ -379,7 +377,14 @@ void gen_setlocal_wc0(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx)
|
|||
mov(cb, mem_opnd(64, RDX, offs), RCX);
|
||||
}
|
||||
|
||||
static void ujit_init()
|
||||
bool
|
||||
rb_ujit_enabled_p(void)
|
||||
{
|
||||
return !!cb;
|
||||
}
|
||||
|
||||
void
|
||||
rb_ujit_init(void)
|
||||
{
|
||||
// Initialize the code blocks
|
||||
size_t mem_size = 64 * 1024 * 1024;
|
||||
|
|
|
@ -3,12 +3,15 @@
|
|||
|
||||
#include "stddef.h"
|
||||
#include "stdint.h"
|
||||
#include "stdbool.h"
|
||||
|
||||
#ifndef rb_iseq_t
|
||||
typedef struct rb_iseq_struct rb_iseq_t;
|
||||
#define rb_iseq_t rb_iseq_t
|
||||
#endif
|
||||
|
||||
void rb_ujit_init(void);
|
||||
bool rb_ujit_enabled_p(void);
|
||||
uint8_t* ujit_compile_insn(rb_iseq_t *iseq, unsigned int insn_idx, unsigned int* next_ujit_idx);
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче