diff --git a/ecmascript/ecma_vm.cpp b/ecmascript/ecma_vm.cpp index 264e92f8b0..a2efcd4370 100644 --- a/ecmascript/ecma_vm.cpp +++ b/ecmascript/ecma_vm.cpp @@ -147,8 +147,6 @@ EcmaVM::EcmaVM(JSRuntimeOptions options, EcmaParamConfiguration config) options_ = std::move(options); icEnabled_ = options_.EnableIC(); optionalLogEnabled_ = options_.EnableOptionalLog(); - snapshotFileName_ = options_.GetSnapshotFile().c_str(); - frameworkAbcFileName_ = options_.GetFrameworkAbcFile().c_str(); options_.ParseAsmInterOption(); } @@ -445,15 +443,8 @@ JSTaggedValue EcmaVM::ExecuteAot(size_t actualNumArgs, JSTaggedType *args, const Expected EcmaVM::InvokeEcmaEntrypoint(const JSPandaFile *jsPandaFile, std::string_view entryPoint, bool excuteFromJob) { - JSTaggedValue result; [[maybe_unused]] EcmaHandleScope scope(thread_); - JSHandle program; - if (jsPandaFile != frameworkPandaFile_) { - program = JSPandaFileManager::GetInstance()->GenerateProgram(this, jsPandaFile, entryPoint); - } else { - program = JSHandle(thread_, frameworkProgram_); - frameworkProgram_ = JSTaggedValue::Hole(); - } + JSHandle program = JSPandaFileManager::GetInstance()->GenerateProgram(this, jsPandaFile, entryPoint); if (program.IsEmpty()) { LOG_ECMA(ERROR) << "program is empty, invoke entrypoint failed"; return Unexpected(false); @@ -463,8 +454,9 @@ Expected EcmaVM::InvokeEcmaEntrypoint(const JSPandaFile *js JSHandle func = JSHandle(thread_, program->GetMainFunction()); JSHandle global = GlobalEnv::Cast(globalEnv_.GetTaggedObject())->GetJSGlobalObject(); + JSHandle undefined = thread_->GlobalConstants()->GetHandledUndefined(); if (jsPandaFile->IsModule(entryPoint.data())) { - global = JSHandle(thread_, JSTaggedValue::Undefined()); + global = undefined; CString moduleName = jsPandaFile->GetJSPandaFileDesc(); if (!jsPandaFile->IsBundlePack()) { moduleName = entryPoint.data(); @@ -478,6 +470,7 @@ Expected EcmaVM::InvokeEcmaEntrypoint(const JSPandaFile *js func->SetModule(thread_, recordName); } + JSTaggedValue result; if (aotFileManager_->IsLoadMain(jsPandaFile, entryPoint.data())) { thread_->SetPrintBCOffset(true); EcmaRuntimeStatScope runtimeStatScope(this); @@ -486,7 +479,6 @@ Expected EcmaVM::InvokeEcmaEntrypoint(const JSPandaFile *js if (jsPandaFile->IsCjs(entryPoint.data())) { CJSExecution(func, global, jsPandaFile); } else { - JSHandle undefined = thread_->GlobalConstants()->GetHandledUndefined(); EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread_, JSHandle(func), global, undefined, 0); EcmaRuntimeStatScope runtimeStatScope(this); @@ -500,8 +492,7 @@ Expected EcmaVM::InvokeEcmaEntrypoint(const JSPandaFile *js // print exception information if (!excuteFromJob && thread_->HasPendingException()) { - auto exception = thread_->GetException(); - HandleUncaughtException(exception.GetTaggedObject()); + HandleUncaughtException(thread_->GetException()); } return result; } @@ -568,7 +559,7 @@ void EcmaVM::CJSExecution(JSHandle &func, JSHandle &t if (jsPandaFile->IsBundlePack()) { RequireManager::ResolveCurrentPath(thread_, dirname, filename, jsPandaFile); } else { - filename.Update(JSFunction::Cast(func.GetTaggedValue().GetTaggedObject())->GetModule()); + filename.Update(func->GetModule()); ASSERT(filename->IsString()); RequireManager::ResolveDirPath(thread_, dirname, filename); } @@ -600,8 +591,7 @@ void EcmaVM::CJSExecution(JSHandle &func, JSHandle &t // print exception information if (thread_->HasPendingException()) { - auto exception = thread_->GetException(); - HandleUncaughtException(exception.GetTaggedObject()); + HandleUncaughtException(thread_->GetException()); } // Collecting module.exports : exports ---> module.exports --->Module._cache RequireManager::CollectExecutedExp(thread_, cjsInfo); @@ -640,13 +630,13 @@ void EcmaVM::EnableUserUncaughtErrorHandler() isUncaughtExceptionRegistered_ = true; } -void EcmaVM::HandleUncaughtException(TaggedObject *exception) +void EcmaVM::HandleUncaughtException(JSTaggedValue exception) { if (isUncaughtExceptionRegistered_) { return; } [[maybe_unused]] EcmaHandleScope handleScope(thread_); - JSHandle exceptionHandle(thread_, JSTaggedValue(exception)); + JSHandle exceptionHandle(thread_, exception); // if caught exceptionHandle type is JSError thread_->ClearException(); if (exceptionHandle->IsJSError()) { @@ -829,7 +819,6 @@ void EcmaVM::Iterate(const RootVisitor &v, const RootRangeVisitor &rv) v(Root::ROOT_VM, ObjectSlot(reinterpret_cast(&globalEnv_))); v(Root::ROOT_VM, ObjectSlot(reinterpret_cast(µJobQueue_))); v(Root::ROOT_VM, ObjectSlot(reinterpret_cast(®expCache_))); - v(Root::ROOT_VM, ObjectSlot(reinterpret_cast(&frameworkProgram_))); rv(Root::ROOT_VM, ObjectSlot(ToUintPtr(&internalNativeMethods_.front())), ObjectSlot(ToUintPtr(&internalNativeMethods_.back()) + JSTaggedValue::TaggedTypeSize())); moduleManager_->Iterate(v); diff --git a/ecmascript/ecma_vm.h b/ecmascript/ecma_vm.h index ca7a8f789c..ec6ea9381b 100644 --- a/ecmascript/ecma_vm.h +++ b/ecmascript/ecma_vm.h @@ -591,7 +591,7 @@ public: protected: - void HandleUncaughtException(TaggedObject *exception); + void HandleUncaughtException(JSTaggedValue exception); void PrintJSErrorInfo(const JSHandle &exceptionInfo); @@ -655,11 +655,6 @@ private: JSTaggedValue microJobQueue_ {JSTaggedValue::Hole()}; EcmaRuntimeStat *runtimeStat_ {nullptr}; - // For framewrok file snapshot. - CString snapshotFileName_; - CString frameworkAbcFileName_; - JSTaggedValue frameworkProgram_ {JSTaggedValue::Hole()}; - const JSPandaFile *frameworkPandaFile_ {nullptr}; CMap> cachedConstpools_ {}; // VM resources. diff --git a/ecmascript/js_runtime_options.cpp b/ecmascript/js_runtime_options.cpp index 47ecc26f4e..6f77757019 100644 --- a/ecmascript/js_runtime_options.cpp +++ b/ecmascript/js_runtime_options.cpp @@ -138,7 +138,6 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv) {"enable-type-lowering", required_argument, nullptr, OPTION_ENABLE_TYPE_LOWERING}, {"entry-point", required_argument, nullptr, OPTION_ENTRY_POINT}, {"force-full-gc", required_argument, nullptr, OPTION_FORCE_FULL_GC}, - {"framework-abc-file", required_argument, nullptr, OPTION_FRAMEWORK_ABC_FILE}, {"gcThreadNum", required_argument, nullptr, OPTION_GC_THREADNUM}, {"heap-size-limit", required_argument, nullptr, OPTION_HEAP_SIZE_LIMIT}, {"help", no_argument, nullptr, OPTION_HELP}, @@ -160,7 +159,6 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv) {"print-any-types", required_argument, nullptr, OPTION_PRINT_ANY_TYPES}, {"reloc-mode", required_argument, nullptr, OPTION_RELOCATION_MODE}, {"serializer-buffer-size-limit", required_argument, nullptr, OPTION_SERIALIZER_BUFFER_SIZE_LIMIT}, - {"snapshot-file", required_argument, nullptr, OPTION_SNAPSHOT_FILE}, {"startup-time", required_argument, nullptr, OPTION_STARTUP_TIME}, {"stub-file", required_argument, nullptr, OPTION_STUB_FILE}, {"target-triple", required_argument, nullptr, OPTION_TARGET_TRIPLE}, @@ -333,9 +331,6 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv) return false; } break; - case OPTION_FRAMEWORK_ABC_FILE: - SetFrameworkAbcFile(optarg); - break; case OPTION_GC_THREADNUM: ret = ParseUint32Param("gcThreadNum", &argUint32); if (ret) { @@ -479,9 +474,6 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv) return false; } break; - case OPTION_SNAPSHOT_FILE: - SetSnapshotFile(optarg); - break; case OPTION_STARTUP_TIME: ret = ParseBoolParam(&argBool); if (ret) { diff --git a/ecmascript/js_runtime_options.h b/ecmascript/js_runtime_options.h index 3f7da786f1..4364c90189 100644 --- a/ecmascript/js_runtime_options.h +++ b/ecmascript/js_runtime_options.h @@ -73,8 +73,6 @@ enum CommandValues { OPTION_SERIALIZER_BUFFER_SIZE_LIMIT, OPTION_HEAP_SIZE_LIMIT, OPTION_ENABLE_IC, - OPTION_SNAPSHOT_FILE, - OPTION_FRAMEWORK_ABC_FILE, OPTION_ICU_DATA_PATH, OPTION_STARTUP_TIME, OPTION_COMPILER_LOG_OPT, @@ -508,36 +506,6 @@ public: return WasOptionSet(OPTION_ENABLE_IC); } - std::string GetSnapshotFile() const - { - return snapshotFile_; - } - - void SetSnapshotFile(std::string value) - { - snapshotFile_ = std::move(value); - } - - bool WasSetSnapshotFile() const - { - return WasOptionSet(OPTION_SNAPSHOT_FILE); - } - - std::string GetFrameworkAbcFile() const - { - return frameworkAbcFile_; - } - - void SetFrameworkAbcFile(std::string value) - { - frameworkAbcFile_ = std::move(value); - } - - bool WasSetFrameworkAbcFile() const - { - return WasOptionSet(OPTION_FRAMEWORK_ABC_FILE); - } - std::string GetIcuDataPath() const { return icuDataPath_; @@ -879,8 +847,6 @@ private: uint64_t serializerBufferSizeLimit_ {2_GB}; uint32_t heapSizeLimit_ {512_MB}; bool enableIC_ {true}; - std::string snapshotFile_ {"/system/etc/snapshot"}; - std::string frameworkAbcFile_ {"strip.native.min.abc"}; std::string icuDataPath_ {"default"}; bool startupTime_ {false}; std::string compilerLogOpt_ {"none"}; diff --git a/ecmascript/jspandafile/js_pandafile.cpp b/ecmascript/jspandafile/js_pandafile.cpp index 12b0986fb4..3aa71f507c 100644 --- a/ecmascript/jspandafile/js_pandafile.cpp +++ b/ecmascript/jspandafile/js_pandafile.cpp @@ -201,11 +201,11 @@ MethodLiteral *JSPandaFile::FindMethodLiteral(uint32_t offset) const bool JSPandaFile::IsModule(const CString &recordName) const { if (IsBundlePack()) { - return jsRecordInfo_.begin()->second.moduleRecordIdx == -1 ? false : true; + return jsRecordInfo_.begin()->second.moduleRecordIdx != -1; } auto info = jsRecordInfo_.find(recordName); if (info != jsRecordInfo_.end()) { - return info->second.moduleRecordIdx == -1 ? false : true; + return info->second.moduleRecordIdx != -1; } LOG_FULL(FATAL) << "find entryPoint failed: " << recordName; UNREACHABLE(); diff --git a/ecmascript/jspandafile/js_pandafile_executor.cpp b/ecmascript/jspandafile/js_pandafile_executor.cpp index 61bca5c3d7..e4e52353f2 100644 --- a/ecmascript/jspandafile/js_pandafile_executor.cpp +++ b/ecmascript/jspandafile/js_pandafile_executor.cpp @@ -59,8 +59,8 @@ Expected JSPandaFileExecutor::ExecuteFromFile(JSThread *thr entry = entryPoint.data(); } - const JSPandaFile *jsPandaFile = JSPandaFileManager::GetInstance()->LoadJSPandaFile(thread, name, entry.c_str(), - needUpdate); + const JSPandaFile *jsPandaFile = + JSPandaFileManager::GetInstance()->LoadJSPandaFile(thread, name, entry.c_str(), needUpdate); if (jsPandaFile == nullptr) { return Unexpected(false); } @@ -83,11 +83,11 @@ Expected JSPandaFileExecutor::ExecuteFromFile(JSThread *thr SourceTextModule::Instantiate(thread, moduleRecord); if (thread->HasPendingException()) { if (!excuteFromJob) { - auto exception = thread->GetException(); - vm->HandleUncaughtException(exception.GetTaggedObject()); + vm->HandleUncaughtException(thread->GetException()); } return JSTaggedValue::Undefined(); } + moduleRecord->SetStatus(ModuleStatus::INSTANTIATED); SourceTextModule::Evaluate(thread, moduleRecord, nullptr, 0, excuteFromJob); return JSTaggedValue::Undefined(); @@ -105,6 +105,7 @@ Expected JSPandaFileExecutor::ExecuteFromBuffer(JSThread *t if (jsPandaFile == nullptr) { return Unexpected(false); } + CString entry = entryPoint.data(); bool isModule = jsPandaFile->IsModule(entry); bool isBundle = jsPandaFile->IsBundlePack(); @@ -162,8 +163,7 @@ Expected JSPandaFileExecutor::CommonExecuteBuffer(JSThread } SourceTextModule::Instantiate(thread, moduleRecord); if (thread->HasPendingException()) { - auto exception = thread->GetException(); - vm->HandleUncaughtException(exception.GetTaggedObject()); + vm->HandleUncaughtException(thread->GetException()); return JSTaggedValue::Undefined(); } moduleRecord->SetStatus(ModuleStatus::INSTANTIATED); diff --git a/ecmascript/jspandafile/js_pandafile_executor.h b/ecmascript/jspandafile/js_pandafile_executor.h index dc0659afc7..3cb45b0b0a 100644 --- a/ecmascript/jspandafile/js_pandafile_executor.h +++ b/ecmascript/jspandafile/js_pandafile_executor.h @@ -16,7 +16,6 @@ #ifndef ECMASCRIPT_JSPANDAFILE_JS_PANDAFILE_EXECUTOR_H #define ECMASCRIPT_JSPANDAFILE_JS_PANDAFILE_EXECUTOR_H -#include "ecmascript/mem/c_containers.h" #include "ecmascript/js_tagged_value.h" #include "ecmascript/js_thread.h" #include "ecmascript/jspandafile/js_pandafile.h" diff --git a/ecmascript/jspandafile/js_pandafile_manager.cpp b/ecmascript/jspandafile/js_pandafile_manager.cpp index 06ee82784b..b95ed53803 100644 --- a/ecmascript/jspandafile/js_pandafile_manager.cpp +++ b/ecmascript/jspandafile/js_pandafile_manager.cpp @@ -120,8 +120,7 @@ JSHandle JSPandaFileManager::GenerateProgram( { ASSERT(GetJSPandaFile(jsPandaFile->GetPandaFile()) != nullptr); vm->GetAOTFileManager()->LoadAiFile(jsPandaFile); - JSHandle program = PandaFileTranslator::GenerateProgram(vm, jsPandaFile, entryPoint); - return program; + return PandaFileTranslator::GenerateProgram(vm, jsPandaFile, entryPoint); } const JSPandaFile *JSPandaFileManager::FindJSPandaFileWithChecksum(const CString &filename, uint32_t checksum) diff --git a/ecmascript/napi/jsnapi.cpp b/ecmascript/napi/jsnapi.cpp index 110edb4e6d..4c7967a72a 100644 --- a/ecmascript/napi/jsnapi.cpp +++ b/ecmascript/napi/jsnapi.cpp @@ -2730,8 +2730,7 @@ bool JSNApi::InitForConcurrentFunction(EcmaVM *vm, Local function) } ecmascript::SourceTextModule::Instantiate(thread, moduleRecord); if (thread->HasPendingException()) { - auto exception = thread->GetException(); - vm->HandleUncaughtException(exception.GetTaggedObject()); + vm->HandleUncaughtException(thread->GetException()); return false; } moduleRecord->SetStatus(ecmascript::ModuleStatus::INSTANTIATED);