MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / CreateThread

Method CreateThread

FEXCore/Source/Interface/Core/Core.cpp:395–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393}
394
395FEXCore::Core::InternalThreadState*
396ContextImpl::CreateThread(uint64_t InitialRIP, uint64_t StackPointer, const FEXCore::Core::CPUState* NewThreadState) {
397 FEXCore::Core::InternalThreadState* Thread = new FEXCore::Core::InternalThreadState {
398 .CTX = this,
399 };
400
401 Thread->CurrentFrame->State.gregs[X86State::REG_RSP] = StackPointer;
402 Thread->CurrentFrame->State.rip = InitialRIP;
403
404 // Copy over the new thread state to the new object
405 if (NewThreadState) {
406 memcpy(&Thread->CurrentFrame->State, NewThreadState, sizeof(FEXCore::Core::CPUState));
407 }
408
409 // Set up the thread manager state
410 Thread->CurrentFrame->Thread = Thread;
411
412 InitializeCompiler(Thread);
413
414 Thread->CurrentFrame->State.DeferredSignalRefCount.Store(0);
415
416 if (Config.BlockJITNaming() || Config.GlobalJITNaming() || Config.LibraryJITNaming()) {
417 // Allocate a JIT symbol buffer only if enabled.
418 Thread->SymbolBuffer = JITSymbols::AllocateBuffer();
419 }
420
421 return Thread;
422}
423
424void ContextImpl::DestroyThread(FEXCore::Core::InternalThreadState* Thread) {
425 FEXCore::Allocator::VirtualProtect(&Thread->InterruptFaultPage, sizeof(Thread->InterruptFaultPage),

Callers 1

CreateMethod · 0.45

Calls 1

StoreMethod · 0.80

Tested by

no test coverage detected