Skip to content

Commit

Permalink
kernel: remove *_BRK_CURR_STAT
Browse files Browse the repository at this point in the history
In a few select spaces, we insert `SET_BRK_CALL_TO` calls instead,
in order to improve certain backtraces.
  • Loading branch information
fingolfin committed Sep 27, 2018
1 parent 74b68a1 commit 6d71dc4
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 75 deletions.
19 changes: 3 additions & 16 deletions src/funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ static UInt ExecProccallOpts(Stat call)
{
Obj opts;

SET_BRK_CURR_STAT( call );
opts = EVAL_EXPR(READ_STAT(call, 0));
CALL_1ARGS(PushOptions, opts);

Expand Down Expand Up @@ -131,8 +130,6 @@ static ALWAYS_INLINE Obj EvalOrExecCall(Int ignoreResult, UInt nr, Stat call)
Obj result;

// evaluate the function
if (ignoreResult)
SET_BRK_CURR_STAT( call );
func = EVAL_EXPR( FUNC_CALL( call ) );

// evaluate the arguments
Expand Down Expand Up @@ -426,16 +423,6 @@ void RecursionDepthTrap( void )

#endif

static void ExecFuncHelper(void)
{
OLD_BRK_CURR_STAT // old executing statement

// execute the statement sequence
REM_BRK_CURR_STAT();
EXEC_STAT( OFFSET_FIRST_STAT );
RES_BRK_CURR_STAT();
}

static Obj PopReturnObjStat(void)
{
Obj returnObjStat = STATE(ReturnObjStat);
Expand Down Expand Up @@ -500,7 +487,7 @@ static ALWAYS_INLINE Obj DoExecFunc(Obj func, Int narg, const Obj *arg)
ASS_LVAR( i+1, arg[i] );

/* execute the statement sequence */
ExecFuncHelper();
EXEC_STAT( OFFSET_FIRST_STAT );
#ifdef HPCGAP
CLEAR_LOCK_STACK();
#endif
Expand Down Expand Up @@ -588,7 +575,7 @@ static Obj DoExecFuncXargs(Obj func, Obj args)
}

/* execute the statement sequence */
ExecFuncHelper();
EXEC_STAT( OFFSET_FIRST_STAT );
#ifdef HPCGAP
CLEAR_LOCK_STACK();
#endif
Expand Down Expand Up @@ -641,7 +628,7 @@ static Obj DoPartialUnWrapFunc(Obj func, Obj args)
ASS_LVAR(named+1, args);

/* execute the statement sequence */
ExecFuncHelper();
EXEC_STAT( OFFSET_FIRST_STAT );
#ifdef HPCGAP
CLEAR_LOCK_STACK();
#endif
Expand Down
42 changes: 18 additions & 24 deletions src/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ UInt ExecIf (
Stat body; /* body */

/* if the condition evaluates to 'true', execute the if-branch body */
SET_BRK_CURR_STAT( stat );
cond = READ_STAT(stat, 0);
if ( EVAL_BOOL_EXPR( cond ) != False ) {

Expand All @@ -232,7 +231,6 @@ UInt ExecIfElse (
Stat body; /* body */

/* if the condition evaluates to 'true', execute the if-branch body */
SET_BRK_CURR_STAT( stat );
cond = READ_STAT(stat, 0);
if ( EVAL_BOOL_EXPR( cond ) != False ) {

Expand Down Expand Up @@ -262,7 +260,6 @@ UInt ExecIfElif (
for ( i = 1; i <= nr; i++ ) {

/* if the condition evaluates to 'true', execute the branch body */
SET_BRK_CURR_STAT( stat );
cond = READ_STAT(stat, 2 * (i - 1));
if ( EVAL_BOOL_EXPR( cond ) != False ) {

Expand Down Expand Up @@ -293,7 +290,6 @@ UInt ExecIfElifElse (
for ( i = 1; i <= nr; i++ ) {

/* if the condition evaluates to 'true', execute the branch body */
SET_BRK_CURR_STAT( stat );
cond = READ_STAT(stat, 2 * (i - 1));
if ( EVAL_BOOL_EXPR( cond ) != False ) {

Expand Down Expand Up @@ -371,7 +367,6 @@ static ALWAYS_INLINE UInt ExecForHelper(Stat stat, UInt nr)
}

/* evaluate the list */
SET_BRK_CURR_STAT( stat );
list = EVAL_EXPR(READ_STAT(stat, 1));

/* get the body */
Expand Down Expand Up @@ -513,7 +508,6 @@ static ALWAYS_INLINE UInt ExecForRangeHelper(Stat stat, UInt nr)
lvar = LVAR_REFLVAR(READ_STAT(stat, 0));

/* evaluate the range */
SET_BRK_CURR_STAT( stat );
VisitStatIfHooked(READ_STAT(stat, 1));
elm = EVAL_EXPR(READ_EXPR(READ_STAT(stat, 1), 0));
while ( ! IS_INTOBJ(elm) ) {
Expand Down Expand Up @@ -593,7 +587,6 @@ UInt ExecAtomic(Stat stat)
UInt nrexprs,i,j,status;
Obj o;

SET_BRK_CURR_STAT( stat );
nrexprs = ((SIZE_STAT(stat)/sizeof(Stat))-1)/2;

j = 0;
Expand Down Expand Up @@ -679,8 +672,12 @@ static ALWAYS_INLINE UInt ExecWhileHelper(Stat stat, UInt nr)
body2 = (nr >= 2) ? READ_STAT(stat, 2) : 0;
body3 = (nr >= 3) ? READ_STAT(stat, 3) : 0;

// HACK: point current "statement" at the condition expression, so
// that if there is an error in it, it resp. its location is printed,
// not the whole loop statement.
SET_BRK_CALL_TO(cond);

/* while the condition evaluates to 'true', execute the body */
SET_BRK_CURR_STAT( stat );
while ( EVAL_BOOL_EXPR( cond ) != False ) {

#if !defined(HAVE_SIGNAL)
Expand All @@ -697,8 +694,10 @@ static ALWAYS_INLINE UInt ExecWhileHelper(Stat stat, UInt nr)
if (nr >= 3)
EXEC_STAT_IN_LOOP(body3);

SET_BRK_CURR_STAT( stat );

// HACK: point current "statement" at the condition expression, so
// that if there is an error in it, it resp. its location is printed,
// not the whole loop statement.
SET_BRK_CALL_TO(cond);
}

/* return 0 (to indicate that no leave-statement was executed) */
Expand Down Expand Up @@ -754,7 +753,6 @@ static ALWAYS_INLINE UInt ExecRepeatHelper(Stat stat, UInt nr)
body3 = (nr >= 3) ? READ_STAT(stat, 3) : 0;

/* execute the body until the condition evaluates to 'true' */
SET_BRK_CURR_STAT( stat );
do {

#if !defined(HAVE_SIGNAL)
Expand All @@ -771,7 +769,10 @@ static ALWAYS_INLINE UInt ExecRepeatHelper(Stat stat, UInt nr)
if (nr >= 3)
EXEC_STAT_IN_LOOP(body3);

SET_BRK_CURR_STAT( stat );
// HACK: point current "statement" at the condition expression, so
// that if there is an error in it, it resp. its location is printed,
// not the whole loop statement.
SET_BRK_CALL_TO(cond);

} while ( EVAL_BOOL_EXPR( cond ) == False );

Expand Down Expand Up @@ -872,9 +873,6 @@ UInt ExecInfo (
selectors = EVAL_EXPR( ARGI_INFO( stat, 1 ) );
level = EVAL_EXPR( ARGI_INFO( stat, 2) );

SET_BRK_CALL_TO( stat );
SET_BRK_CURR_STAT( stat );

selected = InfoCheckLevel(selectors, level);
if (selected == True) {

Expand Down Expand Up @@ -919,9 +917,6 @@ UInt ExecAssert2Args (
Obj level;
Obj decision;

SET_BRK_CURR_STAT( stat );
SET_BRK_CALL_TO( stat );

level = EVAL_EXPR(READ_STAT(stat, 0));
if ( ! LT(CurrentAssertionLevel, level) ) {
decision = EVAL_EXPR(READ_STAT(stat, 1));
Expand All @@ -932,7 +927,10 @@ UInt ExecAssert2Args (
"you may 'return true;' or 'return false;'");
}
if ( decision == False ) {
SET_BRK_CURR_STAT( stat );
// make sure the error back trace prints again at the statement,
// not any subexpression
SET_BRK_CALL_TO( stat );

ErrorReturnVoid( "Assertion failure", 0L, 0L, "you may 'return;'");
}
}
Expand All @@ -955,9 +953,6 @@ UInt ExecAssert3Args (
Obj decision;
Obj message;

SET_BRK_CURR_STAT( stat );
SET_BRK_CALL_TO( stat );

level = EVAL_EXPR(READ_STAT(stat, 0));
if ( ! LT(CurrentAssertionLevel, level) ) {
decision = EVAL_EXPR(READ_STAT(stat, 1));
Expand All @@ -970,6 +965,7 @@ UInt ExecAssert3Args (
if ( decision == False ) {
message = EVAL_EXPR(READ_STAT(stat, 2));
if ( message != (Obj) 0 ) {
SET_BRK_CALL_TO( stat );
if (IS_STRING_REP( message ))
PrintString1( message );
else
Expand Down Expand Up @@ -1006,7 +1002,6 @@ UInt ExecReturnObj (
#endif

/* evaluate the expression */
SET_BRK_CURR_STAT( stat );
STATE(ReturnObjStat) = EVAL_EXPR(READ_STAT(stat, 0));

/* return up to function interpreter */
Expand Down Expand Up @@ -1118,7 +1113,6 @@ UInt ExecIntrStat (
HaveInterrupt();

/* and now for something completely different */
SET_BRK_CURR_STAT( stat );
if ( SyStorOverrun != 0 ) {
SyStorOverrun = 0; /* reset */
ErrorReturnVoid(
Expand Down
13 changes: 0 additions & 13 deletions src/stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,6 @@ extern UInt EXEC_STAT(Stat stat);
extern UInt (* IntrExecStatFuncs[256]) ( Stat stat );


/****************************************************************************
**
*F SET_BRK_CURR_STAT(<stat>) . . . . . . . set currently executing statement
*F OLD_BRK_CURR_STAT . . . . . . . . . define variable to remember CurrStat
*F REM_BRK_CURR_STAT() . . . . . . . remember currently executing statement
*F RES_BRK_CURR_STAT() . . . . . . . . restore currently executing statement
*/
#define SET_BRK_CURR_STAT(stat) do {} while (0) /* do nothing */
#define OLD_BRK_CURR_STAT do {} while (0) /* do nothing */ ;
#define REM_BRK_CURR_STAT() do {} while (0) /* do nothing */
#define RES_BRK_CURR_STAT() do {} while (0) /* do nothing */


/****************************************************************************
**
*V ReturnObjStat . . . . . . . . . . . . . . . . result of return-statement
Expand Down
Loading

0 comments on commit 6d71dc4

Please sign in to comment.