mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 16:13:49 +00:00
d8f421a6e3
1. Record local to share in write barrier 2. Update local to share rememberset after GC 3. Remove ecmaVM_ from ObjXray Signed-off-by: lukai <lukai25@huawei.com> Change-Id: Id53bab9b0af8675282b51e95412798f7c36cfb68
64 lines
2.4 KiB
C++
64 lines
2.4 KiB
C++
/*
|
|
* 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_SERIALIZER_BASE_SERIALIZER_INL_H
|
|
#define ECMASCRIPT_SERIALIZER_BASE_SERIALIZER_INL_H
|
|
|
|
#include "ecmascript/serializer/base_serializer.h"
|
|
|
|
namespace panda::ecmascript {
|
|
|
|
template<SerializeType serializeType>
|
|
void BaseSerializer::SerializeObjectField(TaggedObject *object)
|
|
{
|
|
auto visitor = [this](TaggedObject *root, ObjectSlot start, ObjectSlot end, VisitObjectArea area) {
|
|
switch (area) {
|
|
case VisitObjectArea::RAW_DATA:
|
|
WriteMultiRawData(start.SlotAddress(), end.SlotAddress() - start.SlotAddress());
|
|
break;
|
|
case VisitObjectArea::NATIVE_POINTER:
|
|
if (serializeType == SerializeType::VALUE_SERIALIZE) {
|
|
WriteMultiRawData(start.SlotAddress(), end.SlotAddress() - start.SlotAddress());
|
|
}
|
|
break;
|
|
case VisitObjectArea::IN_OBJECT: {
|
|
SerializeInObjField(root, start, end);
|
|
break;
|
|
}
|
|
default:
|
|
SerializeTaggedObjField(serializeType, root, start, end);
|
|
break;
|
|
}
|
|
};
|
|
|
|
ObjectXRay::VisitObjectBody<VisitType::ALL_VISIT>(object, object->GetClass(), visitor);
|
|
}
|
|
|
|
template<SerializeType serializeType>
|
|
void BaseSerializer::SerializeTaggedObject(TaggedObject *object)
|
|
{
|
|
JSHClass *hclass = object->GetClass();
|
|
size_t objectSize = hclass->SizeFromJSHClass(object);
|
|
SerializedObjectSpace space = GetSerializedObjectSpace(object);
|
|
data_->WriteUint8(SerializeData::EncodeNewObject(space));
|
|
data_->WriteUint32(objectSize);
|
|
data_->CalculateSerializedObjectSize(space, objectSize);
|
|
referenceMap_.emplace(object, objectIndex_++);
|
|
|
|
SerializeObjectField<serializeType>(object);
|
|
}
|
|
}
|
|
|
|
#endif // ECMASCRIPT_SERIALIZER_BASE_SERIALIZER_INL_H
|