• 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 ECMASCRIPT_SERIALIZER_INTER_OP_VALUE_DESERIALIZER_H
17 #define ECMASCRIPT_SERIALIZER_INTER_OP_VALUE_DESERIALIZER_H
18 
19 #include "ecmascript/serializer/base_deserializer.h"
20 #include "ecmascript/serializer/serialize_data.h"
21 
22 namespace panda::ecmascript {
23 class Heap;
24 class JSThread;
25 struct XRefBindingAttachInfo {
26     AttachXRefFunc af_ {nullptr};
27     void *attachXRefData_ = {nullptr};
28     JSHandle<JSTaggedValue> obj_;
29     size_t offset_ {0U};
30 
XRefBindingAttachInfoXRefBindingAttachInfo31     XRefBindingAttachInfo(AttachXRefFunc af, void *attachXRefData, JSHandle<JSTaggedValue> obj, size_t offset)
32         : af_(af), attachXRefData_(attachXRefData), obj_(obj), offset_(offset) {}
33 
GetObjAddrXRefBindingAttachInfo34     uintptr_t GetObjAddr() const
35     {
36         return static_cast<uintptr_t>(obj_->GetRawData());
37     }
38 
GetFieldOffsetXRefBindingAttachInfo39     size_t GetFieldOffset() const
40     {
41         return offset_;
42     }
43 
GetSlotXRefBindingAttachInfo44     ObjectSlot GetSlot() const
45     {
46         return ObjectSlot(GetObjAddr() + offset_);
47     }
48 };
49 
50 class InterOpValueDeserializer : public BaseDeserializer {
51 public:
52     explicit InterOpValueDeserializer(JSThread *thread, SerializeData *data, void *hint = nullptr)
BaseDeserializer(thread,data,hint)53         : BaseDeserializer(thread, data, hint) {}
54 
55     ~InterOpValueDeserializer() = default;
56 
57     NO_COPY_SEMANTIC(InterOpValueDeserializer);
58     NO_MOVE_SEMANTIC(InterOpValueDeserializer);
59 
60 private:
61     size_t DerivedExtraReadSingleEncodeData(uint8_t encodeFlag, uintptr_t objAddr, size_t fieldOffset) override;
62     void DeserializeSpecialRecordedObjects() override;
63     void DeserializeXRefBindingObject(XRefBindingAttachInfo *info);
64     std::vector<XRefBindingAttachInfo> xRefBindingAttachInfos_;
65 };
66 }
67 
68 #endif  // ECMASCRIPT_SERIALIZER_INTER_OP_VALUE_DESERIALIZER_H