mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
Set stage of HotReload by enum class
Signed-off-by: lijiamin2019 <lijiamin24@huawei.com> Change-Id: I7bcc1f0d0da5137e489d7efa360311887199337e
This commit is contained in:
parent
0c92778215
commit
cc4fcf00a8
@ -24,6 +24,7 @@
|
||||
#include "ecmascript/js_tagged_value.h"
|
||||
#include "ecmascript/mem/c_containers.h"
|
||||
#include "ecmascript/mem/visitor.h"
|
||||
#include "ecmascript/patch/patch_loader.h"
|
||||
#include "ecmascript/regexp/regexp_parser_cache.h"
|
||||
#include "ecmascript/waiter_list.h"
|
||||
#include "global_handle_collection.h"
|
||||
@ -425,11 +426,11 @@ public:
|
||||
cachedPatchModules_.clear();
|
||||
}
|
||||
|
||||
int32_t GetStageOfHotReload() const
|
||||
StageOfHotReload GetStageOfHotReload() const
|
||||
{
|
||||
return stageOfHotReload_;
|
||||
}
|
||||
void SetStageOfHotReload(int32_t stageOfHotReload)
|
||||
void SetStageOfHotReload(StageOfHotReload stageOfHotReload)
|
||||
{
|
||||
stageOfHotReload_ = stageOfHotReload;
|
||||
}
|
||||
@ -490,7 +491,7 @@ private:
|
||||
|
||||
// for HotReload of module.
|
||||
CMap<CString, JSHandle<JSTaggedValue>> cachedPatchModules_ {};
|
||||
int32_t stageOfHotReload_ = 0;
|
||||
StageOfHotReload stageOfHotReload_ = StageOfHotReload::INITIALIZE_STAGE_OF_HOTRELOAD;
|
||||
|
||||
// VM resources.
|
||||
ModuleManager *moduleManager_ {nullptr};
|
||||
|
@ -226,7 +226,7 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::Execute(JSThread *thread, con
|
||||
|
||||
Expected<JSTaggedValue, bool> result;
|
||||
|
||||
if (context->GetStageOfHotReload() < 0) {
|
||||
if (context->GetStageOfHotReload() == StageOfHotReload::BEGIN_EXECUTE_PATCHMAIN) {
|
||||
result = context->InvokeEcmaEntrypointForHotReload(jsPandaFile, entryPoint, excuteFromJob);
|
||||
} else {
|
||||
QuickFixManager *quickFixManager = thread->GetEcmaVM()->GetQuickFixManager();
|
||||
|
@ -115,8 +115,7 @@ JSTaggedValue ModuleManager::GetModuleValueOutterInternal(int32_t index, JSTagge
|
||||
// Support for only modifying var value of HotReload.
|
||||
// Cause patchFile exclude the record of importing modifying var. Can't reresolve moduleRecord.
|
||||
EcmaContext *context = thread->GetCurrentEcmaContext();
|
||||
int32_t InterceptGetModuleValue = 1; // 1: for Interceptint get module var
|
||||
if (context->GetStageOfHotReload() == InterceptGetModuleValue) {
|
||||
if (context->GetStageOfHotReload() == StageOfHotReload::LOAD_END_EXECUTE_PATCHMAIN) {
|
||||
const JSHandle<JSTaggedValue> resolvedModuleOfHotReload =
|
||||
context->FindPatchModule(ConvertToString(module->GetEcmaModuleRecordName()));
|
||||
if (!resolvedModuleOfHotReload->IsHole()) {
|
||||
|
@ -74,7 +74,7 @@ void PatchLoader::ExecuteFuncOrPatchMain(
|
||||
{
|
||||
LOG_ECMA(DEBUG) << "execute main begin";
|
||||
EcmaContext *context = thread->GetCurrentEcmaContext();
|
||||
context->SetStageOfHotReload(BEGIN_EXECUTE_PATCHMAIN);
|
||||
context->SetStageOfHotReload(StageOfHotReload::BEGIN_EXECUTE_PATCHMAIN);
|
||||
|
||||
const auto &replacedRecordNames = patchInfo.replacedRecordNames;
|
||||
|
||||
@ -104,9 +104,9 @@ void PatchLoader::ExecuteFuncOrPatchMain(
|
||||
}
|
||||
|
||||
if (loadPatch) {
|
||||
context->SetStageOfHotReload(LOAD_END_EXECUTE_PATCHMAIN);
|
||||
context->SetStageOfHotReload(StageOfHotReload::LOAD_END_EXECUTE_PATCHMAIN);
|
||||
} else {
|
||||
context->SetStageOfHotReload(UNLOAD_END_EXECUTE_PATCHMAIN);
|
||||
context->SetStageOfHotReload(StageOfHotReload::UNLOAD_END_EXECUTE_PATCHMAIN);
|
||||
}
|
||||
LOG_ECMA(DEBUG) << "execute main end";
|
||||
}
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "ecmascript/js_tagged_value.h"
|
||||
#include "ecmascript/js_thread.h"
|
||||
#include "ecmascript/mem/c_containers.h"
|
||||
#include "ecmascript/module/js_module_source_text.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
@ -58,6 +57,14 @@ struct PatchInfo {
|
||||
// patch replaced recordNames.
|
||||
CUnorderedSet<CString> replacedRecordNames;
|
||||
};
|
||||
|
||||
enum class StageOfHotReload : int32_t {
|
||||
BEGIN_EXECUTE_PATCHMAIN = -1, // -1: For intercepting Evaluate()
|
||||
INITIALIZE_STAGE_OF_HOTRELOAD, // 0 : initialize stageOfHotreload_ in ecma_context.h
|
||||
LOAD_END_EXECUTE_PATCHMAIN, // 1: for Interceptint get module var
|
||||
UNLOAD_END_EXECUTE_PATCHMAIN // 2 :for execute abc normally
|
||||
};
|
||||
|
||||
class PatchLoader {
|
||||
public:
|
||||
PatchLoader() = default;
|
||||
@ -90,10 +97,6 @@ private:
|
||||
static void ClearPatchInfo(JSThread *thread, const CString &patchFileName);
|
||||
|
||||
static void ReplaceModuleOfMethod(JSThread *thread, const JSPandaFile *baseFile, PatchInfo &patchInfo);
|
||||
|
||||
static constexpr int32_t BEGIN_EXECUTE_PATCHMAIN = -1; // -1: For intercepting Evaluate()
|
||||
static constexpr int32_t LOAD_END_EXECUTE_PATCHMAIN = 1; // 1 :For intercepting get module value
|
||||
static constexpr int32_t UNLOAD_END_EXECUTE_PATCHMAIN = 2; // 2 :for execute abc normally
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
#endif // ECMASCRIPT_PATCH_PATCH_LOADER_H
|
||||
|
Loading…
Reference in New Issue
Block a user