summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-06-15 08:55:48 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-10-12 16:21:11 +0900
commitee111dd175f3242649d87a4600e2bad62e8e0940 (patch)
treecabfe4a193075d9110ea3608e8dc4c3bb835e280
parentf0c11269977e83f2e578a32134d4b65a2cf72ec0 (diff)
downloadmruby-ee111dd175f3242649d87a4600e2bad62e8e0940.tar.gz
mruby-ee111dd175f3242649d87a4600e2bad62e8e0940.zip
Clarify the use of `MRB_64BIT` and `MRB_INT64` in `dump.c` and `load.c`.
- `MRB_64BIT`: the size of a pointer is 64 bits - `MRB_INT64`: the size of `mrb_int` is 64 bits
-rw-r--r--include/mruby/irep.h2
-rw-r--r--mrbgems/mruby-compiler/core/codegen.c2
-rw-r--r--src/codedump.c2
-rw-r--r--src/dump.c6
-rw-r--r--src/load.c8
-rw-r--r--src/vm.c8
6 files changed, 17 insertions, 11 deletions
diff --git a/include/mruby/irep.h b/include/mruby/irep.h
index 64a38227c..ede6780e6 100644
--- a/include/mruby/irep.h
+++ b/include/mruby/irep.h
@@ -32,7 +32,7 @@ typedef struct mrb_pool_value {
union {
const char *str;
int32_t i32;
-#ifdef MRB_INT64
+#ifdef MRB_64BIT
int64_t i64;
#endif
mrb_float f;
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c
index 5d29dcb2d..25e157736 100644
--- a/mrbgems/mruby-compiler/core/codegen.c
+++ b/mrbgems/mruby-compiler/core/codegen.c
@@ -588,7 +588,7 @@ new_lit(codegen_scope *s, mrb_value val)
if (pv->tt == IREP_TT_INT32) {
if (v == pv->u.i32) return i;
}
-#ifdef MRB_INT64
+#ifdef MRB_64BIT
else if (pv->tt == IREP_TT_INT64) {
if (v == pv->u.i64) return i;
}
diff --git a/src/codedump.c b/src/codedump.c
index fd73f3104..0e90f22db 100644
--- a/src/codedump.c
+++ b/src/codedump.c
@@ -122,7 +122,7 @@ codedump(mrb_state *mrb, const mrb_irep *irep)
case IREP_TT_INT32:
printf("OP_LOADL\tR%d\tL(%d)\t; %" PRId32, a, b, irep->pool[b].u.i32);
break;
-#ifdef MRB_INT64
+#ifdef MRB_64BIT
case IREP_TT_INT64:
printf("OP_LOADL\tR%d\tL(%d)\t; %" PRId64, a, b, irep->pool[b].u.i64);
break;
diff --git a/src/dump.c b/src/dump.c
index c0c349d68..31dceb593 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -113,7 +113,7 @@ get_pool_block_size(mrb_state *mrb, const mrb_irep *irep)
switch (irep->pool[pool_no].tt) {
case IREP_TT_INT64:
-#ifdef MRB_INT64
+#ifdef MRB_64BIT
{
int64_t i = irep->pool[pool_no].u.i64;
@@ -169,7 +169,7 @@ write_pool_block(mrb_state *mrb, const mrb_irep *irep, uint8_t *buf)
int ai = mrb_gc_arena_save(mrb);
switch (irep->pool[pool_no].tt) {
-#ifdef MRB_INT64
+#ifdef MRB_64BIT
case IREP_TT_INT64:
{
int64_t i = irep->pool[pool_no].u.i64;
@@ -938,7 +938,7 @@ dump_pool(mrb_state *mrb, const mrb_pool_value *p, FILE *fp)
case IREP_TT_INT32:
fprintf(fp, "{IREP_TT_INT32, {.i32=%"PRId32"}},\n", p->u.i32);
break;
-#ifdef MRB_INT64
+#ifdef MRB_64BIT
case IREP_TT_INT64:
fprintf(fp, "{IREP_TT_INT64, {.i64=%"PRId64"}},\n", p->u.i64);
break;
diff --git a/src/load.c b/src/load.c
index 31059e833..766aa0648 100644
--- a/src/load.c
+++ b/src/load.c
@@ -137,7 +137,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, uint8_t flag
{
mrb_int v = (int32_t)bin_to_uint32(src);
src += sizeof(uint32_t);
-#ifdef MRB_INT64
+#ifdef MRB_64BIT
pool[i].tt = IREP_TT_INT64;
pool[i].u.i64 = (int64_t)v;
#else
@@ -147,7 +147,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, uint8_t flag
}
break;
case IREP_TT_INT64:
-#ifdef MRB_INT64
+#ifdef MRB_64BIT
{
uint64_t i = bin_to_uint32(src);
src += sizeof(uint32_t);
@@ -156,10 +156,10 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, uint8_t flag
src += sizeof(uint32_t);
pool[i].u.i64 = (int64_t)i;
}
+ break;
#else
- return NULL; /* INT64 not supported on MRB_INT32 */
+ return NULL; /* INT64 not supported on MRB_32BIT */
#endif
- break;
case IREP_TT_FLOAT:
#ifndef MRB_WITHOUT_FLOAT
diff --git a/src/vm.c b/src/vm.c
index 62805b7ed..98f17e287 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -1017,10 +1017,16 @@ RETRY_TRY_BLOCK:
case IREP_TT_INT32:
regs[a] = mrb_fixnum_value((mrb_int)pool[b].u.i32);
break;
-#ifdef MRB_INT64
case IREP_TT_INT64:
+#if defined(MRB_INT64) && defined(MRB_64BIT)
regs[a] = mrb_fixnum_value((mrb_int)pool[b].u.i64);
break;
+#else
+ {
+ mrb_value exc = mrb_exc_new_str_lit(mrb, E_RUNTIME_ERROR, "integer overflow");
+ mrb_exc_set(mrb, exc);
+ }
+ goto L_RAISE;
#endif
#ifndef MRB_WITHOUT_FLOAT
case IREP_TT_FLOAT: