diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-28 20:09:24 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-28 20:09:24 +0000 |
commit | c39bdb798d838d58126b548465908243c41bb1fb (patch) | |
tree | bcc8cced4989294b64208b8d8c57bc27c301c3a6 /proc.c | |
parent | 67850e8a9e80e82febe32ad127bf941f67eb28e3 (diff) | |
download | ruby-c39bdb798d838d58126b548465908243c41bb1fb.tar.gz |
`$SAFE` as a process global state. [Feature #14250]
* vm_core.h (rb_vm_t): move `rb_execution_context_t::safe_level` to
`rb_vm_t::safe_level_` because `$SAFE` is a process (VM) global state.
* vm_core.h (rb_proc_t): remove `rb_proc_t::safe_level` because `Proc`
objects don't need to keep `$SAFE` at the creation.
Also make `is_from_method` and `is_lambda` as 1 bit fields.
* cont.c (cont_restore_thread): no need to keep `$SAFE` for Continuation.
* eval.c (ruby_cleanup): use `rb_set_safe_level_force()` instead of access
`vm->safe_level_` directly.
* eval_jump.c: End procs `END{}` doesn't keep `$SAFE`.
* proc.c (proc_dup): removed and introduce `rb_proc_dup` in vm.c.
* safe.c (rb_set_safe_level): don't check `$SAFE` 1 -> 0 changes.
* safe.c (safe_setter): use `rb_set_safe_level()`.
* thread.c (rb_thread_safe_level): `Thread#safe_level` returns `$SAFE`.
It should be obsolete.
* transcode.c (load_transcoder_entry): `rb_safe_level()` only returns
0 or 1 so that this check is not needed.
* vm.c (vm_proc_create_from_captured): don't need to keep `$SAFE` for Proc.
* vm.c (rb_proc_create): renamed to `proc_create`.
* vm.c (rb_proc_dup): moved from proc.c.
* vm.c (vm_invoke_proc): do not need to set and restore `$SAFE`
for `Proc#call`.
* vm_eval.c (rb_eval_cmd): rename a local variable to represent clearer
meaning.
* lib/drb/drb.rb: restore `$SAFE`.
* lib/erb.rb: restore `$SAFE`, too.
* test/lib/leakchecker.rb: check `$SAFE == 0` at the end of tests.
* test/rubygems/test_gem.rb: do not set `$SAFE = 1`.
* bootstraptest/test_proc.rb: catch up this change.
* spec/ruby/optional/capi/string_spec.rb: ditto.
* test/bigdecimal/test_bigdecimal.rb: ditto.
* test/fiddle/test_func.rb: ditto.
* test/fiddle/test_handle.rb: ditto.
* test/net/imap/test_imap_response_parser.rb: ditto.
* test/pathname/test_pathname.rb: ditto.
* test/readline/test_readline.rb: ditto.
* test/ruby/test_file.rb: ditto.
* test/ruby/test_optimization.rb: ditto.
* test/ruby/test_proc.rb: ditto.
* test/ruby/test_require.rb: ditto.
* test/ruby/test_thread.rb: ditto.
* test/rubygems/test_gem_specification.rb: ditto.
* test/test_tempfile.rb: ditto.
* test/test_tmpdir.rb: ditto.
* test/win32ole/test_win32ole.rb: ditto.
* test/win32ole/test_win32ole_event.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 25 |
1 files changed, 4 insertions, 21 deletions
@@ -124,28 +124,11 @@ rb_obj_is_proc(VALUE proc) } } -VALUE rb_proc_create(VALUE klass, const struct rb_block *block, - int8_t safe_level, int8_t is_from_method, int8_t is_lambda); - -/* :nodoc: */ -static VALUE -proc_dup(VALUE self) -{ - VALUE procval; - rb_proc_t *src; - - GetProcPtr(self, src); - procval = rb_proc_create(rb_cProc, &src->block, - src->safe_level, src->is_from_method, src->is_lambda); - RB_GC_GUARD(self); /* for: body = proc_dup(body) */ - return procval; -} - /* :nodoc: */ static VALUE proc_clone(VALUE self) { - VALUE procval = proc_dup(self); + VALUE procval = rb_proc_dup(self); CLONESETUP(procval, self); return procval; } @@ -752,7 +735,7 @@ proc_new(VALUE klass, int8_t is_lambda) return procval; } else { - VALUE newprocval = proc_dup(procval); + VALUE newprocval = rb_proc_dup(procval); RBASIC_SET_CLASS(newprocval, klass); return newprocval; } @@ -1982,7 +1965,7 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod) RB_GC_GUARD(body); } else { - VALUE procval = proc_dup(body); + VALUE procval = rb_proc_dup(body); if (vm_proc_iseq(procval) != NULL) { rb_proc_t *proc; GetProcPtr(procval, proc); @@ -3115,7 +3098,7 @@ Init_Proc(void) rb_define_method(rb_cProc, "to_proc", proc_to_proc, 0); rb_define_method(rb_cProc, "arity", proc_arity, 0); rb_define_method(rb_cProc, "clone", proc_clone, 0); - rb_define_method(rb_cProc, "dup", proc_dup, 0); + rb_define_method(rb_cProc, "dup", rb_proc_dup, 0); rb_define_method(rb_cProc, "hash", proc_hash, 0); rb_define_method(rb_cProc, "to_s", proc_to_s, 0); rb_define_alias(rb_cProc, "inspect", "to_s"); |