mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
!9251 Optimizing ArrayBufferData pointer obtaining
Merge pull request !9251 from hlm2001/hlm_kexin0911_br
This commit is contained in:
commit
5902e505c9
@ -327,9 +327,9 @@ JSTaggedValue BuiltinsArrayBuffer::CloneArrayBuffer(JSThread *thread, const JSHa
|
||||
JSHandle<JSArrayBuffer> newArrBuf(thread, taggedBuf);
|
||||
// Perform CopyDataBlockBytes(targetBlock, 0, srcBlock, srcByteOffset, cloneLength).
|
||||
// 7. Let srcBlock be the value of srcBuffer’s [[ArrayBufferData]] internal slot.
|
||||
void *fromBuf = GetDataPointFromBuffer(srcBuffer.GetTaggedValue());
|
||||
void *toBuf = GetDataPointFromBuffer(taggedBuf);
|
||||
if (cloneLen > 0) {
|
||||
void *fromBuf = GetDataPointFromBuffer(srcBuffer.GetTaggedValue());
|
||||
void *toBuf = GetDataPointFromBuffer(taggedBuf);
|
||||
JSArrayBuffer::CopyDataPointBytes(toBuf, fromBuf, srcByteOffset, cloneLen);
|
||||
}
|
||||
return taggedBuf;
|
||||
@ -781,9 +781,11 @@ void *BuiltinsArrayBuffer::GetDataPointFromBuffer(JSTaggedValue arrBuf, uint32_t
|
||||
JSArrayBuffer *arrayBuffer = JSArrayBuffer::Cast(arrBuf.GetTaggedObject());
|
||||
if (arrayBuffer == nullptr) {
|
||||
LOG_ECMA(FATAL) << "BuiltinsArrayBuffer::GetDataPointFromBuffer:arrayBuffer is nullptr";
|
||||
UNREACHABLE();
|
||||
}
|
||||
if (arrayBuffer->GetArrayBufferByteLength() == 0) {
|
||||
return nullptr;
|
||||
LOG_ECMA(FATAL) << "BuiltinsArrayBuffer::GetDataPointFromBuffer:arrayBuffer length is 0";
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
JSTaggedValue data = arrayBuffer->GetArrayBufferData();
|
||||
|
@ -258,6 +258,9 @@ void RuntimeStubs::CopyTypedArrayBuffer(JSTypedArray *srcArray, JSTypedArray *ta
|
||||
int32_t tarStartPos, int32_t count, int32_t elementSize)
|
||||
{
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
if (count <= 0) {
|
||||
return;
|
||||
}
|
||||
JSTaggedValue srcBuffer = srcArray->GetViewedArrayBufferOrByteArray();
|
||||
JSTaggedValue targetBuffer = targetArray->GetViewedArrayBufferOrByteArray();
|
||||
uint32_t srcByteIndex = static_cast<uint32_t>(srcStartPos * elementSize + srcArray->GetByteOffset());
|
||||
@ -265,7 +268,7 @@ void RuntimeStubs::CopyTypedArrayBuffer(JSTypedArray *srcArray, JSTypedArray *ta
|
||||
uint8_t *srcBuf = (uint8_t *)builtins::BuiltinsArrayBuffer::GetDataPointFromBuffer(srcBuffer, srcByteIndex);
|
||||
uint8_t *targetBuf = (uint8_t *)builtins::BuiltinsArrayBuffer::GetDataPointFromBuffer(targetBuffer,
|
||||
targetByteIndex);
|
||||
if (count > 0 && memmove_s(targetBuf, elementSize * count, srcBuf, elementSize * count) != EOK) {
|
||||
if (memmove_s(targetBuf, elementSize * count, srcBuf, elementSize * count) != EOK) {
|
||||
LOG_FULL(FATAL) << "memmove_s failed";
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user