Skip to content

Commit b937753

Browse files
committed
[MERGE #1921 @MikeHolman] update interpreter thunk count last
Merge pull request #1921 from MikeHolman:thunkbug Should only update count once we know we aren't going to throw exception.
2 parents 0e5f533 + 54061df commit b937753

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/Backend/InterpreterThunkEmitter.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ void InterpreterThunkEmitter::NewThunkBlock()
310310
intptr_t epilogEnd;
311311
#endif
312312

313+
DWORD count = this->thunkCount;
313314
FillBuffer(
314315
this->scriptContext->GetThreadContext(),
315316
this->isAsmInterpreterThunk,
@@ -320,7 +321,7 @@ void InterpreterThunkEmitter::NewThunkBlock()
320321
&pdataStart,
321322
&epilogEnd,
322323
#endif
323-
&this->thunkCount
324+
&count
324325
);
325326

326327
if (!emitBufferManager.CommitReadWriteBufferForInterpreter(allocation, buffer, BlockSize))
@@ -341,6 +342,7 @@ void InterpreterThunkEmitter::NewThunkBlock()
341342
Unused(block);
342343
#endif
343344
this->thunkBuffer = buffer;
345+
this->thunkCount = count;
344346
}
345347

346348
#ifdef ENABLE_OOP_NATIVE_CODEGEN
@@ -355,24 +357,25 @@ void InterpreterThunkEmitter::NewOOPJITThunkBlock()
355357
JITManager::HandleServerCallResult(hr);
356358

357359

358-
this->thunkBuffer = (BYTE*)thunkInfo.thunkBlockAddr;
360+
BYTE* buffer = (BYTE*)thunkInfo.thunkBlockAddr;
359361

360362
if (!CONFIG_FLAG(OOPCFGRegistration))
361363
{
362-
this->scriptContext->GetThreadContext()->SetValidCallTargetForCFG(this->thunkBuffer);
364+
this->scriptContext->GetThreadContext()->SetValidCallTargetForCFG(buffer);
363365
}
364366

365367
// Update object state only at the end when everything has succeeded - and no exceptions can be thrown.
366-
auto block = this->thunkBlocks.PrependNode(allocator, this->thunkBuffer);
368+
auto block = this->thunkBlocks.PrependNode(allocator, buffer);
367369
#if PDATA_ENABLED
368370
void* pdataTable;
369-
PDataManager::RegisterPdata((PRUNTIME_FUNCTION)thunkInfo.pdataTableStart, (ULONG_PTR)this->thunkBuffer, (ULONG_PTR)thunkInfo.epilogEndAddr, &pdataTable);
371+
PDataManager::RegisterPdata((PRUNTIME_FUNCTION)thunkInfo.pdataTableStart, (ULONG_PTR)buffer, (ULONG_PTR)thunkInfo.epilogEndAddr, &pdataTable);
370372
block->SetPdata(pdataTable);
371373
#else
372374
Unused(block);
373375
#endif
374376

375377
this->thunkCount = thunkInfo.thunkCount;
378+
this->thunkBuffer = (BYTE*)thunkInfo.thunkBlockAddr;
376379
}
377380
#endif
378381

0 commit comments

Comments
 (0)