mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
Bugfix:[Bug]: An exception was generated while throwing an exception
issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I9EUBS Signed-off-by: hecunmao <hecunmao@huawei.com> Change-Id: I8087345cb5ad6b94be69ba3e99db3357309e1ff8
This commit is contained in:
parent
9b29c5f956
commit
14f68e0ae1
@ -328,15 +328,15 @@
|
||||
} while (false)
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define THROW_ERROR(thread, type, message) \
|
||||
do { \
|
||||
if ((thread)->HasPendingException()) { \
|
||||
return; \
|
||||
} \
|
||||
ObjectFactory *_factory = (thread)->GetEcmaVM()->GetFactory(); \
|
||||
JSHandle<JSObject> _error = _factory->GetJSError(type, message); \
|
||||
(thread)->SetException(_error.GetTaggedValue()); \
|
||||
return; \
|
||||
#define THROW_ERROR(thread, type, message) \
|
||||
do { \
|
||||
if ((thread)->HasPendingException()) { \
|
||||
return; \
|
||||
} \
|
||||
ObjectFactory *_factory = (thread)->GetEcmaVM()->GetFactory(); \
|
||||
JSHandle<JSObject> _error = _factory->GetJSError(type, message, false); \
|
||||
(thread)->SetException(_error.GetTaggedValue()); \
|
||||
return; \
|
||||
} while (false)
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
@ -359,41 +359,41 @@
|
||||
} while (false)
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define THROW_NEW_ERROR_AND_RETURN_HANDLE(thread, errorType, type, message) \
|
||||
do { \
|
||||
if ((thread)->HasPendingException()) { \
|
||||
return JSHandle<type>(thread, JSTaggedValue::Exception()); \
|
||||
} \
|
||||
ObjectFactory *_factory = (thread)->GetEcmaVM()->GetFactory(); \
|
||||
JSHandle<JSObject> _error = _factory->GetJSError(errorType, message); \
|
||||
(thread)->SetException(_error.GetTaggedValue()); \
|
||||
return JSHandle<type>(thread, JSTaggedValue::Exception()); \
|
||||
#define THROW_NEW_ERROR_AND_RETURN_HANDLE(thread, errorType, type, message) \
|
||||
do { \
|
||||
if ((thread)->HasPendingException()) { \
|
||||
return JSHandle<type>(thread, JSTaggedValue::Exception()); \
|
||||
} \
|
||||
ObjectFactory *_factory = (thread)->GetEcmaVM()->GetFactory(); \
|
||||
JSHandle<JSObject> _error = _factory->GetJSError(errorType, message, false); \
|
||||
(thread)->SetException(_error.GetTaggedValue()); \
|
||||
return JSHandle<type>(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<JSObject> _error = _factory->GetJSError(errorType, message); \
|
||||
(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<JSObject> _error = _factory->GetJSError(errorType, message, false); \
|
||||
(thread)->SetException(_error.GetTaggedValue()); \
|
||||
return (value); \
|
||||
} while (false)
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define THROW_MODULE_NOT_FOUND_ERROR_WITH_RETURN_VALUE(thread, requestStr, currentRecord, value) \
|
||||
do { \
|
||||
if ((thread)->HasPendingException()) { \
|
||||
return (value); \
|
||||
} \
|
||||
ObjectFactory *_factory = (thread)->GetEcmaVM()->GetFactory(); \
|
||||
CString normalizeStr = ModulePathHelper::ReformatPath(currentRecord); \
|
||||
CString msg = "Cannot find module '" + requestStr + "' imported from '" + normalizeStr + "'."; \
|
||||
JSHandle<JSObject> _error = _factory->GetJSError(ErrorType::REFERENCE_ERROR, msg.c_str()); \
|
||||
(thread)->SetException(_error.GetTaggedValue()); \
|
||||
return (value); \
|
||||
#define THROW_MODULE_NOT_FOUND_ERROR_WITH_RETURN_VALUE(thread, requestStr, currentRecord, value) \
|
||||
do { \
|
||||
if ((thread)->HasPendingException()) { \
|
||||
return (value); \
|
||||
} \
|
||||
ObjectFactory *_factory = (thread)->GetEcmaVM()->GetFactory(); \
|
||||
CString normalizeStr = ModulePathHelper::ReformatPath(currentRecord); \
|
||||
CString msg = "Cannot find module '" + requestStr + "' imported from '" + normalizeStr + "'."; \
|
||||
JSHandle<JSObject> _error = _factory->GetJSError(ErrorType::REFERENCE_ERROR, msg.c_str(), false); \
|
||||
(thread)->SetException(_error.GetTaggedValue()); \
|
||||
return (value); \
|
||||
} while (false)
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
|
@ -1475,14 +1475,14 @@ void RuntimeStubs::RuntimeThrowPatternNonCoercible(JSThread *thread)
|
||||
{
|
||||
JSHandle<EcmaString> msg(thread->GlobalConstants()->GetHandledObjNotCoercibleString());
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
THROW_NEW_ERROR_AND_RETURN(thread, factory->NewJSError(base::ErrorType::TYPE_ERROR, msg).GetTaggedValue());
|
||||
THROW_NEW_ERROR_AND_RETURN(thread, factory->NewJSError(base::ErrorType::TYPE_ERROR, msg, false).GetTaggedValue());
|
||||
}
|
||||
|
||||
void RuntimeStubs::RuntimeThrowDeleteSuperProperty(JSThread *thread)
|
||||
{
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<EcmaString> info = factory->NewFromASCII("Can not delete super property");
|
||||
JSHandle<JSObject> errorObj = factory->NewJSError(base::ErrorType::REFERENCE_ERROR, info);
|
||||
JSHandle<JSObject> errorObj = factory->NewJSError(base::ErrorType::REFERENCE_ERROR, info, false);
|
||||
THROW_NEW_ERROR_AND_RETURN(thread, errorObj.GetTaggedValue());
|
||||
}
|
||||
|
||||
@ -1492,7 +1492,8 @@ void RuntimeStubs::RuntimeThrowUndefinedIfHole(JSThread *thread, const JSHandle<
|
||||
JSHandle<EcmaString> info = factory->NewFromASCII(" is not initialized");
|
||||
|
||||
JSHandle<EcmaString> msg = factory->ConcatFromString(obj, info);
|
||||
THROW_NEW_ERROR_AND_RETURN(thread, factory->NewJSError(base::ErrorType::REFERENCE_ERROR, msg).GetTaggedValue());
|
||||
THROW_NEW_ERROR_AND_RETURN(thread,
|
||||
factory->NewJSError(base::ErrorType::REFERENCE_ERROR, msg, false).GetTaggedValue());
|
||||
}
|
||||
|
||||
void RuntimeStubs::RuntimeThrowIfNotObject(JSThread *thread)
|
||||
@ -1507,7 +1508,7 @@ void RuntimeStubs::RuntimeThrowConstAssignment(JSThread *thread, const JSHandle<
|
||||
JSHandle<EcmaString> info = factory->NewFromASCII("Assignment to const variable ");
|
||||
|
||||
JSHandle<EcmaString> msg = factory->ConcatFromString(info, value);
|
||||
THROW_NEW_ERROR_AND_RETURN(thread, factory->NewJSError(base::ErrorType::TYPE_ERROR, msg).GetTaggedValue());
|
||||
THROW_NEW_ERROR_AND_RETURN(thread, factory->NewJSError(base::ErrorType::TYPE_ERROR, msg, false).GetTaggedValue());
|
||||
}
|
||||
|
||||
JSTaggedValue RuntimeStubs::RuntimeLdGlobalRecord(JSThread *thread, JSTaggedValue key)
|
||||
@ -1561,7 +1562,7 @@ JSTaggedValue RuntimeStubs::RuntimeThrowReferenceError(JSThread *thread, const J
|
||||
JSHandle<EcmaString> info = factory->NewFromUtf8(desc);
|
||||
JSHandle<EcmaString> msg = factory->ConcatFromString(propName, info);
|
||||
THROW_NEW_ERROR_AND_RETURN_VALUE(thread,
|
||||
factory->NewJSError(base::ErrorType::REFERENCE_ERROR, msg).GetTaggedValue(),
|
||||
factory->NewJSError(base::ErrorType::REFERENCE_ERROR, msg, false).GetTaggedValue(),
|
||||
JSTaggedValue::Exception());
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,43 @@ const v50 = v46.call(v34);
|
||||
print(v50);
|
||||
}
|
||||
|
||||
let msg = [];
|
||||
let msg_cnt = 0;
|
||||
function runNearStackLimit(f) {
|
||||
function t() {
|
||||
try {
|
||||
t();
|
||||
} catch (e) {
|
||||
msg[msg_cnt++] = e.message;
|
||||
f();
|
||||
}
|
||||
};
|
||||
t();
|
||||
}
|
||||
let idx = 0;
|
||||
let obj = {};
|
||||
function f() {
|
||||
idx++;
|
||||
if (idx == 1) {
|
||||
idx = idx11;
|
||||
// 0 in idx
|
||||
}
|
||||
}
|
||||
let funcs = [f];
|
||||
for (let i = 1; i < 2; i++) {
|
||||
funcs[i] = function () {
|
||||
funcs[i - 1]();
|
||||
}
|
||||
}
|
||||
|
||||
for(let i=0;i<funcs.length;i++){
|
||||
print("********************************")
|
||||
msg_cnt = 0;
|
||||
idx=0;
|
||||
runNearStackLimit(funcs[i])
|
||||
print(msg[msg_cnt-1]);
|
||||
}
|
||||
|
||||
// Be sure to put this case at the end because this case will change prototype of error constructor
|
||||
try {
|
||||
0();
|
||||
|
@ -12,4 +12,8 @@
|
||||
# limitations under the License.
|
||||
|
||||
TypeError
|
||||
********************************
|
||||
idx11 is not defined
|
||||
********************************
|
||||
idx11 is not defined
|
||||
ReferenceError
|
||||
|
Loading…
Reference in New Issue
Block a user