Fix sendable didn't adapt deserialize MarkAndPush and delete useless

code
Description:Delete useless code
Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I9G0S6?from=project-issue

Signed-off-by: dingwen <dingwen6@huawei.com>
Change-Id: I3335a22ab374ff390c501b4c206d3bf28a19c700
This commit is contained in:
dingwen 2024-04-12 10:18:00 +08:00
parent aa5add7e17
commit b1b4f083e4
9 changed files with 2 additions and 173 deletions

View File

@ -42,16 +42,4 @@ void Barriers::Update(const JSThread *thread, uintptr_t slotAddr, Region *object
heap->GetWorkManager()->Push(MAIN_THREAD_INDEX, heapValue, valueRegion); heap->GetWorkManager()->Push(MAIN_THREAD_INDEX, heapValue, valueRegion);
} }
} }
// For work deserialize, deserialize root object will be set to another object, however, this object may have been
// marked by concurrent mark, this may cause deserialize root object miss mark, this is to ensure the deserialize object
// will been marked
void Barriers::MarkAndPushForDeserialize(const JSThread *thread, TaggedObject *object)
{
auto heap = thread->GetEcmaVM()->GetHeap();
Region *valueRegion = Region::ObjectAddressToRange(object);
if ((heap->IsConcurrentFullMark() || valueRegion->InYoungSpace()) && valueRegion->AtomicMark(object)) {
heap->GetWorkManager()->Push(MAIN_THREAD_INDEX, object, valueRegion);
}
}
} // namespace panda::ecmascript } // namespace panda::ecmascript

View File

@ -61,8 +61,6 @@ public:
static void PUBLIC_API Update(const JSThread *thread, uintptr_t slotAddr, Region *objectRegion, static void PUBLIC_API Update(const JSThread *thread, uintptr_t slotAddr, Region *objectRegion,
TaggedObject *value, Region *valueRegion, TaggedObject *value, Region *valueRegion,
WriteBarrierType writeType = WriteBarrierType::NORMAL); WriteBarrierType writeType = WriteBarrierType::NORMAL);
// For work deserialize, push deserialize result to mark stack if thread IsConcurrentMarkingOrFinished
static void MarkAndPushForDeserialize(const JSThread *thread, TaggedObject *object);
}; };
} // namespace panda::ecmascript } // namespace panda::ecmascript

View File

@ -62,14 +62,8 @@ JSHandle<JSTaggedValue> BaseDeserializer::DeserializeJSTaggedValue()
while (ReadSingleEncodeData(encodeFlag, resHandle.GetAddress(), 0, true) == 0) { // 0: root object offset while (ReadSingleEncodeData(encodeFlag, resHandle.GetAddress(), 0, true) == 0) { // 0: root object offset
encodeFlag = data_->ReadUint8(position_); encodeFlag = data_->ReadUint8(position_);
} }
// now new constpool here if newConstPoolInfos_ is not empty
for (auto newConstpoolInfo : newConstPoolInfos_) {
DeserializeConstPool(newConstpoolInfo);
delete newConstpoolInfo;
}
newConstPoolInfos_.clear();
// initialize concurrent func here after constpool is set // initialize concurrent func here
for (auto func : concurrentFunctions_) { for (auto func : concurrentFunctions_) {
func->InitializeForConcurrentFunction(thread_); func->InitializeForConcurrentFunction(thread_);
} }
@ -92,11 +86,6 @@ JSHandle<JSTaggedValue> BaseDeserializer::DeserializeJSTaggedValue()
// recovery gc after serialize // recovery gc after serialize
heap_->SetOnSerializeEvent(false); heap_->SetOnSerializeEvent(false);
// If is on concurrent mark, mark push root object to stack for mark
if (resHandle->IsHeapObject() && thread_->IsConcurrentMarkingOrFinished()) {
Barriers::MarkAndPushForDeserialize(thread_, resHandle->GetHeapObject());
}
return resHandle; return resHandle;
} }
@ -118,20 +107,6 @@ void BaseDeserializer::DeserializeObjectField(uintptr_t start, uintptr_t end)
} }
} }
void BaseDeserializer::DeserializeConstPool(NewConstPoolInfo *info)
{
[[maybe_unused]] EcmaHandleScope scope(thread_);
JSPandaFile *jsPandaFile = info->jsPandaFile_;
panda_file::File::EntityId methodId = info->methodId_;
ObjectSlot slot = info->GetSlot();
EcmaContext *context = thread_->GetCurrentEcmaContext();
JSHandle<ConstantPool> constpool = context->CreateConstpoolPair(jsPandaFile, methodId);
slot.Update(constpool.GetTaggedType());
WriteBarrier(thread_, reinterpret_cast<void *>(info->GetObjAddr()), info->GetFieldOffset(),
constpool.GetTaggedType());
}
void BaseDeserializer::DeserializeNativeBindingObject(NativeBindingInfo *info) void BaseDeserializer::DeserializeNativeBindingObject(NativeBindingInfo *info)
{ {
[[maybe_unused]] EcmaHandleScope scope(thread_); [[maybe_unused]] EcmaHandleScope scope(thread_);
@ -178,8 +153,6 @@ void BaseDeserializer::HandleNewObjectEncodeFlag(SerializedObjectSpace space, u
bool isTransferBuffer = GetAndResetTransferBuffer(); bool isTransferBuffer = GetAndResetTransferBuffer();
bool isSharedArrayBuffer = GetAndResetSharedArrayBuffer(); bool isSharedArrayBuffer = GetAndResetSharedArrayBuffer();
void *bufferPointer = GetAndResetBufferPointer(); void *bufferPointer = GetAndResetBufferPointer();
ConstantPool *constpool = GetAndResetConstantPool();
bool needNewConstPool = GetAndResetNeedNewConstPool();
// deserialize object here // deserialize object here
uintptr_t addr = DeserializeTaggedObject(space); uintptr_t addr = DeserializeTaggedObject(space);
@ -190,12 +163,6 @@ void BaseDeserializer::HandleNewObjectEncodeFlag(SerializedObjectSpace space, u
IncreaseSharedArrayBufferReference(addr); IncreaseSharedArrayBufferReference(addr);
} else if (bufferPointer != nullptr) { } else if (bufferPointer != nullptr) {
ResetNativePointerBuffer(addr, bufferPointer); ResetNativePointerBuffer(addr, bufferPointer);
} else if (constpool != nullptr) {
ResetMethodConstantPool(addr, constpool);
} else if (needNewConstPool) {
// defer new constpool
newConstPoolInfos_.back()->objAddr_ = addr;
newConstPoolInfos_.back()->offset_ = Method::CONSTANT_POOL_OFFSET;
} }
TaggedObject *object = reinterpret_cast<TaggedObject *>(addr); TaggedObject *object = reinterpret_cast<TaggedObject *>(addr);
if (object->GetClass()->IsJSNativePointer()) { if (object->GetClass()->IsJSNativePointer()) {
@ -207,7 +174,7 @@ void BaseDeserializer::HandleNewObjectEncodeFlag(SerializedObjectSpace space, u
JSFunction* func = reinterpret_cast<JSFunction *>(object); JSFunction* func = reinterpret_cast<JSFunction *>(object);
FunctionKind funcKind = func->GetFunctionKind(); FunctionKind funcKind = func->GetFunctionKind();
if (funcKind == FunctionKind::CONCURRENT_FUNCTION || object->GetClass()->IsJSSharedFunction()) { if (funcKind == FunctionKind::CONCURRENT_FUNCTION || object->GetClass()->IsJSSharedFunction()) {
// defer initialize concurrent function until constpool is set // defer initialize concurrent function
concurrentFunctions_.push_back(reinterpret_cast<JSFunction *>(object)); concurrentFunctions_.push_back(reinterpret_cast<JSFunction *>(object));
} }
} }
@ -218,24 +185,6 @@ void BaseDeserializer::HandleNewObjectEncodeFlag(SerializedObjectSpace space, u
} }
} }
void BaseDeserializer::HandleMethodEncodeFlag()
{
panda_file::File::EntityId methodId = MethodLiteral::GetMethodId(data_->ReadJSTaggedType(position_));
JSPandaFile *jsPandaFile = reinterpret_cast<JSPandaFile *>(data_->ReadJSTaggedType(position_));
panda_file::IndexAccessor indexAccessor(*jsPandaFile->GetPandaFile(), methodId);
int32_t index = static_cast<int32_t>(indexAccessor.GetHeaderIndex());
JSTaggedValue constpool = thread_->GetCurrentEcmaContext()->FindConstpoolWithAOT(jsPandaFile, index);
if (constpool.IsHole()) {
LOG_ECMA(INFO) << "ValueDeserialize: function deserialize can't find constpool from panda file: "
<< jsPandaFile;
// defer new constpool until deserialize finish
needNewConstPool_ = true;
newConstPoolInfos_.push_back(new NewConstPoolInfo(jsPandaFile, methodId));
} else {
constpool_ = reinterpret_cast<ConstantPool *>(constpool.GetTaggedObject());
}
}
void BaseDeserializer::TransferArrayBufferAttach(uintptr_t objAddr) void BaseDeserializer::TransferArrayBufferAttach(uintptr_t objAddr)
{ {
ASSERT(JSTaggedValue(static_cast<JSTaggedType>(objAddr)).IsArrayBuffer()); ASSERT(JSTaggedValue(static_cast<JSTaggedType>(objAddr)).IsArrayBuffer());
@ -280,13 +229,6 @@ void BaseDeserializer::ResetNativePointerBuffer(uintptr_t objAddr, void *bufferP
np->SetData(thread_->GetEcmaVM()->GetNativeAreaAllocator()); np->SetData(thread_->GetEcmaVM()->GetNativeAreaAllocator());
} }
void BaseDeserializer::ResetMethodConstantPool(uintptr_t objAddr, ConstantPool *constpool)
{
ASSERT(JSTaggedValue(static_cast<JSTaggedType>(objAddr)).IsMethod());
Method *method = reinterpret_cast<Method *>(objAddr);
method->SetConstantPool(thread_, JSTaggedValue(constpool), BarrierMode::SKIP_BARRIER);
}
size_t BaseDeserializer::ReadSingleEncodeData(uint8_t encodeFlag, uintptr_t objAddr, size_t fieldOffset, bool isRoot) size_t BaseDeserializer::ReadSingleEncodeData(uint8_t encodeFlag, uintptr_t objAddr, size_t fieldOffset, bool isRoot)
{ {
size_t handledFieldSize = sizeof(JSTaggedType); size_t handledFieldSize = sizeof(JSTaggedType);
@ -362,11 +304,6 @@ size_t BaseDeserializer::ReadSingleEncodeData(uint8_t encodeFlag, uintptr_t objA
handledFieldSize = 0; handledFieldSize = 0;
break; break;
} }
case (uint8_t)EncodeFlag::METHOD: {
HandleMethodEncodeFlag();
handledFieldSize = 0;
break;
}
case (uint8_t)EncodeFlag::NATIVE_BINDING_OBJECT: { case (uint8_t)EncodeFlag::NATIVE_BINDING_OBJECT: {
slot.Update(JSTaggedValue::Undefined().GetRawData()); slot.Update(JSTaggedValue::Undefined().GetRawData());
AttachFunc af = reinterpret_cast<AttachFunc>(data_->ReadJSTaggedType(position_)); AttachFunc af = reinterpret_cast<AttachFunc>(data_->ReadJSTaggedType(position_));

View File

@ -22,31 +22,6 @@
namespace panda::ecmascript { namespace panda::ecmascript {
class Heap; class Heap;
class JSThread; class JSThread;
struct NewConstPoolInfo {
JSPandaFile *jsPandaFile_ {nullptr};
panda_file::File::EntityId methodId_;
uintptr_t objAddr_ {0U};
size_t offset_ {0U};
NewConstPoolInfo(JSPandaFile *jsPandaFile, panda_file::File::EntityId methodId)
: jsPandaFile_(jsPandaFile), methodId_(methodId) {}
uintptr_t GetObjAddr() const
{
return objAddr_;
}
size_t GetFieldOffset() const
{
return offset_;
}
ObjectSlot GetSlot() const
{
return ObjectSlot(objAddr_ + offset_);
}
};
struct NativeBindingInfo { struct NativeBindingInfo {
AttachFunc af_ {nullptr}; AttachFunc af_ {nullptr};
void *bufferPointer_ {nullptr}; void *bufferPointer_ {nullptr};
@ -123,7 +98,6 @@ public:
private: private:
JSHandle<JSTaggedValue> DeserializeJSTaggedValue(); JSHandle<JSTaggedValue> DeserializeJSTaggedValue();
uintptr_t DeserializeTaggedObject(SerializedObjectSpace space); uintptr_t DeserializeTaggedObject(SerializedObjectSpace space);
void DeserializeConstPool(NewConstPoolInfo *info);
void DeserializeNativeBindingObject(NativeBindingInfo *info); void DeserializeNativeBindingObject(NativeBindingInfo *info);
void DeserializeJSError(JSErrorInfo *info); void DeserializeJSError(JSErrorInfo *info);
uintptr_t RelocateObjectAddr(SerializedObjectSpace space, size_t objSize); uintptr_t RelocateObjectAddr(SerializedObjectSpace space, size_t objSize);
@ -131,12 +105,10 @@ private:
void DeserializeObjectField(uintptr_t start, uintptr_t end); void DeserializeObjectField(uintptr_t start, uintptr_t end);
size_t ReadSingleEncodeData(uint8_t encodeFlag, uintptr_t objAddr, size_t fieldOffset, bool isRoot = false); size_t ReadSingleEncodeData(uint8_t encodeFlag, uintptr_t objAddr, size_t fieldOffset, bool isRoot = false);
void HandleNewObjectEncodeFlag(SerializedObjectSpace space, uintptr_t objAddr, size_t fieldOffset, bool isRoot); void HandleNewObjectEncodeFlag(SerializedObjectSpace space, uintptr_t objAddr, size_t fieldOffset, bool isRoot);
void HandleMethodEncodeFlag();
void TransferArrayBufferAttach(uintptr_t objAddr); void TransferArrayBufferAttach(uintptr_t objAddr);
void IncreaseSharedArrayBufferReference(uintptr_t objAddr); void IncreaseSharedArrayBufferReference(uintptr_t objAddr);
void ResetNativePointerBuffer(uintptr_t objAddr, void *bufferPointer); void ResetNativePointerBuffer(uintptr_t objAddr, void *bufferPointer);
void ResetMethodConstantPool(uintptr_t objAddr, ConstantPool *constpool);
void AllocateToDifferentSpaces(); void AllocateToDifferentSpaces();
void AllocateMultiRegion(SparseSpace *space, size_t spaceObjSize, size_t &regionIndex); void AllocateMultiRegion(SparseSpace *space, size_t spaceObjSize, size_t &regionIndex);
@ -174,15 +146,6 @@ private:
return isSharedArrayBuffer; return isSharedArrayBuffer;
} }
bool GetAndResetNeedNewConstPool()
{
bool needNewConstPool = needNewConstPool_;
if (needNewConstPool_) {
needNewConstPool_ = false;
}
return needNewConstPool;
}
bool GetAndResetIsErrorMsg() bool GetAndResetIsErrorMsg()
{ {
bool isErrorMsg = isErrorMsg_; bool isErrorMsg = isErrorMsg_;
@ -211,16 +174,6 @@ private:
return nullptr; return nullptr;
} }
ConstantPool *GetAndResetConstantPool()
{
if (constpool_) {
ConstantPool *constpool = constpool_;
constpool_ = nullptr;
return constpool;
}
return nullptr;
}
void UpdateMaybeWeak(ObjectSlot slot, uintptr_t addr, bool isWeak) void UpdateMaybeWeak(ObjectSlot slot, uintptr_t addr, bool isWeak)
{ {
isWeak ? slot.UpdateWeak(addr) : slot.Update(addr); isWeak ? slot.UpdateWeak(addr) : slot.Update(addr);
@ -250,10 +203,7 @@ private:
bool isSharedArrayBuffer_ {false}; bool isSharedArrayBuffer_ {false};
bool isErrorMsg_ {false}; bool isErrorMsg_ {false};
void *bufferPointer_ {nullptr}; void *bufferPointer_ {nullptr};
ConstantPool *constpool_ {nullptr};
bool needNewConstPool_ {false};
bool functionInShared_ {false}; bool functionInShared_ {false};
CVector<NewConstPoolInfo *> newConstPoolInfos_;
CVector<NativeBindingInfo *> nativeBindingInfos_; CVector<NativeBindingInfo *> nativeBindingInfos_;
CVector<JSErrorInfo *> jsErrorInfos_; CVector<JSErrorInfo *> jsErrorInfos_;
CVector<JSFunction *> concurrentFunctions_; CVector<JSFunction *> concurrentFunctions_;

View File

@ -121,9 +121,6 @@ bool BaseSerializer::SerializeSpecialObjIndividually(JSType objectType, TaggedOb
case JSType::JS_ASYNC_FUNCTION: case JSType::JS_ASYNC_FUNCTION:
SerializeAsyncFunctionFieldIndividually(root, start, end); SerializeAsyncFunctionFieldIndividually(root, start, end);
return true; return true;
case JSType::METHOD:
SerializeMethodFieldIndividually(root, start, end);
return true;
default: default:
return false; return false;
} }
@ -293,28 +290,6 @@ void BaseSerializer::SerializeAsyncFunctionFieldIndividually(TaggedObject *root,
} }
} }
void BaseSerializer::SerializeMethodFieldIndividually(TaggedObject *root, ObjectSlot start, ObjectSlot end)
{
ASSERT(root->GetClass()->IsMethod());
ObjectSlot slot = start;
while (slot < end) {
size_t fieldOffset = slot.SlotAddress() - ToUintPtr(root);
switch (fieldOffset) {
case Method::CONSTANT_POOL_OFFSET:{
data_->WriteEncodeFlag(EncodeFlag::PRIMITIVE);
data_->WriteJSTaggedValue(JSTaggedValue::Undefined());
slot++;
break;
}
default: {
SerializeJSTaggedValue(JSTaggedValue(slot.GetTaggedType()));
slot++;
break;
}
}
}
}
void BaseSerializer::SerializeObjectProto(JSHClass *kclass, JSTaggedValue proto) void BaseSerializer::SerializeObjectProto(JSHClass *kclass, JSTaggedValue proto)
{ {
if (!proto.IsHeapObject()) { if (!proto.IsHeapObject()) {

View File

@ -59,7 +59,6 @@ protected:
void SerializeSFunctionModule(JSFunction *func); void SerializeSFunctionModule(JSFunction *func);
void SerializeLexicalEnvFieldIndividually(TaggedObject *root, ObjectSlot start, ObjectSlot end); void SerializeLexicalEnvFieldIndividually(TaggedObject *root, ObjectSlot start, ObjectSlot end);
void SerializeAsyncFunctionFieldIndividually(TaggedObject *root, ObjectSlot start, ObjectSlot end); void SerializeAsyncFunctionFieldIndividually(TaggedObject *root, ObjectSlot start, ObjectSlot end);
void SerializeMethodFieldIndividually(TaggedObject *root, ObjectSlot start, ObjectSlot end);
void SerializeObjectProto(JSHClass *kclass, JSTaggedValue proto); void SerializeObjectProto(JSHClass *kclass, JSTaggedValue proto);
void SerializeTaggedObjField(SerializeType serializeType, TaggedObject *root, ObjectSlot start, ObjectSlot end); void SerializeTaggedObjField(SerializeType serializeType, TaggedObject *root, ObjectSlot start, ObjectSlot end);
void SerializeInObjField(TaggedObject *object, ObjectSlot start, ObjectSlot end); void SerializeInObjField(TaggedObject *object, ObjectSlot start, ObjectSlot end);

View File

@ -45,7 +45,6 @@ enum class EncodeFlag : uint8_t {
ARRAY_BUFFER, ARRAY_BUFFER,
TRANSFER_ARRAY_BUFFER, TRANSFER_ARRAY_BUFFER,
SHARED_ARRAY_BUFFER, SHARED_ARRAY_BUFFER,
METHOD,
NATIVE_BINDING_OBJECT, NATIVE_BINDING_OBJECT,
JS_ERROR, JS_ERROR,
JS_REG_EXP, JS_REG_EXP,

View File

@ -179,9 +179,6 @@ void ValueSerializer::SerializeObjectImpl(TaggedObject *object, bool isWeak)
case JSType::JS_SHARED_ARRAY_BUFFER: case JSType::JS_SHARED_ARRAY_BUFFER:
SerializeJSSharedArrayBufferPrologue(object); SerializeJSSharedArrayBufferPrologue(object);
break; break;
case JSType::METHOD:
SerializeMethodPrologue(reinterpret_cast<Method *>(object));
break;
case JSType::JS_ARRAY: { case JSType::JS_ARRAY: {
JSArray *array = reinterpret_cast<JSArray *>(object); JSArray *array = reinterpret_cast<JSArray *>(object);
trackInfo = array->GetTrackInfo(); trackInfo = array->GetTrackInfo();
@ -349,19 +346,6 @@ void ValueSerializer::SerializeJSSharedArrayBufferPrologue(TaggedObject *object)
} }
} }
void ValueSerializer::SerializeMethodPrologue(Method *method)
{
JSTaggedValue constPoolVal = method->GetConstantPool();
if (!constPoolVal.IsHeapObject()) {
return;
}
ConstantPool *constPool = reinterpret_cast<ConstantPool *>(constPoolVal.GetTaggedObject());
const JSPandaFile *jsPandaFile = constPool->GetJSPandaFile();
data_->WriteEncodeFlag(EncodeFlag::METHOD);
data_->WriteJSTaggedType(method->GetLiteralInfo());
data_->WriteJSTaggedType(reinterpret_cast<JSTaggedType>(jsPandaFile));
}
void ValueSerializer::SerializeJSRegExpPrologue(JSRegExp *jsRegExp) void ValueSerializer::SerializeJSRegExpPrologue(JSRegExp *jsRegExp)
{ {
uint32_t bufferSize = jsRegExp->GetLength(); uint32_t bufferSize = jsRegExp->GetLength();

View File

@ -43,7 +43,6 @@ private:
void SerializeNativeBindingObject(TaggedObject *object); void SerializeNativeBindingObject(TaggedObject *object);
bool SerializeJSArrayBufferPrologue(TaggedObject *object); bool SerializeJSArrayBufferPrologue(TaggedObject *object);
void SerializeJSSharedArrayBufferPrologue(TaggedObject *object); void SerializeJSSharedArrayBufferPrologue(TaggedObject *object);
void SerializeMethodPrologue(Method *method);
void SerializeJSRegExpPrologue(JSRegExp *jsRegExp); void SerializeJSRegExpPrologue(JSRegExp *jsRegExp);
void InitTransferSet(CUnorderedSet<uintptr_t> transferDataSet); void InitTransferSet(CUnorderedSet<uintptr_t> transferDataSet);
bool PrepareTransfer(JSThread *thread, const JSHandle<JSTaggedValue> &transfer); bool PrepareTransfer(JSThread *thread, const JSHandle<JSTaggedValue> &transfer);