mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
!6502 [Bug]: fix some bugs for sendable
Merge pull request !6502 from lukai/somebugfix
This commit is contained in:
commit
fcf45afbee
@ -726,7 +726,7 @@ void BuiltinsObjectStubBuilder::HasOwnProperty(Variable *result, Label *exit, La
|
||||
Branch(TaggedIsString(prop), &keyIsString, slowPath); // 2 : two args
|
||||
Bind(&keyIsString);
|
||||
{
|
||||
GateRef res = CallNGCRuntime(glue_, RTSTUB_ID(TryToElementsIndexOrFindInStringTable), { glue_, prop });
|
||||
GateRef res = CallRuntime(glue_, RTSTUB_ID(TryToElementsIndexOrFindInStringTable), { prop });
|
||||
Branch(TaggedIsNumber(res), &isIndex, ¬Index);
|
||||
Bind(&isIndex);
|
||||
{
|
||||
|
@ -2172,38 +2172,6 @@ DEF_CALL_SIGNATURE(JsBoundCallInternal)
|
||||
callSign->SetCallConv(CallSignature::CallConv::CCallConv);
|
||||
}
|
||||
|
||||
DEF_CALL_SIGNATURE(TryToElementsIndexOrFindInStringTable)
|
||||
{
|
||||
// 2 : 2 input parameters
|
||||
CallSignature tryToElementsIndexOrFindInStringTable("TryToElementsIndexOrFindInStringTable", 0, 2,
|
||||
ArgumentsOrder::DEFAULT_ORDER, VariableType::JS_ANY());
|
||||
*callSign = tryToElementsIndexOrFindInStringTable;
|
||||
// 2 : 2 input parameters
|
||||
std::array<VariableType, 2> params = {
|
||||
VariableType::NATIVE_POINTER(),
|
||||
VariableType::JS_POINTER(),
|
||||
};
|
||||
callSign->SetParameters(params.data());
|
||||
callSign->SetGCLeafFunction(true);
|
||||
callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_NO_GC);
|
||||
}
|
||||
|
||||
DEF_CALL_SIGNATURE(TryGetInternString)
|
||||
{
|
||||
// 2 : 2 input parameters
|
||||
CallSignature tryGetInternString("TryGetInternString", 0, 2,
|
||||
ArgumentsOrder::DEFAULT_ORDER, VariableType::JS_ANY());
|
||||
*callSign = tryGetInternString;
|
||||
// 2 : 2 input parameters
|
||||
std::array<VariableType, 2> params = {
|
||||
VariableType::NATIVE_POINTER(),
|
||||
VariableType::JS_POINTER(),
|
||||
};
|
||||
callSign->SetParameters(params.data());
|
||||
callSign->SetGCLeafFunction(true);
|
||||
callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_NO_GC);
|
||||
}
|
||||
|
||||
DEF_CALL_SIGNATURE(CreateArrayFromList)
|
||||
{
|
||||
// 3 : 3 input parameters
|
||||
|
@ -461,8 +461,6 @@ private:
|
||||
V(JSFunctionEntry) \
|
||||
V(OptimizedFastCallEntry) \
|
||||
V(JSProxyCallInternalWithArgV) \
|
||||
V(TryToElementsIndexOrFindInStringTable) \
|
||||
V(TryGetInternString) \
|
||||
V(CreateArrayFromList) \
|
||||
V(JSObjectGetMethod) \
|
||||
V(JsProxyCallInternal) \
|
||||
|
@ -2731,7 +2731,7 @@ GateRef StubBuilder::GetPropertyByValue(GateRef glue, GateRef receiver, GateRef
|
||||
Label notFind(env);
|
||||
Label find(env);
|
||||
// if key can't find in stringtabele, key is not propertyname for a object
|
||||
GateRef res = CallNGCRuntime(glue, RTSTUB_ID(TryGetInternString), { glue, *key });
|
||||
GateRef res = CallRuntime(glue, RTSTUB_ID(TryGetInternString), { *key });
|
||||
Branch(TaggedIsHole(res), ¬Find, &find);
|
||||
Bind(¬Find);
|
||||
{
|
||||
@ -3932,7 +3932,7 @@ GateRef StubBuilder::SetPropertyByValue(GateRef glue, GateRef receiver, GateRef
|
||||
{
|
||||
Label notFind(env);
|
||||
Label find(env);
|
||||
GateRef res = CallNGCRuntime(glue, RTSTUB_ID(TryGetInternString), { glue, *varKey });
|
||||
GateRef res = CallRuntime(glue, RTSTUB_ID(TryGetInternString), { *varKey });
|
||||
Branch(TaggedIsHole(res), ¬Find, &find);
|
||||
Bind(¬Find);
|
||||
{
|
||||
@ -4402,7 +4402,7 @@ void StubBuilder::FastSetPropertyByName(GateRef glue, GateRef obj, GateRef key,
|
||||
{
|
||||
Label notFind(env);
|
||||
Label find(env);
|
||||
GateRef res = CallNGCRuntime(glue, RTSTUB_ID(TryGetInternString), { glue, *keyVar });
|
||||
GateRef res = CallRuntime(glue, RTSTUB_ID(TryGetInternString), { *keyVar });
|
||||
Branch(TaggedIsHole(res), ¬Find, &find);
|
||||
Bind(¬Find);
|
||||
{
|
||||
|
@ -25,19 +25,31 @@
|
||||
namespace panda::ecmascript {
|
||||
static constexpr size_t DEFAULT_HEAP_SIZE = 448_MB; // Recommended range: 128-448MB
|
||||
static constexpr size_t DEFAULT_WORKER_HEAP_SIZE = 768_MB; // Recommended range: 128_MB, LargeHeap: 768_MB
|
||||
static constexpr size_t DEFAULT_SHARED_HEAP_SIZE = 778_MB;
|
||||
|
||||
class EcmaParamConfiguration {
|
||||
public:
|
||||
EcmaParamConfiguration(bool isWorker, size_t poolSize)
|
||||
enum class HeapType : uint8_t {
|
||||
DEFAULT_HEAP,
|
||||
WORKER_HEAP,
|
||||
SHARED_HEAP
|
||||
};
|
||||
|
||||
EcmaParamConfiguration(HeapType heapType, size_t poolSize)
|
||||
{
|
||||
if (isWorker) {
|
||||
maxHeapSize_ = DEFAULT_WORKER_HEAP_SIZE;
|
||||
} else {
|
||||
if (poolSize >= DEFAULT_HEAP_SIZE) {
|
||||
maxHeapSize_ = DEFAULT_HEAP_SIZE;
|
||||
} else {
|
||||
maxHeapSize_ = poolSize; // pool is too small, no memory left for worker
|
||||
}
|
||||
switch (heapType) {
|
||||
case HeapType::WORKER_HEAP:
|
||||
maxHeapSize_ = DEFAULT_WORKER_HEAP_SIZE;
|
||||
break;
|
||||
case HeapType::SHARED_HEAP:
|
||||
maxHeapSize_ = DEFAULT_SHARED_HEAP_SIZE;
|
||||
break;
|
||||
default:
|
||||
if (poolSize >= DEFAULT_HEAP_SIZE) {
|
||||
maxHeapSize_ = DEFAULT_HEAP_SIZE;
|
||||
} else {
|
||||
maxHeapSize_ = poolSize; // pool is too small, no memory left for worker
|
||||
}
|
||||
}
|
||||
Initialize();
|
||||
}
|
||||
|
@ -178,13 +178,17 @@ EcmaString *EcmaStringTable::GetOrInternString(EcmaVM *vm, EcmaString *string)
|
||||
if (EcmaStringAccessor(string).IsInternString()) {
|
||||
return string;
|
||||
}
|
||||
JSHandle<EcmaString> strHandle(vm->GetJSThread(), string);
|
||||
auto thread = vm->GetJSThread();
|
||||
JSHandle<EcmaString> strHandle(thread, string);
|
||||
// may gc
|
||||
auto strFlat = EcmaStringAccessor::Flatten(vm, strHandle, MemSpaceType::SHARED_OLD_SPACE);
|
||||
if (EcmaStringAccessor(strFlat).IsInternString()) {
|
||||
return strFlat;
|
||||
}
|
||||
RuntimeLockHolder locker(vm->GetJSThread(), mutex_);
|
||||
JSHandle<EcmaString> strFlatHandle(thread, strFlat);
|
||||
// may gc
|
||||
RuntimeLockHolder locker(thread, mutex_);
|
||||
strFlat = *strFlatHandle;
|
||||
EcmaString *result = GetStringThreadUnsafe(strFlat);
|
||||
if (result != nullptr) {
|
||||
return result;
|
||||
@ -215,16 +219,16 @@ EcmaString *EcmaStringTable::GetOrInternStringThreadUnsafe(EcmaVM *vm, EcmaStrin
|
||||
|
||||
EcmaString *EcmaStringTable::InsertStringToTable(EcmaVM *vm, const JSHandle<EcmaString> &strHandle)
|
||||
{
|
||||
auto strFlat = EcmaStringAccessor::Flatten(vm, strHandle, MemSpaceType::SHARED_OLD_SPACE);
|
||||
RuntimeLockHolder locker(vm->GetJSThread(), mutex_);
|
||||
auto strFlat = EcmaStringAccessor::Flatten(vm, strHandle, MemSpaceType::SHARED_OLD_SPACE);
|
||||
InternStringThreadUnsafe(strFlat);
|
||||
return strFlat;
|
||||
}
|
||||
|
||||
EcmaString *EcmaStringTable::TryGetInternString(JSThread *thread, EcmaString *string)
|
||||
EcmaString *EcmaStringTable::TryGetInternString(JSThread *thread, const JSHandle<EcmaString> &string)
|
||||
{
|
||||
RuntimeLockHolder locker(thread, mutex_);
|
||||
return GetStringThreadUnsafe(string);
|
||||
return GetStringThreadUnsafe(*string);
|
||||
}
|
||||
|
||||
EcmaString *EcmaStringTable::GetOrInternStringWithSpaceType(EcmaVM *vm, const uint8_t *utf8Data, uint32_t utf8Len,
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
uint32_t idOffset);
|
||||
EcmaString *GetOrInternStringWithSpaceType(EcmaVM *vm, const uint8_t *utf8Data, uint32_t utf16Len,
|
||||
MemSpaceType type);
|
||||
EcmaString *TryGetInternString(JSThread *thread, EcmaString *string);
|
||||
EcmaString *TryGetInternString(JSThread *thread, const JSHandle<EcmaString> &string);
|
||||
EcmaString *InsertStringToTable(EcmaVM *vm, const JSHandle<EcmaString> &strHandle);
|
||||
|
||||
void SweepWeakReference(const WeakRootVisitor &visitor);
|
||||
|
@ -103,7 +103,9 @@ AOTFileManager *JsStackInfo::loader = nullptr;
|
||||
EcmaVM *EcmaVM::Create(const JSRuntimeOptions &options)
|
||||
{
|
||||
Runtime::CreateIfFirstVm(options);
|
||||
auto config = EcmaParamConfiguration(options.IsWorker(),
|
||||
auto heapType = options.IsWorker() ? EcmaParamConfiguration::HeapType::WORKER_HEAP :
|
||||
EcmaParamConfiguration::HeapType::DEFAULT_HEAP;
|
||||
auto config = EcmaParamConfiguration(heapType,
|
||||
MemMapAllocator::GetInstance()->GetCapacity());
|
||||
MemMapAllocator::GetInstance()->IncreaseAndCheckReserved(config.GetMaxHeapSize());
|
||||
JSRuntimeOptions newOptions = options;
|
||||
|
@ -47,20 +47,20 @@ namespace panda::ecmascript {
|
||||
size_t oomOvershootSize = vm->GetEcmaParamConfiguration().GetOutOfMemoryOvershootSize(); \
|
||||
(space)->IncreaseOutOfMemoryOvershootSize(oomOvershootSize); \
|
||||
StatisticHeapDetail(); \
|
||||
(object) = reinterpret_cast<TaggedObject *>((space)->Allocate(size)); \
|
||||
if ((space)->IsOOMDumpSpace() && (object) != nullptr) { \
|
||||
DumpHeapSnapshotBeforeOOM(true, size, message, false); \
|
||||
} else { \
|
||||
ThrowOutOfMemoryError(GetJSThread(), size, message); \
|
||||
} \
|
||||
(object) = reinterpret_cast<TaggedObject *>((space)->Allocate(size)); \
|
||||
}
|
||||
|
||||
#define CHECK_SOBJ_AND_THROW_OOM_ERROR(thread, object, size, space, message) \
|
||||
if (UNLIKELY((object) == nullptr)) { \
|
||||
size_t oomOvershootSize = GetEcmaParamConfiguration().GetOutOfMemoryOvershootSize(); \
|
||||
(space)->IncreaseOutOfMemoryOvershootSize(oomOvershootSize); \
|
||||
(object) = reinterpret_cast<TaggedObject *>((space)->Allocate(thread, size)); \
|
||||
ThrowOutOfMemoryError(thread, size, message); \
|
||||
(object) = reinterpret_cast<TaggedObject *>((space)->Allocate(thread, size)); \
|
||||
}
|
||||
|
||||
template<class Callback>
|
||||
@ -322,12 +322,12 @@ TaggedObject *Heap::AllocateHugeObject(size_t size)
|
||||
// if allocate huge object OOM, temporarily increase space size to avoid vm crash
|
||||
size_t oomOvershootSize = config_.GetOutOfMemoryOvershootSize();
|
||||
oldSpace_->IncreaseOutOfMemoryOvershootSize(oomOvershootSize);
|
||||
object = reinterpret_cast<TaggedObject *>(hugeObjectSpace_->Allocate(size, thread_));
|
||||
DumpHeapSnapshotBeforeOOM(true, size, "Heap::AllocateHugeObject", false);
|
||||
StatisticHeapDetail();
|
||||
#ifndef ENABLE_DUMP_IN_FAULTLOG
|
||||
ThrowOutOfMemoryError(thread_, size, "Heap::AllocateHugeObject");
|
||||
#endif
|
||||
object = reinterpret_cast<TaggedObject *>(hugeObjectSpace_->Allocate(size, thread_));
|
||||
if (UNLIKELY(object == nullptr)) {
|
||||
FatalOutOfMemoryError(size, "Heap::AllocateHugeObject");
|
||||
}
|
||||
@ -545,8 +545,6 @@ TaggedObject *SharedHeap::AllocateOldOrHugeObject(JSThread *thread, size_t size)
|
||||
|
||||
TaggedObject *SharedHeap::AllocateHugeObject(JSThread *thread, JSHClass *hclass, size_t size)
|
||||
{
|
||||
// Check whether it is necessary to trigger Old GC before expanding to avoid OOM risk.
|
||||
CheckAndTriggerOldGC(thread, size);
|
||||
auto object = AllocateHugeObject(thread, size);
|
||||
object->SetClass(thread, hclass);
|
||||
// TODO(lukai)
|
||||
@ -556,9 +554,8 @@ TaggedObject *SharedHeap::AllocateHugeObject(JSThread *thread, JSHClass *hclass,
|
||||
|
||||
TaggedObject *SharedHeap::AllocateHugeObject(JSThread *thread, size_t size)
|
||||
{
|
||||
// Check whether it is necessary to trigger Old GC before expanding to avoid OOM risk.
|
||||
CheckAndTriggerOldGC(thread, size);
|
||||
|
||||
// Check whether it is necessary to trigger Shared GC before expanding to avoid OOM risk.
|
||||
CheckHugeAndTriggerGC(thread, size);
|
||||
auto *object = reinterpret_cast<TaggedObject *>(sHugeObjectSpace_->Allocate(thread, size));
|
||||
if (UNLIKELY(object == nullptr)) {
|
||||
CollectGarbage(thread, TriggerGCType::SHARED_GC, GCReason::ALLOCATION_LIMIT);
|
||||
@ -566,11 +563,11 @@ TaggedObject *SharedHeap::AllocateHugeObject(JSThread *thread, size_t size)
|
||||
if (UNLIKELY(object == nullptr)) {
|
||||
// if allocate huge object OOM, temporarily increase space size to avoid vm crash
|
||||
size_t oomOvershootSize = config_.GetOutOfMemoryOvershootSize();
|
||||
sOldSpace_->IncreaseOutOfMemoryOvershootSize(oomOvershootSize);
|
||||
object = reinterpret_cast<TaggedObject *>(sHugeObjectSpace_->Allocate(thread, size));
|
||||
sHugeObjectSpace_->IncreaseOutOfMemoryOvershootSize(oomOvershootSize);
|
||||
// TODO(lukai)
|
||||
// DumpHeapSnapshotBeforeOOM();
|
||||
ThrowOutOfMemoryError(thread, size, "SharedHeap::AllocateHugeObject");
|
||||
object = reinterpret_cast<TaggedObject *>(sHugeObjectSpace_->Allocate(thread, size));
|
||||
if (UNLIKELY(object == nullptr)) {
|
||||
FatalOutOfMemoryError(size, "SharedHeap::AllocateHugeObject");
|
||||
}
|
||||
|
@ -63,7 +63,15 @@
|
||||
#endif
|
||||
|
||||
namespace panda::ecmascript {
|
||||
bool SharedHeap::CheckAndTriggerOldGC(JSThread *thread, size_t size)
|
||||
SharedHeap* SharedHeap::GetInstance()
|
||||
{
|
||||
EcmaParamConfiguration config(EcmaParamConfiguration::HeapType::SHARED_HEAP,
|
||||
MemMapAllocator::GetInstance()->GetCapacity());
|
||||
static SharedHeap *shareHeap = new SharedHeap(config);
|
||||
return shareHeap;
|
||||
}
|
||||
|
||||
bool SharedHeap::CheckAndTriggerGC(JSThread *thread, size_t size)
|
||||
{
|
||||
if ((OldSpaceExceedLimit() || OldSpaceExceedCapacity(size) ||
|
||||
GetHeapObjectSize() > globalSpaceAllocLimit_ ) && !NeedStopCollection()) {
|
||||
@ -73,6 +81,15 @@ bool SharedHeap::CheckAndTriggerOldGC(JSThread *thread, size_t size)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SharedHeap::CheckHugeAndTriggerGC(JSThread *thread, size_t size)
|
||||
{
|
||||
if (sHugeObjectSpace_->CommittedSizeExceed(size) && !NeedStopCollection()) {
|
||||
CollectGarbage(thread, TriggerGCType::SHARED_GC, GCReason::ALLOCATION_LIMIT);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SharedHeap::Initialize(NativeAreaAllocator *nativeAreaAllocator, HeapRegionAllocator *heapRegionAllocator,
|
||||
const JSRuntimeOptions &option)
|
||||
{
|
||||
@ -85,12 +102,11 @@ void SharedHeap::Initialize(NativeAreaAllocator *nativeAreaAllocator, HeapRegion
|
||||
size_t nonmovableSpaceCapacity = config_.GetDefaultNonMovableSpaceSize();
|
||||
sNonMovableSpace_ = new SharedNonMovableSpace(this, nonmovableSpaceCapacity, nonmovableSpaceCapacity);
|
||||
|
||||
size_t oldSpaceCapacity = maxHeapSize - nonmovableSpaceCapacity;
|
||||
size_t readOnlySpaceCapacity = config_.GetDefaultReadOnlySpaceSize();
|
||||
size_t oldSpaceCapacity = (maxHeapSize - nonmovableSpaceCapacity - readOnlySpaceCapacity) / 2; // 2: half
|
||||
globalSpaceAllocLimit_ = maxHeapSize;
|
||||
|
||||
sOldSpace_ = new SharedOldSpace(this, oldSpaceCapacity, oldSpaceCapacity);
|
||||
|
||||
size_t readOnlySpaceCapacity = config_.GetDefaultReadOnlySpaceSize();
|
||||
sReadOnlySpace_ = new SharedReadOnlySpace(this, readOnlySpaceCapacity, readOnlySpaceCapacity);
|
||||
sHugeObjectSpace_ = new SharedHugeObjectSpace(this, heapRegionAllocator_, oldSpaceCapacity, oldSpaceCapacity);
|
||||
}
|
||||
|
@ -313,12 +313,7 @@ public:
|
||||
SharedHeap(const EcmaParamConfiguration &config) : BaseHeap(config) {}
|
||||
virtual ~SharedHeap() = default;
|
||||
|
||||
static SharedHeap* GetInstance()
|
||||
{
|
||||
EcmaParamConfiguration config(false, DEFAULT_HEAP_SIZE);
|
||||
static SharedHeap *shareHeap = new SharedHeap(config);
|
||||
return shareHeap;
|
||||
}
|
||||
static SharedHeap* GetInstance();
|
||||
|
||||
void Initialize(NativeAreaAllocator *nativeAreaAllocator, HeapRegionAllocator *heapRegionAllocator,
|
||||
const JSRuntimeOptions &option);
|
||||
@ -370,7 +365,9 @@ public:
|
||||
return onSerializeEvent_;
|
||||
}
|
||||
|
||||
bool CheckAndTriggerOldGC(JSThread *thread, size_t size = 0);
|
||||
bool CheckAndTriggerGC(JSThread *thread, size_t size = 0);
|
||||
|
||||
bool CheckHugeAndTriggerGC(JSThread *thread, size_t size);
|
||||
|
||||
void TryTriggerConcurrentMarking() override
|
||||
{
|
||||
@ -392,14 +389,13 @@ public:
|
||||
|
||||
bool OldSpaceExceedCapacity(size_t size) const override
|
||||
{
|
||||
size_t totalSize = sOldSpace_->GetCommittedSize() + sHugeObjectSpace_->GetCommittedSize() + size;
|
||||
size_t totalSize = sOldSpace_->GetCommittedSize() + size;
|
||||
return totalSize >= sOldSpace_->GetMaximumCapacity() + sOldSpace_->GetOutOfMemoryOvershootSize();
|
||||
}
|
||||
|
||||
bool OldSpaceExceedLimit() const override
|
||||
{
|
||||
size_t totalSize = sOldSpace_->GetHeapObjectSize() + sHugeObjectSpace_->GetHeapObjectSize();
|
||||
return totalSize >= sOldSpace_->GetInitialCapacity();
|
||||
return sOldSpace_->GetHeapObjectSize() >= sOldSpace_->GetInitialCapacity();
|
||||
}
|
||||
|
||||
SharedConcurrentSweeper *GetSweeper() const
|
||||
|
@ -47,7 +47,8 @@ static constexpr size_t MIN_MEM_POOL_CAPACITY = 64_MB;
|
||||
static constexpr size_t WORKER_NUM = 8;
|
||||
static constexpr size_t PHY_SIZE_MULTIPLE = WORKER_NUM + 1;
|
||||
// todo(Gymee) fix size for shared heap
|
||||
static constexpr size_t STANDARD_POOL_SIZE = WORKER_NUM * DEFAULT_WORKER_HEAP_SIZE + DEFAULT_HEAP_SIZE;
|
||||
static constexpr size_t STANDARD_POOL_SIZE =
|
||||
WORKER_NUM * DEFAULT_WORKER_HEAP_SIZE + DEFAULT_HEAP_SIZE + DEFAULT_SHARED_HEAP_SIZE;
|
||||
|
||||
#if defined(PANDA_TARGET_32)
|
||||
static constexpr size_t MAX_GLOBAL_NATIVE_LIMIT = 512_MB;
|
||||
|
@ -62,8 +62,8 @@ uintptr_t SharedSparseSpace::Allocate(JSThread *thread, size_t size, bool allowG
|
||||
object = AllocateAfterSweepingCompleted(size);
|
||||
CHECK_SOBJECT_AND_INC_OBJ_SIZE(size);
|
||||
}
|
||||
// Check whether it is necessary to trigger Old GC before expanding to avoid OOM risk.
|
||||
if (allowGC && sHeap_->CheckAndTriggerOldGC(thread)) {
|
||||
// Check whether it is necessary to trigger Shared GC before expanding to avoid OOM risk.
|
||||
if (allowGC && sHeap_->CheckAndTriggerGC(thread)) {
|
||||
object = TryAllocate(size);
|
||||
CHECK_SOBJECT_AND_INC_OBJ_SIZE(size);
|
||||
}
|
||||
@ -389,7 +389,7 @@ uintptr_t SharedHugeObjectSpace::Allocate(JSThread *thread, size_t objectSize)
|
||||
// In HugeObject allocation, we have a revervation of 8 bytes for markBitSet in objectSize.
|
||||
// In case Region is not aligned by 16 bytes, HUGE_OBJECT_BITSET_SIZE is 8 bytes more.
|
||||
size_t alignedSize = AlignUp(objectSize + sizeof(Region) + HUGE_OBJECT_BITSET_SIZE, PANDA_POOL_ALIGNMENT_IN_BYTES);
|
||||
if (heap_->OldSpaceExceedCapacity(alignedSize)) {
|
||||
if (CommittedSizeExceed(alignedSize)) {
|
||||
LOG_ECMA_MEM(INFO) << "Committed size " << committedSize_ << " of huge object space is too big.";
|
||||
return 0;
|
||||
}
|
||||
|
@ -191,6 +191,10 @@ public:
|
||||
|
||||
void InvokeAllocationInspector(Address object, size_t objectSize);
|
||||
|
||||
bool CommittedSizeExceed(size_t size) const
|
||||
{
|
||||
return committedSize_ + size >= maximumCapacity_ + outOfMemoryOvershootSize_;
|
||||
}
|
||||
private:
|
||||
static constexpr size_t HUGE_OBJECT_BITSET_SIZE = 16;
|
||||
EcmaList<Region> hugeNeedFreeList_ {};
|
||||
|
@ -83,8 +83,8 @@ std::pair<JSTaggedValue, bool> ObjectFastOperator::HasOwnProperty(JSThread *thre
|
||||
}
|
||||
|
||||
if (!EcmaStringAccessor(key).IsInternString()) {
|
||||
EcmaString *str = thread->GetEcmaVM()->GetEcmaStringTable()->TryGetInternString(
|
||||
thread, EcmaString::Cast(key.GetTaggedObject()));
|
||||
JSHandle<EcmaString> keyHandle(thread, key);
|
||||
EcmaString *str = thread->GetEcmaVM()->GetEcmaStringTable()->TryGetInternString(thread, keyHandle);
|
||||
if (str == nullptr) {
|
||||
return std::make_pair(JSTaggedValue::Hole(), true);
|
||||
}
|
||||
|
@ -3172,7 +3172,7 @@ JSTaggedValue RuntimeStubs::ArrayNumberSort(JSThread *thread, JSHandle<JSObject>
|
||||
return thisObj.GetTaggedValue();
|
||||
}
|
||||
|
||||
JSTaggedType RuntimeStubs::RuntimeTryGetInternString(uintptr_t argGlue, EcmaString *string)
|
||||
JSTaggedType RuntimeStubs::RuntimeTryGetInternString(uintptr_t argGlue, const JSHandle<EcmaString> &string)
|
||||
{
|
||||
auto thread = JSThread::GlueToJSThread(argGlue);
|
||||
EcmaString *str =
|
||||
|
@ -758,7 +758,7 @@ DEF_RUNTIME_STUBS(RegularJSObjDeletePrototype)
|
||||
JSTaggedValue value = GetArg(argv, argc, 1);
|
||||
uint32_t index = 0;
|
||||
if (value.IsString()) {
|
||||
auto string = reinterpret_cast<EcmaString *>(value.GetTaggedObject());
|
||||
auto string = JSHandle<EcmaString>(thread, value);
|
||||
if (EcmaStringAccessor(string).ToElementIndex(&index)) {
|
||||
value = JSTaggedValue(index);
|
||||
} else if (!EcmaStringAccessor(string).IsInternString()) {
|
||||
@ -2746,9 +2746,10 @@ DEF_RUNTIME_STUBS(SlowFlattenString)
|
||||
return JSTaggedValue(EcmaStringAccessor::SlowFlatten(thread->GetEcmaVM(), str)).GetRawData();
|
||||
}
|
||||
|
||||
JSTaggedType RuntimeStubs::TryToElementsIndexOrFindInStringTable(uintptr_t argGlue, JSTaggedType ecmaString)
|
||||
DEF_RUNTIME_STUBS(TryToElementsIndexOrFindInStringTable)
|
||||
{
|
||||
auto string = reinterpret_cast<EcmaString *>(ecmaString);
|
||||
RUNTIME_STUBS_HEADER(TryToElementsIndexOrFindInStringTable);
|
||||
JSHandle<EcmaString> string = GetHArg<EcmaString>(argv, argc, 0); // 0: means the zeroth parameter
|
||||
uint32_t index = 0;
|
||||
if (EcmaStringAccessor(string).ToElementIndex(&index)) {
|
||||
return JSTaggedValue(index).GetRawData();
|
||||
@ -2756,12 +2757,13 @@ JSTaggedType RuntimeStubs::TryToElementsIndexOrFindInStringTable(uintptr_t argGl
|
||||
if (!EcmaStringAccessor(string).IsInternString()) {
|
||||
return RuntimeTryGetInternString(argGlue, string);
|
||||
}
|
||||
return ecmaString;
|
||||
return string.GetTaggedValue().GetRawData();
|
||||
}
|
||||
|
||||
JSTaggedType RuntimeStubs::TryGetInternString(uintptr_t argGlue, JSTaggedType ecmaString)
|
||||
DEF_RUNTIME_STUBS(TryGetInternString)
|
||||
{
|
||||
auto string = reinterpret_cast<EcmaString *>(ecmaString);
|
||||
RUNTIME_STUBS_HEADER(TryGetInternString);
|
||||
JSHandle<EcmaString> string = GetHArg<EcmaString>(argv, argc, 0); // 0: means the zeroth parameter
|
||||
return RuntimeTryGetInternString(argGlue, string);
|
||||
}
|
||||
|
||||
|
@ -123,8 +123,6 @@ using FastCallAotEntryType = JSTaggedValue (*)(uintptr_t glue, uint32_t argc, co
|
||||
V(FloatATan) \
|
||||
V(FloatFloor) \
|
||||
V(FindElementWithCache) \
|
||||
V(TryToElementsIndexOrFindInStringTable) \
|
||||
V(TryGetInternString) \
|
||||
V(CreateArrayFromList) \
|
||||
V(StringsAreEquals) \
|
||||
V(BigIntEquals) \
|
||||
@ -388,7 +386,9 @@ using FastCallAotEntryType = JSTaggedValue (*)(uintptr_t glue, uint32_t argc, co
|
||||
V(FunctionDefineOwnProperty) \
|
||||
V(AOTEnableProtoChangeMarker) \
|
||||
V(HasProperty) \
|
||||
V(DumpObject)
|
||||
V(DumpObject) \
|
||||
V(TryGetInternString) \
|
||||
V(TryToElementsIndexOrFindInStringTable)
|
||||
|
||||
#define RUNTIME_STUB_LIST(V) \
|
||||
RUNTIME_ASM_STUB_LIST(V) \
|
||||
@ -446,8 +446,6 @@ public:
|
||||
uintptr_t object, size_t offset, TaggedObject *value);
|
||||
static void StoreBarrier([[maybe_unused]] uintptr_t argGlue,
|
||||
uintptr_t object, size_t offset, TaggedObject *value);
|
||||
static JSTaggedType TryToElementsIndexOrFindInStringTable(uintptr_t argGlue, JSTaggedType ecmaString);
|
||||
static JSTaggedType TryGetInternString(uintptr_t argGlue, JSTaggedType ecmaString);
|
||||
static JSTaggedType CreateArrayFromList([[maybe_unused]] uintptr_t argGlue, int32_t argc, JSTaggedValue *argvPtr);
|
||||
static JSTaggedType GetActualArgvNoGC(uintptr_t argGlue);
|
||||
static void InsertOldToNewRSet([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset);
|
||||
@ -818,7 +816,7 @@ private:
|
||||
static inline bool ShouldUseAOTHClass(const JSHandle<JSTaggedValue> &ihc,
|
||||
const JSHandle<JSTaggedValue> &chc,
|
||||
const JSHandle<ClassLiteral> &classLiteral);
|
||||
static inline JSTaggedType RuntimeTryGetInternString(uintptr_t argGlue, EcmaString *string);
|
||||
static inline JSTaggedType RuntimeTryGetInternString(uintptr_t argGlue, const JSHandle<EcmaString> &string);
|
||||
friend class SlowRuntimeStub;
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
|
Loading…
Reference in New Issue
Block a user