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 d1c377e commit d2d073f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 76 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
26 changes: 1 addition & 25 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 @@ -680,7 +673,6 @@ static ALWAYS_INLINE UInt ExecWhileHelper(Stat stat, UInt nr)
body3 = (nr >= 3) ? READ_STAT(stat, 3) : 0;

/* 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 +689,6 @@ static ALWAYS_INLINE UInt ExecWhileHelper(Stat stat, UInt nr)
if (nr >= 3)
EXEC_STAT_IN_LOOP(body3);

SET_BRK_CURR_STAT( stat );

}

/* return 0 (to indicate that no leave-statement was executed) */
Expand Down Expand Up @@ -754,7 +744,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,8 +760,6 @@ static ALWAYS_INLINE UInt ExecRepeatHelper(Stat stat, UInt nr)
if (nr >= 3)
EXEC_STAT_IN_LOOP(body3);

SET_BRK_CURR_STAT( stat );

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

/* return 0 (to indicate that no leave-statement was executed) */
Expand Down Expand Up @@ -872,9 +859,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 +903,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 +913,6 @@ UInt ExecAssert2Args (
"you may 'return true;' or 'return false;'");
}
if ( decision == False ) {
SET_BRK_CURR_STAT( stat );
ErrorReturnVoid( "Assertion failure", 0L, 0L, "you may 'return;'");
}
}
Expand All @@ -955,9 +935,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 +947,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 +984,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 +1095,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
19 changes: 0 additions & 19 deletions src/vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ UInt ExecAssLVar (
Obj rhs; /* value of right hand side */

/* assign the right hand side to the local variable */
SET_BRK_CURR_STAT( stat );
rhs = EVAL_EXPR(READ_STAT(stat, 1));
ASS_LVAR(READ_STAT(stat, 0), rhs);

Expand Down Expand Up @@ -320,7 +319,6 @@ UInt ExecAssHVar (
Obj rhs; /* value of right hand side */

/* assign the right hand side to the higher variable */
SET_BRK_CURR_STAT( stat );
rhs = EVAL_EXPR(READ_STAT(stat, 1));
ASS_HVAR(READ_STAT(stat, 0), rhs);

Expand Down Expand Up @@ -436,7 +434,6 @@ UInt ExecAssGVar (
Obj rhs; /* value of right hand side */

/* assign the right hand side to the global variable */
SET_BRK_CURR_STAT( stat );
rhs = EVAL_EXPR(READ_STAT(stat, 1));
AssGVar(READ_STAT(stat, 0), rhs);

Expand Down Expand Up @@ -554,7 +551,6 @@ UInt ExecAssList (
Obj rhs; /* right hand side, right operand */

/* evaluate the list (checking is done by 'ASS_LIST') */
SET_BRK_CURR_STAT( stat );
list = EVAL_EXPR(READ_STAT(stat, 0));

/* evaluate the position */
Expand Down Expand Up @@ -603,7 +599,6 @@ UInt ExecAss2List (
Obj rhs; /* right hand side, right operand */

/* evaluate the list (checking is done by 'ASS_LIST') */
SET_BRK_CURR_STAT( stat );
list = EVAL_EXPR(READ_STAT(stat, 0));

/* evaluate the position */
Expand Down Expand Up @@ -635,7 +630,6 @@ UInt ExecAsssList (
Obj rhss; /* right hand sides, right operand */

/* evaluate the list (checking is done by 'ASSS_LIST') */
SET_BRK_CURR_STAT( stat );
list = EVAL_EXPR(READ_STAT(stat, 0));

/* evaluate and check the positions */
Expand Down Expand Up @@ -681,7 +675,6 @@ UInt ExecAssListLevel (

/* evaluate lists (if this works, then <lists> is nested <level> deep, */
/* checking it is nested <level>+1 deep is done by 'AssListLevel') */
SET_BRK_CURR_STAT( stat );
lists = EVAL_EXPR(READ_STAT(stat, 0));
narg = SIZE_STAT(stat)/sizeof(Stat) -3;
ixs = NEW_PLIST(T_PLIST, narg);
Expand Down Expand Up @@ -730,7 +723,6 @@ UInt ExecAsssListLevel (

/* evaluate lists (if this works, then <lists> is nested <level> deep, */
/* checking it is nested <level>+1 deep is done by 'AsssListLevel') */
SET_BRK_CURR_STAT( stat );
lists = EVAL_EXPR(READ_STAT(stat, 0));

/* evaluate and check the positions */
Expand Down Expand Up @@ -768,7 +760,6 @@ UInt ExecUnbList (
Int i;

/* evaluate the list (checking is done by 'LEN_LIST') */
SET_BRK_CURR_STAT( stat );
list = EVAL_EXPR(READ_STAT(stat, 0));
narg = SIZE_STAT(stat)/sizeof(Stat) - 1;
if (narg == 1) {
Expand Down Expand Up @@ -1207,7 +1198,6 @@ UInt ExecAssRecName (
Obj rhs; /* rhs, right operand */

/* evaluate the record (checking is done by 'ASS_REC') */
SET_BRK_CURR_STAT( stat );
record = EVAL_EXPR(READ_STAT(stat, 0));

/* get the name (stored immediately in the statement) */
Expand Down Expand Up @@ -1239,7 +1229,6 @@ UInt ExecAssRecExpr (
Obj rhs; /* rhs, right operand */

/* evaluate the record (checking is done by 'ASS_REC') */
SET_BRK_CURR_STAT( stat );
record = EVAL_EXPR(READ_STAT(stat, 0));

/* evaluate the name and convert it to a record name */
Expand Down Expand Up @@ -1270,7 +1259,6 @@ UInt ExecUnbRecName (
UInt rnam; /* name, left operand */

/* evaluate the record (checking is done by 'UNB_REC') */
SET_BRK_CURR_STAT( stat );
record = EVAL_EXPR(READ_STAT(stat, 0));

/* get the name (stored immediately in the statement) */
Expand Down Expand Up @@ -1298,7 +1286,6 @@ UInt ExecUnbRecExpr (
UInt rnam; /* name, left operand */

/* evaluate the record (checking is done by 'UNB_REC') */
SET_BRK_CURR_STAT( stat );
record = EVAL_EXPR(READ_STAT(stat, 0));

/* evaluate the name and convert it to a record name */
Expand Down Expand Up @@ -1558,7 +1545,6 @@ UInt ExecAssPosObj (
Obj rhs; /* right hand side, right operand */

/* evaluate the list (checking is done by 'ASS_LIST') */
SET_BRK_CURR_STAT( stat );
list = EVAL_EXPR(READ_STAT(stat, 0));

/* evaluate and check the position */
Expand Down Expand Up @@ -1612,7 +1598,6 @@ UInt ExecUnbPosObj (
Int p; /* position, as a C integer */

/* evaluate the list (checking is done by 'LEN_LIST') */
SET_BRK_CURR_STAT( stat );
list = EVAL_EXPR(READ_STAT(stat, 0));

/* evaluate and check the position */
Expand Down Expand Up @@ -1850,7 +1835,6 @@ UInt ExecAssComObjName (
Obj rhs; /* rhs, right operand */

/* evaluate the record (checking is done by 'ASS_REC') */
SET_BRK_CURR_STAT( stat );
record = EVAL_EXPR(READ_STAT(stat, 0));

/* get the name (stored immediately in the statement) */
Expand Down Expand Up @@ -1906,7 +1890,6 @@ UInt ExecAssComObjExpr (
Obj rhs; /* rhs, right operand */

/* evaluate the record (checking is done by 'ASS_REC') */
SET_BRK_CURR_STAT( stat );
record = EVAL_EXPR(READ_STAT(stat, 0));

/* evaluate the name and convert it to a record name */
Expand Down Expand Up @@ -1949,7 +1932,6 @@ UInt ExecUnbComObjName (
UInt rnam; /* name, left operand */

/* evaluate the record (checking is done by 'UNB_REC') */
SET_BRK_CURR_STAT( stat );
record = EVAL_EXPR(READ_STAT(stat, 0));

/* get the name (stored immediately in the statement) */
Expand Down Expand Up @@ -1989,7 +1971,6 @@ UInt ExecUnbComObjExpr (
UInt rnam; /* name, left operand */

/* evaluate the record (checking is done by 'UNB_REC') */
SET_BRK_CURR_STAT( stat );
record = EVAL_EXPR(READ_STAT(stat, 0));

/* evaluate the name and convert it to a record name */
Expand Down
2 changes: 1 addition & 1 deletion tst/testspecial/bad-array-int-0.g.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function( ) ... end
gap> f();
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `[]' on 2 arguments at GAPROOT/lib/methsel2.g:250 called from
l[0] at *stdin*:5 called from
return l[0]; at *stdin*:5 called from
<function "f">( <arguments> )
called from read-eval loop at *stdin*:7
type 'quit;' to quit to outer loop
Expand Down
Loading

0 comments on commit d2d073f

Please sign in to comment.