diff options
| author | Kouhei Sutou <[email protected]> | 2015-12-29 20:36:12 +0900 |
|---|---|---|
| committer | Kouhei Sutou <[email protected]> | 2015-12-29 20:36:12 +0900 |
| commit | a561bdb25ff51809c5de63ab7083ebf25d37cda9 (patch) | |
| tree | 7c19c9a51246879dc01b1b112f483352c6f4480c /src/state.c | |
| parent | e132de9e8eaf095f6f8b826e34a1c145403c3311 (diff) | |
| download | mruby-a561bdb25ff51809c5de63ab7083ebf25d37cda9.tar.gz mruby-a561bdb25ff51809c5de63ab7083ebf25d37cda9.zip | |
Support backtrace after method calls
GitHub: fix #2902, #2917
The current implementation traverses stack to retrieve backtrace. But
stack will be changed when some operations are occurred. It means that
backtrace may be broken after some operations.
This change (1) saves the minimum information to retrieve backtrace when
exception is raised and (2) restores backtrace from the minimum
information when backtrace is needed. It reduces overhead for creating
backtrace Ruby objects.
The space for the minimum information is reused by multiple
exceptions. So memory allocation isn't occurred for each exception.
Diffstat (limited to 'src/state.c')
| -rw-r--r-- | src/state.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/state.c b/src/state.c index c8c0658e4..898e77336 100644 --- a/src/state.c +++ b/src/state.c @@ -215,6 +215,8 @@ mrb_str_pool(mrb_state *mrb, mrb_value str) return mrb_obj_value(ns); } +void mrb_free_backtrace(mrb_state *mrb); + MRB_API void mrb_free_context(mrb_state *mrb, struct mrb_context *c) { @@ -242,6 +244,7 @@ mrb_close(mrb_state *mrb) /* free */ mrb_gc_free_gv(mrb); + mrb_free_backtrace(mrb); mrb_free_context(mrb, mrb->root_c); mrb_free_symtbl(mrb); mrb_alloca_free(mrb); |
