From 5ae1f55200741dd0089f603d07777a1b9faf4690 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 20 Apr 2019 19:32:26 -0700 Subject: unwind: use allocate-struct in frame reification. * struct.c (allocate_struct): Changed from internal to external linkage. * struct.h (allocate_struct): Declared. * unwind.c (uw_get_frames, uw_find_frames_by_mask): Use allocate_struct instead of make_struct. --- struct.c | 3 +-- struct.h | 1 + unwind.c | 16 ++++++---------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/struct.c b/struct.c index 5ea77869..48f961b6 100644 --- a/struct.c +++ b/struct.c @@ -114,7 +114,6 @@ static val make_struct_type_compat(val name, val super, val slots, val initfun, val boactor); static val call_super_method(val inst, val sym, struct args *); static val call_super_fun(val type, val sym, struct args *); -static val allocate_struct(val type); void struct_init(void) { @@ -516,7 +515,7 @@ static void call_postinitfun_chain(struct struct_type *st, val strct) } } -static val allocate_struct(val type) +val allocate_struct(val type) { val self = lit("allocate-struct"); struct struct_type *st = stype_handle(&type, self); diff --git a/struct.h b/struct.h index a7be3123..857bce92 100644 --- a/struct.h +++ b/struct.h @@ -44,6 +44,7 @@ val struct_from_plist(val type, struct args *plist); val struct_from_args(val type, struct args *boa); val make_lazy_struct(val type, val argfun); val make_struct_lit(val type, val plist); +val allocate_struct(val type); val copy_struct(val strct); val clear_struct(val strct, val value); val replace_struct(val target, val source); diff --git a/unwind.c b/unwind.c index d937e094..994fed38 100644 --- a/unwind.c +++ b/unwind.c @@ -314,8 +314,7 @@ val uw_get_frames(void) switch (ex->uw.type) { case UW_CATCH: if (ex->ca.matches && ex->ca.visible) { - args_decl(args, ARGS_MIN); - val cf = make_struct(catch_frame_type, nil, args); + val cf = allocate_struct(catch_frame_type); slotset(cf, types_s, ex->ca.matches); slotset(cf, jump_s, cptr(coerce(mem_t *, ex))); ptail = list_collect(ptail, cf); @@ -323,8 +322,7 @@ val uw_get_frames(void) break; case UW_HANDLE: if (ex->ha.visible) { - args_decl(args, ARGS_MIN); - val hf = make_struct(handle_frame_type, nil, args); + val hf = allocate_struct(handle_frame_type); slotset(hf, types_s, ex->ha.matches); slotset(hf, fun_s, ex->ha.fun); ptail = list_collect(ptail, hf); @@ -369,8 +367,7 @@ static val uw_find_frames_impl(val extype, val frtype, val just_one) if (uw_exception_subtype_p(extype, car(match))) break; if (match) { - args_decl(args, ARGS_MIN); - val fr = make_struct(frtype, nil, args); + val fr = allocate_struct(frtype); slotset(fr, types_s, ex->ca.matches); if (et == UW_CATCH) { slotset(fr, desc_s, ex->ca.desc); @@ -410,11 +407,10 @@ val uw_find_frames_by_mask(val mask_in) uw_frtype_t type = fr->uw.type; if (((1U << type) & mask) != 0) { val frame = nil; - args_decl(args, ARGS_MIN); switch (type) { case UW_CATCH: { - frame = make_struct(catch_frame_type, nil, args); + frame = allocate_struct(catch_frame_type); slotset(frame, types_s, fr->ca.matches); slotset(frame, desc_s, fr->ca.desc); slotset(frame, jump_s, cptr(coerce(mem_t *, fr))); @@ -422,7 +418,7 @@ val uw_find_frames_by_mask(val mask_in) } case UW_HANDLE: { - frame = make_struct(handle_frame_type, nil, args); + frame = allocate_struct(handle_frame_type); slotset(frame, types_s, fr->ha.matches); slotset(frame, fun_s, fr->ha.fun); break; @@ -432,7 +428,7 @@ val uw_find_frames_by_mask(val mask_in) struct args *frargs = fr->fc.args; args_decl(acopy, frargs->argc); args_copy(acopy, frargs); - frame = make_struct(fcall_frame_type, nil, args); + frame = allocate_struct(fcall_frame_type); slotset(frame, fun_s, fr->fc.fun); slotset(frame, args_s, args_get_list(acopy)); break; -- cgit v1.2.3