summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-11 08:34:25 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-11 08:34:25 +0000
commit6306aa9222ec1b67c5c94811bd2aff5e43ba779e (patch)
treeb981f52a4f7fe4fb9c13afae75675eaa27cdeea5
parentb2e0d54024766009567baa708ae3bed1f50dd5ed (diff)
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
-rw-r--r--mjit.c28
-rw-r--r--mjit.h1
-rw-r--r--mjit_compile.c1
-rw-r--r--mjit_worker.c15
4 files changed, 22 insertions, 23 deletions
diff --git a/mjit.c b/mjit.c
index d2db35a14e..36ada7ce16 100644
--- a/mjit.c
+++ b/mjit.c
@@ -85,7 +85,7 @@ int mjit_in_jit;
char *mjit_tmp_dir;
/* Hash like { 1 => true, 2 => true, ... } whose keys are valid `class_serial`s.
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 char *mjit_pch_file;
@@ -688,9 +688,9 @@ mjit_init(struct mjit_options *opts)
rb_native_cond_initialize(&mjit_gc_wakeup);
/* Initialize class_serials cache for compilation */
- valid_class_serials = rb_hash_new();
- rb_obj_hide(valid_class_serials);
- rb_gc_register_mark_object(valid_class_serials);
+ mjit_valid_class_serials = rb_hash_new();
+ rb_obj_hide(mjit_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(CLASS_OF(rb_vm_top_self())));
if (RCLASS_CONST_TBL(rb_cObject)) {
@@ -837,7 +837,7 @@ mjit_mark(void)
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
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
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
mjit_remove_class_serial(rb_serial_t class_serial)
{
@@ -857,18 +857,6 @@ mjit_remove_class_serial(rb_serial_t class_serial)
return;
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");
}
-
-/* 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;
-}
diff --git a/mjit.h b/mjit.h
index 5781d04982..eee3a8badb 100644
--- a/mjit.h
+++ b/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_add_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
takes too much time to be compiled. */
diff --git a/mjit_compile.c b/mjit_compile.c
index 63d0757877..6ac5ec66b0 100644
--- a/mjit_compile.c
+++ b/mjit_compile.c
@@ -51,6 +51,7 @@ struct case_dispatch_var {
static int
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
&& mjit_valid_class_serial_p(cc->class_serial) && cc->me;
}
diff --git a/mjit_worker.c b/mjit_worker.c
index 5b0d28d39f..dc084c2abe 100644
--- a/mjit_worker.c
+++ b/mjit_worker.c
@@ -76,8 +76,6 @@
#include "vm_core.h"
#include "mjit.h"
#include "gc.h"
-#include "constant.h"
-#include "id_table.h"
#include "ruby_assert.h"
#include "ruby/thread.h"
#include "ruby/util.h"
@@ -208,6 +206,19 @@ static const char *const CC_LIBS[] = {
shared by the workers and the pch thread. */
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
high priority unit or the unit whose iseq has the biggest number
of calls so far. */