mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Fix an error in calculation of ExecutionPause length for Code Cache
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
This commit is contained in:
parent
97e698db34
commit
f77f28fa84
3 changed files with 29 additions and 15 deletions
|
|
@ -613,6 +613,18 @@ void CodeCacheWriter::storeByteCodeStream(ByteCodeBlock* block)
|
|||
break;
|
||||
}
|
||||
case GetObjectPreComputedCaseSimpleInlineCacheOpcode:
|
||||
case ExecutionPauseOpcode: {
|
||||
// add tail data length
|
||||
ExecutionPause* bc = static_cast<ExecutionPause*>(currentCode);
|
||||
if (bc->m_reason == ExecutionPause::Reason::Yield) {
|
||||
code += bc->m_yieldData.m_tailDataLength;
|
||||
} else if (bc->m_reason == ExecutionPause::Reason::Await) {
|
||||
code += bc->m_awaitData.m_tailDataLength;
|
||||
} else if (bc->m_reason == ExecutionPause::Reason::GeneratorsInitialize) {
|
||||
code += bc->m_asyncGeneratorInitializeData.m_tailDataLength;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ExecutionResumeOpcode:
|
||||
RELEASE_ASSERT_NOT_REACHED();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -317,15 +317,23 @@ void ByteCodeBlock::finalizeLexicalBlock(ByteCodeGenerateContext* context, const
|
|||
|
||||
void ByteCodeBlock::pushPauseStatementExtraData(ByteCodeGenerateContext* context)
|
||||
{
|
||||
auto iter = context->m_recursiveStatementStack.begin();
|
||||
while (iter != context->m_recursiveStatementStack.end()) {
|
||||
size_t pos = m_code.size();
|
||||
m_code.resizeWithUninitializedValues(pos + sizeof(ByteCodeGenerateContext::RecursiveStatementKind));
|
||||
new (m_code.data() + pos) size_t(iter->first);
|
||||
pos = m_code.size();
|
||||
m_code.resizeWithUninitializedValues(pos + sizeof(size_t));
|
||||
new (m_code.data() + pos) size_t(iter->second);
|
||||
iter++;
|
||||
if (context->m_recursiveStatementStack.size()) {
|
||||
size_t startSize = m_code.size();
|
||||
size_t tailDataLength = context->m_recursiveStatementStack.size() * (sizeof(ByteCodeGenerateContext::RecursiveStatementKind) + sizeof(size_t));
|
||||
m_code.resizeWithUninitializedValues(startSize + tailDataLength);
|
||||
|
||||
auto* codeAddr = m_code.data();
|
||||
auto iter = context->m_recursiveStatementStack.begin();
|
||||
size_t pos = startSize;
|
||||
while (iter != context->m_recursiveStatementStack.end()) {
|
||||
new (codeAddr + pos) size_t(iter->first);
|
||||
pos += sizeof(ByteCodeGenerateContext::RecursiveStatementKind);
|
||||
new (codeAddr + pos) size_t(iter->second);
|
||||
pos += sizeof(size_t);
|
||||
iter++;
|
||||
}
|
||||
|
||||
ASSERT(tailDataLength == (pos - startSize));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -419,12 +419,6 @@ ScriptParser::InitializeScriptResult ScriptParser::initializeScript(String* orig
|
|||
if (LIKELY(needByteCodeGeneration)) {
|
||||
try {
|
||||
#if defined(ENABLE_CODE_CACHE)
|
||||
// give up if there is top-level-await
|
||||
if (topCodeBlock->isAsync()) {
|
||||
cacheable = false;
|
||||
deleteCodeBlockCacheInfo();
|
||||
}
|
||||
|
||||
// Store cache
|
||||
if (cacheable) {
|
||||
codeCache->prepareCacheWriting(srcHash);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue