Skip to content

Commit

Permalink
Revert "Handle stack overflow in Attributes"
Browse files Browse the repository at this point in the history
This reverts commit 579456e,
as it was too expensive
  • Loading branch information
ChrisJefferson authored and fingolfin committed Jul 18, 2019
1 parent ac79ff0 commit a02f6d4
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 2,010 deletions.
81 changes: 16 additions & 65 deletions src/calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#ifndef GAP_CALLS_H
#define GAP_CALLS_H

#include "funcs.h"
#include "gaputils.h"
#include "objects.h"

Expand Down Expand Up @@ -313,66 +312,42 @@ EXPORT_INLINE int IS_FUNC(Obj obj)
*/
EXPORT_INLINE Obj CALL_0ARGS(Obj f)
{
CheckRecursionBefore();
Obj o = HDLR_0ARGS(f)(f);
DecRecursionDepth();
return o;
return HDLR_0ARGS(f)(f);
}

EXPORT_INLINE Obj CALL_1ARGS(Obj f, Obj a1)
{
CheckRecursionBefore();
Obj o = HDLR_1ARGS(f)(f, a1);
DecRecursionDepth();
return o;
return HDLR_1ARGS(f)(f, a1);
}

EXPORT_INLINE Obj CALL_2ARGS(Obj f, Obj a1, Obj a2)
{
CheckRecursionBefore();
Obj o = HDLR_2ARGS(f)(f, a1, a2);
DecRecursionDepth();
return o;
return HDLR_2ARGS(f)(f, a1, a2);
}

EXPORT_INLINE Obj CALL_3ARGS(Obj f, Obj a1, Obj a2, Obj a3)
{
CheckRecursionBefore();
Obj o = HDLR_3ARGS(f)(f, a1, a2, a3);
DecRecursionDepth();
return o;
return HDLR_3ARGS(f)(f, a1, a2, a3);
}

EXPORT_INLINE Obj CALL_4ARGS(Obj f, Obj a1, Obj a2, Obj a3, Obj a4)
{
CheckRecursionBefore();
Obj o = HDLR_4ARGS(f)(f, a1, a2, a3, a4);
DecRecursionDepth();
return o;
return HDLR_4ARGS(f)(f, a1, a2, a3, a4);
}

EXPORT_INLINE Obj CALL_5ARGS(Obj f, Obj a1, Obj a2, Obj a3, Obj a4, Obj a5)
{
CheckRecursionBefore();
Obj o = HDLR_5ARGS(f)(f, a1, a2, a3, a4, a5);
DecRecursionDepth();
return o;
return HDLR_5ARGS(f)(f, a1, a2, a3, a4, a5);
}

EXPORT_INLINE Obj CALL_6ARGS(Obj f, Obj a1, Obj a2, Obj a3, Obj a4, Obj a5, Obj a6)
{
CheckRecursionBefore();
Obj o = HDLR_6ARGS(f)(f, a1, a2, a3, a4, a5, a6);
DecRecursionDepth();
return o;
return HDLR_6ARGS(f)(f, a1, a2, a3, a4, a5, a6);
}

EXPORT_INLINE Obj CALL_XARGS(Obj f, Obj as)
{
CheckRecursionBefore();
Obj o = HDLR_XARGS(f)(f, as);
DecRecursionDepth();
return o;
return HDLR_XARGS(f)(f, as);
}


Expand All @@ -393,66 +368,42 @@ EXPORT_INLINE Obj CALL_XARGS(Obj f, Obj as)
*/
EXPORT_INLINE Obj CALL_0ARGS_PROF(Obj f)
{
CheckRecursionBefore();
Obj o = HDLR_0ARGS(PROF_FUNC(f))(f);
DecRecursionDepth();
return o;
return HDLR_0ARGS(PROF_FUNC(f))(f);
}

EXPORT_INLINE Obj CALL_1ARGS_PROF(Obj f, Obj a1)
{
CheckRecursionBefore();
Obj o = HDLR_1ARGS(PROF_FUNC(f))(f, a1);
DecRecursionDepth();
return o;
return HDLR_1ARGS(PROF_FUNC(f))(f, a1);
}

EXPORT_INLINE Obj CALL_2ARGS_PROF(Obj f, Obj a1, Obj a2)
{
CheckRecursionBefore();
Obj o = HDLR_2ARGS(PROF_FUNC(f))(f, a1, a2);
DecRecursionDepth();
return o;
return HDLR_2ARGS(PROF_FUNC(f))(f, a1, a2);
}

EXPORT_INLINE Obj CALL_3ARGS_PROF(Obj f, Obj a1, Obj a2, Obj a3)
{
CheckRecursionBefore();
Obj o = HDLR_3ARGS(PROF_FUNC(f))(f, a1, a2, a3);
DecRecursionDepth();
return o;
return HDLR_3ARGS(PROF_FUNC(f))(f, a1, a2, a3);
}

EXPORT_INLINE Obj CALL_4ARGS_PROF(Obj f, Obj a1, Obj a2, Obj a3, Obj a4)
{
CheckRecursionBefore();
Obj o = HDLR_4ARGS(PROF_FUNC(f))(f, a1, a2, a3, a4);
DecRecursionDepth();
return o;
return HDLR_4ARGS(PROF_FUNC(f))(f, a1, a2, a3, a4);
}

EXPORT_INLINE Obj CALL_5ARGS_PROF(Obj f, Obj a1, Obj a2, Obj a3, Obj a4, Obj a5)
{
CheckRecursionBefore();
Obj o = HDLR_5ARGS(PROF_FUNC(f))(f, a1, a2, a3, a4, a5);
DecRecursionDepth();
return o;
return HDLR_5ARGS(PROF_FUNC(f))(f, a1, a2, a3, a4, a5);
}

EXPORT_INLINE Obj CALL_6ARGS_PROF(Obj f, Obj a1, Obj a2, Obj a3, Obj a4, Obj a5, Obj a6)
{
CheckRecursionBefore();
Obj o = HDLR_6ARGS(PROF_FUNC(f))(f, a1, a2, a3, a4, a5, a6);
DecRecursionDepth();
return o;
return HDLR_6ARGS(PROF_FUNC(f))(f, a1, a2, a3, a4, a5, a6);
}

EXPORT_INLINE Obj CALL_XARGS_PROF(Obj f, Obj as)
{
CheckRecursionBefore();
Obj o = HDLR_XARGS(PROF_FUNC(f))(f, as);
DecRecursionDepth();
return o;
return HDLR_XARGS(PROF_FUNC(f))(f, as);
}


Expand Down
20 changes: 14 additions & 6 deletions src/funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,14 @@ void RecursionDepthTrap( void )
}
}

#define CHECK_RECURSION_BEFORE \
HookedLineIntoFunction(func); \
CheckRecursionBefore();

#define CHECK_RECURSION_AFTER \
DecRecursionDepth(); \
HookedLineOutFunction(func);

#ifdef HPCGAP

#define REMEMBER_LOCKSTACK() \
Expand Down Expand Up @@ -456,7 +464,7 @@ static ALWAYS_INLINE Obj DoExecFunc(Obj func, Int narg, const Obj *arg)
{
Bag oldLvars; /* old values bag */
Obj result;
HookedLineIntoFunction(func);
CHECK_RECURSION_BEFORE

#ifdef HPCGAP
REMEMBER_LOCKSTACK();
Expand All @@ -480,7 +488,7 @@ static ALWAYS_INLINE Obj DoExecFunc(Obj func, Int narg, const Obj *arg)
/* switch back to the old values bag */
SWITCH_TO_OLD_LVARS_AND_FREE( oldLvars );

HookedLineOutFunction(func);
CHECK_RECURSION_AFTER

/* return the result */
return result;
Expand Down Expand Up @@ -534,7 +542,7 @@ static Obj DoExecFuncXargs(Obj func, Obj args)
UInt i; /* loop variable */
Obj result;

HookedLineIntoFunction(func);
CHECK_RECURSION_BEFORE

/* check the number of arguments */
len = NARG_FUNC( func );
Expand Down Expand Up @@ -565,7 +573,7 @@ static Obj DoExecFuncXargs(Obj func, Obj args)
/* switch back to the old values bag */
SWITCH_TO_OLD_LVARS_AND_FREE( oldLvars );

HookedLineOutFunction(func);
CHECK_RECURSION_AFTER

/* return the result */
return result;
Expand All @@ -580,7 +588,7 @@ static Obj DoPartialUnWrapFunc(Obj func, Obj args)
UInt len;
Obj result;

HookedLineIntoFunction(func);
CHECK_RECURSION_BEFORE

named = ((UInt)-NARG_FUNC(func))-1;
len = LEN_PLIST(args);
Expand Down Expand Up @@ -617,7 +625,7 @@ static Obj DoPartialUnWrapFunc(Obj func, Obj args)
/* switch back to the old values bag */
SWITCH_TO_OLD_LVARS_AND_FREE( oldLvars );

HookedLineOutFunction(func);
CHECK_RECURSION_AFTER

/* return the result */
return result;
Expand Down
2 changes: 0 additions & 2 deletions tst/testspecial/stack-depth-func.g

This file was deleted.

13 changes: 0 additions & 13 deletions tst/testspecial/stack-depth-func.g.out

This file was deleted.

2 changes: 0 additions & 2 deletions tst/testspecial/stack-depth-func2.g

This file was deleted.

13 changes: 0 additions & 13 deletions tst/testspecial/stack-depth-func2.g.out

This file was deleted.

3 changes: 0 additions & 3 deletions tst/testspecial/stack-depth-list.g

This file was deleted.

23 changes: 0 additions & 23 deletions tst/testspecial/stack-depth-list.g.out

This file was deleted.

3 changes: 0 additions & 3 deletions tst/testspecial/stack-depth-operation.g

This file was deleted.

7 changes: 0 additions & 7 deletions tst/testspecial/stack-depth-operation.g.out

This file was deleted.

Loading

0 comments on commit a02f6d4

Please sign in to comment.