Store backtrace to field of struct RException

Since the possible values of the backtrace are limited to `nil`, `RData`, and `RAray`, they are now stored as object pointers.

This change saves memory by eliminating the need to use instance variables for common exceptions.

ref. #2485
This commit is contained in:
dearblue
2022-03-13 15:39:07 +09:00
parent 7d85092bc4
commit 92ef9f1a9e
4 changed files with 48 additions and 36 deletions
+2 -1
View File
@@ -182,7 +182,8 @@ set_backtrace(mrb_state *mrb, mrb_value exc, mrb_value backtrace)
p++;
}
}
mrb_iv_set(mrb, exc, MRB_SYM(backtrace), backtrace);
mrb_exc_ptr(exc)->backtrace = mrb_obj_ptr(backtrace);
mrb_field_write_barrier_value(mrb, mrb_basic_ptr(exc), backtrace);
}
static mrb_value