From ec936d57e4dc7b9c24b5e1e9ef182523e3948ab3 Mon Sep 17 00:00:00 2001 From: wengchangcheng Date: Tue, 12 Apr 2022 23:57:04 +0800 Subject: [PATCH] Descriptor: fix stack overflow details: 1. increase stack size 2. modify check stack overflow error issue: https://gitee.com/openharmony/ark_js_runtime/issues/I52EUX Signed-off-by: wengchangcheng Change-Id: Ic5a3cf880288de8eb98b081f839679b8acef3026 --- ecmascript/interpreter/interpreter-inl.h | 6 ++++-- ecmascript/interpreter/interpreter_assembly.cpp | 6 ++++-- ecmascript/js_thread.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ecmascript/interpreter/interpreter-inl.h b/ecmascript/interpreter/interpreter-inl.h index 9a738af112..37e468bbcd 100644 --- a/ecmascript/interpreter/interpreter-inl.h +++ b/ecmascript/interpreter/interpreter-inl.h @@ -381,7 +381,8 @@ JSTaggedValue EcmaInterpreter::ExecuteNative(EcmaRuntimeCallInfo *info) JSTaggedType *sp = const_cast(thread->GetCurrentSPFrame()); int32_t actualNumArgs = info->GetArgsNumber(); JSTaggedType *newSp = sp - INTERPRETER_ENTRY_FRAME_STATE_SIZE - 1 - actualNumArgs - RESERVED_CALL_ARGCOUNT; - if (thread->DoStackOverflowCheck(newSp) || thread->HasPendingException()) { + if (thread->DoStackOverflowCheck(newSp - actualNumArgs - RESERVED_CALL_ARGCOUNT) || + thread->HasPendingException()) { return JSTaggedValue::Undefined(); } for (int i = actualNumArgs - 1; i >= 0; i--) { @@ -442,7 +443,8 @@ JSTaggedValue EcmaInterpreter::Execute(EcmaRuntimeCallInfo *info) int32_t actualNumArgs = info->GetArgsNumber(); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) newSp = newSp - INTERPRETER_ENTRY_FRAME_STATE_SIZE - 1 - actualNumArgs - RESERVED_CALL_ARGCOUNT; - if (thread->DoStackOverflowCheck(newSp) || thread->HasPendingException()) { + if (thread->DoStackOverflowCheck(newSp - actualNumArgs - RESERVED_CALL_ARGCOUNT) || + thread->HasPendingException()) { return JSTaggedValue::Undefined(); } diff --git a/ecmascript/interpreter/interpreter_assembly.cpp b/ecmascript/interpreter/interpreter_assembly.cpp index 4cfec84368..a108034c1b 100644 --- a/ecmascript/interpreter/interpreter_assembly.cpp +++ b/ecmascript/interpreter/interpreter_assembly.cpp @@ -455,7 +455,8 @@ JSTaggedValue InterpreterAssembly::ExecuteNative(EcmaRuntimeCallInfo *info) JSTaggedType *sp = const_cast(thread->GetCurrentSPFrame()); int32_t actualNumArgs = info->GetArgsNumber(); JSTaggedType *newSp = sp - INTERPRETER_ENTRY_FRAME_STATE_SIZE - 1 - actualNumArgs - RESERVED_CALL_ARGCOUNT; - if (thread->DoStackOverflowCheck(newSp) || thread->HasPendingException()) { + if (thread->DoStackOverflowCheck(newSp - actualNumArgs - RESERVED_CALL_ARGCOUNT) || + thread->HasPendingException()) { return JSTaggedValue::Undefined(); } for (int i = actualNumArgs - 1; i >= 0; i--) { @@ -515,7 +516,8 @@ JSTaggedValue InterpreterAssembly::Execute(EcmaRuntimeCallInfo *info) int32_t actualNumArgs = info->GetArgsNumber(); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) newSp = newSp - INTERPRETER_ENTRY_FRAME_STATE_SIZE - 1 - actualNumArgs - RESERVED_CALL_ARGCOUNT; - if (thread->DoStackOverflowCheck(newSp) || thread->HasPendingException()) { + if (thread->DoStackOverflowCheck(newSp - actualNumArgs - RESERVED_CALL_ARGCOUNT) || + thread->HasPendingException()) { return JSTaggedValue::Undefined(); } diff --git a/ecmascript/js_thread.h b/ecmascript/js_thread.h index 9dd82ba834..a9dbd11931 100644 --- a/ecmascript/js_thread.h +++ b/ecmascript/js_thread.h @@ -471,7 +471,7 @@ private: void DumpStack() DUMP_API_ATTR; - static constexpr uint32_t MAX_STACK_SIZE = 128 * 1024; + static constexpr uint32_t MAX_STACK_SIZE = 512 * 1024; static const uint32_t NODE_BLOCK_SIZE_LOG2 = 10; static const uint32_t NODE_BLOCK_SIZE = 1U << NODE_BLOCK_SIZE_LOG2; static constexpr int32_t MIN_HANDLE_STORAGE_SIZE = 2; -- Gitee