diff --git a/runtime/base/object_helper.cpp b/runtime/base/object_helper.cpp index 5e2c346cc78e01fb6a3cf774809351ef75cdfd26..f3a8c78a1e9c4df5f7929684df6aa1d8ac905e85 100644 --- a/runtime/base/object_helper.cpp +++ b/runtime/base/object_helper.cpp @@ -27,6 +27,7 @@ JSTaggedValue ObjectHelper::CreateDataPropertyOnObject(EcmaRuntimeCallInfo *argv // 4. Let propertyKey be ? ToPropertyKey(key). JSHandle key = BuiltinsBase::GetCallArg(argv, 0); + [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle property_key = JSTaggedValue::ToPropertyKey(thread, key); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); diff --git a/runtime/base/string_helper.cpp b/runtime/base/string_helper.cpp index d0230bf01caab7c476941b6853aef3b24d5d1abb..4d57bb98799879c8913938ffba85ea19a5082a75 100644 --- a/runtime/base/string_helper.cpp +++ b/runtime/base/string_helper.cpp @@ -62,6 +62,7 @@ EcmaString *StringHelper::Repeat(JSThread *thread, const std::u16string &this_st EcmaString *StringHelper::Trim(JSThread *thread, const std::u16string &this_str, TrimKind kind) { + [[maybe_unused]] EcmaHandleScope handle_scope(thread); ecmascript::ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); std::u16string tmp_str = this_str; if (tmp_str.empty()) { @@ -104,6 +105,7 @@ panda::ecmascript::JSTaggedValue StringHelper::StringPad(JSThread *thread, JSHan JSHandle max_length, JSHandle fill_string, PadPlacement placement) { + [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Assert: placement is start or end. ASSERT(placement == PadPlacement::START || placement == PadPlacement::END); diff --git a/runtime/builtins/builtins_date.cpp b/runtime/builtins/builtins_date.cpp index 24e3b7c7ff02272c577c3f290a13041d55de664a..5d0c2064735f686ca09c87ddc18eaa4c3b7a0f8c 100644 --- a/runtime/builtins/builtins_date.cpp +++ b/runtime/builtins/builtins_date.cpp @@ -131,7 +131,6 @@ JSTaggedValue BuiltinsDate::GetTime(EcmaRuntimeCallInfo *argv) JSThread *thread = argv->GetThread(); JSHandle msg = GetThis(argv); if (!msg->IsDate()) { - [[maybe_unused]] EcmaHandleScope handle_scope(argv->GetThread()); THROW_TYPE_ERROR_AND_RETURN(thread, "Not a Date Object", JSTaggedValue::Exception()); } return JSDate::Cast(msg->GetTaggedObject())->GetTime(); diff --git a/runtime/builtins/builtins_errors.cpp b/runtime/builtins/builtins_errors.cpp index 4293aa3397a331ffe0b70a7b718869695ff538bf..6dc082e27c82e161dcbdff4190444e957e25cb4e 100644 --- a/runtime/builtins/builtins_errors.cpp +++ b/runtime/builtins/builtins_errors.cpp @@ -66,9 +66,7 @@ JSTaggedValue BuiltinsTypeError::ToString(EcmaRuntimeCallInfo *argv) JSTaggedValue BuiltinsTypeError::ThrowTypeError(EcmaRuntimeCallInfo *argv) { - JSThread *thread = argv->GetThread(); - [[maybe_unused]] EcmaHandleScope handle_scope(thread); - THROW_TYPE_ERROR_AND_RETURN(thread, "type error", JSTaggedValue::Exception()); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "type error", JSTaggedValue::Exception()); } // URIError diff --git a/runtime/builtins/builtins_number.cpp b/runtime/builtins/builtins_number.cpp index 0740fd72a5cd133a5b25831367655cbe0b32f865..528ad47c45a36ba3873cbe04148cba8ce7d1d7af 100644 --- a/runtime/builtins/builtins_number.cpp +++ b/runtime/builtins/builtins_number.cpp @@ -447,8 +447,6 @@ JSTaggedNumber BuiltinsNumber::ThisNumberValue(EcmaRuntimeCallInfo *argv) return JSTaggedNumber(primitive); } } - JSThread *thread = argv->GetThread(); - [[maybe_unused]] EcmaHandleScope handle_scope(thread); - THROW_TYPE_ERROR_AND_RETURN(thread, "not number type", JSTaggedNumber::Exception()); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "not number type", JSTaggedNumber::Exception()); } } // namespace panda::ecmascript::builtins diff --git a/runtime/builtins/builtins_object.cpp b/runtime/builtins/builtins_object.cpp index 1177bb98eeb561264b0f3d5847993e6c5b3366e3..d8da9324a4ac3a9d1e0dcacadb3f1c53582d90cd 100644 --- a/runtime/builtins/builtins_object.cpp +++ b/runtime/builtins/builtins_object.cpp @@ -1003,6 +1003,7 @@ JSTaggedValue BuiltinsObject::DefineGetter(EcmaRuntimeCallInfo *argv) ASSERT(argv); BUILTINS_API_TRACE(argv->GetThread(), Object, DefineGetter); JSThread *thread = argv->GetThread(); + [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be ? ToObject(this value). JSHandle obj = JSTaggedValue::ToObject(thread, GetThis(argv)); @@ -1038,6 +1039,7 @@ JSTaggedValue BuiltinsObject::DefineSetter(EcmaRuntimeCallInfo *argv) ASSERT(argv); BUILTINS_API_TRACE(argv->GetThread(), Object, DefineGetter); JSThread *thread = argv->GetThread(); + [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be ? ToObject(this value). JSHandle obj = JSTaggedValue::ToObject(thread, GetThis(argv)); @@ -1073,6 +1075,7 @@ static JSTaggedValue LookupDesc(EcmaRuntimeCallInfo *argv, ASSERT(argv); BUILTINS_API_TRACE(argv->GetThread(), Object, DefineGetter); JSThread *thread = argv->GetThread(); + [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be ? ToObject(this value). JSHandle obj = JSTaggedValue::ToObject(thread, ecmascript::base::BuiltinsBase::GetThis(argv)); diff --git a/runtime/builtins/builtins_string.cpp b/runtime/builtins/builtins_string.cpp index 1e296b0d5128f66e439a2aaac0bb74f5b010ee2f..e4ad3ff5730032c922b1b56864db854cfef42dab 100644 --- a/runtime/builtins/builtins_string.cpp +++ b/runtime/builtins/builtins_string.cpp @@ -1728,6 +1728,7 @@ JSTaggedValue BuiltinsString::ToLowerCase(EcmaRuntimeCallInfo *argv) ASSERT(argv); BUILTINS_API_TRACE(argv->GetThread(), String, ToLowerCase); JSThread *thread = argv->GetThread(); + [[maybe_unused]] EcmaHandleScope handle_scope(thread); std::u16string u16str_this = ToU16String(argv); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); return JSTaggedValue(ecmascript::base::StringHelper::ToLower(thread, u16str_this)); @@ -1746,6 +1747,7 @@ JSTaggedValue BuiltinsString::ToUpperCase(EcmaRuntimeCallInfo *argv) ASSERT(argv); BUILTINS_API_TRACE(argv->GetThread(), String, ToUpperCase); JSThread *thread = argv->GetThread(); + [[maybe_unused]] EcmaHandleScope handle_scope(thread); std::u16string u16str_this = ToU16String(argv); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); return JSTaggedValue(ecmascript::base::StringHelper::ToUpper(thread, u16str_this)); diff --git a/runtime/ecma_exceptions.cpp b/runtime/ecma_exceptions.cpp index c9e13b841f969f74e09a3a2d9d23e968990d91cd..5b0797b84d42925066893a6621a04f59957d995f 100644 --- a/runtime/ecma_exceptions.cpp +++ b/runtime/ecma_exceptions.cpp @@ -32,6 +32,7 @@ void SetException(JSThread *thread, JSObject *error) void ThrowException(JSThread *thread, const char *name, const char *msg) { auto js_thread = static_cast(thread); + [[maybe_unused]] EcmaHandleScope handle_scope(js_thread); ObjectFactory *factory = js_thread->GetEcmaVM()->GetFactory(); if (std::strcmp(name, REFERENCE_ERROR_STRING) == 0) { SetException(js_thread, *factory->GetJSError(base::ErrorType::REFERENCE_ERROR, msg)); diff --git a/runtime/ecma_macros.h b/runtime/ecma_macros.h index 99a706aa12f26ad484193857f07c2b0215df1fd5..b6b8e29ece456856a59b51af0a1598fce7e6e221 100644 --- a/runtime/ecma_macros.h +++ b/runtime/ecma_macros.h @@ -158,6 +158,7 @@ static inline void UnalignedStore(T *p, T v) { \ ASSERT(argv); \ JSThread *thread = argv->GetThread(); \ + [[maybe_unused]] EcmaHandleScope handle_scope(thread); \ JSHandle msg = GetThis(argv); \ if (!msg->IsDate()) { \ THROW_TYPE_ERROR_AND_RETURN(thread, "Not a Date Object", JSTaggedValue::Exception()); \ @@ -174,6 +175,7 @@ static inline void UnalignedStore(T *p, T v) { \ ASSERT(argv); \ JSThread *thread = argv->GetThread(); \ + [[maybe_unused]] EcmaHandleScope handle_scope(thread); \ JSHandle msg = GetThis(argv); \ if (!msg->IsDate()) { \ THROW_TYPE_ERROR_AND_RETURN(thread, "Not a Date Object", JSTaggedValue::Exception()); \ @@ -211,6 +213,7 @@ static inline void UnalignedStore(T *p, T v) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define THROW_TYPE_ERROR_AND_RETURN(thread, message, exception) \ do { \ + [[maybe_unused]] EcmaHandleScope error_handle_scope(thread); \ ObjectFactory *objectFactory = thread->GetEcmaVM()->GetFactory(); \ JSHandle error = objectFactory->GetJSError(ErrorType::TYPE_ERROR, message); \ THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error.GetTaggedValue(), exception); \ diff --git a/runtime/handle_storage_check.h b/runtime/handle_storage_check.h new file mode 100644 index 0000000000000000000000000000000000000000..189f88ee438fa5f6596a44a3e9abbaecb0ad3d4a --- /dev/null +++ b/runtime/handle_storage_check.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ECMASCRIPT_HANDLE_STORAGE_CHECK_H +#define ECMASCRIPT_HANDLE_STORAGE_CHECK_H + +#include "plugins/ecmascript/runtime/js_thread.h" + +namespace panda::ecmascript { + +#ifndef NDEBUG +constexpr bool IS_HANDLE_STORAGE_ALLOW_CHECK = true; +#else +constexpr bool IS_HANDLE_STORAGE_ALLOW_CHECK = false; +#endif // NDEBUG + +template +class HandleStorageCheckT { +public: + explicit HandleStorageCheckT(JSThread *thread) + { + (void)thread; + } + + NO_COPY_SEMANTIC(HandleStorageCheckT); + NO_MOVE_SEMANTIC(HandleStorageCheckT); + + ~HandleStorageCheckT() = default; +}; + +template <> +class HandleStorageCheckT { +public: + explicit HandleStorageCheckT(JSThread *thread) + : thread_(thread), handle_storage_check_(thread->GetHandleScopeStorageNext()) + { + } + + ~HandleStorageCheckT() + { + (void)thread_; + (void)handle_storage_check_; + ASSERT(handle_storage_check_ == thread_->GetHandleScopeStorageNext()); + } + + NO_COPY_SEMANTIC(HandleStorageCheckT); + NO_MOVE_SEMANTIC(HandleStorageCheckT); + +private: + JSThread *thread_; + JSTaggedType *handle_storage_check_; +}; + +using HandleStorageCheck = HandleStorageCheckT; + +} // namespace panda::ecmascript +#endif // ECMASCRIPT_HANDLE_STORAGE_CHECK_H diff --git a/runtime/interpreter/ecma-interpreter-inl.h b/runtime/interpreter/ecma-interpreter-inl.h index 113cc5c77bfb13e5e82644912a0514ed6b671cd1..6f2aa79ab60a342d2ff7404c2ee93dbd484d2cec 100644 --- a/runtime/interpreter/ecma-interpreter-inl.h +++ b/runtime/interpreter/ecma-interpreter-inl.h @@ -17,6 +17,7 @@ #include "plugins/ecmascript/runtime/js_generator_object.h" #include "plugins/ecmascript/runtime/js_array.h" #include "plugins/ecmascript/runtime/ecma_profiling.h" +#include "plugins/ecmascript/runtime/handle_storage_check.h" #include "plugins/ecmascript/compiler/ecmascript_extensions/thread_environment_api.h" #include "runtime/interpreter/interpreter-inl.h" #include "runtime/interpreter/instruction_handler_base.h" @@ -294,6 +295,7 @@ public: this->SaveAccToFrame(); JSThread *js_thread = this->GetJSThread(); + [[maybe_unused]] HandleStorageCheck handle_storage_check(js_thread); uint64_t function = JSGetCalleDyn(js_thread->GetCurrentFrame(), this->GetInst()); if (UNLIKELY(!JSTaggedValue(function).IsCallable())) { diff --git a/runtime/interpreter/fast_runtime_stub-inl.h b/runtime/interpreter/fast_runtime_stub-inl.h index 63f753c9760a90a8d33544e11518ea4c6a8259a1..b83c0c384805709adf2f79a20182c4324d072724 100644 --- a/runtime/interpreter/fast_runtime_stub-inl.h +++ b/runtime/interpreter/fast_runtime_stub-inl.h @@ -1094,6 +1094,7 @@ void FastRuntimeStub::SetOwnPropertyByName(JSThread *thread, JSTaggedValue recei bool FastRuntimeStub::SetOwnElement(JSThread *thread, JSTaggedValue receiver, uint32_t index, JSTaggedValue value) { INTERPRETER_TRACE(thread, SetOwnElement); + [[maybe_unused]] EcmaHandleScope handle_scope(thread); PropertyAttributes attr; uint32_t index_or_entry; TaggedArray *elements = TaggedArray::Cast(JSObject::Cast(receiver)->GetElements().GetHeapObject()); diff --git a/runtime/interpreter/interpreter-inl.h b/runtime/interpreter/interpreter-inl.h index a89db3460053fbe08418897303af7952b54cc646..9c72d7384c09e6aad86bb03bece1eb6246245287 100644 --- a/runtime/interpreter/interpreter-inl.h +++ b/runtime/interpreter/interpreter-inl.h @@ -17,6 +17,7 @@ #include "plugins/ecmascript/runtime/js_tagged_value.h" #include "plugins/ecmascript/runtime/literal_data_extractor.h" #include "plugins/ecmascript/runtime/template_string.h" +#include "plugins/ecmascript/runtime/handle_storage_check.h" #include "plugins/ecmascript/compiler/ecmascript_extensions/thread_environment_api.h" #include "include/method-inl.h" #include "include/runtime_notification.h" @@ -146,7 +147,7 @@ JSTaggedValue EcmaInterpreter::ExecuteInvoke(EcmaRuntimeCallInfo *info, JSTagged JSTaggedValue EcmaInterpreter::ExecuteInEnv(EcmaRuntimeCallInfo *info, JSTaggedValue fn_object) { JSThread *thread = info->GetThread(); - + [[maybe_unused]] HandleStorageCheck handle_storage_check(thread); if (UNLIKELY(thread->HasPendingException())) { // TODO(vpukhov): replace with assert return JSTaggedValue::Undefined(); } diff --git a/runtime/interpreter/js_frame-inl.h b/runtime/interpreter/js_frame-inl.h index 6ba3e1654705546abc6979c5c45f636087f195d8..d513663a09e9e481a0062fe5d5de2cc739316261 100644 --- a/runtime/interpreter/js_frame-inl.h +++ b/runtime/interpreter/js_frame-inl.h @@ -8,6 +8,7 @@ #include "plugins/ecmascript/runtime/interpreter/js_frame.h" #include "plugins/ecmascript/runtime/js_thread.h" #include "plugins/ecmascript/runtime/ecma_runtime_call_info.h" +#include "plugins/ecmascript/runtime/handle_storage_check.h" #include "runtime/interpreter/frame.h" namespace panda::ecmascript { @@ -56,7 +57,7 @@ inline JSTaggedValue JSFrame::ExecuteNativeMethod(JSThread *js_thread, Frame *fr if (UNLIKELY((!js_thread->StackOverflowCheck()))) { return JSTaggedValue::Exception(); } - + [[maybe_unused]] HandleStorageCheck handle_storage_check(js_thread); EcmaRuntimeCallInfo call_info(js_thread, num_actual_args, reinterpret_cast(&frame->GetVReg(0))); auto ecma_entry_point = reinterpret_cast(method->GetNativePointer()); JSTaggedValue ret_value = ecma_entry_point(&call_info); diff --git a/runtime/interpreter/slow_runtime_stub.cpp b/runtime/interpreter/slow_runtime_stub.cpp index f966111b2d4b2dcf30352d018836f8a3775ee6a5..0a9b3bc336a9f55052ff3bbf648b1bcbd352730a 100644 --- a/runtime/interpreter/slow_runtime_stub.cpp +++ b/runtime/interpreter/slow_runtime_stub.cpp @@ -1916,7 +1916,6 @@ JSTaggedValue SlowRuntimeStub::ThrowReferenceError(JSThread *thread, JSTaggedVal JSTaggedValue SlowRuntimeStub::ThrowTypeError(JSThread *thread, const char *message) { INTERPRETER_TRACE(thread, ThrowTypeError); - [[maybe_unused]] EcmaHandleScope handle_scope(thread); ASSERT_NO_ABRUPT_COMPLETION(thread); THROW_TYPE_ERROR_AND_RETURN(thread, message, JSTaggedValue::Exception()); } diff --git a/runtime/js_date.cpp b/runtime/js_date.cpp index d85f997ee0f799888a8f589b41709ea1c5b752ec..d03fa07d28df058cdc8795e5aedabf926c08b1af 100644 --- a/runtime/js_date.cpp +++ b/runtime/js_date.cpp @@ -946,6 +946,7 @@ JSTaggedValue JSDate::SetDateValue(EcmaRuntimeCallInfo *argv, uint32_t code, boo GetDateValues(time_ms, &date, is_local); + [[maybe_unused]] EcmaHandleScope handle_scope(argv->GetThread()); for (uint32_t i = 0; i < count; i++) { JSHandle value = base::BuiltinsBase::GetCallArg(argv, i); JSThread *thread = argv->GetThread(); diff --git a/runtime/napi/jsnapi.cpp b/runtime/napi/jsnapi.cpp index f2f3fc5128f7ccedf32a2708f33bbaeee1d46bc9..fc01813ef2c1447535dde6104eb2f73b21c5b16b 100644 --- a/runtime/napi/jsnapi.cpp +++ b/runtime/napi/jsnapi.cpp @@ -1448,6 +1448,7 @@ JSTaggedValue Callback::RegisterCallback(ecmascript::EcmaRuntimeCallInfo *info) { // Constructor JSThread *thread = info->GetThread(); + [[maybe_unused]] panda::ecmascript::EcmaHandleScope handleScope(thread); JSHandle constructor = BuiltinsBase::GetConstructor(info); if (!constructor->IsJSFunction()) { return JSTaggedValue::False(); diff --git a/tests/runtime/builtins/builtins_array_test.cpp b/tests/runtime/builtins/builtins_array_test.cpp index 6530527aa7064ade7b22a0c7c5be204e54e433b5..f8cb53c8912e9395cf3507c55f6435c8aead4e85 100644 --- a/tests/runtime/builtins/builtins_array_test.cpp +++ b/tests/runtime/builtins/builtins_array_test.cpp @@ -153,6 +153,7 @@ public: // element = [x] JSTaggedValue element = GetCallArg(argv, 0).GetTaggedValue(); + [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle key0(thread, JSTaggedValue(0)); // val = x diff --git a/tests/runtime/builtins/builtins_function_test.cpp b/tests/runtime/builtins/builtins_function_test.cpp index 1a4a160756dd676030e348c5a5b0faeb1a34bd19..07aac87ed3ebc16e2d8c7a50bf73055930d8ff25 100644 --- a/tests/runtime/builtins/builtins_function_test.cpp +++ b/tests/runtime/builtins/builtins_function_test.cpp @@ -65,6 +65,7 @@ public: JSTaggedValue TestFunctionApplyAndCall(EcmaRuntimeCallInfo *argv) { JSThread *thread = argv->GetThread(); + [[maybe_unused]] EcmaHandleScope handleScope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); int result = 0; diff --git a/tests/runtime/builtins/builtins_promise_test.cpp b/tests/runtime/builtins/builtins_promise_test.cpp index 7a9253c5fb8a13e7342c39c9a9b430b5c1696c75..cd0bf8b8a1b7b3bc67f2ffbe624131b25b11b232 100644 --- a/tests/runtime/builtins/builtins_promise_test.cpp +++ b/tests/runtime/builtins/builtins_promise_test.cpp @@ -74,6 +74,7 @@ JSTaggedValue TestPromiseRaceThenOnRejectd(EcmaRuntimeCallInfo *argv) // native function for all then_on_resolved() JSTaggedValue TestPromiseAllThenOnResolved(EcmaRuntimeCallInfo *argv) { + [[maybe_unused]] EcmaHandleScope handleScope(argv->GetThread()); JSHandle array = BuiltinsBase::GetCallArg(argv, 0); JSHandle object_array = JSHandle::Cast(array); [[maybe_unused]] PropertyDescriptor desc(argv->GetThread()); @@ -104,6 +105,7 @@ JSTaggedValue TestPromiseCatch(EcmaRuntimeCallInfo *argv) // native function for then then_on_resolved() JSTaggedValue TestPromiseThenOnResolved(EcmaRuntimeCallInfo *argv) { + [[maybe_unused]] EcmaHandleScope handleScope(argv->GetThread()); auto factory = argv->GetThread()->GetEcmaVM()->GetFactory(); JSHandle result = BuiltinsBase::GetCallArg(argv, 0); auto expect = factory->NewFromCanBeCompressString("resolve"); @@ -114,6 +116,7 @@ JSTaggedValue TestPromiseThenOnResolved(EcmaRuntimeCallInfo *argv) // native function for then then_on_rejected() JSTaggedValue TestPromiseThenOnRejected(EcmaRuntimeCallInfo *argv) { + [[maybe_unused]] EcmaHandleScope handleScope(argv->GetThread()); auto factory = argv->GetThread()->GetEcmaVM()->GetFactory(); JSHandle result = BuiltinsBase::GetCallArg(argv, 0); auto expect = factory->NewFromCanBeCompressString("reject"); diff --git a/tests/runtime/builtins/builtins_reflect_test.cpp b/tests/runtime/builtins/builtins_reflect_test.cpp index 376f87da16d14a7dfd24dba33bc450327dc7bdd5..529bff9a9e034409d418bc8802afb10ced86e273 100644 --- a/tests/runtime/builtins/builtins_reflect_test.cpp +++ b/tests/runtime/builtins/builtins_reflect_test.cpp @@ -71,6 +71,7 @@ static JSHandle TestObjectCreate(JSThread *thread) JSTaggedValue TestReflectApply(EcmaRuntimeCallInfo *argv) { auto thread = argv->GetThread(); + [[maybe_unused]] EcmaHandleScope handleScope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); int result = 0; diff --git a/tests/runtime/common/js_object_test.cpp b/tests/runtime/common/js_object_test.cpp index 564b1b3c36600b725fbb12698a027285f06efb82..62baabefce5ea9817389b196b0624eeee4ef814e 100644 --- a/tests/runtime/common/js_object_test.cpp +++ b/tests/runtime/common/js_object_test.cpp @@ -606,6 +606,7 @@ TEST_F(JSObjectTest, TestIntegrityLevelWithoutProperty) JSTaggedValue TestGetter(EcmaRuntimeCallInfo *argv) { auto thread = argv->GetThread(); + [[maybe_unused]] EcmaHandleScope handleScope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle obj(BuiltinsBase::GetThis(argv)); JSHandle key(factory->NewFromString("y")); @@ -642,6 +643,7 @@ TEST_F(JSObjectTest, Getter) JSTaggedValue TestSetter(EcmaRuntimeCallInfo *argv) { JSThread *thread = argv->GetThread(); + [[maybe_unused]] EcmaHandleScope handleScope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle obj(BuiltinsBase::GetThis(argv)); JSHandle key(factory->NewFromString("y")); diff --git a/tests/runtime/common/js_proxy_test.cpp b/tests/runtime/common/js_proxy_test.cpp index 7833c01f03aa06125be81747c5c92376d7e5d658..ff80a62e3ed836ddfb07b30a61a7e7a822829b98 100644 --- a/tests/runtime/common/js_proxy_test.cpp +++ b/tests/runtime/common/js_proxy_test.cpp @@ -487,6 +487,7 @@ TEST_F(JSProxyTest, HasProperty) JSTaggedValue HandlerOwnPropertyKeys([[maybe_unused]] EcmaRuntimeCallInfo *argv) { auto thread = argv->GetThread(); + [[maybe_unused]] EcmaHandleScope handleScope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle arr = factory->NewJSArray(); return JSTaggedValue(arr.GetTaggedValue()); @@ -585,6 +586,7 @@ TEST_F(JSProxyTest, Call) JSTaggedValue HandlerConstruct([[maybe_unused]] EcmaRuntimeCallInfo *argv) { auto thread = argv->GetThread(); + [[maybe_unused]] EcmaHandleScope handleScope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle dynclass(thread, JSObjectTestCreate(thread)); JSHandle obj(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); @@ -597,6 +599,7 @@ JSTaggedValue HandlerConstruct([[maybe_unused]] EcmaRuntimeCallInfo *argv) JSTaggedValue HandlerConFunc([[maybe_unused]] EcmaRuntimeCallInfo *argv) { auto thread = argv->GetThread(); + [[maybe_unused]] EcmaHandleScope handleScope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle dynclass(thread, JSObjectTestCreate(thread)); JSHandle obj(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); diff --git a/tests/runtime/tooling/js_test_api.h b/tests/runtime/tooling/js_test_api.h index 2cdb428aba445d02eac123fd5ea43dac82557d85..77303c4ea774b64ca539dc9c494c66dba8556503 100644 --- a/tests/runtime/tooling/js_test_api.h +++ b/tests/runtime/tooling/js_test_api.h @@ -28,6 +28,7 @@ public: static VRegValue StringToVRegValue(const PandaString &value) { JSThread *js_thread = JSThread::Cast(JSThread::GetCurrent()); + [[maybe_unused]] panda::ecmascript::EcmaHandleScope handle_scope(js_thread); auto ecma_vm = js_thread->GetEcmaVM(); panda::ecmascript::ObjectFactory *factory = ecma_vm->GetFactory();