• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PANDA_PLUGINS_ETS_RUNTIME_INTEROP_JS_ETS_PROXY_SHARED_REFERENCE_STORAGE_VERIFIER_H_
17 #define PANDA_PLUGINS_ETS_RUNTIME_INTEROP_JS_ETS_PROXY_SHARED_REFERENCE_STORAGE_VERIFIER_H_
18 
19 #include "plugins/ets/runtime/interop_js/ets_proxy/shared_reference_storage.h"
20 #include "plugins/ets/runtime/interop_js/ets_proxy/mem/items_pool.h"
21 
22 namespace ark::ets::interop::js::ets_proxy {
23 namespace testing {
24 class SharedReferenceStorage1GTest;
25 }  // namespace testing
26 enum class XgcStatus {
27     XGC_START,
28     XGC_FINISHED,
29 };
30 
31 class SharedReferenceStorageVerifier {
32 public:
33     static size_t TraverseAllItems(const SharedReferenceStorage *const storage, XgcStatus status);
34 
35 private:
36     friend class testing::SharedReferenceStorage1GTest;
37     static size_t VerifyOneItem(const SharedReferenceStorage *const storage, size_t index, XgcStatus status);
38     static size_t CheckObjectAlive(const SharedReference *item, size_t index);
39     static size_t CheckObjectAddressValid(const SharedReference *item, size_t index);
40     static size_t CheckJsObjectType(const SharedReference *item, size_t index);
41     static size_t CheckObjectReindex(const SharedReferenceStorage *const storage, const SharedReference *item,
42                                      size_t index);
43     static size_t IsAllItemsMarked(const SharedReference *item, size_t index);
44     static size_t CheckJsObjectAlive(const SharedReference *item, size_t index);
45     static size_t CheckJEtsObjectAlive(const SharedReference *item, size_t index);
46 
47     static size_t CheckJsObjectAddress(const SharedReference *item, size_t index);
48     static size_t CheckEtsObjectAddress(const SharedReference *item, size_t index);
49 
50     static bool CheckJsObjectTypeIsJsXref(const SharedReference *item);
51 
52     static size_t CheckJsObjectReindex(const SharedReferenceStorage *const storage, const SharedReference *item,
53                                        size_t index);
54     static size_t CheckEtsObjectReindex(const SharedReference *item, size_t index);
55 };
56 }  // namespace ark::ets::interop::js::ets_proxy
57 
58 #endif  // !PANDA_PLUGINS_ETS_RUNTIME_INTEROP_JS_ETS_PROXY_SHARED_REFERENCE_STORAGE_VERIFIER_H_