Skip to content

Commit ea2f2fd

Browse files
committed
Fix loops resetting atomicity and warp
1 parent 8862f32 commit ea2f2fd

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/engine/virtualmachine_p.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ VirtualMachinePrivate::~VirtualMachinePrivate()
115115
delete regs;
116116
}
117117

118-
unsigned int *VirtualMachinePrivate::run(unsigned int *pos)
118+
unsigned int *VirtualMachinePrivate::run(unsigned int *pos, bool reset)
119119
{
120120
static const void *dispatch_table[] = {
121121
nullptr,
@@ -186,9 +186,11 @@ unsigned int *VirtualMachinePrivate::run(unsigned int *pos)
186186
unsigned int *loopStart;
187187
unsigned int *loopEnd;
188188
size_t loopCount;
189-
atEnd = false;
190-
atomic = true;
191-
warp = false;
189+
if (reset) {
190+
atEnd = false;
191+
atomic = true;
192+
warp = false;
193+
}
192194
DISPATCH();
193195

194196
do_halt:
@@ -279,7 +281,7 @@ do_repeat_loop_index1 : {
279281
}
280282

281283
do_until_loop:
282-
loopStart = run(pos);
284+
loopStart = run(pos, false);
283285
if (!READ_LAST_REG()->toBool()) {
284286
Loop l;
285287
l.isRepeatLoop = false;
@@ -314,7 +316,7 @@ do_loop_end : {
314316
engine->breakFrame();
315317
return pos - 1;
316318
}
317-
loopStart = run(l.start);
319+
loopStart = run(l.start, false);
318320
if (!READ_LAST_REG()->toBool())
319321
pos = loopStart;
320322
else

src/engine/virtualmachine_p.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct VirtualMachinePrivate
2222
VirtualMachinePrivate(const VirtualMachinePrivate &) = delete;
2323
~VirtualMachinePrivate();
2424

25-
unsigned int *run(unsigned int *pos);
25+
unsigned int *run(unsigned int *pos, bool reset = true);
2626

2727
static const unsigned int instruction_arg_count[];
2828

0 commit comments

Comments
 (0)