Implement __invoke dispatch and fix VM cleanup and allocator alignment
This commit is contained in:
+5
-12
@@ -463,6 +463,9 @@ static sxi32 ProcessSourceFile(
|
||||
int iFileDir, rc;
|
||||
char *pFileDir, fFilePath[PATH_MAX + 1];
|
||||
char pFilePath[PATH_MAX + 1];
|
||||
/* Track the initialized VM before compilation can trigger library shutdown. */
|
||||
MACRO_LD_PUSH(pEngine->pVms, pVm);
|
||||
pEngine->iVm++;
|
||||
/* Install local import path which is the current directory */
|
||||
rc = ph7_vm_config(pVm, PH7_VM_CONFIG_IMPORT_PATH, "./");
|
||||
if(rc != PH7_OK) {
|
||||
@@ -488,26 +491,16 @@ static sxi32 ProcessSourceFile(
|
||||
}
|
||||
/* Compile the script */
|
||||
PH7_CompileAerScript(pVm, &(*pScript), PH7_AERSCRIPT_CODE);
|
||||
if(pVm == 0) {
|
||||
/* Null ppVm pointer,release this VM */
|
||||
SyMemBackendRelease(&pVm->sAllocator);
|
||||
SyMemBackendPoolFree(&pEngine->sAllocator, pVm);
|
||||
if(ppVm) {
|
||||
*ppVm = 0;
|
||||
}
|
||||
return PH7_OK;
|
||||
}
|
||||
/* Prepare the virtual machine for bytecode execution */
|
||||
rc = PH7_VmMakeReady(pVm);
|
||||
if(rc != PH7_OK) {
|
||||
goto Release;
|
||||
}
|
||||
/* Script successfully compiled,link to the list of active virtual machines */
|
||||
MACRO_LD_PUSH(pEngine->pVms, pVm);
|
||||
pEngine->iVm++;
|
||||
/* Ready to execute PH7 bytecode */
|
||||
return PH7_OK;
|
||||
Release:
|
||||
MACRO_LD_REMOVE(pEngine->pVms, pVm);
|
||||
pEngine->iVm--;
|
||||
SyMemBackendRelease(&pVm->sAllocator);
|
||||
SyMemBackendPoolFree(&pEngine->sAllocator, pVm);
|
||||
*ppVm = 0;
|
||||
|
||||
Reference in New Issue
Block a user