From 55d3c1771865322247208d8c72d0c691330a9f15 Mon Sep 17 00:00:00 2001 From: Seonghyun Kim Date: Tue, 10 Sep 2024 12:59:18 +0900 Subject: [PATCH] ByteCodeBlock of top CodeBlock should not be removed from VMInstance * If there is GC jobs from Script init to Script execution, the ByteCode can be remove by ByteCode prunning. this is wrong Signed-off-by: Seonghyun Kim --- src/runtime/VMInstance.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/runtime/VMInstance.cpp b/src/runtime/VMInstance.cpp index 7e5146404..2fd3772cb 100644 --- a/src/runtime/VMInstance.cpp +++ b/src/runtime/VMInstance.cpp @@ -215,7 +215,10 @@ void vmMarkStartCallback(void* data) auto& v = self->compiledByteCodeBlocks(); for (size_t i = 0; i < v.size(); i++) { - v[i]->m_codeBlock->setByteCodeBlock(nullptr); + // ByteCodeBlock of top CodeBlock should be remove by Script class + if (v[i]->m_codeBlock->parent()) { + v[i]->m_codeBlock->setByteCodeBlock(nullptr); + } } } #endif @@ -245,8 +248,10 @@ void vmReclaimEndCallback(void* data) currentCodeSizeTotal = 0; auto& v = self->compiledByteCodeBlocks(); for (size_t i = 0; i < v.size(); i++) { - v[i]->m_codeBlock->setByteCodeBlock(v[i]); - ASSERT(v[i]->m_codeBlock->byteCodeBlock() == v[i]); + if (v[i]->m_codeBlock->parent()) { + v[i]->m_codeBlock->setByteCodeBlock(v[i]); + ASSERT(v[i]->m_codeBlock->byteCodeBlock() == v[i]); + } currentCodeSizeTotal += v[i]->memoryAllocatedSize(); }