Skip to content

Commit 441fa08

Browse files
committed
kernel: don't bother resetting CurrLVars in IntrAbortCoding
This is not necessary because shortly afterwards we call IntrEnd which resets the CurrLVars anyway.
1 parent fd79356 commit 441fa08

3 files changed

Lines changed: 16 additions & 30 deletions

File tree

src/intrprtr.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,17 @@ ExecStatus IntrEnd(IntrState * intr, UInt error, Obj *result)
295295
}
296296

297297

298-
void IntrAbortCoding(IntrState * intr, Obj lvars)
298+
/****************************************************************************
299+
**
300+
*F IntrAbortCoding() . . . . . . . . . . . . . . . . . . . . . abort coding
301+
**
302+
** 'IntrAbortCoding' aborts coding, if it is active.
303+
*/
304+
void IntrAbortCoding(IntrState * intr)
299305
{
300306
if (intr->coding) {
301307
CodeEnd(1);
302308
intr->coding--;
303-
SWITCH_TO_OLD_LVARS(lvars);
304309
}
305310
}
306311

src/intrprtr.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,11 @@ ExecStatus IntrEnd(IntrState * intr, UInt error, Obj * result);
8585

8686
/****************************************************************************
8787
**
88-
*F IntrAbortCoding(<lvars>) . . . . . . . . . . . . . . . . . . abort coding
88+
*F IntrAbortCoding() . . . . . . . . . . . . . . . . . . . . . abort coding
8989
**
90-
** 'IntrAbortCoding' aborts coding, if it is active, and resets the active
91-
** lvars to <lvars>.
90+
** 'IntrAbortCoding' aborts coding, if it is active.
9291
*/
93-
void IntrAbortCoding(IntrState * intr, Obj lvars);
92+
void IntrAbortCoding(IntrState * intr);
9493

9594

9695
/****************************************************************************

src/read.c

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,10 +1187,7 @@ static void ReadFuncExprBody(ReaderState * rs,
11871187
{
11881188
volatile UInt nr; // number of statements
11891189
volatile UInt nrError; // copy of <STATE(NrError)>
1190-
volatile Bag currLVars; // copy of <STATE(CurrLVars)>
11911190

1192-
// remember the current variables in case of an error
1193-
currLVars = STATE(CurrLVars);
11941191
nrError = STATE(NrError);
11951192

11961193
// push the new local variables list
@@ -1230,7 +1227,7 @@ static void ReadFuncExprBody(ReaderState * rs,
12301227
CATCH_ERROR {
12311228
// an error has occurred *after* the 'IntrFuncExprEnd'
12321229
if (nrError == 0)
1233-
IntrAbortCoding(&rs->intr, currLVars);
1230+
IntrAbortCoding(&rs->intr);
12341231
}
12351232

12361233
// pop the new local variables list
@@ -1975,10 +1972,7 @@ static void ReadFor(ReaderState * rs, TypSymbolSet follow)
19751972
{
19761973
volatile UInt nrs; /* number of statements in body */
19771974
volatile UInt nrError; /* copy of <STATE(NrError)> */
1978-
volatile Bag currLVars; /* copy of <STATE(CurrLVars)> */
19791975

1980-
/* remember the current variables in case of an error */
1981-
currLVars = STATE(CurrLVars);
19821976
nrError = STATE(NrError);
19831977

19841978
/* 'for' */
@@ -2018,7 +2012,7 @@ static void ReadFor(ReaderState * rs, TypSymbolSet follow)
20182012
to recover. Otherwise it was probably an error in executing the
20192013
body and we just return */
20202014
if (nrError == 0)
2021-
IntrAbortCoding(&rs->intr, currLVars);
2015+
IntrAbortCoding(&rs->intr);
20222016
}
20232017
}
20242018

@@ -2038,10 +2032,7 @@ static void ReadWhile(ReaderState * rs, TypSymbolSet follow)
20382032
{
20392033
volatile UInt nrs; /* number of statements in body */
20402034
volatile UInt nrError; /* copy of <STATE(NrError)> */
2041-
volatile Bag currLVars; /* copy of <STATE(CurrLVars)> */
20422035

2043-
/* remember the current variables in case of an error */
2044-
currLVars = STATE(CurrLVars);
20452036
nrError = STATE(NrError);
20462037

20472038
/* 'while' <Expr> 'do' */
@@ -2068,7 +2059,7 @@ static void ReadWhile(ReaderState * rs, TypSymbolSet follow)
20682059
to recover. Otherwise it was probably an error in executing the
20692060
body and we just return */
20702061
if (nrError == 0)
2071-
IntrAbortCoding(&rs->intr, currLVars);
2062+
IntrAbortCoding(&rs->intr);
20722063
}
20732064
}
20742065

@@ -2091,13 +2082,10 @@ static void ReadAtomic(ReaderState * rs, TypSymbolSet follow)
20912082
volatile UInt nrs; /* number of statements in body */
20922083
volatile UInt nexprs; /* number of statements in body */
20932084
volatile UInt nrError; /* copy of <STATE(NrError)> */
2094-
volatile Bag currLVars; /* copy of <STATE(CurrLVars)> */
20952085
#ifdef HPCGAP
20962086
volatile int lockSP; /* lock stack */
20972087
#endif
20982088

2099-
/* remember the current variables in case of an error */
2100-
currLVars = STATE(CurrLVars);
21012089
nrError = STATE(NrError);
21022090
#ifdef HPCGAP
21032091
lockSP = RegionLockSP();
@@ -2145,7 +2133,7 @@ static void ReadAtomic(ReaderState * rs, TypSymbolSet follow)
21452133
to recover. Otherwise it was probably an error in executing the
21462134
body and we just return */
21472135
if (nrError == 0)
2148-
IntrAbortCoding(&rs->intr, currLVars);
2136+
IntrAbortCoding(&rs->intr);
21492137
}
21502138
#ifdef HPCGAP
21512139
/* This is a no-op if IntrAtomicEnd(&rs->intr) succeeded, otherwise it restores
@@ -2170,10 +2158,7 @@ static void ReadRepeat(ReaderState * rs, TypSymbolSet follow)
21702158
{
21712159
volatile UInt nrs; /* number of statements in body */
21722160
volatile UInt nrError; /* copy of <STATE(NrError)> */
2173-
volatile Bag currLVars; /* copy of <STATE(CurrLVars)> */
21742161

2175-
/* remember the current variables in case of an error */
2176-
currLVars = STATE(CurrLVars);
21772162
nrError = STATE(NrError);
21782163

21792164
/* 'repeat' */
@@ -2199,7 +2184,7 @@ static void ReadRepeat(ReaderState * rs, TypSymbolSet follow)
21992184
to recover. Otherwise it was probably an error in executing the
22002185
body and we just return */
22012186
if (nrError == 0)
2202-
IntrAbortCoding(&rs->intr, currLVars);
2187+
IntrAbortCoding(&rs->intr);
22032188
}
22042189
}
22052190

@@ -2583,7 +2568,6 @@ UInt ReadEvalFile(Obj *evalResult)
25832568
volatile UInt nr;
25842569
volatile Obj nams;
25852570
volatile Int nloc;
2586-
volatile Bag currLVars; /* copy of <STATE(CurrLVars)> */
25872571
#ifdef HPCGAP
25882572
volatile int lockSP;
25892573
#endif
@@ -2628,8 +2612,6 @@ UInt ReadEvalFile(Obj *evalResult)
26282612
nloc = ReadLocals(rs, 0, nams);
26292613
}
26302614

2631-
currLVars = STATE(CurrLVars);
2632-
26332615
/* fake the 'function ()' */
26342616
IntrFuncExprBegin(&rs->intr, 0, nloc, nams, GetInputLineNumber());
26352617

@@ -2648,7 +2630,7 @@ UInt ReadEvalFile(Obj *evalResult)
26482630
IntrFuncExprEnd(&rs->intr, nr);
26492631
}
26502632
CATCH_ERROR {
2651-
IntrAbortCoding(&rs->intr, currLVars);
2633+
IntrAbortCoding(&rs->intr);
26522634
}
26532635

26542636
/* end the interpreter */

0 commit comments

Comments
 (0)