summaryrefslogtreecommitdiffhomepage
path: root/src/codedump.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-06-09 14:39:38 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-10-12 16:21:08 +0900
commitd428fa0c4acfe4f70ab534d420052c193bd83281 (patch)
tree903e5ab41d1c358e3b512be90d36837e54580e29 /src/codedump.c
parentdaa37be5495393ce3e4654e00e44099f627e6cd4 (diff)
downloadmruby-d428fa0c4acfe4f70ab534d420052c193bd83281.tar.gz
mruby-d428fa0c4acfe4f70ab534d420052c193bd83281.zip
Replace entire `irep->pool`.
Changes: - `pool format is completely replaced - supported types: `STR`, `INT32`, `INT64`, `FLOAT` - `FLOAT` may be replaced by binary representation in the future - insert `NUL` after string literals in `mrb` files - `irep->pool` no longer store values in `mrb_value` - instead it stores in `mrb_pool_value` - less allocation - `mrb_irep` can be stored in ROM
Diffstat (limited to 'src/codedump.c')
-rw-r--r--src/codedump.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/codedump.c b/src/codedump.c
index 14cca8553..fd73f3104 100644
--- a/src/codedump.c
+++ b/src/codedump.c
@@ -115,10 +115,21 @@ codedump(mrb_state *mrb, const mrb_irep *irep)
print_lv_ab(mrb, irep, a, b);
break;
CASE(OP_LOADL, BB):
- {
- mrb_value v = irep->pool[b];
- mrb_value s = mrb_inspect(mrb, v);
- printf("OP_LOADL\tR%d\tL(%d)\t; %s", a, b, RSTRING_PTR(s));
+ switch (irep->pool[b].tt) {
+ case IREP_TT_FLOAT:
+ printf("OP_LOADL\tR%d\tL(%d)\t; %f", a, b, (double)irep->pool[b].u.f);
+ break;
+ case IREP_TT_INT32:
+ printf("OP_LOADL\tR%d\tL(%d)\t; %" PRId32, a, b, irep->pool[b].u.i32);
+ break;
+#ifdef MRB_INT64
+ case IREP_TT_INT64:
+ printf("OP_LOADL\tR%d\tL(%d)\t; %" PRId64, a, b, irep->pool[b].u.i64);
+ break;
+#endif
+ default:
+ printf("OP_LOADL\tR%d\tL(%d)\t", a, b);
+ break;
}
print_lv_a(mrb, irep, a);
break;
@@ -404,10 +415,11 @@ codedump(mrb_state *mrb, const mrb_irep *irep)
print_lv_a(mrb, irep, a);
break;
CASE(OP_STRING, BB):
- {
- mrb_value v = irep->pool[b];
- mrb_value s = mrb_str_dump(mrb, mrb_str_new(mrb, RSTRING_PTR(v), RSTRING_LEN(v)));
- printf("OP_STRING\tR%d\tL(%d)\t; %s", a, b, RSTRING_PTR(s));
+ if ((irep->pool[b].tt & IREP_TT_NFLAG) == 0) {
+ printf("OP_STRING\tR%d\tL(%d)\t; %s", a, b, irep->pool[b].u.str);
+ }
+ else {
+ printf("OP_STRING\tR%d\tL(%d)\t", a, b);
}
print_lv_a(mrb, irep, a);
break;
@@ -453,10 +465,11 @@ codedump(mrb_state *mrb, const mrb_irep *irep)
print_lv_a(mrb, irep, a);
break;
CASE(OP_ERR, B):
- {
- mrb_value v = irep->pool[a];
- mrb_value s = mrb_str_dump(mrb, mrb_str_new(mrb, RSTRING_PTR(v), RSTRING_LEN(v)));
- printf("OP_ERR\t%s\n", RSTRING_PTR(s));
+ if ((irep->pool[a].tt & IREP_TT_NFLAG) == 0) {
+ printf("OP_ERR\t%s\n", irep->pool[a].u.str);
+ }
+ else {
+ printf("OP_ERR\tL(%d)\n", a);
}
break;
CASE(OP_EPUSH, B):