mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-06 23:54:03 +00:00
fix array's dictionary assert prob
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IALUWW Signed-off-by: zhangtianqi <zhangtianqi3@huawei.com> Change-Id: I2ec70fb15995ffdc66feb08390ba9ed310a0c7f5
This commit is contained in:
parent
f972d1e20e
commit
bb91bf679d
@ -365,15 +365,17 @@ inline bool JSObject::ShouldTransToDict(uint32_t capacity, uint32_t index)
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool JSObject::ShouldTransToFastElements(JSHandle<NumberDictionary> dictionary,
|
||||
inline bool JSObject::ShouldTransToFastElements(JSThread *thread, TaggedArray *elements,
|
||||
uint32_t capacity, uint32_t index)
|
||||
{
|
||||
JSHandle<NumberDictionary> dictionary(thread, elements);
|
||||
if (index >= static_cast<uint32_t>(INT32_MAX)) {
|
||||
return false;
|
||||
}
|
||||
uint32_t dictionarySize = static_cast<uint32_t>(dictionary->GetLength());
|
||||
// Turn fast if only saves 50% space.
|
||||
if (dictionarySize * SHOULD_TRANS_TO_FAST_ELEMENTS_FACTOR >= capacity) {
|
||||
if (dictionarySize * SHOULD_TRANS_TO_FAST_ELEMENTS_FACTOR >= capacity ||
|
||||
dictionary->NextEnumerationIndex(thread) > PropertyAttributes::DictionaryOrderField::MaxValue()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -431,7 +431,7 @@ bool JSObject::AddElementInternal(JSThread *thread, const JSHandle<JSObject> &re
|
||||
uint32_t capacity = arr->GetArrayLength();
|
||||
TaggedArray *elements = TaggedArray::Cast(receiver->GetElements().GetTaggedObject());
|
||||
ASSERT(elements->IsDictionaryMode());
|
||||
if (ShouldTransToFastElements(JSHandle<NumberDictionary>(thread, elements), capacity, index)) {
|
||||
if (ShouldTransToFastElements(thread, elements, capacity, index)) {
|
||||
JSObject::TryOptimizeAsFastElements(thread, receiver);
|
||||
}
|
||||
}
|
||||
|
@ -742,7 +742,7 @@ public:
|
||||
static bool IsArrayLengthWritable(JSThread *thread, const JSHandle<JSObject> &receiver);
|
||||
bool UpdatePropertyInDictionary(const JSThread *thread, JSTaggedValue key, JSTaggedValue value);
|
||||
static bool ShouldTransToDict(uint32_t capacity, uint32_t index);
|
||||
static bool ShouldTransToFastElements(JSHandle<NumberDictionary> dictionary, uint32_t capacity, uint32_t index);
|
||||
static bool ShouldTransToFastElements(JSThread *thread, TaggedArray *elements, uint32_t capacity, uint32_t index);
|
||||
static bool ShouldOptimizeAsFastElements(const JSThread *thread, JSHandle<JSObject> obj);
|
||||
static JSHandle<TaggedArray> GrowElementsCapacity(const JSThread *thread, const JSHandle<JSObject> &obj,
|
||||
uint32_t capacity, bool highGrowth = false, bool isNew = false);
|
||||
|
Loading…
Reference in New Issue
Block a user