[前][次][番号順一覧][スレッド一覧]

ruby-changes:57731

From: Koichi <ko1@a...>
Date: Fri, 13 Sep 2019 16:30:22 +0900 (JST)
Subject: [ruby-changes:57731] 2da6b328bb (master): introduce IBF_(MAJOR|MINOR)_VERSION.

https://git.ruby-lang.org/ruby.git/commit/?id=2da6b328bb

From 2da6b328bb5124793a6420c55325f3106b615bb4 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Fri, 13 Sep 2019 16:24:28 +0900
Subject: introduce IBF_(MAJOR|MINOR)_VERSION.

RubyVM::InstructionSequence.to_binary generates a bytecode binary
representation. To check compatibility with binary and loading
MRI we prepared major/minor version and compare them at loading
time. However, development version of MRI can change this format
but we can not increment minor version to make them consistent
with Ruby's major/minor versions.

To solve this issue, we introduce new minor version scheme
(binary's minor_version = ruby's minor * 10000 + dev ver)
and we can check incompatibility with older dev version.

diff --git a/compile.c b/compile.c
index 9e952e4..e1cd82c 100644
--- a/compile.c
+++ b/compile.c
@@ -9184,6 +9184,14 @@ rb_method_for_self_aset(VALUE name, VALUE arg, rb_insn_func_t func) https://github.com/ruby/ruby/blob/trunk/compile.c#L9184
 typedef unsigned int ibf_offset_t;
 #define IBF_OFFSET(ptr) ((ibf_offset_t)(VALUE)(ptr))
 
+#define IBF_MAJOR_VERSION ISEQ_MAJOR_VERSION
+#if RUBY_DEVEL
+#define IBF_DEVEL_VERSION 0
+#define IBF_MINOR_VERSION (ISEQ_MINOR_VERSION * 10000 + IBF_DEVEL_VERSION)
+#else
+#define IBF_MINOR_VERSION ISEQ_MINOR_VERSION
+#endif
+
 struct ibf_header {
     char magic[4]; /* YARB */
     unsigned int major_version;
@@ -10666,8 +10674,8 @@ rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt) https://github.com/ruby/ruby/blob/trunk/compile.c#L10674
     header.magic[1] = 'A';
     header.magic[2] = 'R';
     header.magic[3] = 'B';
-    header.major_version = ISEQ_MAJOR_VERSION;
-    header.minor_version = ISEQ_MINOR_VERSION;
+    header.major_version = IBF_MAJOR_VERSION;
+    header.minor_version = IBF_MINOR_VERSION;
     ibf_dump_iseq_list(dump, &header);
     ibf_dump_id_list(dump, &header);
     ibf_dump_object_list(dump, &header);
@@ -10804,10 +10812,10 @@ ibf_load_setup(struct ibf_load *load, VALUE loader_obj, VALUE str) https://github.com/ruby/ruby/blob/trunk/compile.c#L10812
     if (strncmp(load->header->magic, "YARB", 4) != 0) {
 	rb_raise(rb_eRuntimeError, "unknown binary format");
     }
-    if (load->header->major_version != ISEQ_MAJOR_VERSION ||
-	load->header->minor_version != ISEQ_MINOR_VERSION) {
+    if (load->header->major_version != IBF_MAJOR_VERSION ||
+	load->header->minor_version != IBF_MINOR_VERSION) {
 	rb_raise(rb_eRuntimeError, "unmatched version file (%u.%u for %u.%u)",
-		 load->header->major_version, load->header->minor_version, ISEQ_MAJOR_VERSION, ISEQ_MINOR_VERSION);
+		 load->header->major_version, load->header->minor_version, IBF_MAJOR_VERSION, IBF_MINOR_VERSION);
     }
     if (strcmp(load->buff + sizeof(struct ibf_header), RUBY_PLATFORM) != 0) {
 	rb_raise(rb_eRuntimeError, "unmatched platform");
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]