mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
mjit.c: exclude mjit_valid_class_serial_p
from mjit.c because it's executed only on MJIT worker thread. Instead of that, `valid_class_serials` is shared with mjit_ prefix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b2e0d54024
commit
6306aa9222
4 changed files with 22 additions and 23 deletions
28
mjit.c
28
mjit.c
|
@ -85,7 +85,7 @@ int mjit_in_jit;
|
||||||
char *mjit_tmp_dir;
|
char *mjit_tmp_dir;
|
||||||
/* Hash like { 1 => true, 2 => true, ... } whose keys are valid `class_serial`s.
|
/* Hash like { 1 => true, 2 => true, ... } whose keys are valid `class_serial`s.
|
||||||
This is used to invalidate obsoleted CALL_CACHE. */
|
This is used to invalidate obsoleted CALL_CACHE. */
|
||||||
static VALUE valid_class_serials;
|
VALUE mjit_valid_class_serials;
|
||||||
|
|
||||||
extern const char *mjit_cc_path;
|
extern const char *mjit_cc_path;
|
||||||
extern char *mjit_pch_file;
|
extern char *mjit_pch_file;
|
||||||
|
@ -688,9 +688,9 @@ mjit_init(struct mjit_options *opts)
|
||||||
rb_native_cond_initialize(&mjit_gc_wakeup);
|
rb_native_cond_initialize(&mjit_gc_wakeup);
|
||||||
|
|
||||||
/* Initialize class_serials cache for compilation */
|
/* Initialize class_serials cache for compilation */
|
||||||
valid_class_serials = rb_hash_new();
|
mjit_valid_class_serials = rb_hash_new();
|
||||||
rb_obj_hide(valid_class_serials);
|
rb_obj_hide(mjit_valid_class_serials);
|
||||||
rb_gc_register_mark_object(valid_class_serials);
|
rb_gc_register_mark_object(mjit_valid_class_serials);
|
||||||
mjit_add_class_serial(RCLASS_SERIAL(rb_cObject));
|
mjit_add_class_serial(RCLASS_SERIAL(rb_cObject));
|
||||||
mjit_add_class_serial(RCLASS_SERIAL(CLASS_OF(rb_vm_top_self())));
|
mjit_add_class_serial(RCLASS_SERIAL(CLASS_OF(rb_vm_top_self())));
|
||||||
if (RCLASS_CONST_TBL(rb_cObject)) {
|
if (RCLASS_CONST_TBL(rb_cObject)) {
|
||||||
|
@ -837,7 +837,7 @@ mjit_mark(void)
|
||||||
RUBY_MARK_LEAVE("mjit");
|
RUBY_MARK_LEAVE("mjit");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A hook to update valid_class_serials. This should NOT be used in MJIT worker. */
|
/* A hook to update mjit_valid_class_serials. */
|
||||||
void
|
void
|
||||||
mjit_add_class_serial(rb_serial_t class_serial)
|
mjit_add_class_serial(rb_serial_t class_serial)
|
||||||
{
|
{
|
||||||
|
@ -846,10 +846,10 @@ mjit_add_class_serial(rb_serial_t class_serial)
|
||||||
|
|
||||||
/* Do not wrap CRITICAL_SECTION here. This function is only called in main thread
|
/* Do not wrap CRITICAL_SECTION here. This function is only called in main thread
|
||||||
and guarded by GVL, and `rb_hash_aset` may cause GC and deadlock in it. */
|
and guarded by GVL, and `rb_hash_aset` may cause GC and deadlock in it. */
|
||||||
rb_hash_aset(valid_class_serials, LONG2FIX(class_serial), Qtrue);
|
rb_hash_aset(mjit_valid_class_serials, LONG2FIX(class_serial), Qtrue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A hook to update valid_class_serials. This should NOT be used in MJIT worker. */
|
/* A hook to update mjit_valid_class_serials. */
|
||||||
void
|
void
|
||||||
mjit_remove_class_serial(rb_serial_t class_serial)
|
mjit_remove_class_serial(rb_serial_t class_serial)
|
||||||
{
|
{
|
||||||
|
@ -857,18 +857,6 @@ mjit_remove_class_serial(rb_serial_t class_serial)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CRITICAL_SECTION_START(3, "in mjit_remove_class_serial");
|
CRITICAL_SECTION_START(3, "in mjit_remove_class_serial");
|
||||||
rb_hash_delete_entry(valid_class_serials, LONG2FIX(class_serial));
|
rb_hash_delete_entry(mjit_valid_class_serials, LONG2FIX(class_serial));
|
||||||
CRITICAL_SECTION_FINISH(3, "in mjit_remove_class_serial");
|
CRITICAL_SECTION_FINISH(3, "in mjit_remove_class_serial");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return TRUE if class_serial is not obsoleted. This can be used in MJIT worker. */
|
|
||||||
int
|
|
||||||
mjit_valid_class_serial_p(rb_serial_t class_serial)
|
|
||||||
{
|
|
||||||
int found_p;
|
|
||||||
|
|
||||||
CRITICAL_SECTION_START(3, "in valid_class_serial_p");
|
|
||||||
found_p = st_lookup(RHASH_TBL_RAW(valid_class_serials), LONG2FIX(class_serial), NULL);
|
|
||||||
CRITICAL_SECTION_FINISH(3, "in valid_class_serial_p");
|
|
||||||
return found_p;
|
|
||||||
}
|
|
||||||
|
|
1
mjit.h
1
mjit.h
|
@ -73,7 +73,6 @@ extern struct mjit_cont *mjit_cont_new(rb_execution_context_t *ec);
|
||||||
extern void mjit_cont_free(struct mjit_cont *cont);
|
extern void mjit_cont_free(struct mjit_cont *cont);
|
||||||
extern void mjit_add_class_serial(rb_serial_t class_serial);
|
extern void mjit_add_class_serial(rb_serial_t class_serial);
|
||||||
extern void mjit_remove_class_serial(rb_serial_t class_serial);
|
extern void mjit_remove_class_serial(rb_serial_t class_serial);
|
||||||
extern int mjit_valid_class_serial_p(rb_serial_t class_serial);
|
|
||||||
|
|
||||||
/* A threshold used to reject long iseqs from JITting as such iseqs
|
/* A threshold used to reject long iseqs from JITting as such iseqs
|
||||||
takes too much time to be compiled. */
|
takes too much time to be compiled. */
|
||||||
|
|
|
@ -51,6 +51,7 @@ struct case_dispatch_var {
|
||||||
static int
|
static int
|
||||||
has_valid_method_type(CALL_CACHE cc)
|
has_valid_method_type(CALL_CACHE cc)
|
||||||
{
|
{
|
||||||
|
extern int mjit_valid_class_serial_p(rb_serial_t class_serial);
|
||||||
return GET_GLOBAL_METHOD_STATE() == cc->method_state
|
return GET_GLOBAL_METHOD_STATE() == cc->method_state
|
||||||
&& mjit_valid_class_serial_p(cc->class_serial) && cc->me;
|
&& mjit_valid_class_serial_p(cc->class_serial) && cc->me;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,6 @@
|
||||||
#include "vm_core.h"
|
#include "vm_core.h"
|
||||||
#include "mjit.h"
|
#include "mjit.h"
|
||||||
#include "gc.h"
|
#include "gc.h"
|
||||||
#include "constant.h"
|
|
||||||
#include "id_table.h"
|
|
||||||
#include "ruby_assert.h"
|
#include "ruby_assert.h"
|
||||||
#include "ruby/thread.h"
|
#include "ruby/thread.h"
|
||||||
#include "ruby/util.h"
|
#include "ruby/util.h"
|
||||||
|
@ -208,6 +206,19 @@ static const char *const CC_LIBS[] = {
|
||||||
shared by the workers and the pch thread. */
|
shared by the workers and the pch thread. */
|
||||||
enum pch_status_t mjit_pch_status;
|
enum pch_status_t mjit_pch_status;
|
||||||
|
|
||||||
|
/* Return TRUE if class_serial is not obsoleted. */
|
||||||
|
int
|
||||||
|
mjit_valid_class_serial_p(rb_serial_t class_serial)
|
||||||
|
{
|
||||||
|
extern VALUE mjit_valid_class_serials;
|
||||||
|
int found_p;
|
||||||
|
|
||||||
|
CRITICAL_SECTION_START(3, "in valid_class_serial_p");
|
||||||
|
found_p = st_lookup(RHASH_TBL_RAW(mjit_valid_class_serials), LONG2FIX(class_serial), NULL);
|
||||||
|
CRITICAL_SECTION_FINISH(3, "in valid_class_serial_p");
|
||||||
|
return found_p;
|
||||||
|
}
|
||||||
|
|
||||||
/* Return the best unit from list. The best is the first
|
/* Return the best unit from list. The best is the first
|
||||||
high priority unit or the unit whose iseq has the biggest number
|
high priority unit or the unit whose iseq has the biggest number
|
||||||
of calls so far. */
|
of calls so far. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue