diff --git a/src/parser/ScriptParser.cpp b/src/parser/ScriptParser.cpp index ac789866f..ee2289f0f 100644 --- a/src/parser/ScriptParser.cpp +++ b/src/parser/ScriptParser.cpp @@ -419,6 +419,12 @@ 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); diff --git a/src/runtime/ExecutionPauser.cpp b/src/runtime/ExecutionPauser.cpp index 60857be6c..eb68f4264 100644 --- a/src/runtime/ExecutionPauser.cpp +++ b/src/runtime/ExecutionPauser.cpp @@ -74,43 +74,45 @@ ExecutionPauser::ExecutionPauser(ExecutionState& state, Object* sourceObject, Ex { } -class ExecutionPauserExecutionStateParentBinder { -public: - ExecutionPauserExecutionStateParentBinder(ExecutionState& state, ExecutionState* originalState) - : m_originalState(originalState) - { - m_oldParent = m_originalState->parent(); - - - ExecutionState* pstate = m_originalState; - while (pstate) { - if (pstate == &state) { - // AsyncGeneratorObject::asyncGeneratorResolve can make loop - return; + +Value ExecutionPauser::start(ExecutionState& state, ExecutionPauser* self, Object* source, const Value& resumeValue, bool isAbruptReturn, bool isAbruptThrow, StartFrom from) +{ + class ExecutionPauserExecutionStateParentAndStackLimitBinder { + public: + ExecutionPauserExecutionStateParentAndStackLimitBinder(ExecutionState& state, ExecutionState* originalState) + : m_originalState(originalState) + { + m_oldParent = m_originalState->parent(); + + ExecutionState* pstate = m_originalState; + m_originalState->m_stackLimit = state.context()->vmInstance()->stackLimit(); + while (pstate) { + if (pstate == &state) { + // AsyncGeneratorObject::asyncGeneratorResolve can make loop + return; + } + pstate = pstate->parent(); } - pstate = pstate->parent(); - } - m_originalState->setParent(&state); - } + m_originalState->setParent(&state); + } - ~ExecutionPauserExecutionStateParentBinder() - { - m_originalState->setParent(m_oldParent); - } + ~ExecutionPauserExecutionStateParentAndStackLimitBinder() + { + m_originalState->setParent(m_oldParent); + m_originalState->m_stackLimit = 0; + } - ExecutionState* m_originalState; - ExecutionState* m_oldParent; -}; + ExecutionState* m_originalState; + ExecutionState* m_oldParent; + }; -Value ExecutionPauser::start(ExecutionState& state, ExecutionPauser* self, Object* source, const Value& resumeValue, bool isAbruptReturn, bool isAbruptThrow, StartFrom from) -{ ExecutionState* originalState = self->m_executionState; while (!originalState->pauseSource()) { originalState = originalState->parent(); } - ExecutionPauserExecutionStateParentBinder parentBinder(state, originalState); + ExecutionPauserExecutionStateParentAndStackLimitBinder parentBinder(state, originalState); if (self->m_resumeValueIndex != REGISTER_LIMIT) { self->m_registerFile[self->m_resumeValueIndex] = resumeValue; diff --git a/src/runtime/ExecutionState.cpp b/src/runtime/ExecutionState.cpp index c530056ce..c9382e236 100644 --- a/src/runtime/ExecutionState.cpp +++ b/src/runtime/ExecutionState.cpp @@ -329,7 +329,11 @@ bool ExecutionState::inPauserScope() auto env = state->lexicalEnvironment(); auto record = env->record(); if (record->isGlobalEnvironmentRecord() || record->isModuleEnvironmentRecord()) { - return state->hasRareData() && state->rareData()->m_pauseSource; + // class variable initializer can call {GlobalEnvironment, ModuleEnvironment} + // so we should check above of {GlobalEnvironment, ModuleEnvironment} + if (state->hasRareData() && state->rareData()->m_pauseSource) { + return true; + } } else if (record->isDeclarativeEnvironmentRecord() && record->asDeclarativeEnvironmentRecord()->isFunctionEnvironmentRecord()) { return record->asDeclarativeEnvironmentRecord()->asFunctionEnvironmentRecord()->functionObject()->isScriptGeneratorFunctionObject() || record->asDeclarativeEnvironmentRecord()->asFunctionEnvironmentRecord()->functionObject()->isScriptAsyncFunctionObject() diff --git a/test/vendortest b/test/vendortest index 524b0cb6c..cc5a9dc1a 160000 --- a/test/vendortest +++ b/test/vendortest @@ -1 +1 @@ -Subproject commit 524b0cb6c2536fc2ff9b08abf879a1f8d5f1f67d +Subproject commit cc5a9dc1a32b9b8231d4bdb0c4dcb196dae5f862