mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-26 19:50:55 +00:00
complete pr 4963 of properties add 8
Signed-off-by: xiongluo <xiongluo@huawei.com> Change-Id: I63896508ecfc2b6a426428cc2a17aa8eab0c57ee
This commit is contained in:
parent
ac5f3eca45
commit
b7150160c2
@ -226,7 +226,7 @@ bool EcmaVM::Initialize()
|
||||
}
|
||||
|
||||
callTimer_ = new FunctionCallTimer();
|
||||
strategy_ = new ThrouputJSObjectResizingStrategy();
|
||||
strategy_ = new ThroughputJSObjectResizingStrategy();
|
||||
initialized_ = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -60,9 +60,10 @@ PropertyAttributes::PropertyAttributes(const PropertyDescriptor &desc)
|
||||
}
|
||||
}
|
||||
|
||||
void ThrouputJSObjectResizingStrategy::UpdateGrowStep(JSThread *thread, uint32_t step)
|
||||
void ThroughputJSObjectResizingStrategy::UpdateGrowStep(JSThread *thread, uint32_t step)
|
||||
{
|
||||
thread->SetPropertiesGrowStep(std::min(static_cast<uint32_t>(JSThread::PROPERTIES_GROW_SIZE * 2), step));
|
||||
thread->SetPropertiesGrowStep(std::min(static_cast<uint32_t>(JSObjectResizingStrategy::PROPERTIES_GROW_SIZE * 2),
|
||||
step));
|
||||
}
|
||||
|
||||
Method *ECMAObject::GetCallTarget() const
|
||||
|
@ -363,18 +363,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class JSObjectResizingStrategy {
|
||||
public:
|
||||
JSObjectResizingStrategy() = default;
|
||||
virtual ~JSObjectResizingStrategy() = default;
|
||||
virtual void UpdateGrowStep(JSThread *thread, uint32_t step) = 0;
|
||||
};
|
||||
|
||||
class ThrouputJSObjectResizingStrategy : public JSObjectResizingStrategy {
|
||||
public:
|
||||
virtual void UpdateGrowStep(JSThread *thread, uint32_t step) override;
|
||||
};
|
||||
|
||||
class JSObject : public ECMAObject {
|
||||
public:
|
||||
static constexpr int MIN_ELEMENTS_LENGTH = 3;
|
||||
|
35
ecmascript/js_object_resizing_strategy.h
Normal file
35
ecmascript/js_object_resizing_strategy.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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_JSOBJECT_RESIZING_STRATEGY_H
|
||||
#define ECMASCRIPT_JSOBJECT_RESIZING_STRATEGY_H
|
||||
|
||||
namespace panda::ecmascript {
|
||||
class JSThread;
|
||||
class JSObjectResizingStrategy {
|
||||
public:
|
||||
static constexpr int PROPERTIES_GROW_SIZE = 4;
|
||||
JSObjectResizingStrategy() = default;
|
||||
virtual ~JSObjectResizingStrategy() = default;
|
||||
virtual void UpdateGrowStep(JSThread *thread, uint32_t step = PROPERTIES_GROW_SIZE) = 0;
|
||||
};
|
||||
|
||||
class ThroughputJSObjectResizingStrategy : public JSObjectResizingStrategy {
|
||||
public:
|
||||
virtual void UpdateGrowStep(JSThread *thread, uint32_t step = PROPERTIES_GROW_SIZE) override;
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
|
||||
#endif // ECMASCRIPT_JSOBJECT_RESIZING_STRATEGY_H
|
@ -25,6 +25,7 @@
|
||||
#include "ecmascript/global_env_constants.h"
|
||||
#include "ecmascript/js_thread_hclass_entries.h"
|
||||
#include "ecmascript/js_thread_stub_entries.h"
|
||||
#include "ecmascript/js_object_resizing_strategy.h"
|
||||
#include "ecmascript/mem/visitor.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
@ -64,7 +65,6 @@ public:
|
||||
static constexpr int CHECK_SAFEPOINT_BITFIELD_NUM = 8;
|
||||
static constexpr int PGO_PROFILER_BITFIELD_START = 16;
|
||||
static constexpr int BOOL_BITFIELD_NUM = 1;
|
||||
static constexpr int PROPERTIES_GROW_SIZE = 4;
|
||||
static constexpr uint32_t RESERVE_STACK_SIZE = 128;
|
||||
using MarkStatusBits = BitField<MarkStatus, 0, CONCURRENT_MARKING_BITFIELD_NUM>;
|
||||
using CheckSafePointBit = BitField<bool, 0, BOOL_BITFIELD_NUM>;
|
||||
@ -854,7 +854,7 @@ public:
|
||||
alignas(EAS) JSTaggedValue isStartHeapSampling_ {JSTaggedValue::False()};
|
||||
alignas(EAS) bool isDebugMode_ {false};
|
||||
alignas(EAS) bool isFrameDropped_ {false};
|
||||
alignas(EAS) uint32_t propertiesGrowStep_ {PROPERTIES_GROW_SIZE};
|
||||
alignas(EAS) uint32_t propertiesGrowStep_ {JSObjectResizingStrategy::PROPERTIES_GROW_SIZE};
|
||||
alignas(EAS) uint64_t entryFrameDroppedState_ {FrameDroppedState::StateFalse};
|
||||
};
|
||||
STATIC_ASSERT_EQ_ARCH(sizeof(GlueData), GlueData::SizeArch32, GlueData::SizeArch64);
|
||||
|
@ -271,8 +271,10 @@ bool SemiSpace::AdjustCapacity(size_t allocatedSizeSinceGC)
|
||||
size_t newCapacity = initialCapacity_ * GROWING_FACTOR;
|
||||
SetInitialCapacity(std::min(newCapacity, maximumCapacity_));
|
||||
if (newCapacity == maximumCapacity_) {
|
||||
heap_->GetEcmaVM()->GetJSObjectResizingStrategy()->UpdateGrowStep(heap_->GetJSThread(),
|
||||
JSThread::PROPERTIES_GROW_SIZE * 2);
|
||||
heap_->GetEcmaVM()->GetJSObjectResizingStrategy()->UpdateGrowStep(
|
||||
heap_->GetJSThread(),
|
||||
JSObjectResizingStrategy::PROPERTIES_GROW_SIZE * 2
|
||||
);
|
||||
}
|
||||
return true;
|
||||
} else if (curObjectSurvivalRate < SHRINK_OBJECT_SURVIVAL_RATE) {
|
||||
@ -285,8 +287,7 @@ bool SemiSpace::AdjustCapacity(size_t allocatedSizeSinceGC)
|
||||
}
|
||||
size_t newCapacity = initialCapacity_ / GROWING_FACTOR;
|
||||
SetInitialCapacity(std::max(newCapacity, minimumCapacity_));
|
||||
heap_->GetEcmaVM()->GetJSObjectResizingStrategy()->UpdateGrowStep(heap_->GetJSThread(),
|
||||
JSThread::PROPERTIES_GROW_SIZE);
|
||||
heap_->GetEcmaVM()->GetJSObjectResizingStrategy()->UpdateGrowStep(heap_->GetJSThread());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -567,7 +567,7 @@ PropertyAttributes ObjectFastOperator::AddPropertyByName(JSThread *thread, JSHan
|
||||
}
|
||||
// Grow properties array size
|
||||
uint32_t capacity = JSObject::ComputeNonInlinedFastPropsCapacity(thread, length,
|
||||
maxNonInlinedFastPropsCapacity);
|
||||
maxNonInlinedFastPropsCapacity);
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
array.Update(factory->CopyArray(array, length, capacity).GetTaggedValue());
|
||||
objHandle->SetProperties(thread, array.GetTaggedValue());
|
||||
|
@ -273,7 +273,7 @@ DEF_RUNTIME_STUBS(PropertiesSetValue)
|
||||
} else {
|
||||
uint32_t maxNonInlinedFastPropsCapacity = objHandle->GetNonInlinedFastPropsCapacity();
|
||||
uint32_t newLen = JSObject::ComputeNonInlinedFastPropsCapacity(thread, capacity,
|
||||
maxNonInlinedFastPropsCapacity);
|
||||
maxNonInlinedFastPropsCapacity);
|
||||
properties = factory->CopyArray(arrayHandle, capacity, newLen);
|
||||
}
|
||||
properties->Set(thread, index, valueHandle);
|
||||
|
Loading…
Reference in New Issue
Block a user