From 4b8da4b9c8494635a4fcdf3a14ba1dc3fece6842 Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 9 Dec 2015 15:10:57 +0000 Subject: [PATCH] * iseq.c: rename methods RubyVM::InstructionSequence#to_binary_format -> #to_binary RubyVM::InstructionSequence.from_binary_format -> .load_from_binary RubyVM::InstructionSequence.from_binary_format_extra_data -> .load_from_binary_extra_data * iseq.c: fix document of iseq.to_binary. [Fix GH-1134] * sample/iseq_loader.rb: catch up this change. * test/lib/iseq_loader_checker.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 15 +++++++++++++++ iseq.c | 26 +++++++++++++------------- sample/iseq_loader.rb | 8 ++++---- test/lib/iseq_loader_checker.rb | 6 +++--- 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 26907ce307..8a014da753 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Thu Dec 10 00:06:56 2015 Koichi Sasada + + * iseq.c: rename methods + RubyVM::InstructionSequence#to_binary_format -> #to_binary + RubyVM::InstructionSequence.from_binary_format -> .load_from_binary + RubyVM::InstructionSequence.from_binary_format_extra_data -> + .load_from_binary_extra_data + + * iseq.c: fix document of iseq.to_binary. + [Fix GH-1134] + + * sample/iseq_loader.rb: catch up this change. + + * test/lib/iseq_loader_checker.rb: ditto. + Wed Dec 9 17:02:03 2015 Nobuyoshi Nakada * regparse.h (SET_NTYPE): get rid of breaking strict aliasing. diff --git a/iseq.c b/iseq.c index e6f4fdd8d5..01d2e749fe 100644 --- a/iseq.c +++ b/iseq.c @@ -2334,23 +2334,23 @@ rb_iseqw_local_variables(VALUE iseqval) /* * call-seq: - * iseq.to_binary_format(extra_data = nil) -> binary str + * iseq.to_binary(extra_data = nil) -> binary str * * Returns serialized iseq binary format data as a String object. * A correspnding iseq object is created by - * RubyVM::InstructionSequence.from_binary_format() method. + * RubyVM::InstructionSequence.load_from_binary() method. * * String extra_data will be saved with binary data. * You can access this data with - * RubyVM::InstructionSequence.from_binary_format_extra_data(binary). + * RubyVM::InstructionSequence.load_from_binary_extra_data(binary). * * Note that the translated binary data is not portable. * You can not move this binary data to another machine. - * You can not use the binary data whcih is created by another + * You can not use the binary data which is created by another * version/another architecture of Ruby. */ static VALUE -iseqw_to_binary_format(int argc, VALUE *argv, VALUE self) +iseqw_to_binary(int argc, VALUE *argv, VALUE self) { VALUE opt; rb_scan_args(argc, argv, "01", &opt); @@ -2359,10 +2359,10 @@ iseqw_to_binary_format(int argc, VALUE *argv, VALUE self) /* * call-seq: - * RubyVM::InstructionSequence.from_binary_format(binary) -> iseq + * RubyVM::InstructionSequence.load_from_binary(binary) -> iseq * * Load an iseq object from binary format String object - * created by RubyVM::InstructionSequence.to_binary_format. + * created by RubyVM::InstructionSequence.to_binary. * * This loader does not have a verifier, so that loading broken/modified * binary causes critical problem. @@ -2371,19 +2371,19 @@ iseqw_to_binary_format(int argc, VALUE *argv, VALUE self) * You should use binary data translated by yourself. */ static VALUE -iseqw_s_from_binary_format(VALUE self, VALUE str) +iseqw_s_load_from_binary(VALUE self, VALUE str) { return iseqw_new(iseq_ibf_load(str)); } /* * call-seq: - * RubyVM::InstructionSequence.from_binary_format_extra_data(binary) -> str + * RubyVM::InstructionSequence.load_from_binary_extra_data(binary) -> str * * Load extra data embed into binary format String object. */ static VALUE -iseqw_s_from_binary_format_extra_data(VALUE self, VALUE str) +iseqw_s_load_from_binary_extra_data(VALUE self, VALUE str) { return iseq_ibf_load_extra_data(str); } @@ -2419,9 +2419,9 @@ Init_ISeq(void) rb_define_method(rb_cISeq, "to_a", iseqw_to_a, 0); rb_define_method(rb_cISeq, "eval", iseqw_eval, 0); - rb_define_method(rb_cISeq, "to_binary_format", iseqw_to_binary_format, -1); - rb_define_singleton_method(rb_cISeq, "from_binary_format", iseqw_s_from_binary_format, 1); - rb_define_singleton_method(rb_cISeq, "from_binary_format_extra_data", iseqw_s_from_binary_format_extra_data, 1); + rb_define_method(rb_cISeq, "to_binary", iseqw_to_binary, -1); + rb_define_singleton_method(rb_cISeq, "load_from_binary", iseqw_s_load_from_binary, 1); + rb_define_singleton_method(rb_cISeq, "load_from_binary_extra_data", iseqw_s_load_from_binary_extra_data, 1); /* location APIs */ diff --git a/sample/iseq_loader.rb b/sample/iseq_loader.rb index 2fd9184a7d..bb2d92ea77 100644 --- a/sample/iseq_loader.rb +++ b/sample/iseq_loader.rb @@ -70,9 +70,9 @@ class RubyVM::InstructionSequence $ISEQ_LOADER_LOADED += 1 STDERR.puts "[ISEQ_LOADER] #{Process.pid} load #{fname} from #{iseq_key}" if COMPILE_DEBUG binary = read_compiled_iseq(fname, iseq_key) - iseq = RubyVM::InstructionSequence.from_binary_format(binary) - # p [extra_data(iseq.path), RubyVM::InstructionSequence.from_binary_format_extra_data(binary)] - # raise unless extra_data(iseq.path) == RubyVM::InstructionSequence.from_binary_format_extra_data(binary) + iseq = RubyVM::InstructionSequence.load_from_binary(binary) + # p [extra_data(iseq.path), RubyVM::InstructionSequence.load_from_binary_extra_data(binary)] + # raise unless extra_data(iseq.path) == RubyVM::InstructionSequence.load_from_binary_extra_data(binary) iseq elsif COMPILE_IF_NOT_COMPILED compile_and_save_iseq(fname, iseq_key) @@ -92,7 +92,7 @@ class RubyVM::InstructionSequence STDERR.puts "[RUBY_COMPILED_FILE] compile #{fname}" if COMPILE_DEBUG iseq = RubyVM::InstructionSequence.compile_file(fname) - binary = iseq.to_binary_format(extra_data(fname)) + binary = iseq.to_binary(extra_data(fname)) write_compiled_iseq(fname, iseq_key, binary) iseq end diff --git a/test/lib/iseq_loader_checker.rb b/test/lib/iseq_loader_checker.rb index 09df3d38be..db9b7678c9 100644 --- a/test/lib/iseq_loader_checker.rb +++ b/test/lib/iseq_loader_checker.rb @@ -51,18 +51,18 @@ class RubyVM::InstructionSequence RubyVM::InstructionSequence.iseq_load(ary) }) if CHECK_TO_A && defined?(RubyVM::InstructionSequence.iseq_load) - # check to_binary_format + # check to_binary i2_bin = compare_dump_and_load(i1, proc{|iseq| begin - iseq.to_binary_format + iseq.to_binary rescue RuntimeError => e # not a toplevel # STDERR.puts [:failed, e, iseq].inspect nil end }, proc{|bin| - iseq = RubyVM::InstructionSequence.from_binary_format(bin) + iseq = RubyVM::InstructionSequence.load_from_binary(bin) # STDERR.puts iseq.inspect iseq }) if CHECK_TO_BINARY