aboutsummaryrefslogtreecommitdiffstats
path: root/thread.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-28 02:50:56 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-28 02:50:56 +0000
commit5b8ce2298ae990473a0356eb6bd5a949001aa70c (patch)
treede833160e55407676db31ef7c2ebeca124a4a973 /thread.c
parent50958da687f0494db1ce73494eb85edbafffd608 (diff)
downloadruby-5b8ce2298ae990473a0356eb6bd5a949001aa70c.tar.gz
move storages to ec.
* vm_core.h (rb_thread_t): move storages to rb_execution_context_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c60
1 files changed, 36 insertions, 24 deletions
diff --git a/thread.c b/thread.c
index 8fb7ac0f4d..6c7c9a900b 100644
--- a/thread.c
+++ b/thread.c
@@ -3033,12 +3033,13 @@ static VALUE
threadptr_local_aref(rb_thread_t *th, ID id)
{
if (id == recursive_key) {
- return th->local_storage_recursive_hash;
+ return th->ec.local_storage_recursive_hash;
}
else {
st_data_t val;
+ st_table *local_storage = th->ec.local_storage;
- if (th->local_storage && st_lookup(th->local_storage, id, &val)) {
+ if (local_storage != NULL && st_lookup(local_storage, id, &val)) {
return (VALUE)val;
}
else {
@@ -3143,37 +3144,44 @@ rb_thread_fetch(int argc, VALUE *argv, VALUE self)
GetThreadPtr(self, th);
if (id == recursive_key) {
- return th->local_storage_recursive_hash;
+ return th->ec.local_storage_recursive_hash;
}
- if (id && th->local_storage && st_lookup(th->local_storage, id, &val)) {
+ else if (id && th->ec.local_storage && st_lookup(th->ec.local_storage, id, &val)) {
return val;
}
- if (block_given)
+ else if (block_given) {
return rb_yield(key);
- else if (argc == 1)
+ }
+ else if (argc == 1) {
rb_raise(rb_eKeyError, "key not found: %"PRIsVALUE, key);
- else
+ }
+ else {
return argv[1];
+ }
}
static VALUE
threadptr_local_aset(rb_thread_t *th, ID id, VALUE val)
{
if (id == recursive_key) {
- th->local_storage_recursive_hash = val;
+ th->ec.local_storage_recursive_hash = val;
return val;
}
- else if (NIL_P(val)) {
- if (!th->local_storage) return Qnil;
- st_delete_wrap(th->local_storage, id);
- return Qnil;
- }
else {
- if (!th->local_storage) {
- th->local_storage = st_init_numtable();
+ st_table *local_storage = th->ec.local_storage;
+
+ if (NIL_P(val)) {
+ if (!local_storage) return Qnil;
+ st_delete_wrap(local_storage, id);
+ return Qnil;
+ }
+ else {
+ if (local_storage == NULL) {
+ th->ec.local_storage = local_storage = st_init_numtable();
+ }
+ st_insert(local_storage, id, val);
+ return val;
}
- st_insert(th->local_storage, id, val);
- return val;
}
}
@@ -3286,16 +3294,20 @@ rb_thread_key_p(VALUE self, VALUE key)
{
rb_thread_t *th;
ID id = rb_check_id(&key);
+ st_table *local_storage;
GetThreadPtr(self, th);
+ local_storage= th->ec.local_storage;
- if (!id || !th->local_storage) {
+ if (!id || local_storage == NULL) {
return Qfalse;
}
- if (st_lookup(th->local_storage, id, 0)) {
+ else if (st_lookup(local_storage, id, 0)) {
return Qtrue;
}
- return Qfalse;
+ else {
+ return Qfalse;
+ }
}
static int
@@ -3332,8 +3344,8 @@ rb_thread_keys(VALUE self)
VALUE ary = rb_ary_new();
GetThreadPtr(self, th);
- if (th->local_storage) {
- st_foreach(th->local_storage, thread_keys_i, ary);
+ if (th->ec.local_storage) {
+ st_foreach(th->ec.local_storage, thread_keys_i, ary);
}
return ary;
}
@@ -4512,13 +4524,13 @@ rb_thread_shield_destroy(VALUE self)
static VALUE
threadptr_recursive_hash(rb_thread_t *th)
{
- return th->local_storage_recursive_hash;
+ return th->ec.local_storage_recursive_hash;
}
static void
threadptr_recursive_hash_set(rb_thread_t *th, VALUE hash)
{
- th->local_storage_recursive_hash = hash;
+ th->ec.local_storage_recursive_hash = hash;
}
ID rb_frame_last_func(void);