MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / removeCodeBlock

Method removeCodeBlock

source/kernel/kmemory.cpp:498–539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

496void clearJitBlock(const std::vector<void*>& jitOps);
497
498void KMemory::removeCodeBlock(U32 address, DecodedOp* op, bool clearOps) {
499 DecodedOp* blockOp = op->blockStart;
500 U32 blockLen = blockOp->blockLen;
501 U32 blockOpCount = blockOp->blockOpCount;
502 DecodedOp* nextOp = blockOp;
503 KThread* thread = KThread::currentThread();
504 DecodedOp* currentOp = thread->memory->getDecodedOp(thread->cpu->getEipAddress());
505 void* pMem = (void*)blockOp->pfnJitCode;
506 U32 jitLen = 0;
507
508 std::vector<void*> jitOps;
509 for (U32 i = 0; i < blockOpCount; i++) {
510 if (nextOp->blockStart != blockOp && nextOp->inst != Done) {
511 kpanic("KMemory::removeCodeBlock nextOp->blockStart");
512 }
513 nextOp->blockStart = nullptr;
514 nextOp->blockOpCount = 0;
515 nextOp->blockLen = 0;
516 nextOp->runCount = 0;
517 nextOp->pfn = NormalCPU::getFunctionForOp(nextOp);
518 nextOp->flags &= ~OP_FLAG_JIT;
519 if (nextOp->pfnJitCode) {
520 jitOps.push_back(nextOp->pfnJitCode);
521 }
522 jitLen += nextOp->jitLen;
523 nextOp->pfnJitCode = nullptr;
524 nextOp->jitLen = 0;
525 nextOp = nextOp->next;
526 }
527 if (jitOps.size()) {
528 clearJitBlock(jitOps);
529 }
530 if (clearOps) {
531 data->opCache.remove(address, blockLen, false);
532 }
533 if (pMem) {
534 data->codeMemory.free(pMem);
535 }
536#ifdef _DEBUG1
537 klog_fmt("removed active code block eip = %x - %x host %llx - %llx", thread->cpu->getEipAddress(), thread->cpu->getEipAddress() + blockLen, (U64)pMem, (U64)pMem + jitLen);
538#endif
539}
540#endif
541
542#if defined(BOXEDWINE_JIT)

Callers 2

handleAccessExceptionMethod · 0.80
opCallbackFunction · 0.80

Calls 9

kpanicFunction · 0.85
klog_fmtFunction · 0.85
getDecodedOpMethod · 0.80
getEipAddressMethod · 0.80
clearJitBlockFunction · 0.50
push_backMethod · 0.45
sizeMethod · 0.45
removeMethod · 0.45
freeMethod · 0.45

Tested by

no test coverage detected