Implement PH7_VmMemoryError();
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
90ab131ce8
commit
da198fcb44
23
engine/vm.c
23
engine/vm.c
|
@ -1885,6 +1885,29 @@ static sxi32 VmCallErrorHandler(ph7_vm *pVm, SyBlob *pMsg) {
|
|||
}
|
||||
return rc;
|
||||
}
|
||||
/*
|
||||
* Throw an Out-Of-Memory (OOM) fatal error and invoke the supplied VM output
|
||||
* consumer callback. Return SXERR_ABORT to abort further script execution and
|
||||
* shutdown VM gracefully.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_VmMemoryError(
|
||||
ph7_vm *pVm /* Target VM */
|
||||
){
|
||||
SyBlob sWorker;
|
||||
if(pVm->bErrReport) {
|
||||
/* Report OOM problem */
|
||||
VmInstr *pInstr = SySetPeek(&pVm->aInstrSet);
|
||||
SyBlobInit(&sWorker, &pVm->sAllocator);
|
||||
SyBlobFormat(&sWorker, "Fatal: PH7 Engine is running out of memory. Allocated %u bytes in %z:%u",
|
||||
pVm->sAllocator.pHeap->nSize, pInstr->pFile, pInstr->iLine);
|
||||
VmCallErrorHandler(&(*pVm), &sWorker);
|
||||
}
|
||||
/* Set exit code to 255 */
|
||||
pVm->iExitStatus = 255;
|
||||
/* There is no need to release VM. The script execution will automatically
|
||||
* get aborted and VM will be properly shut down when returned SXERR_ABORT */
|
||||
return SXERR_ABORT;
|
||||
}
|
||||
/*
|
||||
* Throw a run-time error and invoke the supplied VM output consumer callback.
|
||||
* Refer to the implementation of [ph7_context_throw_error()] for additional
|
||||
|
|
Loading…
Reference in New Issue