summaryrefslogtreecommitdiff
path: root/vm_core.h
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-08 05:01:23 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-08 05:01:23 +0000
commit26081169e0a227a6ccf477c7fade17b90f266e23 (patch)
treec27e9109ef640c0de230c50c698df4a1fe1a2608 /vm_core.h
parent96af6823c1b49a41e873fb4d9ffa16dfce7ffdd9 (diff)
separate Thread type (func or proc) explicitly.
* vm_core.h (rb_thread_struct): introduce new fields `invoke_type` and `invoke_arg`. There are two types threads: invoking proc (normal Ruby thread created by `Thread.new do ... end`) and invoking func, created by C-API. `invoke_type` shows the types. * thread.c (thread_do_start): copy `invoke_arg.proc.args` contents from Array to ALLOCA stack memory if args length is enough small (<8). We don't need to keep Array and don't need to cancel using transient heap. * vm.c (thread_mark): For func invoking threads, they can pass (void *) parameter (rb_thread_t::invoke_arg::func::arg). However, a rubyspec test (thread_spec.c) passes an Array object and it expect to mark it. Clealy it is out of scope (misuse of `rb_thread_create` C-API). However, I'm not sure someone else has such kind of misunderstanding. So now we mark conservatively this (void *) arg with rb_gc_mark_maybe. This misuse is found by this error log. http://ci.rvm.jp/results/trunk-theap-asserts@silicon-docker/1448164 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_core.h')
-rw-r--r--vm_core.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/vm_core.h b/vm_core.h
index e5fdba4..faab30b 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -936,9 +936,22 @@ typedef struct rb_thread_struct {
rb_thread_list_t *join_list;
- VALUE first_proc;
- VALUE first_args;
- VALUE (*first_func)(ANYARGS);
+ union {
+ struct {
+ VALUE proc;
+ VALUE args;
+ } proc;
+ struct {
+ VALUE (*func)(ANYARGS);
+ void *arg;
+ } func;
+ } invoke_arg;
+
+ enum {
+ thread_invoke_type_none = 0,
+ thread_invoke_type_proc,
+ thread_invoke_type_func,
+ } invoke_type;
/* statistics data for profiler */
VALUE stat_insn_usage;