mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-08 00:24:00 +00:00
add ark properties ,issue:#I4PVB3
Signed-off-by: lukai <lukai25@huawei.com>
This commit is contained in:
parent
6e3821a860
commit
dcb8f249ca
@ -31,6 +31,9 @@
|
||||
|
||||
#define ECMA_GC_LOG() LOG(DEBUG, ECMASCRIPT) << " ecmascript gc log: "
|
||||
|
||||
#define OPTIONAL_LOG(ecmaVM, level, component) \
|
||||
LOG_IF(ecmaVM->IsOptionalLogEnabled(), level, component)
|
||||
|
||||
/* Note: We can't statically decide the element type is a primitive or heap object, especially for */
|
||||
/* dynamically-typed languages like JavaScript. So we simply skip the read-barrier. */
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
|
@ -109,6 +109,7 @@ EcmaVM::EcmaVM(JSRuntimeOptions options)
|
||||
{
|
||||
options_ = std::move(options);
|
||||
icEnable_ = options_.IsIcEnable();
|
||||
optionalLogEnabled_ = options_.IsEnableOptionalLog();
|
||||
rendezvous_ = chunk_.New<EmptyRendezvous>();
|
||||
snapshotSerializeEnable_ = options_.IsSnapshotSerializeEnabled();
|
||||
if (!snapshotSerializeEnable_) {
|
||||
@ -272,9 +273,9 @@ EcmaVM::~EcmaVM()
|
||||
ClearBufferData();
|
||||
|
||||
if (gcStats_ != nullptr) {
|
||||
#if ECMASCRIPT_ENABLE_GC_LOG
|
||||
gcStats_->PrintStatisticResult(true);
|
||||
#endif
|
||||
if (options_.IsEnableGCStatsPrint()) {
|
||||
gcStats_->PrintStatisticResult(true);
|
||||
}
|
||||
chunk_.Delete(gcStats_);
|
||||
gcStats_ = nullptr;
|
||||
}
|
||||
|
@ -305,6 +305,11 @@ public:
|
||||
return runtimeStatEnabled_;
|
||||
}
|
||||
|
||||
bool IsOptionalLogEnabled() const
|
||||
{
|
||||
return optionalLogEnabled_;
|
||||
}
|
||||
|
||||
void Iterate(const RootVisitor &v);
|
||||
|
||||
const Heap *GetHeap() const
|
||||
@ -480,7 +485,7 @@ private:
|
||||
EcmaRuntimeStat *runtimeStat_ {nullptr}; // maybe nullptr
|
||||
bool runtimeStatEnabled_ {false};
|
||||
bool isUncaughtExceptionRegistered_ {false};
|
||||
|
||||
bool optionalLogEnabled_ {false};
|
||||
// weak reference need Redirect address
|
||||
JSTaggedValue frameworkProgram_ {JSTaggedValue::Hole()}; // no mark for gc
|
||||
CVector<JSNativePointer *> arrayBufferDataList_;
|
||||
|
@ -21,6 +21,15 @@
|
||||
|
||||
// namespace panda {
|
||||
namespace panda::ecmascript {
|
||||
enum ArkProperties {
|
||||
DEFAULT = -1,
|
||||
OPTIONAL_LOG = 1,
|
||||
GC_STATS_PRINT = 1 << 1,
|
||||
PARALLEL_GC = 1 << 2,
|
||||
CONCURRENT_MARK = 1 << 3,
|
||||
CONCURRENT_SWEEP = 1 << 4,
|
||||
};
|
||||
|
||||
class JSRuntimeOptions : public RuntimeOptions {
|
||||
public:
|
||||
explicit JSRuntimeOptions(const std::string &exe_path = "") : RuntimeOptions(exe_path) {}
|
||||
@ -35,6 +44,7 @@ public:
|
||||
parser->Add(&enable_stub_aot_);
|
||||
parser->Add(&stub_module_file_);
|
||||
parser->Add(&enable_cpuprofiler_);
|
||||
parser->Add(&ark_properties_);
|
||||
}
|
||||
|
||||
bool IsEnableArkTools() const
|
||||
@ -102,16 +112,6 @@ public:
|
||||
force_compress_gc_.SetValue(value);
|
||||
}
|
||||
|
||||
bool IsEnableConcurrentSweep() const
|
||||
{
|
||||
return enable_concurrent_sweep_.GetValue();
|
||||
}
|
||||
|
||||
void SetEnableConcurrentSweep(bool value)
|
||||
{
|
||||
enable_concurrent_sweep_.SetValue(value);
|
||||
}
|
||||
|
||||
bool IsEnableCpuProfiler() const
|
||||
{
|
||||
return enable_cpuprofiler_.GetValue();
|
||||
@ -122,6 +122,48 @@ public:
|
||||
enable_cpuprofiler_.SetValue(value);
|
||||
}
|
||||
|
||||
void SetArkProperties(int prop)
|
||||
{
|
||||
if (prop != ArkProperties::DEFAULT) {
|
||||
ark_properties_.SetValue(prop);
|
||||
}
|
||||
}
|
||||
|
||||
int GetDefaultProperties()
|
||||
{
|
||||
return ArkProperties::PARALLEL_GC | ArkProperties::CONCURRENT_MARK | ArkProperties::CONCURRENT_SWEEP;
|
||||
}
|
||||
|
||||
int GetArkProperties()
|
||||
{
|
||||
return ark_properties_.GetValue();
|
||||
}
|
||||
|
||||
bool IsEnableOptionalLog() const
|
||||
{
|
||||
return (ark_properties_.GetValue() & ArkProperties::OPTIONAL_LOG) != 0;
|
||||
}
|
||||
|
||||
bool IsEnableGCStatsPrint() const
|
||||
{
|
||||
return (ark_properties_.GetValue() & ArkProperties::GC_STATS_PRINT) != 0;
|
||||
}
|
||||
|
||||
bool IsEnableParallelGC() const
|
||||
{
|
||||
return (ark_properties_.GetValue() & ArkProperties::PARALLEL_GC) != 0;
|
||||
}
|
||||
|
||||
bool IsEnableConcurrentMark() const
|
||||
{
|
||||
return (ark_properties_.GetValue() & ArkProperties::CONCURRENT_MARK) != 0;
|
||||
}
|
||||
|
||||
bool IsEnableConcurrentSweep() const
|
||||
{
|
||||
return (ark_properties_.GetValue() & ArkProperties::CONCURRENT_SWEEP) != 0;
|
||||
}
|
||||
|
||||
private:
|
||||
PandArg<bool> enable_ark_tools_ {"enable-ark-tools", false, R"(Enable ark tools to debug. Default: false)"};
|
||||
PandArg<bool> enable_cpuprofiler_ {"enable-cpuprofiler", false,
|
||||
@ -134,9 +176,7 @@ private:
|
||||
PandArg<bool> force_compress_gc_ {"force-compress-gc",
|
||||
true,
|
||||
R"(if true trigger compress gc, else trigger semi and old gc)"};
|
||||
PandArg<bool> enable_concurrent_sweep_ {"enable_concurrent_sweep",
|
||||
true,
|
||||
R"(If true enable concurrent sweep, else disable concurrent sweep. Default: true)"};
|
||||
PandArg<int> ark_properties_ {"ark-properties", GetDefaultProperties(), R"(set ark properties)"};
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
|
||||
|
@ -62,7 +62,8 @@ void Heap::Initialize()
|
||||
machineCodeSpace_ = new MachineCodeSpace(this);
|
||||
machineCodeSpace_->Initialize();
|
||||
hugeObjectSpace_ = new HugeObjectSpace(this);
|
||||
paralledGc_ = ecmaVm_->GetJSOptions().IsEnableParalledYoungGc();
|
||||
paralledGc_ = ecmaVm_->GetJSOptions().IsEnableParallelGC();
|
||||
concurrentMarkingEnable_ = ecmaVm_->GetJSOptions().IsEnableConcurrentMark();
|
||||
#if ECMASCRIPT_DISABLE_PARALLEL_GC
|
||||
paralledGc_ = false;
|
||||
#endif
|
||||
@ -198,6 +199,7 @@ void Heap::CollectGarbage(TriggerGCType gcType)
|
||||
#if ECMASCRIPT_SWITCH_GC_MODE_TO_COMPRESS_GC
|
||||
gcType = TriggerGCType::COMPRESS_FULL_GC;
|
||||
#endif
|
||||
OPTIONAL_LOG(ecmaVm_, ERROR, ECMASCRIPT) << "Heap::CollectGarbage, gcType = " << gcType;
|
||||
switch (gcType) {
|
||||
case TriggerGCType::SEMI_GC:
|
||||
if (GetMemController()->IsInAppStartup()) {
|
||||
|
@ -750,6 +750,10 @@ public:
|
||||
enableCpuprofiler_ = value;
|
||||
}
|
||||
|
||||
void SetArkProperties(int prop) {
|
||||
arkProperties_ = prop;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string GetGcType() const
|
||||
{
|
||||
@ -818,6 +822,11 @@ private:
|
||||
return enableCpuprofiler_;
|
||||
}
|
||||
|
||||
int GetArkProperties() const
|
||||
{
|
||||
return arkProperties_;
|
||||
}
|
||||
|
||||
GC_TYPE gcType_ = GC_TYPE::EPSILON;
|
||||
LOG_LEVEL logLevel_ = LOG_LEVEL::DEBUG;
|
||||
uint32_t gcPoolSize_ = DEFAULT_GC_POOL_SIZE;
|
||||
@ -825,6 +834,7 @@ private:
|
||||
std::string debuggerLibraryPath_ {};
|
||||
bool enableArkTools_ {false};
|
||||
bool enableCpuprofiler_ {false};
|
||||
int arkProperties_ {-1};
|
||||
friend JSNApi;
|
||||
};
|
||||
|
||||
|
@ -120,7 +120,7 @@ bool JSNApi::CreateRuntime(const RuntimeOption &option)
|
||||
// GC
|
||||
runtimeOptions.SetGcType(option.GetGcType());
|
||||
runtimeOptions.SetRunGcInPlace(true);
|
||||
|
||||
runtimeOptions.SetArkProperties(option.GetArkProperties());
|
||||
// Mem
|
||||
runtimeOptions.SetHeapSizeLimit(option.GetGcPoolSize());
|
||||
runtimeOptions.SetInternalMemorySizeLimit(INTERNAL_POOL_SIZE);
|
||||
@ -169,7 +169,7 @@ EcmaVM *JSNApi::CreateJSVM(const RuntimeOption &option)
|
||||
return EcmaVM::Cast(runtime->GetPandaVM());
|
||||
}
|
||||
JSRuntimeOptions runtimeOptions;
|
||||
|
||||
runtimeOptions.SetArkProperties(option.GetArkProperties());
|
||||
// GC
|
||||
runtimeOptions.SetGcTriggerType("no-gc-for-start-up"); // A non-production gc strategy. Prohibit stw-gc 10 times.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user