Skip to content

Commit

Permalink
CLEANUP: Removed '$aborted'
Browse files Browse the repository at this point in the history
  • Loading branch information
JanWielemaker committed Oct 2, 2024
1 parent da7d520 commit dbe8a2d
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 47 deletions.
10 changes: 5 additions & 5 deletions boot/init.pl
Original file line number Diff line number Diff line change
Expand Up @@ -649,11 +649,11 @@

%! '$recover_and_rethrow'(:Goal, +Term)
%
% This goal is used to wrap the catch/3 recover handler if the
% exception is not supposed to be `catchable'. An example of an
% uncachable exception is '$aborted', used by abort/0. Note that
% we cut to ensure that the exception is not delayed forever
% because the recover handler leaves a choicepoint.
% This goal is used to wrap the catch/3 recover handler if the
% exception is not supposed to be `catchable'. This applies to
% exceptions of the shape unwind(Term). Note that we cut to ensure
% that the exception is not delayed forever because the recover
% handler leaves a choicepoint.

:- public '$recover_and_rethrow'/2.

Expand Down
2 changes: 0 additions & 2 deletions boot/messages.pl
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@
swi_extra(SWI).
translate_message2(unwind(Term)) -->
unwind_message(Term).
translate_message2('$aborted') -->
[ 'Execution Aborted' ].
translate_message2(message_lines(Lines), L, T) :- % deal with old C-warning()
make_message_lines(Lines, L, T).
translate_message2(format(Fmt, Args)) -->
Expand Down
2 changes: 1 addition & 1 deletion boot/toplevel.pl
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@
'$initialise' :-
catch(initialise_prolog, E, initialise_error(E)).

initialise_error('$aborted') :- !.
initialise_error(unwind(abort)) :- !.
initialise_error(E) :-
print_message(error, initialization_exception(E)),
fail.
Expand Down
2 changes: 0 additions & 2 deletions library/debug.pl
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,6 @@
assertion_failed.

assertion_rethrow(time_limit_exceeded).
assertion_rethrow('$aborted').


/*******************************
* EXPANSION *
Expand Down
4 changes: 2 additions & 2 deletions library/wasm.pl
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@

%! wasm_abort
%
% Execution aborted by userthe
% Execution aborted by user.

wasm_abort :-
print_message(error, '$aborted'),
print_message(error, unwind(abort)),
abort.

with_heartbeat(Goal) :-
Expand Down
18 changes: 9 additions & 9 deletions man/builtin.doc
Original file line number Diff line number Diff line change
Expand Up @@ -3004,9 +3004,7 @@ Raising an exception fails due to lack of resources, e.g., lack of
stack space to store the exception. In this case a resource exception is
raised. If that too fails the system tries to raise a resource exception
without (stack) context. If that fails it will raise the exception
\verb='$aborted'=, also raised by abort/0. As no stack space is
required for processing this atomic exception, this should always
succeed.
\term{unwind}{abort}, also raised by abort/0.
\item
Certain \jargon{callback} operations raise an exception while processing
another exception or a previous callback already raised an exception
Expand All @@ -3022,7 +3020,9 @@ If the most urgent exceptions needs to be preserved, the following
exception ordering is respected, preserving the topmost matching error.

\begin{enumerate}
\item \verb='$aborted'= (abort/0)
\item \verb=unwind(halt(_))= (halt/1)
\item \verb=unwind(thread_exit(_))= (thread_exit/1)
\item \verb=unwind(abort)= (abort/0)
\item \verb$time_limit_exceeded$ (call_with_time_limit/2)
\item \term{error}{\term{resource_error}{Resource}, Context}
\item \term{error}{Formal, Context}
Expand Down Expand Up @@ -11277,11 +11277,11 @@ Abort the Prolog execution and restart the top level. If the
restarted instead of entering the default interactive top level.

Aborting is implemented by throwing the reserved exception
\verb='$aborted'=. This exception can be caught using catch/3, but the
recovery goal is wrapped with a predicate that prunes the choice points
of the recovery goal (i.e., as once/1) and re-throws the exception.
This is illustrated in the example below, where we press control-C
and `a'. See also \secref{urgentexceptions}.
\term{unwind}{abort}. This exception can be caught using catch/3, but
the recovery goal is wrapped with a predicate that prunes the choice
points of the recovery goal (i.e., as once/1) and re-throws the
exception. This is illustrated in the example below, where we press
control-C and `a'. See also \secref{urgentexceptions}.

\begin{code}
?- catch((repeat,fail), E, true).
Expand Down
10 changes: 1 addition & 9 deletions man/foreign.doc
Original file line number Diff line number Diff line change
Expand Up @@ -3682,15 +3682,7 @@ print_message/2 through the C interface.
Generate an exception (as throw/1) and return \const{FALSE}. If there is
already a pending exception, the most urgent exception is kept; and if both
are of the same urgency, the new exception is kept. Urgency
of exceptions is defined as

\begin{enumerate}
\item abort (\verb|'$aborted'|).
\item \const{time_limit_exceeded} (see call_with_time_limit/2).
\item \const{resource_error} exceptions.
\item Other \term{error}{Formal, ImplDef} exceptions.
\item Other exceptions.
\end{enumerate}
of exceptions is described in secref{urgentexceptions}.


This function is rarely used directly. Instead, errors are typically
Expand Down
1 change: 0 additions & 1 deletion src/ATOMS
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ A ISO_8859_1 "ISO-8859-1"
A dollar "$"
A abi "abi"
A abort "abort"
A aborted "$aborted"
A abs "abs"
A abstract "abstract"
A access "access"
Expand Down
2 changes: 1 addition & 1 deletion src/pl-alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ outOfStack(void *stack, stack_overflow_action how)
} else
{ Sdprintf("ERROR: Out of global-stack.\n"
"ERROR: No room for exception term. Aborting.\n");
*valTermRef(LD->exception.bin) = ATOM_aborted;
*valTermRef(LD->exception.bin) = ATOM_abort;
}
exception_term = exception_bin;

Expand Down
6 changes: 2 additions & 4 deletions src/pl-fli.c
Original file line number Diff line number Diff line change
Expand Up @@ -4625,7 +4625,7 @@ copy_exception(DECL_LD term_t ex, term_t bin)
}

Sdprintf("WARNING: mapped exception to abort due to stack overflow\n");
PL_put_atom(bin, ATOM_aborted);
PL_put_atom(bin, ATOM_abort);
return true;
}

Expand All @@ -4636,9 +4636,7 @@ classify_exception_p(DECL_LD Word p)
if ( isVar(*p) )
{ return EXCEPT_NONE;
} else if ( isAtom(*p) )
{ if ( *p == ATOM_aborted )
return EXCEPT_ABORT;
if ( *p == ATOM_time_limit_exceeded )
{ if ( *p == ATOM_time_limit_exceeded )
return EXCEPT_TIMEOUT;
} else if ( hasFunctor(*p, FUNCTOR_error2) )
{ p = argTermP(*p, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/pl-incl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1935,7 +1935,7 @@ typedef enum except_class
EXCEPT_RESOURCE, /* ISO error(resource_error(_), _) */
EXCEPT_TIMEOUT, /* time_limit_exceeded */
EXCEPT_UNWIND, /* unwind(Term) */
EXCEPT_ABORT, /* '$aborted' or unwind(abort) */
EXCEPT_ABORT, /* unwind(abort) */
EXCEPT_THREAD_EXIT, /* unwind(thread_exit(Term)) */
EXCEPT_HALT /* unwind(halt(Code) */
} except_class;
Expand Down
7 changes: 4 additions & 3 deletions src/pl-pro.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ restore_after_exception(term_t except)
debugmode(DBG_OFF, NULL);
if ( classify_exception(except) == EXCEPT_ABORT )
{ rc = ( callEventHook(PLEV_ABORT) &&
printMessage(ATOM_informational, PL_ATOM, ATOM_aborted) );
printMessage(ATOM_informational, PL_FUNCTOR, FUNCTOR_unwind1,
PL_ATOM, ATOM_abort) );
}

return rc;
Expand Down Expand Up @@ -570,11 +571,11 @@ abortProlog(void)
LD->exception.processing = true; /* allow using spare stack */

if ( (fid = PL_open_foreign_frame()) &&
(ex = PL_new_term_ref()) )
(ex = PL_new_term_ref()) &&
PL_unify_term(ex, PL_FUNCTOR, FUNCTOR_unwind1, PL_ATOM, ATOM_abort) )
{ clearSegStack(&LD->cycle.lstack); /* can do no harm */
clearSegStack(&LD->cycle.vstack);

PL_put_atom(ex, ATOM_aborted);
rc = PL_raise_exception(ex);
PL_close_foreign_frame(fid);
}
Expand Down
5 changes: 1 addition & 4 deletions src/pl-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,7 @@ tracePort(DECL_LD LocalFrame frame, Choice bfr, int port, Code PC)
return ACTION_CONTINUE;

if ( port == EXCEPTION_PORT ) /* do not trace abort */
{ Word p = valTermRef(LD->exception.pending);

deRef(p);
if ( *p == ATOM_aborted )
{ if ( classify_exception(LD->exception.pending) >= EXCEPT_ABORT )
return ACTION_CONTINUE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/pl-vmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -5080,7 +5080,7 @@ VMH(b_throw, 0, (), ())
});

if ( debugstatus.suspendTrace == false && !rewritten++ &&
!uncachableException(exception_term) && /* e.g., $aborted */
!uncachableException(exception_term) && /* unwind(_) */
!resourceException(exception_term) )
{ int rc;

Expand Down
3 changes: 1 addition & 2 deletions src/pl-wam.c
Original file line number Diff line number Diff line change
Expand Up @@ -2081,8 +2081,7 @@ uncachableException(DECL_LD term_t t)
{ Word p = valTermRef(t);

deRef(p);
if ( hasFunctor(*p, FUNCTOR_unwind1) ||
*p == ATOM_aborted ) /* compat */
if ( hasFunctor(*p, FUNCTOR_unwind1) )
return *p;

return 0;
Expand Down

0 comments on commit dbe8a2d

Please sign in to comment.