Descriptor: Add quickfix testcases

Details:
1. Add quickfix testcases
2. delete isPatch flag
3. use the same recore name of base and patch

Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I5UPMC

Signed-off-by: wengchangcheng <wengchangcheng@huawei.com>
Change-Id: I1e03addb8f37240557df899fbee8bc99beb97e92
This commit is contained in:
wengchangcheng 2022-10-09 18:01:37 +08:00
parent dedc3bf323
commit aaf47ba3d0
90 changed files with 2045 additions and 110 deletions

View File

@ -129,6 +129,9 @@ if (defined(ark_standalone_build)) {
# js bytecode test # js bytecode test
deps += [ "//arkcompiler/ets_runtime/test/moduletest:ark_js_moduletest" ] deps += [ "//arkcompiler/ets_runtime/test/moduletest:ark_js_moduletest" ]
# quickfix test
deps += [ "//arkcompiler/ets_runtime/test/quickfix:ark_quickfix_test" ]
# ts aot test and asm test # ts aot test and asm test
if (is_standard_system && !run_with_asan) { if (is_standard_system && !run_with_asan) {
deps += [ deps += [

View File

@ -90,6 +90,8 @@ int Main(const int argc, const char **argv)
return -1; return -1;
} }
bool isMergeAbc = runtimeOptions.GetMergeAbc();
JSNApi::SetBundle(vm, !isMergeAbc);
{ {
LocalScope scope(vm); LocalScope scope(vm);
std::string entry = runtimeOptions.GetEntryPoint(); std::string entry = runtimeOptions.GetEntryPoint();

View File

@ -23,8 +23,8 @@
#include "libpandafile/class_data_accessor-inl.h" #include "libpandafile/class_data_accessor-inl.h"
namespace panda::ecmascript { namespace panda::ecmascript {
JSPandaFile::JSPandaFile(const panda_file::File *pf, const CString &descriptor, bool isPatch) JSPandaFile::JSPandaFile(const panda_file::File *pf, const CString &descriptor)
: pf_(pf), desc_(descriptor), isPatch_(isPatch) : pf_(pf), desc_(descriptor)
{ {
ASSERT(pf_ != nullptr); ASSERT(pf_ != nullptr);
#if ECMASCRIPT_ENABLE_MERGE_ABC #if ECMASCRIPT_ENABLE_MERGE_ABC
@ -257,20 +257,20 @@ CString JSPandaFile::FindrecordName(const CString &recordName) const
return name; return name;
} }
std::string JSPandaFile::ParseOhmUrl(std::string fileName) CString JSPandaFile::ParseOhmUrl(const CString &fileName)
{ {
std::string bundleInstallName(BUNDLE_INSTALL_PATH); CString bundleInstallName(BUNDLE_INSTALL_PATH);
size_t startStrLen = bundleInstallName.length(); size_t startStrLen = bundleInstallName.length();
size_t pos = std::string::npos; size_t pos = CString::npos;
if (fileName.length() > startStrLen && fileName.compare(0, startStrLen, bundleInstallName) == 0) { if (fileName.length() > startStrLen && fileName.compare(0, startStrLen, bundleInstallName) == 0) {
pos = startStrLen; pos = startStrLen;
} }
std::string result = fileName; CString result = fileName;
if (pos != std::string::npos) { if (pos != CString::npos) {
result = fileName.substr(pos); result = fileName.substr(pos);
pos = result.find('/'); pos = result.find('/');
if (pos != std::string::npos) { if (pos != CString::npos) {
result = result.substr(pos + 1); result = result.substr(pos + 1);
} }
} else { } else {
@ -278,14 +278,14 @@ std::string JSPandaFile::ParseOhmUrl(std::string fileName)
result = MODULE_DEFAULE_ETS + result; result = MODULE_DEFAULE_ETS + result;
} }
pos = result.find_last_of("."); pos = result.find_last_of(".");
if (pos != std::string::npos) { if (pos != CString::npos) {
result = result.substr(0, pos); result = result.substr(0, pos);
} }
return result; return result;
} }
std::string JSPandaFile::ParseRecordName(const std::string &fileName) CString JSPandaFile::ParseRecordName(const CString &fileName)
{ {
size_t begin = fileName.find_last_of("/"); size_t begin = fileName.find_last_of("/");
ASSERT(begin != std::string::npos); ASSERT(begin != std::string::npos);

View File

@ -39,7 +39,6 @@ public:
static constexpr char PATCH_ENTRY_FUNCTION[] = "_GLOBAL::patch_main_0"; static constexpr char PATCH_ENTRY_FUNCTION[] = "_GLOBAL::patch_main_0";
static constexpr char PATCH_FUNCTION_NAME_0[] = "patch_main_0"; static constexpr char PATCH_FUNCTION_NAME_0[] = "patch_main_0";
static constexpr char PATCH_FUNCTION_NAME_1[] = "patch_main_1"; static constexpr char PATCH_FUNCTION_NAME_1[] = "patch_main_1";
static constexpr char PATCH_RECORD_PREFIX[] = "Patch.";
static constexpr char MODULE_CLASS[] = "L_ESModuleRecord;"; static constexpr char MODULE_CLASS[] = "L_ESModuleRecord;";
static constexpr char TS_TYPES_CLASS[] = "L_ESTypeInfoRecord;"; static constexpr char TS_TYPES_CLASS[] = "L_ESTypeInfoRecord;";
@ -56,7 +55,7 @@ public:
static constexpr char NODE_MODULES_ZERO[] = "node_modules/0/"; static constexpr char NODE_MODULES_ZERO[] = "node_modules/0/";
static constexpr char NODE_MODULES_ONE[] = "node_modules/1/"; static constexpr char NODE_MODULES_ONE[] = "node_modules/1/";
JSPandaFile(const panda_file::File *pf, const CString &descriptor, bool isPatch); JSPandaFile(const panda_file::File *pf, const CString &descriptor);
~JSPandaFile(); ~JSPandaFile();
const CString &GetJSPandaFileDesc() const const CString &GetJSPandaFileDesc() const
@ -240,9 +239,6 @@ public:
CString ParseEntryPoint(const CString &recordName) const CString ParseEntryPoint(const CString &recordName) const
{ {
CString record = recordName.substr(1, recordName.size() - 2); // 2 : skip symbol "L" and ";" CString record = recordName.substr(1, recordName.size() - 2); // 2 : skip symbol "L" and ";"
if (isPatch_) {
record = PATCH_RECORD_PREFIX + record;
}
return record; return record;
} }
@ -250,9 +246,9 @@ public:
CString FindrecordName(const CString &record) const; CString FindrecordName(const CString &record) const;
static std::string ParseOhmUrl(std::string fileName); static CString ParseOhmUrl(const CString &fileName);
// For local merge abc, get record name from file name. // For local merge abc, get record name from file name.
static std::string PUBLIC_API ParseRecordName(const std::string &fileName); static CString PUBLIC_API ParseRecordName(const CString &fileName);
private: private:
void InitializeUnMergedPF(); void InitializeUnMergedPF();
@ -272,7 +268,6 @@ private:
bool isLoadedAOT_ {false}; bool isLoadedAOT_ {false};
uint32_t typeSummaryOffset_ {0}; uint32_t typeSummaryOffset_ {0};
bool isNewVersion_ {false}; bool isNewVersion_ {false};
bool isPatch_ {false};
// marge abc // marge abc
bool isBundlePack_ {true}; // isBundlePack means app compile mode is JSBundle bool isBundlePack_ {true}; // isBundlePack means app compile mode is JSBundle

View File

@ -31,9 +31,9 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::ExecuteFromFile(JSThread *thr
#if ECMASCRIPT_ENABLE_MERGE_ABC #if ECMASCRIPT_ENABLE_MERGE_ABC
if (!thread->GetEcmaVM()->IsBundlePack()) { if (!thread->GetEcmaVM()->IsBundlePack()) {
#if defined(PANDA_TARGET_LINUX) #if defined(PANDA_TARGET_LINUX)
entry = JSPandaFile::ParseRecordName(filename.c_str()); entry = JSPandaFile::ParseRecordName(filename);
#else #else
entry = JSPandaFile::ParseOhmUrl(filename.c_str()); entry = JSPandaFile::ParseOhmUrl(filename);
#if !WIN_OR_MAC_PLATFORM #if !WIN_OR_MAC_PLATFORM
name = JSPandaFile::MERGE_ABC_PATH; name = JSPandaFile::MERGE_ABC_PATH;
#elif defined(PANDA_TARGET_WINDOWS) #elif defined(PANDA_TARGET_WINDOWS)
@ -107,7 +107,7 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::ExecuteModuleBuffer(
CString assetPath = thread->GetEcmaVM()->GetAssetPath().c_str(); CString assetPath = thread->GetEcmaVM()->GetAssetPath().c_str();
name = assetPath + "/modules.abc"; name = assetPath + "/modules.abc";
#endif #endif
CString entry = ConvertToString(JSPandaFile::ParseOhmUrl(filename.c_str())); CString entry = JSPandaFile::ParseOhmUrl(filename);
const JSPandaFile *jsPandaFile = const JSPandaFile *jsPandaFile =
JSPandaFileManager::GetInstance()->LoadJSPandaFile(thread, name, entry.c_str(), buffer, size); JSPandaFileManager::GetInstance()->LoadJSPandaFile(thread, name, entry.c_str(), buffer, size);
if (jsPandaFile == nullptr) { if (jsPandaFile == nullptr) {

View File

@ -44,7 +44,7 @@ JSPandaFileManager::~JSPandaFileManager()
} }
const JSPandaFile *JSPandaFileManager::LoadJSPandaFile(JSThread *thread, const CString &filename, const JSPandaFile *JSPandaFileManager::LoadJSPandaFile(JSThread *thread, const CString &filename,
std::string_view entryPoint, bool isPatch) std::string_view entryPoint)
{ {
{ {
os::memory::LockHolder lock(jsPandaFileLock_); os::memory::LockHolder lock(jsPandaFileLock_);
@ -61,13 +61,12 @@ const JSPandaFile *JSPandaFileManager::LoadJSPandaFile(JSThread *thread, const C
return nullptr; return nullptr;
} }
const JSPandaFile *jsPandaFile = GenerateJSPandaFile(thread, pf.release(), filename, entryPoint, isPatch); const JSPandaFile *jsPandaFile = GenerateJSPandaFile(thread, pf.release(), filename, entryPoint);
return jsPandaFile; return jsPandaFile;
} }
const JSPandaFile *JSPandaFileManager::LoadJSPandaFile(JSThread *thread, const CString &filename, const JSPandaFile *JSPandaFileManager::LoadJSPandaFile(JSThread *thread, const CString &filename,
std::string_view entryPoint, const void *buffer, size_t size, std::string_view entryPoint, const void *buffer, size_t size)
bool isPatch)
{ {
if (buffer == nullptr || size == 0) { if (buffer == nullptr || size == 0) {
return nullptr; return nullptr;
@ -86,7 +85,7 @@ const JSPandaFile *JSPandaFileManager::LoadJSPandaFile(JSThread *thread, const C
LOG_ECMA(ERROR) << "open file " << filename << " error"; LOG_ECMA(ERROR) << "open file " << filename << " error";
return nullptr; return nullptr;
} }
const JSPandaFile *jsPandaFile = GenerateJSPandaFile(thread, pf.release(), filename, entryPoint, isPatch); const JSPandaFile *jsPandaFile = GenerateJSPandaFile(thread, pf.release(), filename, entryPoint);
return jsPandaFile; return jsPandaFile;
} }
@ -175,9 +174,9 @@ JSPandaFile *JSPandaFileManager::OpenJSPandaFile(const CString &filename)
return jsPandaFile; return jsPandaFile;
} }
JSPandaFile *JSPandaFileManager::NewJSPandaFile(const panda_file::File *pf, const CString &desc, bool isPatch) JSPandaFile *JSPandaFileManager::NewJSPandaFile(const panda_file::File *pf, const CString &desc)
{ {
return new JSPandaFile(pf, desc, isPatch); return new JSPandaFile(pf, desc);
} }
void JSPandaFileManager::ReleaseJSPandaFile(const JSPandaFile *jsPandaFile) void JSPandaFileManager::ReleaseJSPandaFile(const JSPandaFile *jsPandaFile)
@ -209,11 +208,10 @@ DebugInfoExtractor *JSPandaFileManager::GetJSPtExtractor(const JSPandaFile *jsPa
} }
const JSPandaFile *JSPandaFileManager::GenerateJSPandaFile(JSThread *thread, const panda_file::File *pf, const JSPandaFile *JSPandaFileManager::GenerateJSPandaFile(JSThread *thread, const panda_file::File *pf,
const CString &desc, std::string_view entryPoint, const CString &desc, std::string_view entryPoint)
bool isPatch)
{ {
ASSERT(GetJSPandaFile(pf) == nullptr); ASSERT(GetJSPandaFile(pf) == nullptr);
JSPandaFile *newJsPandaFile = NewJSPandaFile(pf, desc, isPatch); JSPandaFile *newJsPandaFile = NewJSPandaFile(pf, desc);
auto loader = thread->GetEcmaVM()->GetFileLoader(); auto loader = thread->GetEcmaVM()->GetFileLoader();
if (loader->hasLoaded(newJsPandaFile)) { if (loader->hasLoaded(newJsPandaFile)) {

View File

@ -35,15 +35,14 @@ public:
JSHandle<Program> GenerateProgram(EcmaVM *vm, const JSPandaFile *jsPandaFile, std::string_view entryPoint); JSHandle<Program> GenerateProgram(EcmaVM *vm, const JSPandaFile *jsPandaFile, std::string_view entryPoint);
const JSPandaFile *LoadJSPandaFile(JSThread *thread, const CString &filename, std::string_view entryPoint, const JSPandaFile *LoadJSPandaFile(JSThread *thread, const CString &filename, std::string_view entryPoint);
bool isPatch = false);
const JSPandaFile *LoadJSPandaFile(JSThread *thread, const CString &filename, std::string_view entryPoint, const JSPandaFile *LoadJSPandaFile(JSThread *thread, const CString &filename, std::string_view entryPoint,
const void *buffer, size_t size, bool isPatch = false); const void *buffer, size_t size);
JSPandaFile *OpenJSPandaFile(const CString &filename); JSPandaFile *OpenJSPandaFile(const CString &filename);
JSPandaFile *NewJSPandaFile(const panda_file::File *pf, const CString &desc, bool isPatch = false); JSPandaFile *NewJSPandaFile(const panda_file::File *pf, const CString &desc);
DebugInfoExtractor *GetJSPtExtractor(const JSPandaFile *jsPandaFile); DebugInfoExtractor *GetJSPtExtractor(const JSPandaFile *jsPandaFile);
@ -75,7 +74,7 @@ private:
}; };
const JSPandaFile *GenerateJSPandaFile(JSThread *thread, const panda_file::File *pf, const CString &desc, const JSPandaFile *GenerateJSPandaFile(JSThread *thread, const panda_file::File *pf, const CString &desc,
std::string_view entryPoint, bool isPatch); std::string_view entryPoint);
void ReleaseJSPandaFile(const JSPandaFile *jsPandaFile); void ReleaseJSPandaFile(const JSPandaFile *jsPandaFile);
const JSPandaFile *GetJSPandaFile(const panda_file::File *pf); const JSPandaFile *GetJSPandaFile(const panda_file::File *pf);
const JSPandaFile *FindJSPandaFileUnlocked(const CString &filename); const JSPandaFile *FindJSPandaFileUnlocked(const CString &filename);

View File

@ -252,6 +252,13 @@ JSHandle<JSFunction> LiteralDataExtractor::DefineMethodInLiteral(JSThread *threa
if (!entryPoint.empty()) { if (!entryPoint.empty()) {
moduleName = entryPoint; moduleName = entryPoint;
entry = entryPoint; entry = entryPoint;
} else {
#if defined(PANDA_TARGET_LINUX)
if (!jsPandaFile->IsBundlePack()) {
entry = JSPandaFile::ParseRecordName(moduleName);
moduleName = entry;
}
#endif
} }
if (jsPandaFile->IsModule(entry)) { if (jsPandaFile->IsModule(entry)) {
EcmaVM *vm = thread->GetEcmaVM(); EcmaVM *vm = thread->GetEcmaVM();

View File

@ -37,7 +37,7 @@ bool QuickFixLoader::LoadPatch(JSThread *thread, const CString &patchFileName, c
// The entry point is not work for merge abc. // The entry point is not work for merge abc.
patchFile_ = JSPandaFileManager::GetInstance()->LoadJSPandaFile(thread, patchFileName, patchFile_ = JSPandaFileManager::GetInstance()->LoadJSPandaFile(thread, patchFileName,
JSPandaFile::PATCH_ENTRY_FUNCTION, true); JSPandaFile::PATCH_ENTRY_FUNCTION);
if (patchFile_ == nullptr) { if (patchFile_ == nullptr) {
LOG_FULL(ERROR) << "load patch jsPandafile failed"; LOG_FULL(ERROR) << "load patch jsPandafile failed";
return false; return false;
@ -58,7 +58,7 @@ bool QuickFixLoader::LoadPatch(JSThread *thread, const CString &patchFileName, c
patchFile_ = JSPandaFileManager::GetInstance()->LoadJSPandaFile(thread, patchFileName, patchFile_ = JSPandaFileManager::GetInstance()->LoadJSPandaFile(thread, patchFileName,
JSPandaFile::PATCH_ENTRY_FUNCTION, JSPandaFile::PATCH_ENTRY_FUNCTION,
patchBuffer, patchSize, true); patchBuffer, patchSize);
if (patchFile_ == nullptr) { if (patchFile_ == nullptr) {
LOG_FULL(ERROR) << "load patch jsPandafile failed"; LOG_FULL(ERROR) << "load patch jsPandafile failed";
return false; return false;
@ -69,6 +69,7 @@ bool QuickFixLoader::LoadPatch(JSThread *thread, const CString &patchFileName, c
bool QuickFixLoader::LoadPatchInternal(JSThread *thread) bool QuickFixLoader::LoadPatchInternal(JSThread *thread)
{ {
// support multi constpool: baseFile_->GetPandaFile()->GetHeader()->num_indexes
EcmaVM *vm = thread->GetEcmaVM(); EcmaVM *vm = thread->GetEcmaVM();
if (baseFile_->IsBundlePack() != patchFile_->IsBundlePack()) { if (baseFile_->IsBundlePack() != patchFile_->IsBundlePack()) {
LOG_FULL(ERROR) << "base and patch is not the same type hap!"; LOG_FULL(ERROR) << "base and patch is not the same type hap!";
@ -144,16 +145,32 @@ CVector<JSHandle<Program>> QuickFixLoader::ParseAllConstpoolWithMerge(JSThread *
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
JSHandle<JSHClass> hclass = JSHandle<JSHClass>::Cast(vm->GetGlobalEnv()->GetFunctionClassWithProto()); JSHandle<JSHClass> hclass = JSHandle<JSHClass>::Cast(vm->GetGlobalEnv()->GetFunctionClassWithProto());
bool isNewVersion = jsPandaFile->IsNewVersion();
JSHandle<ConstantPool> constpool; JSHandle<ConstantPool> constpool;
JSTaggedValue constpoolValue = vm->FindConstpool(jsPandaFile, 0); JSTaggedValue constpoolValue = vm->FindConstpool(jsPandaFile, 0);
if (constpoolValue.IsHole()) { if (constpoolValue.IsHole()) {
constpool = PandaFileTranslator::ParseConstPool(vm, jsPandaFile); if (isNewVersion) {
const CString &filename = jsPandaFile->GetJSPandaFileDesc();
#if defined(PANDA_TARGET_LINUX)
CString entry = JSPandaFile::ParseRecordName(filename);
#else
CString entry = JSPandaFile::ParseOhmUrl(filename);
#endif
uint32_t mainMethodIndex = jsPandaFile->GetMainMethodIndex(entry);
ASSERT(mainMethodIndex != 0);
constpool = ConstantPool::CreateConstPool(vm, jsPandaFile, mainMethodIndex);
} else {
constpool = PandaFileTranslator::ParseConstPool(vm, jsPandaFile);
}
int32_t index = 0; int32_t index = 0;
int32_t total = 1; int32_t total = 1;
vm->AddConstpool(jsPandaFile, constpool.GetTaggedValue(), index, total); vm->AddConstpool(jsPandaFile, constpool.GetTaggedValue(), index, total);
} else { } else {
constpool = JSHandle<ConstantPool>(thread, constpoolValue); constpool = JSHandle<ConstantPool>(thread, constpoolValue);
} }
if (isNewVersion) {
GenerateConstpoolCache(vm, jsPandaFile, constpool);
}
CVector<JSHandle<Program>> programs; CVector<JSHandle<Program>> programs;
auto recordInfos = jsPandaFile->GetJSRecordInfo(); auto recordInfos = jsPandaFile->GetJSRecordInfo();
@ -162,11 +179,13 @@ CVector<JSHandle<Program>> QuickFixLoader::ParseAllConstpoolWithMerge(JSThread *
const CString &recordName = item.first; const CString &recordName = item.first;
LOG_FULL(DEBUG) << "Parse constpool: " << fileName << ":" << recordName; LOG_FULL(DEBUG) << "Parse constpool: " << fileName << ":" << recordName;
vm->GetModuleManager()->HostResolveImportedModuleWithMerge(fileName, recordName); vm->GetModuleManager()->HostResolveImportedModuleWithMerge(fileName, recordName);
PandaFileTranslator::ParseFuncAndLiteralConstPool(vm, jsPandaFile, recordName, constpool); if (!isNewVersion) {
PandaFileTranslator::ParseFuncAndLiteralConstPool(vm, jsPandaFile, recordName, constpool);
}
// Generate Program for every record. // Generate Program for every record.
uint32_t mainMethodIndex = jsPandaFile->GetMainMethodIndex(recordName); uint32_t recordIndex = jsPandaFile->GetMainMethodIndex(recordName);
auto methodLiteral = jsPandaFile->FindMethodLiteral(mainMethodIndex); auto methodLiteral = jsPandaFile->FindMethodLiteral(recordIndex);
JSHandle<Program> program = factory->NewProgram(); JSHandle<Program> program = factory->NewProgram();
if (methodLiteral == nullptr) { if (methodLiteral == nullptr) {
program->SetMainFunction(thread, JSTaggedValue::Undefined()); program->SetMainFunction(thread, JSTaggedValue::Undefined());
@ -182,6 +201,80 @@ CVector<JSHandle<Program>> QuickFixLoader::ParseAllConstpoolWithMerge(JSThread *
return programs; return programs;
} }
void QuickFixLoader::GenerateConstpoolCache(EcmaVM *vm, const JSPandaFile *jsPandaFile,
JSHandle<ConstantPool> constpool)
{
ASSERT(jsPandaFile->IsNewVersion());
auto thread = vm->GetJSThread();
const panda_file::File *pf = jsPandaFile->GetPandaFile();
Span<const uint32_t> classIndexes = jsPandaFile->GetClasses();
for (const uint32_t index : classIndexes) {
panda_file::File::EntityId classId(index);
if (pf->IsExternal(classId)) {
continue;
}
panda_file::ClassDataAccessor cda(*pf, classId);
cda.EnumerateMethods([pf, thread, constpool](panda_file::MethodDataAccessor &mda) {
auto codeId = mda.GetCodeId();
ASSERT(codeId.has_value());
panda_file::CodeDataAccessor codeDataAccessor(*pf, codeId.value());
uint32_t codeSize = codeDataAccessor.GetCodeSize();
const uint8_t *insns = codeDataAccessor.GetInstructions();
auto bcIns = BytecodeInstruction(insns);
auto bcInsLast = bcIns.JumpTo(codeSize);
while (bcIns.GetAddress() != bcInsLast.GetAddress()) {
if (!bcIns.HasFlag(BytecodeInstruction::Flags::STRING_ID) ||
!BytecodeInstruction::HasId(BytecodeInstruction::GetFormat(bcIns.GetOpcode()), 0)) {
BytecodeInstruction::Opcode opcode = bcIns.GetOpcode();
switch (opcode) {
// add opcode about method
case EcmaOpcode::DEFINEMETHOD_IMM8_ID16_IMM8:
U_FALLTHROUGH;
case EcmaOpcode::DEFINEMETHOD_IMM16_ID16_IMM8:
U_FALLTHROUGH;
case EcmaOpcode::DEFINEFUNC_IMM8_ID16_IMM8:
U_FALLTHROUGH;
case EcmaOpcode::DEFINEFUNC_IMM16_ID16_IMM8: {
uint32_t id = bcIns.GetId().AsRawValue();
ConstantPool::GetMethodFromCache(thread, constpool.GetTaggedValue(), id);
break;
}
case EcmaOpcode::CREATEOBJECTWITHBUFFER_IMM8_ID16:
U_FALLTHROUGH;
case EcmaOpcode::CREATEOBJECTWITHBUFFER_IMM16_ID16: {
uint32_t id = bcIns.GetId().AsRawValue();
ConstantPool::GetLiteralFromCache<ConstPoolType::OBJECT_LITERAL>(
thread, constpool.GetTaggedValue(), id);
break;
}
case EcmaOpcode::CREATEARRAYWITHBUFFER_IMM8_ID16:
U_FALLTHROUGH;
case EcmaOpcode::CREATEARRAYWITHBUFFER_IMM16_ID16: {
uint32_t id = bcIns.GetId().AsRawValue();
ConstantPool::GetLiteralFromCache<ConstPoolType::ARRAY_LITERAL>(
thread, constpool.GetTaggedValue(), id);
break;
}
case EcmaOpcode::DEFINECLASSWITHBUFFER_IMM8_ID16_ID16_IMM16_V8:
U_FALLTHROUGH;
case EcmaOpcode::DEFINECLASSWITHBUFFER_IMM16_ID16_ID16_IMM16_V8: {
uint32_t methodId = bcIns.GetId(0).AsRawValue();
uint32_t literalId = bcIns.GetId(1).AsRawValue();
ConstantPool::GetClassMethodFromCache(thread, constpool, methodId);
ConstantPool::GetClassLiteralFromCache(thread, constpool, literalId);
break;
}
default:
break;
}
}
bcIns = bcIns.GetNext();
}
});
}
}
bool QuickFixLoader::ReplaceMethod(JSThread *thread, bool QuickFixLoader::ReplaceMethod(JSThread *thread,
const JSHandle<ConstantPool> &baseConstpool, const JSHandle<ConstantPool> &baseConstpool,
const JSHandle<ConstantPool> &patchConstpool) const JSHandle<ConstantPool> &patchConstpool)
@ -223,7 +316,7 @@ bool QuickFixLoader::ReplaceMethod(JSThread *thread,
} }
// For merge abc, method and record name must be same to base. // For merge abc, method and record name must be same to base.
CString baseRecordName = GetRecordName(baseFile_, baseMethod->GetMethodId()); CString baseRecordName = GetRecordName(baseFile_, baseMethod->GetMethodId());
if (patchRecordName != JSPandaFile::PATCH_RECORD_PREFIX + baseRecordName) { if (patchRecordName != baseRecordName) {
continue; continue;
} }
@ -249,7 +342,7 @@ bool QuickFixLoader::ReplaceMethod(JSThread *thread,
} }
// For merge abc, method and record name must be same to base. // For merge abc, method and record name must be same to base.
CString baseRecordName = GetRecordName(baseFile_, baseMethod->GetMethodId()); CString baseRecordName = GetRecordName(baseFile_, baseMethod->GetMethodId());
if (patchRecordName != JSPandaFile::PATCH_RECORD_PREFIX + baseRecordName) { if (patchRecordName != baseRecordName) {
continue; continue;
} }
@ -418,22 +511,22 @@ void QuickFixLoader::InsertBaseClassMethodInfo(uint32_t constpoolIndex, uint32_t
bool QuickFixLoader::CheckIsInvalidPatch(EcmaVM *vm) const bool QuickFixLoader::CheckIsInvalidPatch(EcmaVM *vm) const
{ {
DISALLOW_GARBAGE_COLLECTION; DISALLOW_GARBAGE_COLLECTION;
static constexpr size_t prefixSize = sizeof(JSPandaFile::PATCH_RECORD_PREFIX) - 1;
auto thread = vm->GetJSThread();
auto moduleManager = vm->GetModuleManager(); auto moduleManager = vm->GetModuleManager();
auto patchRecordInfos = patchFile_->GetJSRecordInfo(); auto patchRecordInfos = patchFile_->GetJSRecordInfo();
[[maybe_unused]] auto baseRecordInfos = baseFile_->GetJSRecordInfo(); [[maybe_unused]] auto baseRecordInfos = baseFile_->GetJSRecordInfo();
for (const auto &patchItem : patchRecordInfos) { for (const auto &patchItem : patchRecordInfos) {
const CString &patchRecordName = patchItem.first; const CString &patchRecordName = patchItem.first;
ASSERT(patchRecordName.substr(0, prefixSize) == JSPandaFile::PATCH_RECORD_PREFIX); CString baseRecordName = patchRecordName;
CString baseRecordName = patchRecordName.substr(prefixSize);
ASSERT(baseRecordInfos.find(baseRecordName) != baseRecordInfos.end()); ASSERT(baseRecordInfos.find(baseRecordName) != baseRecordInfos.end());
JSHandle<SourceTextModule> patchModule = moduleManager->HostGetImportedModule(patchRecordName); JSHandle<SourceTextModule> patchModule =
moduleManager->ResolveModuleWithMerge(thread, patchFile_, patchRecordName);
JSHandle<SourceTextModule> baseModule = moduleManager->HostGetImportedModule(baseRecordName); JSHandle<SourceTextModule> baseModule = moduleManager->HostGetImportedModule(baseRecordName);
if (CheckIsModuleMismatch(vm->GetJSThread(), patchModule, baseModule)) { if (CheckIsModuleMismatch(thread, patchModule, baseModule)) {
return true; return true;
} }
} }

View File

@ -49,6 +49,7 @@ private:
CString GetRecordName(const JSPandaFile *jsPandaFile, EntityId methodId); CString GetRecordName(const JSPandaFile *jsPandaFile, EntityId methodId);
CVector<JSHandle<Program>> ParseAllConstpoolWithMerge(JSThread *thread, const JSPandaFile *jsPandaFile); CVector<JSHandle<Program>> ParseAllConstpoolWithMerge(JSThread *thread, const JSPandaFile *jsPandaFile);
void GenerateConstpoolCache(EcmaVM *vm, const JSPandaFile *jsPandaFile, JSHandle<ConstantPool> constpool);
bool ExecutePatchMain(JSThread *thread, const JSHandle<Program> &patchProgram); bool ExecutePatchMain(JSThread *thread, const JSHandle<Program> &patchProgram);
bool ExecutePatchMain(JSThread *thread, const CVector<JSHandle<Program>> &programs); bool ExecutePatchMain(JSThread *thread, const CVector<JSHandle<Program>> &programs);

View File

@ -256,7 +256,13 @@ JSHandle<SourceTextModule> ModuleManager::HostResolveImportedModuleWithMerge(con
UNREACHABLE(); UNREACHABLE();
} }
return ResolveModuleWithMerge(thread, jsPandaFile, recordName); JSHandle<SourceTextModule> moduleRecord = ResolveModuleWithMerge(thread, jsPandaFile, recordName);
JSHandle<NameDictionary> handleDict(thread, resolvedModules_);
resolvedModules_ = NameDictionary::Put(thread, handleDict, JSHandle<JSTaggedValue>(recordNameHandle),
JSHandle<JSTaggedValue>(moduleRecord), PropertyAttributes::Default())
.GetTaggedValue();
return moduleRecord;
} }
JSHandle<SourceTextModule> ModuleManager::HostResolveImportedModule(const CString &referencingModule) JSHandle<SourceTextModule> ModuleManager::HostResolveImportedModule(const CString &referencingModule)
@ -354,10 +360,6 @@ JSHandle<SourceTextModule> ModuleManager::ResolveModuleWithMerge(
JSHandle<JSTaggedValue> recordNameHandle = JSHandle<JSTaggedValue>::Cast(factory->NewFromUtf8(recordName)); JSHandle<JSTaggedValue> recordNameHandle = JSHandle<JSTaggedValue>::Cast(factory->NewFromUtf8(recordName));
JSHandle<SourceTextModule>::Cast(moduleRecord)->SetEcmaModuleRecordName(thread, recordNameHandle); JSHandle<SourceTextModule>::Cast(moduleRecord)->SetEcmaModuleRecordName(thread, recordNameHandle);
JSHandle<NameDictionary> dict(thread, resolvedModules_);
resolvedModules_ =
NameDictionary::Put(thread, dict, recordNameHandle, moduleRecord, PropertyAttributes::Default())
.GetTaggedValue();
return JSHandle<SourceTextModule>::Cast(moduleRecord); return JSHandle<SourceTextModule>::Cast(moduleRecord);
} }

View File

@ -564,17 +564,17 @@ bool JSNApi::ExecuteModuleFromBuffer(EcmaVM *vm, const void *data, int32_t size,
return true; return true;
} }
Local<ObjectRef> JSNApi::GetExportObject(EcmaVM *vm, const std::string &file, [[maybe_unused]] const std::string &key) Local<ObjectRef> JSNApi::GetExportObject(EcmaVM *vm, const std::string &file, const std::string &key)
{ {
std::string entry = file; ecmascript::CString entry = file.c_str();
#if ECMASCRIPT_ENABLE_MERGE_ABC #if ECMASCRIPT_ENABLE_MERGE_ABC
if (!vm->IsBundlePack()) { if (!vm->IsBundlePack()) {
entry = ecmascript::JSPandaFile::ParseOhmUrl(file.c_str()); entry = ecmascript::JSPandaFile::ParseOhmUrl(entry);
} }
#endif #endif
ecmascript::ModuleManager *moduleManager = vm->GetModuleManager(); ecmascript::ModuleManager *moduleManager = vm->GetModuleManager();
JSThread *thread = vm->GetJSThread(); JSThread *thread = vm->GetJSThread();
JSHandle<ecmascript::SourceTextModule> ecmaModule = moduleManager->HostGetImportedModule(entry.c_str()); JSHandle<ecmascript::SourceTextModule> ecmaModule = moduleManager->HostGetImportedModule(entry);
if (ecmaModule->GetIsNewBcVersion()) { if (ecmaModule->GetIsNewBcVersion()) {
// 0: There's only one export value "default" // 0: There's only one export value "default"
JSHandle<JSTaggedValue> exportObj(thread, ecmaModule->GetModuleValue(thread, 0, false)); JSHandle<JSTaggedValue> exportObj(thread, ecmaModule->GetModuleValue(thread, 0, false));
@ -589,7 +589,7 @@ Local<ObjectRef> JSNApi::GetExportObject(EcmaVM *vm, const std::string &file, [[
} }
Local<ObjectRef> JSNApi::GetExportObjectFromBuffer(EcmaVM *vm, const std::string &file, Local<ObjectRef> JSNApi::GetExportObjectFromBuffer(EcmaVM *vm, const std::string &file,
[[maybe_unused]] const std::string &key) const std::string &key)
{ {
ecmascript::ModuleManager *moduleManager = vm->GetModuleManager(); ecmascript::ModuleManager *moduleManager = vm->GetModuleManager();
JSThread *thread = vm->GetJSThread(); JSThread *thread = vm->GetJSThread();

View File

@ -60,15 +60,15 @@ int Main(const int argc, const char **argv)
BlockSignals(); BlockSignals();
if (argc < 2) { // 2: at least have two arguments if (argc < 2) { // 2: at least have two arguments
std::cerr << GetHelper(); std::cout << GetHelper();
return -1; return -1;
} }
int newArgc = argc; int newArgc = argc;
std::string files = argv[argc - 1]; std::string files = argv[argc - 1];
if (!base::StringHelper::EndsWith(files, ".abc")) { if (!base::StringHelper::EndsWith(files, ".abc")) {
std::cerr << "The last argument must be abc file" << std::endl; std::cout << "The last argument must be abc file" << std::endl;
std::cerr << GetHelper(); std::cout << GetHelper();
return 1; return 1;
} }
@ -76,7 +76,7 @@ int Main(const int argc, const char **argv)
JSRuntimeOptions runtimeOptions; JSRuntimeOptions runtimeOptions;
bool retOpt = runtimeOptions.ParseCommand(newArgc, argv); bool retOpt = runtimeOptions.ParseCommand(newArgc, argv);
if (!retOpt) { if (!retOpt) {
std::cerr << GetHelper(); std::cout << GetHelper();
return 1; return 1;
} }
@ -86,12 +86,12 @@ int Main(const int argc, const char **argv)
} }
EcmaVM *vm = JSNApi::CreateEcmaVM(runtimeOptions); EcmaVM *vm = JSNApi::CreateEcmaVM(runtimeOptions);
if (vm == nullptr) { if (vm == nullptr) {
std::cerr << "Cannot Create vm" << std::endl; std::cout << "Cannot Create vm" << std::endl;
return -1; return -1;
} }
{ {
std::cout << "QuickFix Test start!" << std::endl; std::cout << "QuickFix Execute start" << std::endl;
LocalScope scope(vm); LocalScope scope(vm);
std::string entry = runtimeOptions.GetEntryPoint(); std::string entry = runtimeOptions.GetEntryPoint();
@ -102,59 +102,63 @@ int Main(const int argc, const char **argv)
#endif #endif
uint32_t len = fileNames.size(); uint32_t len = fileNames.size();
if (len < 4) { // 4: four abc file if (len < 4) { // 4: four abc file
std::cerr << "Must include base.abc, patch.abc, test1.abc, test2.abc absolute path" << std::endl; std::cout << "Must include base.abc, patch.abc, test1.abc, test2.abc absolute path" << std::endl;
return -1; return -1;
} }
std::string baseFileName = fileNames[0]; std::string baseFileName = fileNames[0];
std::string patchFileName = fileNames[1]; // 1: second file, patch.abc
std::string testLoadFileName = fileNames[2]; // 2: third file, test loadpatch abc file.
std::string testUnloadFileName = fileNames[3]; // 3: fourth file, test unloadpatch abc file.
JSNApi::EnableUserUncaughtErrorHandler(vm);
bool isMergeAbc = runtimeOptions.GetMergeAbc(); bool isMergeAbc = runtimeOptions.GetMergeAbc();
JSNApi::SetBundle(vm, !isMergeAbc); JSNApi::SetBundle(vm, !isMergeAbc);
auto res = JSNApi::Execute(vm, baseFileName, entry); auto res = JSNApi::Execute(vm, baseFileName, entry);
if (!res) { if (!res) {
std::cerr << "Cannot execute panda file '" << baseFileName << "' with entry '" << entry << "'" << std::endl; std::cout << "Cannot execute panda file '" << baseFileName << "' with entry '" << entry << "'" << std::endl;
return -1; return -1;
} }
JSNApi::EnableUserUncaughtErrorHandler(vm);
res = JSNApi::LoadPatch(vm, patchFileName, baseFileName); std::string testLoadFileName = fileNames[1];
if (!res) { std::string testUnloadFileName = fileNames[2]; // 2: third file, test unloadpatch abc file.
std::cerr << "LoadPatch failed!"<< std::endl; for (uint32_t i = 3; i < len; i++) { // 3: patch file, test unloadpatch abc file.
return -1; std::string patchFileName = fileNames[i];
std::cout << "QuickFix start load patch" << std::endl;
res = JSNApi::LoadPatch(vm, patchFileName, baseFileName);
if (!res) {
std::cout << "LoadPatch failed"<< std::endl;
return -1;
}
std::cout << "QuickFix load patch success" << std::endl;
res = JSNApi::Execute(vm, testLoadFileName, entry);
if (!res) {
std::cout << "Cannot execute panda file '" << testLoadFileName
<< "' with entry '" << entry << "'" << std::endl;
return -1;
}
std::cout << "QuickFix start check exception" << std::endl;
Local<ObjectRef> exception = JSNApi::GetAndClearUncaughtException(vm);
res = JSNApi::IsQuickFixCausedException(vm, exception, patchFileName);
if (res) {
std::cout << "QuickFix have exception." << std::endl;
} else {
std::cout << "QuickFix have no exception" << std::endl;
}
std::cout << "QuickFix start unload patch" << std::endl;
res = JSNApi::UnloadPatch(vm, patchFileName);
if (!res) {
std::cout << "UnloadPatch failed!" << std::endl;
return -1;
}
std::cout << "QuickFix unload patch success" << std::endl;
res = JSNApi::Execute(vm, testUnloadFileName, entry);
if (!res) {
std::cout << "Cannot execute panda file '" << testUnloadFileName
<< "' with entry '" << entry << "'" << std::endl;
return -1;
}
} }
std::cout << "QuickFix Execute end" << std::endl;
res = JSNApi::Execute(vm, testLoadFileName, entry);
if (!res) {
std::cerr << "Cannot execute panda file '" << testLoadFileName
<< "' with entry '" << entry << "'" << std::endl;
return -1;
}
Local<ObjectRef> exception = JSNApi::GetUncaughtException(vm);
res = JSNApi::IsQuickFixCausedException(vm, exception, patchFileName);
if (res) {
std::cout << "Patch have exception." << std::endl;
} else {
std::cout << "-------------------------------------------" << std::endl;
}
res = JSNApi::UnloadPatch(vm, patchFileName);
if (!res) {
std::cerr << "UnloadPatch failed!" << std::endl;
return -1;
}
res = JSNApi::Execute(vm, testUnloadFileName, entry);
if (!res) {
std::cerr << "Cannot execute panda file '" << testUnloadFileName
<< "' with entry '" << entry << "'" << std::endl;
return -1;
}
std::cout << "QuickFix Test end!" << std::endl;
} }
JSNApi::DestroyJSVM(vm); JSNApi::DestroyJSVM(vm);

View File

@ -15,9 +15,8 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
Description: run script Description: run script
expect_output will get run result, input: resource file
expect_sub_output will catch pivotal sub output, output: output file
expect_file will get print string
""" """
import argparse import argparse

51
test/quickfix/BUILD.gn Normal file
View File

@ -0,0 +1,51 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
test_list = [
"check_import",
"class_inheritance",
"class_mem_func",
"class_mem_var",
"class_name",
"closure",
"global_func",
"global_var",
"import_export",
"print_string",
]
host_quickfix_test_action("multi_patch") {
extra_patches = [
"patch1",
"patch2",
]
}
foreach(testcase, test_list) {
host_quickfix_test_action("${testcase}") {
extra_patches = []
}
}
group("ark_quickfix_test") {
testonly = true
deps = []
foreach(testcase, test_list) {
deps += [ ":${testcase}QuickfixAction" ]
}
deps += [ ":multi_patchQuickfixAction" ]
}

2
test/quickfix/base.txt Normal file
View File

@ -0,0 +1,2 @@
base.js;base;module;base.js
module.js;module;module;module.js

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function foo() {
print("base foo")
}
globalThis.foo = foo

View File

@ -0,0 +1,16 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
QuickFix Execute start
QuickFix start load patch
LoadPatch failed

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { nop } from './module.js'
function foo() {
print("patch foo")
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
globalThis.foo()

View File

@ -0,0 +1,29 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BaseA {
constructor() {
}
PrintStr() {
print("print BaseA");
}
}
class A {
constructor() {
}
}
globalThis.AA = new A();

View File

@ -0,0 +1,23 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
QuickFix Execute start
QuickFix start load patch
QuickFix load patch success
AA.PrintStr not function
QuickFix start check exception
QuickFix have no exception
QuickFix start unload patch
QuickFix unload patch success
AA.PrintStr not function
QuickFix Execute end

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BaseA {
constructor() {
}
PrintStr() {
print("print BaseA");
}
}
class A extends BaseA {
constructor() {
super();
}
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
if (AA.PrintStr instanceof Function) {
AA.PrintStr()
} else {
print("AA.PrintStr not function")
}

View File

@ -0,0 +1,30 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class C {
constructor() {
}
PrintBase() {
print("print base");
}
}
function A() {
var c = new C()
c.PrintBase()
}
globalThis.A = A;
globalThis.C = new C();

View File

@ -0,0 +1,23 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
QuickFix Execute start
QuickFix start load patch
QuickFix load patch success
print base patch
QuickFix start check exception
QuickFix have exception.
QuickFix start unload patch
QuickFix unload patch success
print base
QuickFix Execute end

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class C {
constructor() {
}
PrintBase() {
print("print base patch" );
}
PrintPatch() {
print("print patch");
}
}
function A() {
var c = new C()
c.PrintBase()
c.PrintPatch()
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
A()

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class A {
constructor() {
this.str = "base"
}
PrintStr() {
print("print base str :" + this.str);
}
}
globalThis.A = A;
globalThis.AA = new A();

View File

@ -0,0 +1,27 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
QuickFix Execute start
QuickFix start load patch
QuickFix load patch success
print patch str :patch
print patch new :a
print patch str :base
print patch new :undefined
QuickFix start check exception
QuickFix have no exception
QuickFix start unload patch
QuickFix unload patch success
print base str :base
print base str :base
QuickFix Execute end

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class A {
constructor() {
this.str = "patch"
this.a = "a"
}
PrintStr() {
print("print patch str :" + this.str);
print("print patch new :" + this.a);
}
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,18 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const a = new A();
a.PrintStr();
AA.PrintStr()

View File

@ -0,0 +1,29 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function foo() {
class C1 {
constructor() {
}
PrintStr() {
print("print base str");
}
}
var c = new C1()
c.PrintStr()
}
globalThis.foo = foo;

View File

@ -0,0 +1,23 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
QuickFix Execute start
QuickFix start load patch
QuickFix load patch success
print patch str
QuickFix start check exception
QuickFix have no exception
QuickFix start unload patch
QuickFix unload patch success
print base str
QuickFix Execute end

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function foo() {
class C2 {
constructor() {
}
PrintStr() {
print("print patch str");
}
}
var c = new C2()
c.PrintStr()
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
foo()

32
test/quickfix/closure/base.js Executable file
View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var e1 = -1
function A() {
var a1 = 1
function B() {
var b1 = 11
function C() {
print("base: " + e1)
print("base: " + a1)
print("base: " + b1)
}
C()
}
B()
}
globalThis.A = A

View File

@ -0,0 +1,31 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
QuickFix Execute start
QuickFix start load patch
QuickFix load patch success
patch: -1
patch: 2
patch: 3
patch: 4
patch: 12
patch: 13
patch: 14
QuickFix start check exception
QuickFix have no exception
QuickFix start unload patch
QuickFix unload patch success
base: -1
base: 1
base: 11
QuickFix Execute end

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var e1 = -10
function A() {
var a0 = 2
var a1 = 3
var a2 = 4
function B() {
var b0 = 12
var b1 = 13
var b2 = 14
function C() {
print("patch: " + e1)
print("patch: " + a0)
print("patch: " + a1)
print("patch: " + a2)
print("patch: " + b0)
print("patch: " + b1)
print("patch: " + b2)
}
C()
}
B()
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

16
test/quickfix/closure/test.js Executable file
View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
A();

View File

@ -0,0 +1,47 @@
#!/usr/bin/env python3
#coding: utf-8
"""
Copyright (c) 2022-2023 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Description: run script
input: input file
output: output file
prefix: prefix
"""
import argparse
import sys
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--input', type=str, required=True)
parser.add_argument('--output', type=str, required=True)
parser.add_argument('--prefix', type=str, required=True)
args = parser.parse_args()
input_file = open(args.input, 'r')
output_file = open(args.output, 'w')
for line in input_file:
output_line = args.prefix + line
output_file.write(output_line)
input_file.close()
output_file.close()
if __name__ == '__main__':
sys.exit(main())

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function A() {
print("base A()");
globalThis.C()
}
function C() {
print("base C()");
}
globalThis.A = A;
globalThis.C = C;

View File

@ -0,0 +1,24 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
QuickFix Execute start
QuickFix start load patch
QuickFix load patch success
base A()
QuickFix start check exception
QuickFix have exception.
QuickFix start unload patch
QuickFix unload patch success
base A()
base C()
QuickFix Execute end

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function A() {
print("base A()");
globalThis.B();
}
function B() {
print("patch B()");
}
globalThis.B = B;

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
A();

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
globalThis.a = 100
function A() {
print("base global var :" + globalThis.a);
}
globalThis.A = A;

View File

@ -0,0 +1,24 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
QuickFix Execute start
QuickFix start load patch
QuickFix load patch success
patch old global var :100
patch new global var :undefined
QuickFix start check exception
QuickFix have no exception
QuickFix start unload patch
QuickFix unload patch success
base global var :100
QuickFix Execute end

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,24 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
globalThis.a = 200
globalThis.b = 300
function A() {
// old value will not update
print("patch old global var :" + globalThis.a);
// new value is undefined
print("patch new global var :" + globalThis.b);
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
A();

View File

@ -0,0 +1,24 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { a } from './module.js'
import { foo } from './module.js'
function A() {
print("print base: " + a);
foo()
}
globalThis.A = A;

View File

@ -0,0 +1,25 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
QuickFix Execute start
QuickFix start load patch
QuickFix load patch success
print patch: 100
patch foo
QuickFix start check exception
QuickFix have no exception
QuickFix start unload patch
QuickFix unload patch success
print base: 100
base foo
QuickFix Execute end

View File

@ -0,0 +1,19 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var a = 100
export function foo() {
print("base foo")
}

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { a } from './module.js'
import { foo } from './module.js'
function A() {
print("print patch: " + a);
foo()
}

View File

@ -0,0 +1,19 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var a = 200
export function foo() {
print("patch foo")
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
A();

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { a } from './module.js'
import { foo } from './module.js'
class Index {
constructor() {
}
render() {
print("print base:" + a + " - " + foo());
}
}
globalThis.index = new Index();

View File

@ -0,0 +1,39 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
QuickFix Execute start
QuickFix start load patch
QuickFix load patch success
print patch:100 - 200
QuickFix start check exception
QuickFix have no exception
QuickFix start unload patch
QuickFix unload patch success
print base:100 - 100
QuickFix start load patch
QuickFix load patch success
print patch1:100 - 300
QuickFix start check exception
QuickFix have no exception
QuickFix start unload patch
QuickFix unload patch success
print base:100 - 100
QuickFix start load patch
QuickFix load patch success
print patch2: 100 - 400
QuickFix start check exception
QuickFix have no exception
QuickFix start unload patch
QuickFix unload patch success
print base:100 - 100
QuickFix Execute end

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var a = 100
export function foo() {
var b = 100
return b
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { a } from './module.js'
import { foo } from './module.js'
class Index {
constructor() {
}
render() {
print("print patch:" + a + " - " + foo());
}
}

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var a = 200
export function foo() {
var b = 200
return b
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { a } from './module.js'
import { foo } from './module.js'
class Index {
constructor() {
}
render() {
print("print patch1:" + a + " - " + foo());
}
}

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var a = 300
export function foo() {
var b = 300
return b
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { a } from './module.js'
import { foo } from './module.js'
class Index {
constructor() {
}
render() {
print("print patch2: " + a + " - " + foo());
}
}

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var a = 400
export function foo() {
var b = 400
return b
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
globalThis.index.render()

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function foo() {
print("base foo")
}
globalThis.foo = foo

View File

@ -0,0 +1,23 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
QuickFix Execute start
QuickFix start load patch
QuickFix load patch success
patch foo
QuickFix start check exception
QuickFix have no exception
QuickFix start unload patch
QuickFix unload patch success
base foo
QuickFix Execute end

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,18 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function foo() {
print("patch foo")
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var nop = undefined

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
globalThis.foo()

1
test/quickfix/retest.txt Normal file
View File

@ -0,0 +1 @@
test.js;retest;module;test.js

1
test/quickfix/test.txt Normal file
View File

@ -0,0 +1 @@
test.js;test;module;test.js

View File

@ -608,3 +608,245 @@ template("host_typeinfer_test_action") {
outputs = [ "$target_out_dir/${_target_name_}/" ] outputs = [ "$target_out_dir/${_target_name_}/" ]
} }
} }
template("host_quickfix_test_action") {
_target_name_ = "${target_name}"
_extra_patches_ = invoker.extra_patches
_test_js_path_ = [
"./${_target_name_}/base.js",
"./${_target_name_}/module.js",
"./${_target_name_}/patch/base.js",
"./${_target_name_}/patch/module.js",
"./${_target_name_}/test.js",
]
foreach(patch, _extra_patches_) {
_test_js_path_ += [
"./${_target_name_}/${patch}/base.js",
"./${_target_name_}/${patch}/module.js",
]
}
_base_merge_file_raw_ = "//arkcompiler/ets_runtime/test/quickfix/base.txt"
_test_merge_file_raw_ = "//arkcompiler/ets_runtime/test/quickfix/test.txt"
_retest_merge_file_raw_ = "//arkcompiler/ets_runtime/test/quickfix/retest.txt"
_base_merge_file_ = "$target_out_dir/${_target_name_}/base.txt"
_test_merge_file_ = "$target_out_dir/${_target_name_}/test.txt"
_retest_merge_file_ = "$target_out_dir/${_target_name_}/retest.txt"
_patch_merge_file_ = "$target_out_dir/${_target_name_}/patch.txt"
_base_abc_path_ = "$target_out_dir/${_target_name_}/base.abc"
_test_abc_path_ = "$target_out_dir/${_target_name_}/test.abc"
_retest_abc_path_ = "$target_out_dir/${_target_name_}/retest.abc"
_patch_abc_path_ = "$target_out_dir/${_target_name_}/patch/base.abc"
_test_expect_path_ = "./${_target_name_}/expect_output.txt"
action("gen_${_target_name_}_base_merge_file") {
script = "//arkcompiler/ets_runtime/test/quickfix/generate_merge_file.py"
args = [
"--input",
rebase_path(_base_merge_file_raw_),
"--output",
rebase_path(_base_merge_file_),
"--prefix",
rebase_path("//arkcompiler/ets_runtime/test/quickfix/${_target_name_}/"),
]
inputs = [ _base_merge_file_raw_ ]
outputs = [ _base_merge_file_ ]
}
action("gen_${_target_name_}_test_merge_file") {
script = "//arkcompiler/ets_runtime/test/quickfix/generate_merge_file.py"
args = [
"--input",
rebase_path(_test_merge_file_raw_),
"--output",
rebase_path(_test_merge_file_),
"--prefix",
rebase_path("//arkcompiler/ets_runtime/test/quickfix/${_target_name_}/"),
]
inputs = [ _test_merge_file_raw_ ]
outputs = [ _test_merge_file_ ]
}
action("gen_${_target_name_}_retest_merge_file") {
script = "//arkcompiler/ets_runtime/test/quickfix/generate_merge_file.py"
args = [
"--input",
rebase_path(_retest_merge_file_raw_),
"--output",
rebase_path(_retest_merge_file_),
"--prefix",
rebase_path("//arkcompiler/ets_runtime/test/quickfix/${_target_name_}/"),
]
inputs = [ _retest_merge_file_raw_ ]
outputs = [ _retest_merge_file_ ]
}
action("gen_${_target_name_}_patch_merge_file") {
script = "//arkcompiler/ets_runtime/test/quickfix/generate_merge_file.py"
args = [
"--input",
rebase_path(_base_merge_file_raw_),
"--output",
rebase_path(_patch_merge_file_),
"--prefix",
rebase_path(
"//arkcompiler/ets_runtime/test/quickfix/${_target_name_}/patch/"),
]
inputs = [ _base_merge_file_raw_ ]
outputs = [ _patch_merge_file_ ]
}
es2abc_gen_abc("gen_${_target_name_}_base_abc") {
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
extra_dependencies = [ ":gen_${_target_name_}_base_merge_file" ]
src_js = "@" + rebase_path(_base_merge_file_)
dst_file = rebase_path(_base_abc_path_)
extra_args = []
extra_args += [ "--module" ]
extra_args += [ "--merge-abc" ]
in_puts = [ _test_expect_path_ ]
in_puts += _test_js_path_
out_puts = [ _base_abc_path_ ]
}
es2abc_gen_abc("gen_${_target_name_}_test_abc") {
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
extra_dependencies = [ ":gen_${_target_name_}_test_merge_file" ]
src_js = "@" + rebase_path(_test_merge_file_)
dst_file = rebase_path(_test_abc_path_)
extra_args = []
extra_args += [ "--module" ]
extra_args += [ "--merge-abc" ]
in_puts = [ _test_expect_path_ ]
in_puts += _test_js_path_
out_puts = [ _test_abc_path_ ]
}
es2abc_gen_abc("gen_${_target_name_}_retest_abc") {
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
extra_dependencies = [ ":gen_${_target_name_}_retest_merge_file" ]
src_js = "@" + rebase_path(_retest_merge_file_)
dst_file = rebase_path(_retest_abc_path_)
extra_args = []
extra_args += [ "--module" ]
extra_args += [ "--merge-abc" ]
in_puts = [ _test_expect_path_ ]
in_puts += _test_js_path_
out_puts = [ _retest_abc_path_ ]
}
es2abc_gen_abc("gen_${_target_name_}_patch_abc") {
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
extra_dependencies = [ ":gen_${_target_name_}_patch_merge_file" ]
src_js = "@" + rebase_path(_patch_merge_file_)
dst_file = rebase_path(_patch_abc_path_)
extra_args = []
extra_args += [ "--module" ]
extra_args += [ "--merge-abc" ]
in_puts = [ _test_expect_path_ ]
in_puts += _test_js_path_
out_puts = [ _patch_abc_path_ ]
}
_script_args_ =
rebase_path(_base_abc_path_) + ":" + rebase_path(_test_abc_path_) + ":" +
rebase_path(_retest_abc_path_) + ":" + rebase_path(_patch_abc_path_)
foreach(patch, _extra_patches_) {
_merge_file_ = "$target_out_dir/${_target_name_}/${patch}.txt"
_abc_file_ = "$target_out_dir/${_target_name_}/${patch}/base.abc"
action("gen_${_target_name_}_${patch}_merge_file") {
script = "//arkcompiler/ets_runtime/test/quickfix/generate_merge_file.py"
args = [
"--input",
rebase_path(_base_merge_file_raw_),
"--output",
rebase_path(_merge_file_),
"--prefix",
rebase_path(
"//arkcompiler/ets_runtime/test/quickfix/${_target_name_}/${patch}/"),
]
inputs = [ _base_merge_file_raw_ ]
outputs = [ _merge_file_ ]
}
es2abc_gen_abc("gen_${_target_name_}_${patch}_abc") {
extra_visibility =
[ ":*" ] # Only targets in this file can depend on this.
extra_dependencies = [ ":gen_${_target_name_}_${patch}_merge_file" ]
src_js = "@" + rebase_path(_merge_file_)
dst_file = rebase_path(_abc_file_)
extra_args = []
extra_args += [ "--module" ]
extra_args += [ "--merge-abc" ]
in_puts = [ _test_expect_path_ ]
in_puts += _test_js_path_
out_puts = [ _abc_file_ ]
}
_script_args_ += ":" + rebase_path(_abc_file_)
}
action("${_target_name_}QuickfixAction") {
testonly = true
_host_quickfix_target_ = "//arkcompiler/ets_runtime/ecmascript/quick_fix:quick_fix(${host_toolchain})"
_root_out_dir_ = get_label_info(_host_quickfix_target_, "root_out_dir")
deps = [
":gen_${_target_name_}_base_abc",
":gen_${_target_name_}_patch_abc",
":gen_${_target_name_}_retest_abc",
":gen_${_target_name_}_test_abc",
_host_quickfix_target_,
]
foreach(patch, _extra_patches_) {
deps += [ ":gen_${_target_name_}_${patch}_abc" ]
}
script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
quickfix_options = " --merge-abc true --log-level info "
args = [
"--script-file",
rebase_path(_root_out_dir_) + "/ark/ark_js_runtime/quick_fix",
"--script-options",
quickfix_options,
"--script-args",
_script_args_,
"--timeout-limit",
"120",
"--expect-file",
rebase_path(_test_expect_path_),
"--env-path",
rebase_path(_root_out_dir_) + "/ark/ark:" + rebase_path(_root_out_dir_) +
"/ark/ark_js_runtime:" + rebase_path(_root_out_dir_) +
"/${_icu_path_}:" + rebase_path(_root_out_dir_) +
rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
]
inputs = [
_base_abc_path_,
_test_abc_path_,
_retest_abc_path_,
_patch_abc_path_,
]
outputs = [ "$target_out_dir/${_target_name_}/" ]
}
}