Skip to content

Commit 4e2eb76

Browse files
goyox86XrXr
authored andcommitted
Yet Another Ruby JIT!
Renaming uJIT to YJIT. AKA s/ujit/yjit/g.
1 parent 7f7e79d commit 4e2eb76

36 files changed

+1312
-1320
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,5 +229,5 @@ lcov*.info
229229
/mjit_config.h
230230
/include/ruby-*/*/rb_mjit_min_header-*.h
231231

232-
# UJIT
233-
/ujit_hooks.inc
232+
# YJIT
233+
/yjit_hooks.inc

common.mk

Lines changed: 822 additions & 822 deletions
Large diffs are not rendered by default.

inits.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ rb_call_builtin_inits(void)
9999
BUILTIN(timev);
100100
BUILTIN(nilclass);
101101
BUILTIN(marshal);
102-
BUILTIN(ujit);
102+
BUILTIN(yjit);
103103
Init_builtin_prelude();
104104
}
105105
#undef CALL

iseq.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "ruby/util.h"
3939
#include "vm_core.h"
4040
#include "vm_callinfo.h"
41-
#include "ujit.h"
41+
#include "yjit.h"
4242

4343
#include "builtin.h"
4444
#include "insns.inc"
@@ -110,7 +110,7 @@ rb_iseq_free(const rb_iseq_t *iseq)
110110
if (iseq && iseq->body) {
111111
struct rb_iseq_constant_body *const body = iseq->body;
112112
mjit_free_iseq(iseq); /* Notify MJIT */
113-
rb_ujit_iseq_free(body);
113+
rb_yjit_iseq_free(body);
114114
ruby_xfree((void *)body->iseq_encoded);
115115
ruby_xfree((void *)body->insns_info.body);
116116
if (body->insns_info.positions) ruby_xfree((void *)body->insns_info.positions);
@@ -323,7 +323,7 @@ rb_iseq_update_references(rb_iseq_t *iseq)
323323
#if USE_MJIT
324324
mjit_update_references(iseq);
325325
#endif
326-
rb_ujit_iseq_update_references(body);
326+
rb_yjit_iseq_update_references(body);
327327
}
328328
}
329329

@@ -404,7 +404,7 @@ rb_iseq_mark(const rb_iseq_t *iseq)
404404
#if USE_MJIT
405405
mjit_mark_cc_entries(body);
406406
#endif
407-
rb_ujit_iseq_mark(body);
407+
rb_yjit_iseq_mark(body);
408408
}
409409

410410
if (FL_TEST_RAW((VALUE)iseq, ISEQ_NOT_LOADED_YET)) {
@@ -3184,7 +3184,7 @@ static insn_data_t insn_data[VM_INSTRUCTION_SIZE/2];
31843184

31853185

31863186

3187-
#include "ujit_asm.h"
3187+
#include "yjit_asm.h"
31883188

31893189

31903190

@@ -3490,7 +3490,7 @@ trace_set_i(void *vstart, void *vend, size_t stride, void *data)
34903490
}
34913491

34923492
void
3493-
rb_ujit_empty_func_with_ec(rb_control_frame_t *cfp, rb_execution_context_t *ec)
3493+
rb_yjit_empty_func_with_ec(rb_control_frame_t *cfp, rb_execution_context_t *ec)
34943494
{
34953495
// it's put in this file instead of say, compile.c to dodge long C compile time.
34963496
// it just needs to be in a different unit from vm.o so the compiler can't see the definition

iseq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ VALUE rb_iseq_defined_string(enum defined_type type);
315315
/* vm.c */
316316
VALUE rb_iseq_local_variables(const rb_iseq_t *iseq);
317317

318-
NOINLINE(void rb_ujit_empty_func_with_ec(rb_control_frame_t *cfp, rb_execution_context_t *ec));
318+
NOINLINE(void rb_yjit_empty_func_with_ec(rb_control_frame_t *cfp, rb_execution_context_t *ec));
319319

320320
RUBY_SYMBOL_EXPORT_END
321321

mjit.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
#include "debug_counter.h"
1818
#include "ruby.h"
19-
#include "ujit.h"
19+
#include "vm_core.h"
20+
#include "yjit.h"
2021

2122
// Special address values of a function generated from the
2223
// corresponding iseq by MJIT:
@@ -143,15 +144,15 @@ mjit_exec(rb_execution_context_t *ec)
143144
const rb_iseq_t *iseq;
144145
struct rb_iseq_constant_body *body;
145146

146-
if (mjit_call_p || rb_ujit_enabled_p()) {
147+
if (mjit_call_p || rb_yjit_enabled_p()) {
147148
iseq = ec->cfp->iseq;
148149
body = iseq->body;
149150
body->total_calls++;
150151
}
151152

152153
#ifndef MJIT_HEADER
153-
if (rb_ujit_enabled_p() && !mjit_call_p && body->total_calls == rb_ujit_call_threshold()) {
154-
rb_ujit_compile_iseq(iseq, ec);
154+
if (rb_yjit_enabled_p() && !mjit_call_p && body->total_calls == rb_yjit_call_threshold()) {
155+
rb_yjit_compile_iseq(iseq, ec);
155156
return Qundef;
156157
}
157158
#endif

ractor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "variable.h"
1717
#include "gc.h"
1818
#include "transient_heap.h"
19-
#include "ujit.h"
19+
#include "yjit.h"
2020

2121
VALUE rb_cRactor;
2222

@@ -1605,7 +1605,7 @@ ractor_create(rb_execution_context_t *ec, VALUE self, VALUE loc, VALUE name, VAL
16051605
r->verbose = cr->verbose;
16061606
r->debug = cr->debug;
16071607

1608-
rb_ujit_before_ractor_spawn();
1608+
rb_yjit_before_ractor_spawn();
16091609
rb_thread_create_ractor(r, args, block);
16101610

16111611
RB_GC_GUARD(rv);

ruby.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#include "internal/process.h"
6060
#include "internal/variable.h"
6161
#include "mjit.h"
62-
#include "ujit.h"
62+
#include "yjit.h"
6363
#include "ruby/encoding.h"
6464
#include "ruby/thread.h"
6565
#include "ruby/util.h"
@@ -105,7 +105,7 @@ void rb_warning_category_update(unsigned int mask, unsigned int bits);
105105
SEP \
106106
X(jit) \
107107
SEP \
108-
X(ujit)
108+
X(yjit)
109109
/* END OF FEATURES */
110110
#define EACH_DEBUG_FEATURES(X, SEP) \
111111
X(frozen_string_literal) \
@@ -189,7 +189,7 @@ struct ruby_cmdline_options {
189189
#if USE_MJIT
190190
struct mjit_options mjit;
191191
#endif
192-
struct rb_ujit_options ujit;
192+
struct rb_yjit_options yjit;
193193

194194
int sflag, xflag;
195195
unsigned int warning: 1;
@@ -234,7 +234,7 @@ cmdline_options_init(ruby_cmdline_options_t *opt)
234234
#ifdef MJIT_FORCE_ENABLE /* to use with: ./configure cppflags="-DMJIT_FORCE_ENABLE" */
235235
opt->features.set |= FEATURE_BIT(jit);
236236
#endif
237-
opt->features.set |= FEATURE_BIT(ujit);
237+
opt->features.set |= FEATURE_BIT(yjit);
238238
return opt;
239239
}
240240

@@ -333,7 +333,7 @@ usage(const char *name, int help, int highlight, int columns)
333333
M("rubyopt", "", "RUBYOPT environment variable (default: enabled)"),
334334
M("frozen-string-literal", "", "freeze all string literals (default: disabled)"),
335335
M("jit", "", "JIT compiler (default: disabled)"),
336-
M("ujit", "", "in-process JIT compiler (default: enabled)"),
336+
M("yjit", "", "in-process JIT compiler (default: enabled)"),
337337
};
338338
static const struct message warn_categories[] = {
339339
M("deprecated", "", "deprecated features"),
@@ -1031,20 +1031,20 @@ set_option_encoding_once(const char *type, VALUE *name, const char *e, long elen
10311031
opt_match(s, l, name) && (*(s) ? 1 : (rb_raise(rb_eRuntimeError, "--jit-" name " needs an argument"), 0))
10321032

10331033
static void
1034-
setup_ujit_options(const char *s, struct rb_ujit_options *ujit_opt)
1034+
setup_yjit_options(const char *s, struct rb_yjit_options *yjit_opt)
10351035
{
10361036
if (*s != '-') return;
10371037
const size_t l = strlen(++s);
10381038

10391039
if (opt_match_arg(s, l, "call-threshold")) {
1040-
ujit_opt->call_threshold = atoi(s + 1);
1040+
yjit_opt->call_threshold = atoi(s + 1);
10411041
}
10421042
else if (opt_match_noarg(s, l, "stats")) {
1043-
ujit_opt->gen_stats = true;
1043+
yjit_opt->gen_stats = true;
10441044
}
10451045
else {
10461046
rb_raise(rb_eRuntimeError,
1047-
"invalid ujit option `%s' (--help will show valid ujit options)", s);
1047+
"invalid yjit option `%s' (--help will show valid yjit options)", s);
10481048
}
10491049
}
10501050

@@ -1461,9 +1461,9 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
14611461
rb_warn("MJIT support is disabled.");
14621462
#endif
14631463
}
1464-
else if (strncmp("ujit", s, 4) == 0) {
1465-
FEATURE_SET(opt->features, FEATURE_BIT(ujit));
1466-
setup_ujit_options(s + 4, &opt->ujit);
1464+
else if (strncmp("yjit", s, 4) == 0) {
1465+
FEATURE_SET(opt->features, FEATURE_BIT(yjit));
1466+
setup_yjit_options(s + 4, &opt->yjit);
14671467
}
14681468
else if (strcmp("yydebug", s) == 0) {
14691469
if (envopt) goto noenvopt_long;
@@ -1825,8 +1825,8 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
18251825
*/
18261826
rb_warning("-K is specified; it is for 1.8 compatibility and may cause odd behavior");
18271827

1828-
if (opt->features.set & FEATURE_BIT(ujit))
1829-
rb_ujit_init(&opt->ujit);
1828+
if (opt->features.set & FEATURE_BIT(yjit))
1829+
rb_yjit_init(&opt->yjit);
18301830
#if USE_MJIT
18311831
if (opt->features.set & FEATURE_BIT(jit)) {
18321832
opt->mjit.on = TRUE; /* set mjit.on for ruby_show_version() API and check to call mjit_init() */

template/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ update-known-errors:
590590
$(IFCHANGE) $(srcdir)/defs/known_errors.def -
591591

592592
INSNS = opt_sc.inc optinsn.inc optunifs.inc insns.inc insns_info.inc \
593-
vmtc.inc vm.inc mjit_compile.inc ujit_hooks.inc
593+
vmtc.inc vm.inc mjit_compile.inc yjit_hooks.inc
594594

595595
$(INSNS): $(srcdir)/insns.def vm_opts.h \
596596
$(srcdir)/defs/opt_operand.def $(srcdir)/defs/opt_insn_unif.def \

test_asm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
clear
55

6-
clang -std=gnu99 -Wall -Werror -Wshorten-64-to-32 ujit_asm.c ujit_asm_tests.c -o asm_test
6+
clang -std=gnu99 -Wall -Werror -Wshorten-64-to-32 yjit_asm.c yjit_asm_tests.c -o asm_test
77

88
./asm_test
99

0 commit comments

Comments
 (0)