mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2025-02-17 02:10:00 +00:00
Memory usage optimization
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAYAPP Signed-off-by: hlm2001 <huanglimin10@huawei.com>
This commit is contained in:
parent
63eb0994e4
commit
c62c5d56ed
@ -27,6 +27,7 @@
|
||||
namespace panda::ecmascript::builtins {
|
||||
using ArrayHelper = base::ArrayHelper;
|
||||
using TypedArrayHelper = base::TypedArrayHelper;
|
||||
const CString STRING_SEPERATOR = ",";
|
||||
|
||||
// 22.1.1
|
||||
JSTaggedValue BuiltinsArray::ArrayConstructor(EcmaRuntimeCallInfo *argv)
|
||||
|
@ -114,7 +114,6 @@
|
||||
namespace panda::ecmascript::builtins {
|
||||
static constexpr uint8_t INDEX_TWO = 2;
|
||||
static constexpr uint8_t INDEX_THREE = 3;
|
||||
static const CString STRING_SEPERATOR = ",";
|
||||
class BuiltinsArray : public base::BuiltinsBase {
|
||||
public:
|
||||
// 22.1.1
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "ecmascript/dfx/tracing/tracing.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
const std::string JS_PATH = "entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/";
|
||||
|
||||
SamplesRecord::SamplesRecord()
|
||||
{
|
||||
profileInfo_ = std::make_unique<struct ProfileInfo>();
|
||||
|
@ -37,7 +37,6 @@ const int QUEUE_CAPACITY = 51; // the capacity of the circular queue is QUEUE_CA
|
||||
const size_t NAPI_CALL_SETP = 2; // 2: step size of the variable napiCallIdx in while loop
|
||||
const size_t PRE_IDX_RANGE = 5; // 5: length of variable preIdx looping backward
|
||||
const size_t SUB_LEN = 6; // 6: Truncate the path length
|
||||
const std::string JS_PATH = "entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/";
|
||||
|
||||
struct FrameInfo {
|
||||
int scriptId = 0;
|
||||
|
@ -276,7 +276,7 @@ HWTEST_F_L0(SamplesRecordTest, TranslateUrlPositionBySourceMapTest)
|
||||
sourceMapTranslateCallback_ = [](const std::string&, int, int) { return false; };
|
||||
samplesRecord.sourceMapTranslateCallbackTest(sourceMapTranslateCallback_);
|
||||
samplesRecord.TranslateUrlPositionBySourceMapTest(entry4);
|
||||
EXPECT_EQ(entry4.url, JS_PATH + "some_key.js");
|
||||
EXPECT_EQ(entry4.url, "entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/some_key.js");
|
||||
|
||||
FrameInfo entry5;
|
||||
entry5.url = "entry/some_key.other";
|
||||
|
@ -71,6 +71,14 @@ const std::vector<CompactDisplayOption> JSNumberFormat::COMPACT_DISPLAY_OPTION =
|
||||
};
|
||||
const std::vector<std::string> JSNumberFormat::COMPACT_DISPLAY_OPTION_NAME = {"short", "long"};
|
||||
|
||||
const std::set<std::string> SANCTIONED_UNIT({ "acre", "bit", "byte", "celsius", "centimeter", "day", "degree",
|
||||
"fahrenheit", "fluid-ounce", "foot", "gallon", "gigabit", "gigabyte",
|
||||
"gram", "hectare", "hour", "inch", "kilobit", "kilobyte", "kilogram",
|
||||
"kilometer", "liter", "megabit", "megabyte", "meter", "mile",
|
||||
"mile-scandinavian", "millimeter", "milliliter", "millisecond",
|
||||
"minute", "month", "ounce", "percent", "petabyte", "pound", "second",
|
||||
"stone", "terabit", "terabyte", "week", "yard", "year" });
|
||||
|
||||
JSHandle<JSTaggedValue> OptionToEcmaString(JSThread *thread, StyleOption style)
|
||||
{
|
||||
JSMutableHandle<JSTaggedValue> result(thread, JSTaggedValue::Undefined());
|
||||
|
@ -42,14 +42,6 @@ struct FractionDigitsOption {
|
||||
int32_t mxfdDefault = 0;
|
||||
};
|
||||
|
||||
static const std::set<std::string> SANCTIONED_UNIT({ "acre", "bit", "byte", "celsius", "centimeter", "day", "degree",
|
||||
"fahrenheit", "fluid-ounce", "foot", "gallon", "gigabit", "gigabyte",
|
||||
"gram", "hectare", "hour", "inch", "kilobit", "kilobyte", "kilogram",
|
||||
"kilometer", "liter", "megabit", "megabyte", "meter", "mile",
|
||||
"mile-scandinavian", "millimeter", "milliliter", "millisecond",
|
||||
"minute", "month", "ounce", "percent", "petabyte", "pound", "second",
|
||||
"stone", "terabit", "terabyte", "week", "yard", "year" });
|
||||
|
||||
class JSNumberFormat : public JSObject {
|
||||
public:
|
||||
static constexpr uint32_t DEFAULT_FRACTION_DIGITS = 2;
|
||||
|
@ -91,7 +91,6 @@ inline int PageProtectProt([[maybe_unused]] bool disable_codesign)
|
||||
|
||||
static constexpr char HEAP_TAG[] = "ArkTS Heap";
|
||||
static constexpr char CODE_TAG[] = "ArkTS Code";
|
||||
static const std::string EMPTY_STRING = "";
|
||||
MemMap PUBLIC_API PageMap(size_t size, int prot = PAGE_PROT_NONE, size_t alignment = 0, void *addr = nullptr,
|
||||
int flags = 0);
|
||||
void PUBLIC_API PageUnmap(MemMap it);
|
||||
@ -99,7 +98,7 @@ MemMap PUBLIC_API MachineCodePageMap(size_t size, int prot = PAGE_PROT_NONE, siz
|
||||
void PUBLIC_API MachineCodePageUnmap(MemMap it);
|
||||
void PageRelease(void *mem, size_t size);
|
||||
void PUBLIC_API PagePreRead(void *mem, size_t size);
|
||||
void PageTag(void *mem, size_t size, PageTagType type, const std::string &spaceName = EMPTY_STRING,
|
||||
void PageTag(void *mem, size_t size, PageTagType type, const std::string &spaceName = "",
|
||||
const uint32_t threadId = 0);
|
||||
void PageClearTag(void *mem, size_t size);
|
||||
const std::string GetPageTagString(PageTagType type, const std::string &spaceName, const uint32_t threadId = 0);
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
namespace panda::ecmascript {
|
||||
const char XATTR_KEY[] = {"user.security"};
|
||||
const std::string DEFAULT_DATA_LEVEL = "s1";
|
||||
constexpr std::string_view DEFAULT_DATA_LEVEL = "s1";
|
||||
const int DEFAULT_DATA_LENGTH = 2;
|
||||
size_t MallocUsableSize(void *p);
|
||||
uint32_t NumberOfCpuCore();
|
||||
|
@ -104,7 +104,6 @@ void *PageMapExecFortSpace(void *addr, size_t size, int prot)
|
||||
|
||||
void SetSecurityLabel(const std::string& path)
|
||||
{
|
||||
const std::string dataLevel = DEFAULT_DATA_LEVEL;
|
||||
auto xattrValueSize = getxattr(path.c_str(), XATTR_KEY, nullptr, 0);
|
||||
if (xattrValueSize == static_cast<ssize_t>(DEFAULT_DATA_LENGTH)) {
|
||||
char xattrValue[DEFAULT_DATA_LENGTH + 1];
|
||||
@ -112,8 +111,8 @@ void SetSecurityLabel(const std::string& path)
|
||||
xattrValue[DEFAULT_DATA_LENGTH] = '\0';
|
||||
}
|
||||
|
||||
if (setxattr(path.c_str(), XATTR_KEY, dataLevel.c_str(), dataLevel.size(), 0) < 0) {
|
||||
LOG_ECMA(WARN) << "set label failed! level: " << dataLevel << ", file: " << path;
|
||||
if (setxattr(path.c_str(), XATTR_KEY, DEFAULT_DATA_LEVEL.data(), DEFAULT_DATA_LEVEL.size(), 0) < 0) {
|
||||
LOG_ECMA(WARN) << "set label failed! level: " << DEFAULT_DATA_LEVEL << ", file: " << path;
|
||||
}
|
||||
}
|
||||
} // namespace panda::ecmascript
|
||||
|
@ -77,7 +77,6 @@ void *PageMapExecFortSpace(void *addr, [[maybe_unused]] size_t size, [[maybe_unu
|
||||
|
||||
void SetSecurityLabel(const std::string& path)
|
||||
{
|
||||
const std::string dataLevel = DEFAULT_DATA_LEVEL;
|
||||
auto xattrValueSize = getxattr(path.c_str(), XATTR_KEY, nullptr, 0, 0, 0);
|
||||
if (xattrValueSize == static_cast<ssize_t>(DEFAULT_DATA_LENGTH)) {
|
||||
char xattrValue[DEFAULT_DATA_LENGTH + 1];
|
||||
@ -85,8 +84,8 @@ void SetSecurityLabel(const std::string& path)
|
||||
xattrValue[DEFAULT_DATA_LENGTH] = '\0';
|
||||
}
|
||||
|
||||
if (setxattr(path.c_str(), XATTR_KEY, dataLevel.c_str(), dataLevel.size(), 0, 0) < 0) {
|
||||
LOG_ECMA(WARN) << "set label failed! level: " << dataLevel << ", file: " << path;
|
||||
if (setxattr(path.c_str(), XATTR_KEY, DEFAULT_DATA_LEVEL.data(), DEFAULT_DATA_LEVEL.size(), 0, 0) < 0) {
|
||||
LOG_ECMA(WARN) << "set label failed! level: " << DEFAULT_DATA_LEVEL << ", file: " << path;
|
||||
}
|
||||
}
|
||||
} // namespace panda::ecmascript
|
||||
|
Loading…
x
Reference in New Issue
Block a user