mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 16:13:49 +00:00
!7833 Support sendable arraybuffer/typedarray set in clone list.
Merge pull request !7833 from lijiamin/debug
This commit is contained in:
commit
63eab1965c
@ -667,7 +667,6 @@ private:
|
||||
EcmaRuntimeStat *runtimeStat_ {nullptr};
|
||||
|
||||
CMap<const JSPandaFile *, CMap<int32_t, JSTaggedValue>> cachedSharedConstpools_ {};
|
||||
// todo(lijiamin) Consider expanding capacity.
|
||||
std::array<JSTaggedValue, UNSHARED_CONSTANTPOOL_COUNT> unsharedConstpools_ {};
|
||||
static constexpr int32_t SHARED_CONSTPOOL_KEY_NOT_FOUND = INT32_MAX; // INT32_MAX :invalid value.
|
||||
|
||||
|
@ -297,6 +297,7 @@ size_t BaseDeserializer::ReadSingleEncodeData(uint8_t encodeFlag, uintptr_t objA
|
||||
break;
|
||||
}
|
||||
case (uint8_t)EncodeFlag::ARRAY_BUFFER:
|
||||
case (uint8_t)EncodeFlag::SENDABLE_ARRAY_BUFFER:
|
||||
case (uint8_t)EncodeFlag::JS_REG_EXP: {
|
||||
size_t bufferLength = data_->ReadUint32(position_);
|
||||
auto nativeAreaAllocator = thread_->GetEcmaVM()->GetNativeAreaAllocator();
|
||||
|
@ -45,6 +45,7 @@ enum class EncodeFlag : uint8_t {
|
||||
ARRAY_BUFFER,
|
||||
TRANSFER_ARRAY_BUFFER,
|
||||
SHARED_ARRAY_BUFFER,
|
||||
SENDABLE_ARRAY_BUFFER,
|
||||
NATIVE_BINDING_OBJECT,
|
||||
JS_ERROR,
|
||||
JS_REG_EXP,
|
||||
|
@ -184,6 +184,11 @@ void ValueSerializer::SerializeObjectImpl(TaggedObject *object, bool isWeak)
|
||||
SerializeJSSharedArrayBufferPrologue(object);
|
||||
break;
|
||||
}
|
||||
case JSType::JS_SENDABLE_ARRAY_BUFFER: {
|
||||
supportJSNativePointer_ = true;
|
||||
SerializeJSSendableArrayBufferPrologue(object);
|
||||
break;
|
||||
}
|
||||
case JSType::JS_ARRAY: {
|
||||
JSArray *array = reinterpret_cast<JSArray *>(object);
|
||||
trackInfo = array->GetTrackInfo();
|
||||
@ -211,6 +216,7 @@ void ValueSerializer::SerializeObjectImpl(TaggedObject *object, bool isWeak)
|
||||
switch (type) {
|
||||
case JSType::JS_ARRAY_BUFFER:
|
||||
case JSType::JS_SHARED_ARRAY_BUFFER:
|
||||
case JSType::JS_SENDABLE_ARRAY_BUFFER:
|
||||
case JSType::JS_REG_EXP:
|
||||
// JSNativePointer supports serialization only during serialize JSArrayBuffer,
|
||||
// JSSharedArrayBuffer and JSRegExp
|
||||
@ -368,6 +374,31 @@ void ValueSerializer::SerializeJSSharedArrayBufferPrologue(TaggedObject *object)
|
||||
}
|
||||
}
|
||||
|
||||
void ValueSerializer::SerializeJSSendableArrayBufferPrologue(TaggedObject *object)
|
||||
{
|
||||
ASSERT(object->GetClass()->IsSendableArrayBuffer());
|
||||
JSSendableArrayBuffer *arrayBuffer = reinterpret_cast<JSSendableArrayBuffer *>(object);
|
||||
if (arrayBuffer->IsDetach()) {
|
||||
LOG_ECMA(ERROR) << "ValueSerialize: don't support serialize detached sendable array buffer";
|
||||
notSupport_ = true;
|
||||
return;
|
||||
}
|
||||
size_t arrayLength = arrayBuffer->GetArrayBufferByteLength();
|
||||
if (arrayLength > 0) {
|
||||
bool nativeAreaAllocated = arrayBuffer->GetWithNativeAreaAllocator();
|
||||
if (!nativeAreaAllocated) {
|
||||
LOG_ECMA(ERROR) << "ValueSerialize: don't support clone sendablearraybuffer has external allocated buffer";
|
||||
notSupport_ = true;
|
||||
return;
|
||||
}
|
||||
data_->WriteEncodeFlag(EncodeFlag::SENDABLE_ARRAY_BUFFER);
|
||||
data_->WriteUint32(arrayLength);
|
||||
JSNativePointer *np =
|
||||
reinterpret_cast<JSNativePointer *>(arrayBuffer->GetArrayBufferData().GetTaggedObject());
|
||||
data_->WriteRawData(static_cast<uint8_t *>(np->GetExternalPointer()), arrayLength);
|
||||
}
|
||||
}
|
||||
|
||||
void ValueSerializer::SerializeJSRegExpPrologue(JSRegExp *jsRegExp)
|
||||
{
|
||||
uint32_t bufferSize = jsRegExp->GetLength();
|
||||
|
@ -43,6 +43,7 @@ private:
|
||||
void SerializeNativeBindingObject(TaggedObject *object);
|
||||
bool SerializeJSArrayBufferPrologue(TaggedObject *object);
|
||||
void SerializeJSSharedArrayBufferPrologue(TaggedObject *object);
|
||||
void SerializeJSSendableArrayBufferPrologue(TaggedObject *object);
|
||||
void SerializeJSRegExpPrologue(JSRegExp *jsRegExp);
|
||||
void InitTransferSet(CUnorderedSet<uintptr_t> transferDataSet);
|
||||
bool PrepareTransfer(JSThread *thread, const JSHandle<JSTaggedValue> &transfer);
|
||||
|
Loading…
Reference in New Issue
Block a user