mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-27 12:10:47 +00:00
add handlescope and add option control print execute pandafile spent time
Signed-off-by: linxiang <linxiang8@huawei.com> Change-Id: I1e7cb9660f3a42f9c413dc2fce85b49fd5fb97cc
This commit is contained in:
parent
dedc3bf323
commit
444e381051
@ -69,6 +69,7 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv)
|
||||
{"startup-time", required_argument, nullptr, OPTION_STARTUP_TIME},
|
||||
{"stub-file", required_argument, nullptr, OPTION_STUB_FILE},
|
||||
{"target-triple", required_argument, nullptr, OPTION_TARGET_TRIPLE},
|
||||
{"enable-print-execute-time", required_argument, nullptr, OPTION_PRINT_EXECUTE_TIME},
|
||||
{nullptr, 0, nullptr, 0},
|
||||
};
|
||||
|
||||
@ -307,6 +308,14 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv)
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case OPTION_PRINT_EXECUTE_TIME:
|
||||
ret = ParseBoolParam(&argBool);
|
||||
if (ret) {
|
||||
SetEnablePrintExecuteTime(argBool);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case OPTION_RELOCATION_MODE:
|
||||
ret = ParseUint32Param("reloc-mode", &argUint32);
|
||||
if (ret) {
|
||||
|
@ -120,6 +120,7 @@ const std::string HELP_OPTION_MSG =
|
||||
"--startup-time: Print the start time of command execution. Default: false\n"
|
||||
"--stub-file: Path of file includes common stubs module compiled by stub compiler. Default: \"stub.an\"\n"
|
||||
"--target-triple: target triple for aot compiler or stub compiler.\n"
|
||||
"--enable-print-execute-time: enable print execute pandafile spent time\"\n"
|
||||
" Possible values: [\"x86_64-unknown-linux-gnu\", \"arm-unknown-linux-gnu\", "
|
||||
"\"aarch64-unknown-linux-gnu\"].\n"
|
||||
" Default: \"x86_64-unknown-linux-gnu\"\n";
|
||||
@ -173,7 +174,8 @@ enum CommandValues {
|
||||
OPTION_MERGE_ABC,
|
||||
OPTION_ENABLE_TYPE_LOWERING,
|
||||
OPTION_HELP,
|
||||
OPTION_OPTIONS
|
||||
OPTION_OPTIONS,
|
||||
OPTION_PRINT_EXECUTE_TIME
|
||||
};
|
||||
|
||||
class PUBLIC_API JSRuntimeOptions {
|
||||
@ -800,6 +802,16 @@ public:
|
||||
mergeAbc_ = value;
|
||||
}
|
||||
|
||||
void SetEnablePrintExecuteTime(bool value)
|
||||
{
|
||||
enablePrintExecuteTime_ = value;
|
||||
}
|
||||
|
||||
bool IsEnablePrintExecuteTime()
|
||||
{
|
||||
return enablePrintExecuteTime_;
|
||||
}
|
||||
|
||||
void ParseAbcListFile(std::vector<std::string> &moduleList) const
|
||||
{
|
||||
std::ifstream moduleFile(abcFilelist_);
|
||||
@ -890,6 +902,7 @@ private:
|
||||
bool mergeAbc_ {false};
|
||||
bool enableTypeLowering_ {true};
|
||||
uint64_t wasSet_ {0};
|
||||
bool enablePrintExecuteTime_ {false};
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "ecmascript/js_runtime_options.h"
|
||||
#include "ecmascript/log.h"
|
||||
#include "ecmascript/mem/mem_controller.h"
|
||||
#include "ecmascript/mem/clock_scope.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
@ -98,6 +99,7 @@ int Main(const int argc, const char **argv)
|
||||
#else
|
||||
arg_list_t fileNames = base::StringHelper::SplitString(files, ":");
|
||||
#endif
|
||||
ClockScope execute;
|
||||
for (const auto &fileName : fileNames) {
|
||||
auto res = JSNApi::Execute(vm, fileName, entry);
|
||||
if (!res) {
|
||||
@ -106,6 +108,10 @@ int Main(const int argc, const char **argv)
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto totalTime = execute.TotalSpentTime();
|
||||
if (runtimeOptions.IsEnablePrintExecuteTime()) {
|
||||
std::cout << "execute pandafile spent time " << totalTime << "ms" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
|
@ -140,7 +140,6 @@ void JSPandaFileManager::InsertJSPandaFile(const JSPandaFile *jsPandaFile)
|
||||
void JSPandaFileManager::IncreaseRefJSPandaFileUnlocked(const JSPandaFile *jsPandaFile)
|
||||
{
|
||||
auto const filename = jsPandaFile->GetJSPandaFileDesc();
|
||||
LOG_ECMA(DEBUG) << "IncreaseRefJSPandaFileUnlocked " << filename;
|
||||
auto iter = loadedJSPandaFiles_.find(filename);
|
||||
ASSERT(iter != loadedJSPandaFiles_.end());
|
||||
iter->second.second++;
|
||||
@ -149,7 +148,6 @@ void JSPandaFileManager::IncreaseRefJSPandaFileUnlocked(const JSPandaFile *jsPan
|
||||
void JSPandaFileManager::DecreaseRefJSPandaFile(const JSPandaFile *jsPandaFile)
|
||||
{
|
||||
const auto &filename = jsPandaFile->GetJSPandaFileDesc();
|
||||
LOG_ECMA(DEBUG) << "DecreaseRefJSPandaFile " << filename;
|
||||
os::memory::LockHolder lock(jsPandaFileLock_);
|
||||
auto iter = loadedJSPandaFiles_.find(filename);
|
||||
if (iter != loadedJSPandaFiles_.end()) {
|
||||
|
@ -61,6 +61,7 @@ void ModuleDataExtractor::ExtractModuleDatas(JSThread *thread, const JSPandaFile
|
||||
panda_file::File::EntityId moduleId,
|
||||
JSHandle<SourceTextModule> &moduleRecord)
|
||||
{
|
||||
[[maybe_unused]] EcmaHandleScope scope(thread);
|
||||
const panda_file::File *pf = jsPandaFile->GetPandaFile();
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
ModuleDataAccessor mda(*pf, moduleId);
|
||||
|
@ -217,6 +217,7 @@ int SourceTextModule::Instantiate(JSThread *thread, const JSHandle<SourceTextMod
|
||||
int SourceTextModule::InnerModuleInstantiation(JSThread *thread, const JSHandle<ModuleRecord> &moduleRecord,
|
||||
CVector<JSHandle<SourceTextModule>> &stack, int index)
|
||||
{
|
||||
[[maybe_unused]] EcmaHandleScope scope(thread);
|
||||
// 1. If module is not a Source Text Module Record, then
|
||||
if (!moduleRecord.GetTaggedValue().IsSourceTextModule()) {
|
||||
// a. Perform ? module.Instantiate().
|
||||
@ -251,6 +252,7 @@ int SourceTextModule::InnerModuleInstantiation(JSThread *thread, const JSHandle<
|
||||
size_t requestedModulesLen = requestedModules->GetLength();
|
||||
JSMutableHandle<JSTaggedValue> required(thread, thread->GlobalConstants()->GetUndefined());
|
||||
for (size_t idx = 0; idx < requestedModulesLen; idx++) {
|
||||
[[maybe_unused]] EcmaHandleScope scope2(thread);
|
||||
required.Update(requestedModules->Get(idx));
|
||||
// a. Let requiredModule be ? HostResolveImportedModule(module, required).
|
||||
JSMutableHandle<SourceTextModule> requiredModule(thread, thread->GlobalConstants()->GetUndefined());
|
||||
@ -539,6 +541,7 @@ int SourceTextModule::InnerModuleEvaluation(JSThread *thread, const JSHandle<Mod
|
||||
CVector<JSHandle<SourceTextModule>> &stack, int index,
|
||||
const void *buffer, size_t size)
|
||||
{
|
||||
[[maybe_unused]] EcmaHandleScope scope(thread);
|
||||
// 1. If module is not a Source Text Module Record, then
|
||||
if (!moduleRecord.GetTaggedValue().IsSourceTextModule()) {
|
||||
// a. Perform ? module.Instantiate().
|
||||
@ -581,6 +584,7 @@ int SourceTextModule::InnerModuleEvaluation(JSThread *thread, const JSHandle<Mod
|
||||
size_t requestedModulesLen = requestedModules->GetLength();
|
||||
JSMutableHandle<JSTaggedValue> required(thread, thread->GlobalConstants()->GetUndefined());
|
||||
for (size_t idx = 0; idx < requestedModulesLen; idx++) {
|
||||
[[maybe_unused]] EcmaHandleScope scope2(thread);
|
||||
required.Update(requestedModules->Get(idx));
|
||||
// a. Let requiredModule be ! HostResolveImportedModule(module, required).
|
||||
JSMutableHandle<SourceTextModule> requiredModule(thread, thread->GlobalConstants()->GetUndefined());
|
||||
|
Loading…
Reference in New Issue
Block a user