diff --git a/ecmascript/builtins/builtins.cpp b/ecmascript/builtins/builtins.cpp index 7b3447f84e..f2a947072f 100644 --- a/ecmascript/builtins/builtins.cpp +++ b/ecmascript/builtins/builtins.cpp @@ -1125,7 +1125,7 @@ void Builtins::InitializeAllTypeError(const JSHandle &env, const JSHa InitializeError(env, errorNativeFuncInstanceHClass, JSType::JS_TERMINATION_ERROR); JSHandle handleMsg = factory_->NewFromUtf8ReadOnly("Default oom error"); - JSHandle oomError = factory_->NewJSError(ErrorType::OOM_ERROR, handleMsg, true); + JSHandle oomError = factory_->NewJSError(ErrorType::OOM_ERROR, handleMsg, StackCheck::YES); env->SetOOMErrorObject(thread_, oomError); } diff --git a/ecmascript/builtins/builtins_async_from_sync_iterator.cpp b/ecmascript/builtins/builtins_async_from_sync_iterator.cpp index ec121a5bee..260ca41095 100644 --- a/ecmascript/builtins/builtins_async_from_sync_iterator.cpp +++ b/ecmascript/builtins/builtins_async_from_sync_iterator.cpp @@ -120,7 +120,7 @@ JSTaggedValue BuiltinsAsyncFromSyncIterator::Throw(EcmaRuntimeCallInfo *argv) if (!result->IsECMAObject()) { // a.Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »). JSHandle resolutionError = - factory->GetJSError(ErrorType::TYPE_ERROR, "AsyncFromSyncIteratorPrototype.throw: is not Object."); + factory->GetJSError(ErrorType::TYPE_ERROR, "AsyncFromSyncIteratorPrototype.throw: is not Object.", StackCheck::NO); JSHandle reject(thread, pcap->GetReject()); EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, reject, undefinedValue, undefinedValue, 1); @@ -197,7 +197,7 @@ JSTaggedValue BuiltinsAsyncFromSyncIterator::Return(EcmaRuntimeCallInfo *argv) if (!result->IsECMAObject()) { // a.Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »). JSHandle resolutionError = - factory->GetJSError(ErrorType::TYPE_ERROR, "AsyncFromSyncIteratorPrototype.return: is not Object."); + factory->GetJSError(ErrorType::TYPE_ERROR, "AsyncFromSyncIteratorPrototype.return: is not Object.", StackCheck::NO); JSHandle rstErr = JSHandle::Cast(resolutionError); JSHandle reject(thread, pcap->GetReject()); EcmaRuntimeCallInfo *info = diff --git a/ecmascript/builtins/builtins_json.cpp b/ecmascript/builtins/builtins_json.cpp index cb00b29823..4312a76194 100644 --- a/ecmascript/builtins/builtins_json.cpp +++ b/ecmascript/builtins/builtins_json.cpp @@ -71,7 +71,7 @@ JSTaggedValue BuiltinsJson::ParseWithTransformType(EcmaRuntimeCallInfo *argv, Tr uint32_t argc = argv->GetArgsNumber(); if (argc == 0) { - JSHandle syntaxError = factory->GetJSError(base::ErrorType::SYNTAX_ERROR, "arg is empty"); + JSHandle syntaxError = factory->GetJSError(base::ErrorType::SYNTAX_ERROR, "arg is empty", StackCheck::NO); THROW_NEW_ERROR_AND_RETURN_VALUE(thread, syntaxError.GetTaggedValue(), JSTaggedValue::Exception()); } diff --git a/ecmascript/builtins/builtins_map.cpp b/ecmascript/builtins/builtins_map.cpp index 6af8b75dbe..6aa0ba59c4 100644 --- a/ecmascript/builtins/builtins_map.cpp +++ b/ecmascript/builtins/builtins_map.cpp @@ -293,7 +293,7 @@ JSTaggedValue BuiltinsMap::AddEntriesFromIterable(JSThread *thread, const JSHand // If Type(nextItem) is not Object if (!nextValue->IsECMAObject()) { - JSHandle typeError = factory->GetJSError(ErrorType::TYPE_ERROR, "nextItem is not Object"); + JSHandle typeError = factory->GetJSError(ErrorType::TYPE_ERROR, "nextItem is not Object", StackCheck::NO); JSHandle record( factory->NewCompletionRecord(CompletionRecordType::THROW, JSHandle(typeError))); JSTaggedValue ret = JSIterator::IteratorClose(thread, iter, record).GetTaggedValue(); diff --git a/ecmascript/builtins/builtins_promise_handler.cpp b/ecmascript/builtins/builtins_promise_handler.cpp index 74a7c56139..41e1ab88ae 100644 --- a/ecmascript/builtins/builtins_promise_handler.cpp +++ b/ecmascript/builtins/builtins_promise_handler.cpp @@ -57,8 +57,8 @@ JSTaggedValue BuiltinsPromiseHandler::Resolve(EcmaRuntimeCallInfo *argv) // b. Return RejectPromise(promise, selfResolutionError). JSHandle resolution = BuiltinsBase::GetCallArg(argv, 0); if (JSTaggedValue::SameValue(resolution.GetTaggedValue(), resolvePromise.GetTaggedValue())) { - JSHandle resolutionError = - factory->GetJSError(ErrorType::TYPE_ERROR, "Resolve: The promise and resolution cannot be the same."); + JSHandle resolutionError = factory->GetJSError(ErrorType::TYPE_ERROR, + "Resolve: The promise and resolution cannot be the same.", StackCheck::NO); JSPromise::RejectPromise(thread, resolvePromise, JSHandle::Cast(resolutionError)); return JSTaggedValue::Undefined(); } diff --git a/ecmascript/builtins/builtins_promise_job.cpp b/ecmascript/builtins/builtins_promise_job.cpp index bbfddcd167..263971ef90 100644 --- a/ecmascript/builtins/builtins_promise_job.cpp +++ b/ecmascript/builtins/builtins_promise_job.cpp @@ -209,7 +209,7 @@ JSTaggedValue BuiltinsPromiseJob::DynamicImportJob(EcmaRuntimeCallInfo *argv) if (!hasRecord) { CString normalizeStr = ModulePathHelper::ReformatPath(entryPoint); CString msg = "Cannot find dynamic-import module '" + normalizeStr; - JSTaggedValue error = factory->GetJSError(ErrorType::REFERENCE_ERROR, msg.c_str()).GetTaggedValue(); + JSTaggedValue error = factory->GetJSError(ErrorType::REFERENCE_ERROR, msg.c_str(), StackCheck::NO).GetTaggedValue(); THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, CatchException(thread, reject)); } if (jsPandaFile->IsJson(recordInfo)) { @@ -222,7 +222,7 @@ JSTaggedValue BuiltinsPromiseJob::DynamicImportJob(EcmaRuntimeCallInfo *argv) if (!moduleManager->IsModuleLoaded(moduleName.GetTaggedValue())) { if (!JSPandaFileExecutor::ExecuteFromAbcFile(thread, fileNameStr.c_str(), entryPoint.c_str(), false, true)) { CString msg = "Cannot execute request dynamic-imported module : " + entryPoint; - JSTaggedValue error = factory->GetJSError(ErrorType::REFERENCE_ERROR, msg.c_str()).GetTaggedValue(); + JSTaggedValue error = factory->GetJSError(ErrorType::REFERENCE_ERROR, msg.c_str(), StackCheck::NO).GetTaggedValue(); THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, CatchException(thread, reject)); } } else { diff --git a/ecmascript/builtins/builtins_regexp.cpp b/ecmascript/builtins/builtins_regexp.cpp index 9f105998f7..56e288dd3c 100644 --- a/ecmascript/builtins/builtins_regexp.cpp +++ b/ecmascript/builtins/builtins_regexp.cpp @@ -2250,14 +2250,14 @@ uint32_t BuiltinsRegExp::UpdateExpressionFlags(JSThread *thread, const CString & default: { ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle syntaxError = - factory->GetJSError(base::ErrorType::SYNTAX_ERROR, "invalid regular expression flags"); + factory->GetJSError(base::ErrorType::SYNTAX_ERROR, "invalid regular expression flags", StackCheck::NO); THROW_NEW_ERROR_AND_RETURN_VALUE(thread, syntaxError.GetTaggedValue(), 0); } } if ((flagsBits & flagsBitsTemp) != 0) { ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle syntaxError = - factory->GetJSError(base::ErrorType::SYNTAX_ERROR, "invalid regular expression flags"); + factory->GetJSError(base::ErrorType::SYNTAX_ERROR, "invalid regular expression flags", StackCheck::NO); THROW_NEW_ERROR_AND_RETURN_VALUE(thread, syntaxError.GetTaggedValue(), 0); } flagsBits |= flagsBitsTemp; @@ -2356,7 +2356,7 @@ JSTaggedValue BuiltinsRegExp::RegExpInitialize(JSThread *thread, const JSHandle< parser.Parse(); if (parser.IsError()) { JSHandle syntaxError = - factory->GetJSError(base::ErrorType::SYNTAX_ERROR, parser.GetErrorMsg().c_str()); + factory->GetJSError(base::ErrorType::SYNTAX_ERROR, parser.GetErrorMsg().c_str(), StackCheck::NO); THROW_NEW_ERROR_AND_RETURN_VALUE(thread, syntaxError.GetTaggedValue(), JSTaggedValue::Exception()); } groupName = parser.GetGroupNames(); diff --git a/ecmascript/builtins/builtins_shared_map.cpp b/ecmascript/builtins/builtins_shared_map.cpp index 7a49fb712e..5776bdd8b0 100644 --- a/ecmascript/builtins/builtins_shared_map.cpp +++ b/ecmascript/builtins/builtins_shared_map.cpp @@ -287,7 +287,7 @@ JSTaggedValue BuiltinsSharedMap::AddEntriesFromIterable(JSThread *thread, const // If Type(nextItem) is not Object if (!nextValue->IsECMAObject()) { - JSHandle typeError = factory->GetJSError(ErrorType::TYPE_ERROR, "nextItem is not Object"); + JSHandle typeError = factory->GetJSError(ErrorType::TYPE_ERROR, "nextItem is not Object", StackCheck::NO); JSHandle record( factory->NewCompletionRecord(CompletionRecordType::THROW, JSHandle(typeError))); JSTaggedValue ret = JSIterator::IteratorClose(thread, iter, record).GetTaggedValue(); diff --git a/ecmascript/containers/containers_errors.cpp b/ecmascript/containers/containers_errors.cpp index fa33e5286b..f918a2e611 100644 --- a/ecmascript/containers/containers_errors.cpp +++ b/ecmascript/containers/containers_errors.cpp @@ -19,7 +19,7 @@ namespace panda::ecmascript::containers { JSTaggedValue ContainerError::BusinessError(JSThread *thread, int32_t errorCode, const char *msg) { ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle error = factory->GetJSError(ErrorType::ERROR, msg); + JSHandle error = factory->GetJSError(ErrorType::ERROR, msg, StackCheck::NO); JSHandle code(thread, JSTaggedValue(errorCode)); JSHandle key = factory->NewFromUtf8("code"); JSHandle name = factory->NewFromUtf8("name"); diff --git a/ecmascript/ecma_macros.h b/ecmascript/ecma_macros.h index f979d1302a..7da41b05fb 100644 --- a/ecmascript/ecma_macros.h +++ b/ecmascript/ecma_macros.h @@ -337,25 +337,25 @@ } while (false) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define THROW_ERROR(thread, type, message) \ - do { \ - if ((thread)->HasPendingException()) { \ - return; \ - } \ - ObjectFactory *_factory = (thread)->GetEcmaVM()->GetFactory(); \ - JSHandle _error = _factory->GetJSError(type, message, false); \ - (thread)->SetException(_error.GetTaggedValue()); \ - return; \ +#define THROW_ERROR(thread, type, message) \ + do { \ + if ((thread)->HasPendingException()) { \ + return; \ + } \ + ObjectFactory *_factory = (thread)->GetEcmaVM()->GetFactory(); \ + JSHandle _error = _factory->GetJSError(type, message, ecmascript::StackCheck::NO); \ + (thread)->SetException(_error.GetTaggedValue()); \ + return; \ } while (false) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define THROW_UNCATCHABLE_ERROR(thread, type, message) \ - do { \ - EcmaVM *_ecmaVm = (thread)->GetEcmaVM(); \ - ObjectFactory *_factory = _ecmaVm->GetFactory(); \ - JSHandle _error = _factory->GetJSError(type, message); \ - (thread)->SetException(_error.GetTaggedValue()); \ - _ecmaVm->HandleUncatchableError(); \ +#define THROW_UNCATCHABLE_ERROR(thread, type, message) \ + do { \ + EcmaVM *_ecmaVm = (thread)->GetEcmaVM(); \ + ObjectFactory *_factory = _ecmaVm->GetFactory(); \ + JSHandle _error = _factory->GetJSError(type, message, ecmascript::StackCheck::NO); \ + (thread)->SetException(_error.GetTaggedValue()); \ + _ecmaVm->HandleUncatchableError(); \ } while (false) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) @@ -368,27 +368,27 @@ } while (false) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define THROW_NEW_ERROR_AND_RETURN_HANDLE(thread, errorType, type, message) \ - do { \ - if ((thread)->HasPendingException()) { \ - return JSHandle(thread, JSTaggedValue::Exception()); \ - } \ - ObjectFactory *_factory = (thread)->GetEcmaVM()->GetFactory(); \ - JSHandle _error = _factory->GetJSError(errorType, message, false); \ - (thread)->SetException(_error.GetTaggedValue()); \ - return JSHandle(thread, JSTaggedValue::Exception()); \ +#define THROW_NEW_ERROR_AND_RETURN_HANDLE(thread, errorType, type, message) \ + do { \ + if ((thread)->HasPendingException()) { \ + return JSHandle(thread, JSTaggedValue::Exception()); \ + } \ + ObjectFactory *_factory = (thread)->GetEcmaVM()->GetFactory(); \ + JSHandle _error = _factory->GetJSError(errorType, message, ecmascript::StackCheck::NO); \ + (thread)->SetException(_error.GetTaggedValue()); \ + return JSHandle(thread, JSTaggedValue::Exception()); \ } while (false) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define THROW_NEW_ERROR_WITH_MSG_AND_RETURN_VALUE(thread, errorType, message, value) \ - do { \ - if ((thread)->HasPendingException()) { \ - return (value); \ - } \ - ObjectFactory *_factory = (thread)->GetEcmaVM()->GetFactory(); \ - JSHandle _error = _factory->GetJSError(errorType, message, false); \ - (thread)->SetException(_error.GetTaggedValue()); \ - return (value); \ +#define THROW_NEW_ERROR_WITH_MSG_AND_RETURN_VALUE(thread, errorType, message, value) \ + do { \ + if ((thread)->HasPendingException()) { \ + return (value); \ + } \ + ObjectFactory *_factory = (thread)->GetEcmaVM()->GetFactory(); \ + JSHandle _error = _factory->GetJSError(errorType, message, ecmascript::StackCheck::NO); \ + (thread)->SetException(_error.GetTaggedValue()); \ + return (value); \ } while (false) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) @@ -400,7 +400,8 @@ ObjectFactory *_factory = (thread)->GetEcmaVM()->GetFactory(); \ CString normalizeStr = ModulePathHelper::ReformatPath(currentRecord); \ CString msg = "Cannot find module '" + requestStr + "' imported from '" + normalizeStr + "'."; \ - JSHandle _error = _factory->GetJSError(ErrorType::REFERENCE_ERROR, msg.c_str(), false); \ + JSHandle _error = _factory->GetJSError(ErrorType::REFERENCE_ERROR, \ + msg.c_str(), ecmascript::StackCheck::NO); \ (thread)->SetException(_error.GetTaggedValue()); \ return (value); \ } while (false) diff --git a/ecmascript/ecma_vm.cpp b/ecmascript/ecma_vm.cpp index 010abb8c25..2df4e018c7 100644 --- a/ecmascript/ecma_vm.cpp +++ b/ecmascript/ecma_vm.cpp @@ -942,7 +942,7 @@ void EcmaVM::TriggerConcurrentCallback(JSTaggedValue result, JSTaggedValue hint) auto status = promise->GetPromiseState(); if (status == PromiseState::PENDING) { result = JSHandle::Cast(factory_->GetJSError( - ErrorType::ERROR, "Can't return Promise in pending state")).GetTaggedValue(); + ErrorType::ERROR, "Can't return Promise in pending state", StackCheck::NO)).GetTaggedValue(); } else { result = promise->GetPromiseResult(); } diff --git a/ecmascript/interpreter/interpreter-inl.cpp b/ecmascript/interpreter/interpreter-inl.cpp index 194f0c3008..9c542d93fe 100644 --- a/ecmascript/interpreter/interpreter-inl.cpp +++ b/ecmascript/interpreter/interpreter-inl.cpp @@ -251,46 +251,46 @@ using CommonStubCSigns = kungfu::CommonStubCSigns; } while (false) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define DEPRECATED_CALL_INITIALIZE() \ - do { \ - SAVE_PC(); \ - thread->CheckSafepoint(); \ - funcTagged = sp[startReg]; \ - JSTaggedValue funcValue(funcTagged); \ - if (!funcValue.IsCallable()) { \ - { \ - [[maybe_unused]] EcmaHandleScope handleScope(thread); \ - JSHandle error = factory->GetJSError( \ - ErrorType::TYPE_ERROR, "is not callable"); \ - thread->SetException(error.GetTaggedValue()); \ - } \ - INTERPRETER_GOTO_EXCEPTION_HANDLER(); \ - } \ - funcObject = ECMAObject::Cast(funcValue.GetTaggedObject()); \ - methodHandle.Update(JSTaggedValue(funcObject->GetCallTarget())); \ - newSp = sp - InterpretedFrame::NumOfMembers(); \ +#define DEPRECATED_CALL_INITIALIZE() \ + do { \ + SAVE_PC(); \ + thread->CheckSafepoint(); \ + funcTagged = sp[startReg]; \ + JSTaggedValue funcValue(funcTagged); \ + if (!funcValue.IsCallable()) { \ + { \ + [[maybe_unused]] EcmaHandleScope handleScope(thread); \ + JSHandle error = factory->GetJSError( \ + ErrorType::TYPE_ERROR, "is not callable", StackCheck::NO); \ + thread->SetException(error.GetTaggedValue()); \ + } \ + INTERPRETER_GOTO_EXCEPTION_HANDLER(); \ + } \ + funcObject = ECMAObject::Cast(funcValue.GetTaggedObject()); \ + methodHandle.Update(JSTaggedValue(funcObject->GetCallTarget())); \ + newSp = sp - InterpretedFrame::NumOfMembers(); \ } while (false) -#define CALL_INITIALIZE() \ - do { \ - SAVE_PC(); \ - SAVE_ACC(); \ - thread->CheckSafepoint(); \ - RESTORE_ACC(); \ - funcTagged = acc.GetRawData(); \ - JSTaggedValue funcValue = acc; \ - if (!funcValue.IsCallable()) { \ - { \ - [[maybe_unused]] EcmaHandleScope handleScope(thread); \ - JSHandle error = factory->GetJSError( \ - ErrorType::TYPE_ERROR, "is not callable"); \ - thread->SetException(error.GetTaggedValue()); \ - } \ - INTERPRETER_GOTO_EXCEPTION_HANDLER(); \ - } \ - funcObject = ECMAObject::Cast(funcValue.GetTaggedObject()); \ - methodHandle.Update(JSTaggedValue(funcObject->GetCallTarget())); \ - newSp = sp - InterpretedFrame::NumOfMembers(); \ +#define CALL_INITIALIZE() \ + do { \ + SAVE_PC(); \ + SAVE_ACC(); \ + thread->CheckSafepoint(); \ + RESTORE_ACC(); \ + funcTagged = acc.GetRawData(); \ + JSTaggedValue funcValue = acc; \ + if (!funcValue.IsCallable()) { \ + { \ + [[maybe_unused]] EcmaHandleScope handleScope(thread); \ + JSHandle error = factory->GetJSError( \ + ErrorType::TYPE_ERROR, "is not callable", StackCheck::NO); \ + thread->SetException(error.GetTaggedValue()); \ + } \ + INTERPRETER_GOTO_EXCEPTION_HANDLER(); \ + } \ + funcObject = ECMAObject::Cast(funcValue.GetTaggedObject()); \ + methodHandle.Update(JSTaggedValue(funcObject->GetCallTarget())); \ + newSp = sp - InterpretedFrame::NumOfMembers(); \ } while (false) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) @@ -855,7 +855,7 @@ JSTaggedValue EcmaInterpreter::GeneratorReEnterAot(JSThread *thread, JSHandleGetEcmaVM(); ObjectFactory *factory = ecmaVm->GetFactory(); JSHandle error = - factory->GetJSError(ErrorType::TYPE_ERROR, "class constructor cannot called without 'new'"); + factory->GetJSError(ErrorType::TYPE_ERROR, "class constructor cannot called without 'new'", StackCheck::NO); thread->SetException(error.GetTaggedValue()); } return thread->GetException(); @@ -1434,7 +1434,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t { [[maybe_unused]] EcmaHandleScope handleScope(thread); JSHandle error = - factory->GetJSError(ErrorType::TYPE_ERROR, "class constructor cannot called without 'new'"); + factory->GetJSError(ErrorType::TYPE_ERROR, "class constructor cannot called without 'new'", StackCheck::NO); thread->SetException(error.GetTaggedValue()); } INTERPRETER_GOTO_EXCEPTION_HANDLER(); @@ -1556,7 +1556,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t { [[maybe_unused]] EcmaHandleScope handleScope(thread); JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, - "Derived constructor must return object or undefined"); + "Derived constructor must return object or undefined", StackCheck::NO); thread->SetException(error.GetTaggedValue()); } INTERPRETER_GOTO_EXCEPTION_HANDLER(); @@ -1601,7 +1601,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t { [[maybe_unused]] EcmaHandleScope handleScope(thread); JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, - "Derived constructor must return object or undefined"); + "Derived constructor must return object or undefined", StackCheck::NO); thread->SetException(error.GetTaggedValue()); } INTERPRETER_GOTO_EXCEPTION_HANDLER(); diff --git a/ecmascript/interpreter/interpreter-inl.h b/ecmascript/interpreter/interpreter-inl.h index 8fe6f8516c..7f64ca60d5 100644 --- a/ecmascript/interpreter/interpreter-inl.h +++ b/ecmascript/interpreter/interpreter-inl.h @@ -254,46 +254,46 @@ using CommonStubCSigns = kungfu::CommonStubCSigns; } while (false) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define DEPRECATED_CALL_INITIALIZE() \ - do { \ - SAVE_PC(); \ - thread->CheckSafepoint(); \ - funcTagged = sp[startReg]; \ - JSTaggedValue funcValue(funcTagged); \ - if (!funcValue.IsCallable()) { \ - { \ - [[maybe_unused]] EcmaHandleScope handleScope(thread); \ - JSHandle error = factory->GetJSError( \ - ErrorType::TYPE_ERROR, "is not callable"); \ - thread->SetException(error.GetTaggedValue()); \ - } \ - INTERPRETER_GOTO_EXCEPTION_HANDLER(); \ - } \ - funcObject = ECMAObject::Cast(funcValue.GetTaggedObject()); \ - methodHandle.Update(JSTaggedValue(funcObject->GetCallTarget())); \ - newSp = sp - InterpretedFrame::NumOfMembers(); \ +#define DEPRECATED_CALL_INITIALIZE() \ + do { \ + SAVE_PC(); \ + thread->CheckSafepoint(); \ + funcTagged = sp[startReg]; \ + JSTaggedValue funcValue(funcTagged); \ + if (!funcValue.IsCallable()) { \ + { \ + [[maybe_unused]] EcmaHandleScope handleScope(thread); \ + JSHandle error = factory->GetJSError( \ + ErrorType::TYPE_ERROR, "is not callable", StackCheck::NO); \ + thread->SetException(error.GetTaggedValue()); \ + } \ + INTERPRETER_GOTO_EXCEPTION_HANDLER(); \ + } \ + funcObject = ECMAObject::Cast(funcValue.GetTaggedObject()); \ + methodHandle.Update(JSTaggedValue(funcObject->GetCallTarget())); \ + newSp = sp - InterpretedFrame::NumOfMembers(); \ } while (false) -#define CALL_INITIALIZE() \ - do { \ - SAVE_PC(); \ - SAVE_ACC(); \ - thread->CheckSafepoint(); \ - RESTORE_ACC(); \ - funcTagged = acc.GetRawData(); \ - JSTaggedValue funcValue = acc; \ - if (!funcValue.IsCallable()) { \ - { \ - [[maybe_unused]] EcmaHandleScope handleScope(thread); \ - JSHandle error = factory->GetJSError( \ - ErrorType::TYPE_ERROR, "is not callable"); \ - thread->SetException(error.GetTaggedValue()); \ - } \ - INTERPRETER_GOTO_EXCEPTION_HANDLER(); \ - } \ - funcObject = ECMAObject::Cast(funcValue.GetTaggedObject()); \ - methodHandle.Update(JSTaggedValue(funcObject->GetCallTarget())); \ - newSp = sp - InterpretedFrame::NumOfMembers(); \ +#define CALL_INITIALIZE() \ + do { \ + SAVE_PC(); \ + SAVE_ACC(); \ + thread->CheckSafepoint(); \ + RESTORE_ACC(); \ + funcTagged = acc.GetRawData(); \ + JSTaggedValue funcValue = acc; \ + if (!funcValue.IsCallable()) { \ + { \ + [[maybe_unused]] EcmaHandleScope handleScope(thread); \ + JSHandle error = factory->GetJSError( \ + ErrorType::TYPE_ERROR, "is not callable", StackCheck::NO); \ + thread->SetException(error.GetTaggedValue()); \ + } \ + INTERPRETER_GOTO_EXCEPTION_HANDLER(); \ + } \ + funcObject = ECMAObject::Cast(funcValue.GetTaggedObject()); \ + methodHandle.Update(JSTaggedValue(funcObject->GetCallTarget())); \ + newSp = sp - InterpretedFrame::NumOfMembers(); \ } while (false) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) diff --git a/ecmascript/interpreter/interpreter.cpp b/ecmascript/interpreter/interpreter.cpp index dc6f7a90eb..97bb88c1be 100644 --- a/ecmascript/interpreter/interpreter.cpp +++ b/ecmascript/interpreter/interpreter.cpp @@ -38,11 +38,12 @@ namespace panda::ecmascript { // +--------------------------+ EcmaRuntimeCallInfo* EcmaInterpreter::NewRuntimeCallInfoBase( JSThread *thread, JSTaggedType func, JSTaggedType thisObj, JSTaggedType newTarget, - uint32_t numArgs, bool needCheckStack) + uint32_t numArgs, StackCheck needCheckStack) { JSTaggedType *prevSp = const_cast(thread->GetCurrentSPFrame()); JSTaggedType *newSp = GetInterpreterFrameEnd(thread, prevSp); - if (needCheckStack && UNLIKELY(thread->DoStackOverflowCheck(newSp - numArgs - NUM_MANDATORY_JSFUNC_ARGS))) { + if (needCheckStack == StackCheck::YES && + UNLIKELY(thread->DoStackOverflowCheck(newSp - numArgs - NUM_MANDATORY_JSFUNC_ARGS))) { return nullptr; } @@ -68,7 +69,7 @@ EcmaRuntimeCallInfo* EcmaInterpreter::NewRuntimeCallInfoBase( EcmaRuntimeCallInfo* EcmaInterpreter::NewRuntimeCallInfo( JSThread *thread, JSTaggedValue func, JSTaggedValue thisObj, JSTaggedValue newTarget, - uint32_t numArgs, bool needCheckStack) + uint32_t numArgs, StackCheck needCheckStack) { return NewRuntimeCallInfoBase(thread, func.GetRawData(), thisObj.GetRawData(), newTarget.GetRawData(), numArgs, needCheckStack); @@ -76,14 +77,14 @@ EcmaRuntimeCallInfo* EcmaInterpreter::NewRuntimeCallInfo( EcmaRuntimeCallInfo* EcmaInterpreter::NewRuntimeCallInfo( JSThread *thread, JSHandle func, JSHandle thisObj, - JSHandle newTarget, uint32_t numArgs, bool needCheckStack) + JSHandle newTarget, uint32_t numArgs, StackCheck needCheckStack) { return NewRuntimeCallInfoBase(thread, func.GetTaggedType(), thisObj.GetTaggedType(), newTarget.GetTaggedType(), numArgs, needCheckStack); } EcmaRuntimeCallInfo* EcmaInterpreter::ReBuildRuntimeCallInfo(JSThread *thread, EcmaRuntimeCallInfo* info, - int numArgs, bool needCheckStack) + int numArgs, StackCheck needCheckStack) { JSTaggedValue func = info->GetFunctionValue(); JSTaggedValue newTarget = info->GetNewTargetValue(); @@ -99,7 +100,8 @@ EcmaRuntimeCallInfo* EcmaInterpreter::ReBuildRuntimeCallInfo(JSThread *thread, E args[i] = info->GetCallArgValue(actualArgc - i - 1).GetRawData(); } currentSp += (info->GetArgsNumber() + NUM_MANDATORY_JSFUNC_ARGS + 2); // 2: include thread_ and numArgs_ - if (needCheckStack && UNLIKELY(thread->DoStackOverflowCheck(currentSp - numArgs - NUM_MANDATORY_JSFUNC_ARGS))) { + if (needCheckStack == StackCheck::YES && + UNLIKELY(thread->DoStackOverflowCheck(currentSp - numArgs - NUM_MANDATORY_JSFUNC_ARGS))) { return nullptr; } ASSERT(numArgs != actualArgc); diff --git a/ecmascript/interpreter/interpreter.h b/ecmascript/interpreter/interpreter.h index bf4688b5ae..baaa6399db 100644 --- a/ecmascript/interpreter/interpreter.h +++ b/ecmascript/interpreter/interpreter.h @@ -23,6 +23,7 @@ #include "ecmascript/frames.h" #include "ecmascript/method.h" #include "ecmascript/require/js_cjs_module.h" +#include "ecmascript/object_factory.h" #include "libpandafile/bytecode_instruction-inl.h" namespace panda::ecmascript { @@ -44,12 +45,12 @@ public: static JSTaggedValue ExecuteNative(EcmaRuntimeCallInfo *info); static EcmaRuntimeCallInfo* NewRuntimeCallInfo( JSThread *thread, JSTaggedValue func, JSTaggedValue thisObj, JSTaggedValue newTarget, - uint32_t numArgs, bool needCheckStack = true); + uint32_t numArgs, StackCheck needCheckStack = StackCheck::YES); static EcmaRuntimeCallInfo* NewRuntimeCallInfo( JSThread *thread, JSHandle func, JSHandle thisObj, - JSHandle newTarget, uint32_t numArgs, bool needCheckStack = true); + JSHandle newTarget, uint32_t numArgs, StackCheck needCheckStack = StackCheck::YES); static EcmaRuntimeCallInfo* ReBuildRuntimeCallInfo( - JSThread *thread, EcmaRuntimeCallInfo* info, int numArgs, bool needCheckStack = true); + JSThread *thread, EcmaRuntimeCallInfo* info, int numArgs, StackCheck needCheckStack = StackCheck::YES); static JSTaggedValue GeneratorReEnterInterpreter(JSThread *thread, JSHandle context); static JSTaggedValue GeneratorReEnterAot(JSThread *thread, JSHandle context); #ifndef EXCLUDE_C_INTERPRETER @@ -84,7 +85,7 @@ private: static void InitStackFrameForSP(JSTaggedType *prevSp); static EcmaRuntimeCallInfo* NewRuntimeCallInfoBase( JSThread *thread, JSTaggedType func, JSTaggedType thisObj, JSTaggedType newTarget, - uint32_t numArgs, bool needCheckStack = true); + uint32_t numArgs, StackCheck needCheckStack = StackCheck::YES); }; } // namespace panda::ecmascript #endif // ECMASCRIPT_INTERPRETER_INTERPRETER_H diff --git a/ecmascript/interpreter/interpreter_assembly.cpp b/ecmascript/interpreter/interpreter_assembly.cpp index 7c13db8b4d..d0c0b80f05 100644 --- a/ecmascript/interpreter/interpreter_assembly.cpp +++ b/ecmascript/interpreter/interpreter_assembly.cpp @@ -242,7 +242,7 @@ JSTaggedValue InterpreterAssembly::Execute(EcmaRuntimeCallInfo *info) EcmaVM *ecmaVm = thread->GetEcmaVM(); ObjectFactory *factory = ecmaVm->GetFactory(); JSHandle error = - factory->GetJSError(ErrorType::TYPE_ERROR, "class constructor cannot called without 'new'"); + factory->GetJSError(ErrorType::TYPE_ERROR, "class constructor cannot called without 'new'", StackCheck::NO); thread->SetException(error.GetTaggedValue()); } return thread->GetException(); diff --git a/ecmascript/js_async_generator_object.cpp b/ecmascript/js_async_generator_object.cpp index 73f873ad19..3d92cc49c6 100644 --- a/ecmascript/js_async_generator_object.cpp +++ b/ecmascript/js_async_generator_object.cpp @@ -75,7 +75,7 @@ JSTaggedValue JSAsyncGeneratorObject::AsyncGeneratorResolve(JSThread *thread, JSHandle resolve(thread, capability->GetResolve()); JSHandle undefined = thread->GlobalConstants()->GetHandledUndefined(); EcmaRuntimeCallInfo* info = - EcmaInterpreter::NewRuntimeCallInfo(thread, resolve, undefined, undefined, 1, false); + EcmaInterpreter::NewRuntimeCallInfo(thread, resolve, undefined, undefined, 1, StackCheck::NO); info->SetCallArg(its.GetTaggedValue()); [[maybe_unused]] JSTaggedValue res = JSFunction::Call(info); if ((thread)->HasPendingException()) { @@ -262,8 +262,8 @@ JSTaggedValue JSAsyncGeneratorObject::AsyncGeneratorEnqueue(JSThread *thread, co if (thread->HasPendingException()) { thread->ClearException(); // a. Let badGeneratorError be a newly created TypeError object. - JSHandle resolutionError = - factory->GetJSError(ErrorType::TYPE_ERROR, "Resolve: The promise and resolution cannot be the same."); + JSHandle resolutionError = factory->GetJSError(ErrorType::TYPE_ERROR, + "Resolve: The promise and resolution cannot be the same.", StackCheck::NO); // b. Perform ! Call(promiseCapability.[[Reject]], undefined, « badGeneratorError »). const GlobalEnvConstants *constants = thread->GlobalConstants(); JSHandle rstErr = JSHandle::Cast(resolutionError); diff --git a/ecmascript/js_function.cpp b/ecmascript/js_function.cpp index d891c3a608..34295ba1f1 100644 --- a/ecmascript/js_function.cpp +++ b/ecmascript/js_function.cpp @@ -486,8 +486,8 @@ JSTaggedValue JSFunction::InvokeOptimizedEntrypoint(JSThread *thread, JSHandleIsClassConstructor()) { { ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle error = - factory->GetJSError(ErrorType::TYPE_ERROR, "class constructor cannot called without 'new'"); + JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, + "class constructor cannot called without 'new'", StackCheck::NO); thread->SetException(error.GetTaggedValue()); } return thread->GetException(); diff --git a/ecmascript/js_list_format.cpp b/ecmascript/js_list_format.cpp index 0354a7c351..6baa4c3f10 100644 --- a/ecmascript/js_list_format.cpp +++ b/ecmascript/js_list_format.cpp @@ -249,7 +249,8 @@ JSHandle JSListFormat::StringListFromIterable(JSThread *thread, c RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread); if (!nextValue->IsString()) { ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle typeError = factory->GetJSError(ErrorType::TYPE_ERROR, "nextValue is not string"); + JSHandle typeError = + factory->GetJSError(ErrorType::TYPE_ERROR, "nextValue is not string", StackCheck::NO); JSHandle error( factory->NewCompletionRecord(CompletionRecordType::THROW, JSHandle(typeError))); JSTaggedValue result = JSIterator::IteratorClose(thread, iteratorRecord, error).GetTaggedValue(); diff --git a/ecmascript/js_serializer.cpp b/ecmascript/js_serializer.cpp index 40e01cccaf..6c4558d053 100644 --- a/ecmascript/js_serializer.cpp +++ b/ecmascript/js_serializer.cpp @@ -1438,7 +1438,7 @@ JSHandle JSDeserializer::ReadJSError(SerializationUID uid) } JSHandle msg = DeserializeJSTaggedValue(); JSHandle handleMsg(msg); - JSHandle errorTag = JSHandle::Cast(factory_->NewJSError(errorType, handleMsg)); + JSHandle errorTag = JSHandle::Cast(factory_->NewJSError(errorType, handleMsg, StackCheck::NO)); referenceMap_.emplace(objectId_++, errorTag); return errorTag; } diff --git a/ecmascript/js_thread.cpp b/ecmascript/js_thread.cpp index 5fdc32736f..d999ed3c17 100644 --- a/ecmascript/js_thread.cpp +++ b/ecmascript/js_thread.cpp @@ -491,7 +491,7 @@ bool JSThread::DoStackOverflowCheck(const JSTaggedType *sp) LOG_ECMA(ERROR) << "Stack overflow! Remaining stack size is: " << (sp - glueData_.frameBase_); if (!IsCrossThreadExecutionEnable() && LIKELY(!HasPendingException())) { ObjectFactory *factory = GetEcmaVM()->GetFactory(); - JSHandle error = factory->GetJSError(base::ErrorType::RANGE_ERROR, "Stack overflow!", false); + JSHandle error = factory->GetJSError(base::ErrorType::RANGE_ERROR, "Stack overflow!", StackCheck::NO); SetException(error.GetTaggedValue()); } return true; @@ -506,7 +506,7 @@ bool JSThread::DoStackLimitCheck() LOG_ECMA(ERROR) << "Stack overflow! current:" << GetCurrentStackPosition() << " limit:" << GetStackLimit(); if (!IsCrossThreadExecutionEnable() && LIKELY(!HasPendingException())) { ObjectFactory *factory = GetEcmaVM()->GetFactory(); - JSHandle error = factory->GetJSError(base::ErrorType::RANGE_ERROR, "Stack overflow!", false); + JSHandle error = factory->GetJSError(base::ErrorType::RANGE_ERROR, "Stack overflow!", StackCheck::NO); SetException(error.GetTaggedValue()); } return true; @@ -700,7 +700,7 @@ void JSThread::TerminateExecution() { // set the TERMINATE_ERROR to exception ObjectFactory *factory = GetEcmaVM()->GetFactory(); - JSHandle error = factory->GetJSError(ErrorType::TERMINATION_ERROR, "Terminate execution!"); + JSHandle error = factory->GetJSError(ErrorType::TERMINATION_ERROR, "Terminate execution!", StackCheck::NO); SetException(error.GetTaggedValue()); } diff --git a/ecmascript/mem/heap.cpp b/ecmascript/mem/heap.cpp index a9457f9121..4c8918712b 100644 --- a/ecmascript/mem/heap.cpp +++ b/ecmascript/mem/heap.cpp @@ -1087,7 +1087,7 @@ void BaseHeap::SetMachineCodeOutOfMemoryError(JSThread *thread, size_t size, std EcmaVM *ecmaVm = thread->GetEcmaVM(); ObjectFactory *factory = ecmaVm->GetFactory(); - JSHandle error = factory->GetJSError(ErrorType::OOM_ERROR, oss.str().c_str()); + JSHandle error = factory->GetJSError(ErrorType::OOM_ERROR, oss.str().c_str(), StackCheck::NO); thread->SetException(error.GetTaggedValue()); } diff --git a/ecmascript/module/js_module_manager.cpp b/ecmascript/module/js_module_manager.cpp index bcc9dccc27..33a0d4d268 100644 --- a/ecmascript/module/js_module_manager.cpp +++ b/ecmascript/module/js_module_manager.cpp @@ -701,7 +701,7 @@ int ModuleManager::GetExportObjectIndex(EcmaVM *vm, JSHandle e msg += "' which exported by '" + ConvertToString(ecmaModule->GetEcmaModuleFilename()) + "'"; } ObjectFactory *factory = vm->GetFactory(); - JSTaggedValue error = factory->GetJSError(ErrorType::SYNTAX_ERROR, msg.c_str()).GetTaggedValue(); + JSTaggedValue error = factory->GetJSError(ErrorType::SYNTAX_ERROR, msg.c_str(), StackCheck::NO).GetTaggedValue(); THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, 0); } JSHandle localExportEntries(thread, ecmaModule->GetLocalExportEntries()); diff --git a/ecmascript/module/js_module_source_text.cpp b/ecmascript/module/js_module_source_text.cpp index 5952663807..4cc0e949b9 100644 --- a/ecmascript/module/js_module_source_text.cpp +++ b/ecmascript/module/js_module_source_text.cpp @@ -1060,7 +1060,7 @@ int SourceTextModule::InnerModuleEvaluationUnsafe(JSThread *thread, const JSHand ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSTaggedValue promiseResult = JSPromise::Cast(promise.GetTaggedObject())->GetPromiseResult(); JSHandle error = - factory->GetJSError(base::ErrorType::ERROR, nullptr); + factory->GetJSError(base::ErrorType::ERROR, nullptr, StackCheck::NO); THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error.GetTaggedValue(), promiseResult.GetInt()); } return index; diff --git a/ecmascript/module/module_manager_helper.cpp b/ecmascript/module/module_manager_helper.cpp index d97a5a2091..c2b46ddf0f 100644 --- a/ecmascript/module/module_manager_helper.cpp +++ b/ecmascript/module/module_manager_helper.cpp @@ -124,7 +124,7 @@ JSTaggedValue ModuleManagerHelper::GetCJSModuleValue(JSThread *thread, JSTaggedV ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); CString errorMsg = "Loading requireModule" + ConvertToString(cjsModuleName.GetTaggedValue()) + "failed"; JSHandle syntaxError = - factory->GetJSError(base::ErrorType::SYNTAX_ERROR, errorMsg.c_str()); + factory->GetJSError(base::ErrorType::SYNTAX_ERROR, errorMsg.c_str(), StackCheck::NO); THROW_NEW_ERROR_AND_RETURN_VALUE(thread, syntaxError.GetTaggedValue(), JSTaggedValue::Exception()); } return cjsExports.GetTaggedValue(); @@ -151,7 +151,7 @@ JSTaggedValue ModuleManagerHelper::GetCJSModuleValue(JSThread *thread, JSTaggedV ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); CString errorMsg = "Loading requireModule" + ConvertToString(cjsModuleName.GetTaggedValue()) + "failed"; JSHandle syntaxError = - factory->GetJSError(base::ErrorType::SYNTAX_ERROR, errorMsg.c_str()); + factory->GetJSError(base::ErrorType::SYNTAX_ERROR, errorMsg.c_str(), StackCheck::NO); THROW_NEW_ERROR_AND_RETURN_VALUE(thread, syntaxError.GetTaggedValue(), JSTaggedValue::Exception()); } return cjsExports.GetTaggedValue(); diff --git a/ecmascript/napi/jsnapi_expo.cpp b/ecmascript/napi/jsnapi_expo.cpp index 6f438a8496..77e0323d3f 100644 --- a/ecmascript/napi/jsnapi_expo.cpp +++ b/ecmascript/napi/jsnapi_expo.cpp @@ -3303,16 +3303,17 @@ bool SendableArrayRef::SetValueAt(const EcmaVM *vm, Local obj, uint3 // ---------------------------------- Error --------------------------------------- // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define EXCEPTION_ERROR_NEW(name, type) \ - Local Exception::name(const EcmaVM *vm, Local message) \ - { \ - CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm)); \ - ecmascript::ThreadManagedScope managedScope(vm->GetJSThread()); \ - ObjectFactory *factory = vm->GetFactory(); \ - \ - JSHandle messageValue(JSNApiHelper::ToJSHandle(message)); \ - JSHandle result(factory->NewJSError(ErrorType::type, messageValue)); \ - return JSNApiHelper::ToLocal(result); \ +#define EXCEPTION_ERROR_NEW(name, type) \ + Local Exception::name(const EcmaVM *vm, Local message) \ + { \ + CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm)); \ + ecmascript::ThreadManagedScope managedScope(vm->GetJSThread()); \ + ObjectFactory *factory = vm->GetFactory(); \ + \ + JSHandle messageValue(JSNApiHelper::ToJSHandle(message)); \ + JSHandle result(factory->NewJSError(ErrorType::type, \ + messageValue, ecmascript::StackCheck::NO)); \ + return JSNApiHelper::ToLocal(result); \ } EXCEPTION_ERROR_ALL(EXCEPTION_ERROR_NEW) diff --git a/ecmascript/object_factory.cpp b/ecmascript/object_factory.cpp index 57ded9b2d8..25d7b694b5 100644 --- a/ecmascript/object_factory.cpp +++ b/ecmascript/object_factory.cpp @@ -967,7 +967,7 @@ JSHandle ObjectFactory::NewJSArguments() return obj; } -JSHandle ObjectFactory::GetJSError(const ErrorType &errorType, const char *data, bool needCheckStack) +JSHandle ObjectFactory::GetJSError(const ErrorType &errorType, const char *data, StackCheck needCheckStack) { ASSERT_PRINT(errorType == ErrorType::ERROR || errorType == ErrorType::EVAL_ERROR || errorType == ErrorType::RANGE_ERROR || errorType == ErrorType::REFERENCE_ERROR || @@ -984,7 +984,7 @@ JSHandle ObjectFactory::GetJSError(const ErrorType &errorType, const c } JSHandle ObjectFactory::NewJSError(const ErrorType &errorType, const JSHandle &message, - bool needCheckStack) + StackCheck needCheckStack) { // if there have exception in thread, then return current exception, no need to new js error. if (thread_->HasPendingException()) { diff --git a/ecmascript/object_factory.h b/ecmascript/object_factory.h index 5ff69385be..3ba6375fa6 100644 --- a/ecmascript/object_factory.h +++ b/ecmascript/object_factory.h @@ -191,6 +191,7 @@ using base::ErrorType; enum class RemoveSlots { YES, NO }; enum class GrowMode { KEEP, GROW }; +enum class StackCheck { YES, NO }; class ObjectFactory { public: @@ -207,10 +208,10 @@ public: JSHandle NewProgram(); JSHandle PUBLIC_API GetJSError(const ErrorType &errorType, const char *data = nullptr, - bool needCheckStack = true); + StackCheck needCheckStack = StackCheck::YES); JSHandle NewJSError(const ErrorType &errorType, const JSHandle &message, - bool needCheckStack = true); + StackCheck needCheckStack = StackCheck::YES); JSHandle NewJSAggregateError(); diff --git a/ecmascript/serializer/base_deserializer.cpp b/ecmascript/serializer/base_deserializer.cpp index 3fe6874ab2..8a1c482dc2 100644 --- a/ecmascript/serializer/base_deserializer.cpp +++ b/ecmascript/serializer/base_deserializer.cpp @@ -136,7 +136,7 @@ void BaseDeserializer::DeserializeJSError(JSErrorInfo *info) JSTaggedValue errorMsg = info->errorMsg_; bool root = info->root_; ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); - JSHandle errorTag = factory->NewJSError(errorType, JSHandle(thread_, errorMsg)); + JSHandle errorTag = factory->NewJSError(errorType, JSHandle(thread_, errorMsg), StackCheck::NO); ObjectSlot slot = info->GetSlot(); slot.Update(errorTag.GetTaggedType()); if (!root && !errorTag.GetTaggedValue().IsInvalidValue()) { diff --git a/ecmascript/serializer/tests/serializer_test.cpp b/ecmascript/serializer/tests/serializer_test.cpp index fdbe84bd86..13cc820674 100644 --- a/ecmascript/serializer/tests/serializer_test.cpp +++ b/ecmascript/serializer/tests/serializer_test.cpp @@ -1262,7 +1262,7 @@ HWTEST_F_L0(JSSerializerTest, SerializeJSError1) ObjectFactory *factory = ecmaVm->GetFactory(); JSHandle msg(factory->NewFromASCII("this is error")); JSHandle errorTag = - JSHandle::Cast(factory->NewJSError(base::ErrorType::ERROR, msg)); + JSHandle::Cast(factory->NewJSError(base::ErrorType::ERROR, msg, StackCheck::NO)); ValueSerializer *serializer = new ValueSerializer(thread); serializer->WriteValue(thread, errorTag, JSHandle(thread, JSTaggedValue::Undefined()), @@ -1283,7 +1283,7 @@ HWTEST_F_L0(JSSerializerTest, SerializeJSError2) JSHandle key2(factory->NewFromASCII("error2")); JSHandle msg(factory->NewFromASCII("this is error")); JSHandle errorTag = - JSHandle::Cast(factory->NewJSError(base::ErrorType::ERROR, msg)); + JSHandle::Cast(factory->NewJSError(base::ErrorType::ERROR, msg, StackCheck::NO)); JSObject::SetProperty(thread, JSHandle(obj), JSHandle(key1), errorTag); diff --git a/ecmascript/stubs/runtime_stubs-inl.h b/ecmascript/stubs/runtime_stubs-inl.h index 5b5b1ab0b4..fc8b456e5c 100644 --- a/ecmascript/stubs/runtime_stubs-inl.h +++ b/ecmascript/stubs/runtime_stubs-inl.h @@ -1495,14 +1495,14 @@ void RuntimeStubs::RuntimeThrowPatternNonCoercible(JSThread *thread) { JSHandle msg(thread->GlobalConstants()->GetHandledObjNotCoercibleString()); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - THROW_NEW_ERROR_AND_RETURN(thread, factory->NewJSError(base::ErrorType::TYPE_ERROR, msg, false).GetTaggedValue()); + THROW_NEW_ERROR_AND_RETURN(thread, factory->NewJSError(base::ErrorType::TYPE_ERROR, msg, StackCheck::NO).GetTaggedValue()); } void RuntimeStubs::RuntimeThrowDeleteSuperProperty(JSThread *thread) { ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle info = factory->NewFromASCII("Can not delete super property"); - JSHandle errorObj = factory->NewJSError(base::ErrorType::REFERENCE_ERROR, info, false); + JSHandle errorObj = factory->NewJSError(base::ErrorType::REFERENCE_ERROR, info, StackCheck::NO); THROW_NEW_ERROR_AND_RETURN(thread, errorObj.GetTaggedValue()); } @@ -1513,7 +1513,7 @@ void RuntimeStubs::RuntimeThrowUndefinedIfHole(JSThread *thread, const JSHandle< JSHandle msg = factory->ConcatFromString(obj, info); THROW_NEW_ERROR_AND_RETURN(thread, - factory->NewJSError(base::ErrorType::REFERENCE_ERROR, msg, false).GetTaggedValue()); + factory->NewJSError(base::ErrorType::REFERENCE_ERROR, msg, StackCheck::NO).GetTaggedValue()); } void RuntimeStubs::RuntimeThrowIfNotObject(JSThread *thread) @@ -1528,7 +1528,7 @@ void RuntimeStubs::RuntimeThrowConstAssignment(JSThread *thread, const JSHandle< JSHandle info = factory->NewFromASCII("Assignment to const variable "); JSHandle msg = factory->ConcatFromString(info, value); - THROW_NEW_ERROR_AND_RETURN(thread, factory->NewJSError(base::ErrorType::TYPE_ERROR, msg, false).GetTaggedValue()); + THROW_NEW_ERROR_AND_RETURN(thread, factory->NewJSError(base::ErrorType::TYPE_ERROR, msg, StackCheck::NO).GetTaggedValue()); } JSTaggedValue RuntimeStubs::RuntimeLdGlobalRecord(JSThread *thread, JSTaggedValue key) @@ -1582,7 +1582,7 @@ JSTaggedValue RuntimeStubs::RuntimeThrowReferenceError(JSThread *thread, const J JSHandle info = factory->NewFromUtf8(desc); JSHandle msg = factory->ConcatFromString(propName, info); THROW_NEW_ERROR_AND_RETURN_VALUE(thread, - factory->NewJSError(base::ErrorType::REFERENCE_ERROR, msg, false).GetTaggedValue(), + factory->NewJSError(base::ErrorType::REFERENCE_ERROR, msg, StackCheck::NO).GetTaggedValue(), JSTaggedValue::Exception()); } diff --git a/ecmascript/stubs/runtime_stubs.cpp b/ecmascript/stubs/runtime_stubs.cpp index d0330e3971..f6baa00faa 100644 --- a/ecmascript/stubs/runtime_stubs.cpp +++ b/ecmascript/stubs/runtime_stubs.cpp @@ -931,7 +931,7 @@ DEF_RUNTIME_STUBS(RegularJSObjDeletePrototype) RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception().GetRawData()); if (!result) { auto factory = thread->GetEcmaVM()->GetFactory(); - JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, "Cannot delete property"); + JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, "Cannot delete property", StackCheck::NO); thread->SetException(error.GetTaggedValue()); return JSTaggedValue::Exception().GetRawData(); } @@ -947,7 +947,7 @@ DEF_RUNTIME_STUBS(CallJSObjDeletePrototype) RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception().GetRawData()); if (!result) { auto factory = thread->GetEcmaVM()->GetFactory(); - JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, "Cannot delete property"); + JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, "Cannot delete property", StackCheck::NO); thread->SetException(error.GetTaggedValue()); return JSTaggedValue::Exception().GetRawData(); } @@ -2088,7 +2088,7 @@ DEF_RUNTIME_STUBS(ThrowTypeError) JSTaggedValue argMessageStringId = GetArg(argv, argc, 0); // 0: means the zeroth parameter std::string message = MessageString::GetMessageString(argMessageStringId.GetInt()); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, message.c_str()); + JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, message.c_str(), StackCheck::NO); THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error.GetTaggedValue(), JSTaggedValue::Hole().GetRawData()); } @@ -2107,7 +2107,7 @@ DEF_RUNTIME_STUBS(ThrowRangeError) JSTaggedValue argMessageStringId = GetArg(argv, argc, 0); std::string message = MessageString::GetMessageString(argMessageStringId.GetInt()); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle error = factory->GetJSError(ErrorType::RANGE_ERROR, message.c_str()); + JSHandle error = factory->GetJSError(ErrorType::RANGE_ERROR, message.c_str(), StackCheck::NO); THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error.GetTaggedValue(), JSTaggedValue::Hole().GetRawData()); } @@ -2580,7 +2580,7 @@ DEF_RUNTIME_STUBS(ThrowNotCallableException) RUNTIME_STUBS_HEADER(ThrowNotCallableException); EcmaVM *ecmaVm = thread->GetEcmaVM(); ObjectFactory *factory = ecmaVm->GetFactory(); - JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, "is not callable"); + JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, "is not callable", StackCheck::NO); thread->SetException(error.GetTaggedValue()); return JSTaggedValue::Exception().GetRawData(); } @@ -2591,7 +2591,7 @@ DEF_RUNTIME_STUBS(ThrowSetterIsUndefinedException) EcmaVM *ecmaVm = thread->GetEcmaVM(); ObjectFactory *factory = ecmaVm->GetFactory(); JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, - "Cannot set property when setter is undefined"); + "Cannot set property when setter is undefined", StackCheck::NO); thread->SetException(error.GetTaggedValue()); return JSTaggedValue::Exception().GetRawData(); } @@ -2602,7 +2602,7 @@ DEF_RUNTIME_STUBS(ThrowCallConstructorException) EcmaVM *ecmaVm = thread->GetEcmaVM(); ObjectFactory *factory = ecmaVm->GetFactory(); JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, - "class constructor cannot called without 'new'"); + "class constructor cannot called without 'new'", StackCheck::NO); thread->SetException(error.GetTaggedValue()); return JSTaggedValue::Exception().GetRawData(); } @@ -2613,7 +2613,7 @@ DEF_RUNTIME_STUBS(ThrowNonConstructorException) EcmaVM *ecmaVm = thread->GetEcmaVM(); ObjectFactory *factory = ecmaVm->GetFactory(); JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, - "function is non-constructor"); + "function is non-constructor", StackCheck::NO); thread->SetException(error.GetTaggedValue()); return JSTaggedValue::Exception().GetRawData(); } @@ -2626,7 +2626,7 @@ DEF_RUNTIME_STUBS(ThrowStackOverflowException) // so check thread here to distinguish it with the actual stack overflow. ecmaVm->CheckThread(); ObjectFactory *factory = ecmaVm->GetFactory(); - JSHandle error = factory->GetJSError(ErrorType::RANGE_ERROR, "Stack overflow!", false); + JSHandle error = factory->GetJSError(ErrorType::RANGE_ERROR, "Stack overflow!", StackCheck::NO); if (LIKELY(!thread->HasPendingException())) { thread->SetException(error.GetTaggedValue()); } @@ -2639,7 +2639,8 @@ DEF_RUNTIME_STUBS(ThrowDerivedMustReturnException) EcmaVM *ecmaVm = thread->GetEcmaVM(); ObjectFactory *factory = ecmaVm->GetFactory(); JSHandle error = factory->GetJSError(ErrorType::TYPE_ERROR, - "Derived constructor must return object or undefined"); + "Derived constructor must return object or undefined", + StackCheck::NO); thread->SetException(error.GetTaggedValue()); return JSTaggedValue::Exception().GetRawData(); }