mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Revert "Revert some recent JIT changes"
This reverts commit b7dc04e518
.
This should be fine, rather necessary, too.
This commit is contained in:
parent
12a1a25181
commit
9e8f732f39
1 changed files with 14 additions and 1 deletions
|
@ -936,6 +936,7 @@ compile_compact_jit_code(char* c_file)
|
||||||
// TODO: Consider using a more granular lock after we implement inlining across
|
// TODO: Consider using a more granular lock after we implement inlining across
|
||||||
// compacted functions (not done yet).
|
// compacted functions (not done yet).
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
CRITICAL_SECTION_START(3, "before active_units list_for_each");
|
||||||
list_for_each(&active_units.head, child_unit, unode) {
|
list_for_each(&active_units.head, child_unit, unode) {
|
||||||
char funcname[MAXPATHLEN];
|
char funcname[MAXPATHLEN];
|
||||||
sprint_funcname(funcname, child_unit);
|
sprint_funcname(funcname, child_unit);
|
||||||
|
@ -951,6 +952,7 @@ compile_compact_jit_code(char* c_file)
|
||||||
fprintf(f, "\n/* %s%s%s:%ld */\n", iseq_label, sep, iseq_path, iseq_lineno);
|
fprintf(f, "\n/* %s%s%s:%ld */\n", iseq_label, sep, iseq_path, iseq_lineno);
|
||||||
success &= mjit_compile(f, child_unit->iseq, funcname, child_unit->id);
|
success &= mjit_compile(f, child_unit->iseq, funcname, child_unit->id);
|
||||||
}
|
}
|
||||||
|
CRITICAL_SECTION_FINISH(3, "after active_units list_for_each");
|
||||||
|
|
||||||
// release blocking mjit_gc_start_hook
|
// release blocking mjit_gc_start_hook
|
||||||
CRITICAL_SECTION_START(3, "after mjit_compile to wakeup client for GC");
|
CRITICAL_SECTION_START(3, "after mjit_compile to wakeup client for GC");
|
||||||
|
@ -1359,16 +1361,27 @@ mjit_worker(void)
|
||||||
while (!stop_worker_p) {
|
while (!stop_worker_p) {
|
||||||
struct rb_mjit_unit *unit;
|
struct rb_mjit_unit *unit;
|
||||||
|
|
||||||
// wait until unit is available
|
// Wait until a unit becomes available
|
||||||
CRITICAL_SECTION_START(3, "in worker dequeue");
|
CRITICAL_SECTION_START(3, "in worker dequeue");
|
||||||
while ((list_empty(&unit_queue.head) || active_units.length >= mjit_opts.max_cache_size) && !stop_worker_p) {
|
while ((list_empty(&unit_queue.head) || active_units.length >= mjit_opts.max_cache_size) && !stop_worker_p) {
|
||||||
rb_native_cond_wait(&mjit_worker_wakeup, &mjit_engine_mutex);
|
rb_native_cond_wait(&mjit_worker_wakeup, &mjit_engine_mutex);
|
||||||
verbose(3, "Getting wakeup from client");
|
verbose(3, "Getting wakeup from client");
|
||||||
|
|
||||||
|
// Unload some units as needed
|
||||||
if (unload_requests >= throttle_threshold) {
|
if (unload_requests >= throttle_threshold) {
|
||||||
|
while (in_gc) {
|
||||||
|
verbose(3, "Waiting wakeup from GC");
|
||||||
|
rb_native_cond_wait(&mjit_gc_wakeup, &mjit_engine_mutex);
|
||||||
|
}
|
||||||
|
in_jit = true; // Lock GC
|
||||||
|
|
||||||
RB_DEBUG_COUNTER_INC(mjit_unload_units);
|
RB_DEBUG_COUNTER_INC(mjit_unload_units);
|
||||||
unload_units();
|
unload_units();
|
||||||
unload_requests = 0;
|
unload_requests = 0;
|
||||||
|
|
||||||
|
in_jit = false; // Unlock GC
|
||||||
|
verbose(3, "Sending wakeup signal to client in a mjit-worker for GC");
|
||||||
|
rb_native_cond_signal(&mjit_client_wakeup);
|
||||||
}
|
}
|
||||||
if (active_units.length == mjit_opts.max_cache_size && mjit_opts.wait) { // Sometimes all methods may be in use
|
if (active_units.length == mjit_opts.max_cache_size && mjit_opts.wait) { // Sometimes all methods may be in use
|
||||||
mjit_opts.max_cache_size++; // avoid infinite loop on `rb_mjit_wait_call`. Note that --jit-wait is just for testing.
|
mjit_opts.max_cache_size++; // avoid infinite loop on `rb_mjit_wait_call`. Note that --jit-wait is just for testing.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue