diff --git a/es2panda/binder/binder.cpp b/es2panda/binder/binder.cpp index 85ed70ccdf2b805b3dfe239363bb7124deff9ee3..07f9866b99654f1c8d5f9d5a4ac95e806f3cab86 100644 --- a/es2panda/binder/binder.cpp +++ b/es2panda/binder/binder.cpp @@ -365,7 +365,7 @@ void Binder::BuildFunction(FunctionScope *funcScope, util::StringView name, cons } functionScopes_.push_back(funcScope); funcScope->SetInFunctionScopes(); - if (Program()->TargetApiVersion() > 11) { + if (!util::Helpers::IsBeta2() && Program()->TargetApiVersion() > 11) { funcScope->SetSelfScopeName(name); auto recordName = program_->FormatedRecordName().Mutf8(); funcScope->BindNameWithScopeInfo(name, util::UString(recordName, Allocator()).View()); diff --git a/es2panda/compiler/core/emitter/emitter.cpp b/es2panda/compiler/core/emitter/emitter.cpp index 3b6db73ecc7dd4fafa8069375fc3e6e45c59927d..355679715d5e9dab495c4575a50863364452b46b 100644 --- a/es2panda/compiler/core/emitter/emitter.cpp +++ b/es2panda/compiler/core/emitter/emitter.cpp @@ -429,7 +429,7 @@ void Emitter::AddScopeNamesRecord(CompilerContext *context) { std::lock_guard lock(m_); // make literalarray for scope names - if (context->Binder()->Program()->TargetApiVersion() < 12) { + if (util::Helpers::IsBeta2() || context->Binder()->Program()->TargetApiVersion() < 12) { return; } const auto &scopeNamesMap = context->Binder()->GetScopeNames(); diff --git a/es2panda/compiler/core/pandagen.cpp b/es2panda/compiler/core/pandagen.cpp index 6b92fffdc1f643ea6b7b4ed0ac906dc38921d8bf..7f132c2fb44815b4830daa4a0613b4f387fa6046 100644 --- a/es2panda/compiler/core/pandagen.cpp +++ b/es2panda/compiler/core/pandagen.cpp @@ -576,9 +576,13 @@ void PandaGen::StoreObjByName(const ir::AstNode *node, VReg obj, const util::Str void PandaGen::DefineFieldByName(const ir::AstNode *node, VReg obj, const util::StringView &prop) { +# if defined Beta2 + ra_.Emit(node, 0, prop, obj); +# else // use definepropertybyname instead of definefieldbyname since api12 for runtime's performance. Binder()->Program()->TargetApiVersion() >= 12 ? ra_.Emit(node, 0, prop, obj) : ra_.Emit(node, 0, prop, obj); +# endif strings_.insert(prop); } @@ -1091,8 +1095,12 @@ void PandaGen::GreaterEqual(const ir::AstNode *node, VReg lhs) void PandaGen::IsTrue(const ir::AstNode *node) { +# if defined Beta2 + ra_.Emit(node); +# else // use callruntime.istrue instead of istrue since api12 for runtime's performance. Binder()->Program()->TargetApiVersion() >= 12 ? ra_.Emit(node, 0) : ra_.Emit(node); +# endif } void PandaGen::BranchIfUndefined(const ir::AstNode *node, Label *target) @@ -1149,9 +1157,13 @@ void PandaGen::BranchIfNotTrue(const ir::AstNode *node, Label *target) void PandaGen::BranchIfFalse(const ir::AstNode *node, Label *target) { +# if defined Beta2 + ra_.Emit(node); +# else // use callruntime.istrue instead of istrue since api12 for runtime's performance. Binder()->Program()->TargetApiVersion() >= 12 ? ra_.Emit(node, 0) : ra_.Emit(node); ra_.Emit(node, target); +# endif } void PandaGen::BranchIfStrictNull(const ir::AstNode *node, class Label *target) diff --git a/es2panda/util/helpers.cpp b/es2panda/util/helpers.cpp index 906ca54335415834d7225c5f25dbe2c0be944b2f..03e2865a2906625c3732cce56de44ef1af2570d2 100644 --- a/es2panda/util/helpers.cpp +++ b/es2panda/util/helpers.cpp @@ -951,6 +951,11 @@ bool Helpers::IsSpecialScopeName(const util::StringView &name) name.Find(Helpers::BACKSLASH.data()) != std::string::npos; } +bool Helpers::IsBeta2() +{ + return true; +} + bool Helpers::BelongingToRecords(const std::string &name, const std::unordered_set &retainRecordSet, const std::string &delimiter) { diff --git a/es2panda/util/helpers.h b/es2panda/util/helpers.h index 660f79f901aed986d99568a59e925d3d82963bc3..93658529aa4c4bfd6846dbd20eea2303b8eeaa17 100644 --- a/es2panda/util/helpers.h +++ b/es2panda/util/helpers.h @@ -150,6 +150,7 @@ public: static bool IsUseShared(const ir::Statement *statement); static const ir::ClassDefinition *GetContainingSendableClass(const ir::AstNode *node); static bool IsSpecialScopeName(const util::StringView &str); + static bool IsBeta2(); static bool BelongingToRecords(const std::string &name, const std::unordered_set &retainRecordSet, const std::string &delimiter = std::string(DOT)); static void RemoveProgramsRedundantData(std::map &progsInfo, diff --git a/es2panda/util/patchFix.cpp b/es2panda/util/patchFix.cpp index 0940e77046ad03a05a0be4b3960ea996e90590c6..81919b838733c617ef74b51a9745e644b4eca2de 100644 --- a/es2panda/util/patchFix.cpp +++ b/es2panda/util/patchFix.cpp @@ -126,7 +126,7 @@ void PatchFix::ValidateJsonContentRecInfo(const std::string &recordName, const s bool PatchFix::IsAnonymousOrSpecialOrDuplicateFunction(const std::string &funcName) { - if (targetApiVersion_ < 12) { + if (util::Helpers::IsBeta2() || targetApiVersion_ < 12) { return funcName.find(binder::Binder::ANONYMOUS_SPECIAL_DUPLICATE_FUNCTION_SPECIFIER) != std::string::npos; } // Function name is like: #scopes^1#functionname^1 @@ -567,7 +567,8 @@ void PatchFix::HandleFunction(const compiler::PandaGen *pg, panda::pandasm::Func std::string funcName = func->name; auto originFunction = originFunctionInfo_->find(funcName); if (originFunction == originFunctionInfo_->end()) { - if (pg->Binder()->Program()->TargetApiVersion() > 11 && + if ((!util::Helpers::IsBeta2() && + pg->Binder()->Program()->TargetApiVersion() > 11) && IsHotFix() && IsAnonymousOrSpecialOrDuplicateFunction(funcName)) { std::cerr << "[Patch] Found new anonymous, special(containing '.' or '\\') or duplicate name function " @@ -624,7 +625,7 @@ void PatchFix::DumpFunctionInfo(const compiler::PandaGen *pg, panda::pandasm::Fu std::vector> hashList = GenerateFunctionAndClassHash(func, literalBuffers); ss << hashList.back().second << SymbolTable::SECOND_LEVEL_SEPERATOR; - if (pg->Binder()->Program()->TargetApiVersion() < 12) { + if (util::Helpers::IsBeta2() || pg->Binder()->Program()->TargetApiVersion() < 12) { auto internalNameStr = pg->InternalName().Mutf8(); if (internalNameStr.find("#") != std::string::npos) { ss << (pg->Binder()->SpecialFuncNameIndexMap()).at(internalNameStr) << SymbolTable::SECOND_LEVEL_SEPERATOR; diff --git a/es2panda/util/symbolTable.cpp b/es2panda/util/symbolTable.cpp index 2b2cbc8837f226233cbf3dc2a0a7c5b1127c27a1..2264424a3488b0c1200d882bd3b0958cd6b22690 100644 --- a/es2panda/util/symbolTable.cpp +++ b/es2panda/util/symbolTable.cpp @@ -17,6 +17,7 @@ #include #include +#include namespace panda::es2panda::util { const std::string SymbolTable::FIRST_LEVEL_SEPERATOR = "|"; @@ -110,7 +111,7 @@ bool SymbolTable::ReadSymbolTable(const std::string &symbolTable) } originFunctionInfo_.insert(std::pair(info.funcInternalName, info)); - if (targetApiVersion_ < 12) { + if (util::Helpers::IsBeta2() || targetApiVersion_ < 12) { // index of function in its record's special function array std::string specialFuncIndex{funcItems[3]}; ReadRecordHashFunctionNames(info.recordName, info.funcInternalName, specialFuncIndex);