mirror of
https://github.com/openharmony/ark_js_runtime.git
synced 2026-08-27 02:31:17 -04:00
Fix GC memcpy_sp bug
Description: Fix memcpy_sp copy object fail bug issue:https://gitee.com/openharmony/ark_js_runtime/issues/I5E0FE Signed-off-by: dingwen <dingwen6@huawei.com> Change-Id: I34655bc18f7f8333507cd5a00115a8e8135b3c12
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
#include "ecmascript/mem/mem.h"
|
||||
#include "ecmascript/mem/space-inl.h"
|
||||
#include "ecmascript/mem/tlab_allocator-inl.h"
|
||||
#include "ecmascript/mem/utils.h"
|
||||
#include "ecmascript/mem/visitor.h"
|
||||
#include "ecmascript/mem/gc_stats.h"
|
||||
#include "ecmascript/ecma_string_table.h"
|
||||
@@ -132,7 +131,9 @@ void ParallelEvacuator::EvacuateRegion(TlabAllocator *allocator, Region *region)
|
||||
}
|
||||
LOG_IF(address == 0, FATAL, RUNTIME) << "Evacuate object failed:" << size;
|
||||
|
||||
Utils::Copy(ToVoidPtr(address), size, ToVoidPtr(ToUintPtr(mem)), size);
|
||||
if (memcpy_s(ToVoidPtr(address), size, ToVoidPtr(ToUintPtr(mem)), size) != EOK) {
|
||||
LOG_ECMA(FATAL) << "memcpy_s failed";
|
||||
}
|
||||
|
||||
Barriers::SetDynPrimitive(header, 0, MarkWord::FromForwardingAddress(address));
|
||||
#if ECMASCRIPT_ENABLE_HEAP_VERIFY
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "ecmascript/mem/heap.h"
|
||||
#include "ecmascript/mem/region-inl.h"
|
||||
#include "ecmascript/mem/tlab_allocator-inl.h"
|
||||
#include "ecmascript/mem/utils.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
constexpr size_t HEAD_SIZE = TaggedObject::TaggedObjectSize();
|
||||
@@ -160,8 +159,10 @@ inline uintptr_t MovableMarker::AllocateDstSpace(uint32_t threadId, size_t size,
|
||||
inline void MovableMarker::UpdateForwardAddressIfSuccess(uint32_t threadId, TaggedObject *object, JSHClass *klass,
|
||||
uintptr_t toAddress, size_t size, const MarkWord &markWord, ObjectSlot slot, bool isPromoted)
|
||||
{
|
||||
Utils::Copy(ToVoidPtr(toAddress + HEAD_SIZE), size - HEAD_SIZE, ToVoidPtr(ToUintPtr(object) + HEAD_SIZE),
|
||||
size - HEAD_SIZE);
|
||||
if (memcpy_s(ToVoidPtr(toAddress + HEAD_SIZE), size - HEAD_SIZE, ToVoidPtr(ToUintPtr(object) + HEAD_SIZE),
|
||||
size - HEAD_SIZE) != EOK) {
|
||||
LOG_ECMA(FATAL) << "memcpy_s failed";
|
||||
}
|
||||
workManager_->IncreaseAliveSize(threadId, size);
|
||||
if (isPromoted) {
|
||||
workManager_->IncreasePromotedSize(threadId, size);
|
||||
|
||||
@@ -104,6 +104,7 @@ public:
|
||||
wasted_(0)
|
||||
{
|
||||
flags_.spaceFlag_ = spaceType;
|
||||
flags_.gcFlags_ = 0;
|
||||
bitsetSize_ = (spaceType == RegionSpaceFlag::IN_HUGE_OBJECT_SPACE) ?
|
||||
GCBitset::BYTE_PER_WORD : GCBitset::SizeOfGCBitset(end - begin);
|
||||
markGCBitset_ = new (ToVoidPtr(begin)) GCBitset();
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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_MEM_UTILS_H
|
||||
#define ECMASCRIPT_MEM_UTILS_H
|
||||
|
||||
#include "ecmascript/ecma_macros.h"
|
||||
#include "securec.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
class Utils {
|
||||
public:
|
||||
static ARK_INLINE void Copy(void *dest, size_t destCount, void *src, size_t count)
|
||||
{
|
||||
switch (count) {
|
||||
#if !defined(PANDA_TARGET_WINDOWS)
|
||||
#define COPY_BY_CONST(destCount, value) \
|
||||
case value: \
|
||||
if (memcpy_sp(dest, destCount, src, value) != EOK) { \
|
||||
LOG_ECMA(FATAL) << "memcpy_s failed"; \
|
||||
} \
|
||||
break;
|
||||
#else
|
||||
#define COPY_BY_CONST(destCount, value) \
|
||||
case value: \
|
||||
if (memcpy_s(dest, destCount, src, value) != EOK) { \
|
||||
LOG_ECMA(FATAL) << "memcpy_s failed"; \
|
||||
} \
|
||||
break;
|
||||
#endif
|
||||
COPY_BY_CONST(destCount, 16)
|
||||
COPY_BY_CONST(destCount, 24)
|
||||
COPY_BY_CONST(destCount, 32)
|
||||
COPY_BY_CONST(destCount, 40)
|
||||
COPY_BY_CONST(destCount, 48)
|
||||
COPY_BY_CONST(destCount, 56)
|
||||
COPY_BY_CONST(destCount, 64)
|
||||
COPY_BY_CONST(destCount, 72)
|
||||
COPY_BY_CONST(destCount, 80)
|
||||
COPY_BY_CONST(destCount, 88)
|
||||
COPY_BY_CONST(destCount, 96)
|
||||
COPY_BY_CONST(destCount, 104)
|
||||
COPY_BY_CONST(destCount, 112)
|
||||
COPY_BY_CONST(destCount, 120)
|
||||
COPY_BY_CONST(destCount, 128)
|
||||
#undef COPY_BY_CONST
|
||||
default:
|
||||
if (memcpy_s(dest, destCount, src, count) != EOK) {
|
||||
LOG_ECMA(FATAL) << "memcpy_s failed";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
#endif // ECMASCRIPT_MEM_UTILS_H
|
||||
Reference in New Issue
Block a user