From 7344f5a1467e8e6cb6b58568ac70feee3d89ccf6 Mon Sep 17 00:00:00 2001 From: Vsevolod Pukhov Date: Thu, 27 Oct 2022 20:03:40 +0300 Subject: [PATCH] Add thread.exception and intrinsic result equivalence asserts Signed-off-by: Vsevolod Pukhov --- runtime/interpreter/ecma-interpreter-inl.h | 54 ++++++++++++---------- runtime/interpreter/slow_runtime_stub.cpp | 10 +++- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/runtime/interpreter/ecma-interpreter-inl.h b/runtime/interpreter/ecma-interpreter-inl.h index e7d0a922d..fdf956816 100644 --- a/runtime/interpreter/ecma-interpreter-inl.h +++ b/runtime/interpreter/ecma-interpreter-inl.h @@ -24,40 +24,44 @@ namespace panda::ecmascript { // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define INTRINSIC_CALL_SETACC(intrinsic_call) \ - { \ - JSTaggedValue result(intrinsic_call); \ - SetAccFromTaggedValue(result); \ +#define INTRINSIC_CALL_SETACC(intrinsic_call) \ + { \ + JSTaggedValue result(intrinsic_call); \ + ASSERT(!this->GetJSThread()->HasPendingException()); \ + SetAccFromTaggedValue(result); \ } // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define INTRINSIC_CALL_CHECK(intrinsic_call) \ - { \ - JSTaggedValue result(intrinsic_call); \ - if (UNLIKELY(result.IsException())) { \ - this->MoveToExceptionHandler(); \ - return; \ - } \ +#define INTRINSIC_CALL_CHECK(intrinsic_call) \ + { \ + JSTaggedValue result(intrinsic_call); \ + if (UNLIKELY(result.IsException())) { \ + this->MoveToExceptionHandler(); \ + return; \ + } \ + ASSERT(!this->GetJSThread()->HasPendingException()); \ } // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define INTRINSIC_CALL_CHECK_SETACC(intrinsic_call) \ - { \ - JSTaggedValue result(intrinsic_call); \ - if (UNLIKELY(result.IsException())) { \ - this->MoveToExceptionHandler(); \ - return; \ - } \ - SetAccFromTaggedValue(result); \ +#define INTRINSIC_CALL_CHECK_SETACC(intrinsic_call) \ + { \ + JSTaggedValue result(intrinsic_call); \ + if (UNLIKELY(result.IsException())) { \ + this->MoveToExceptionHandler(); \ + return; \ + } \ + ASSERT(!this->GetJSThread()->HasPendingException()); \ + SetAccFromTaggedValue(result); \ } // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define INTERPRETER_RETURN_IF_ABRUPT(result) \ - do { \ - if (result.IsException()) { \ - this->MoveToExceptionHandler(); \ - return; \ - } \ +#define INTERPRETER_RETURN_IF_ABRUPT(result) \ + do { \ + if (result.IsException()) { \ + this->MoveToExceptionHandler(); \ + return; \ + } \ + ASSERT(!this->GetJSThread()->HasPendingException()); \ } while (false) #define UPDATE_UNARY_ARITH_PROFILE(lhs) \ diff --git a/runtime/interpreter/slow_runtime_stub.cpp b/runtime/interpreter/slow_runtime_stub.cpp index f64d28f1a..3a3e9b3d0 100644 --- a/runtime/interpreter/slow_runtime_stub.cpp +++ b/runtime/interpreter/slow_runtime_stub.cpp @@ -1434,7 +1434,10 @@ JSTaggedValue SlowRuntimeStub::ClassPrivateFieldGet(JSThread *thread, JSTaggedVa THROW_TYPE_ERROR_AND_RETURN(thread, "Private field was defined without a getter", JSTaggedValue::Exception()); } - return JSFunction::Call(thread, prop_desc.GetGetter(), obj_handle, 0, nullptr); + JSTaggedValue res = JSFunction::Call(thread, prop_desc.GetGetter(), obj_handle, 0, + nullptr); // TODO(vpukhov): return Exception on unwind + RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); + return res; } JSTaggedValue SlowRuntimeStub::ClassPrivateFieldSet(JSThread *thread, JSTaggedValue ctor, JSTaggedValue obj, @@ -1477,7 +1480,10 @@ JSTaggedValue SlowRuntimeStub::ClassPrivateFieldSet(JSThread *thread, JSTaggedVa InternalCallParams *params = thread->GetInternalCallParams(); params->MakeArgv(value_handle); - return JSFunction::Call(thread, prop_desc.GetSetter(), obj_handle, 1, params->GetArgv()); + JSTaggedValue res = JSFunction::Call(thread, prop_desc.GetSetter(), obj_handle, 1, + params->GetArgv()); // TODO(vpukhov): return Exception on unwind + RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); + return res; } JSTaggedValue SlowRuntimeStub::ClassPrivateFieldIn(JSThread *thread, JSTaggedValue ctor, JSTaggedValue obj, -- Gitee