diff --git a/src/bin/jbc2mpl b/src/bin/jbc2mpl index 65ce781285bc223cffc2aeb7d0baa494d8974a8a..2e4626e18824218f6fb191d093c0249dc3127457 100755 Binary files a/src/bin/jbc2mpl and b/src/bin/jbc2mpl differ diff --git a/src/bin/maple b/src/bin/maple index 1c10b3d9097104742289a160a14777c11b9080d9..7fc07943c556cd3533ee659cbb630304dc57c2a1 100755 Binary files a/src/bin/maple and b/src/bin/maple differ diff --git a/src/bin/mplcg b/src/bin/mplcg index c25e4ad7499593b2e005e0ce94d8de7a57e3e678..4b9e5f72824e922f8b1bb4bef58a2ba4a962de41 100755 Binary files a/src/bin/mplcg and b/src/bin/mplcg differ diff --git a/src/maple_driver/defs/phases.def b/src/maple_driver/defs/phases.def index 65fc2ad077bfd0cea80c968ec6593d4d4baf27f0..7f2a50401d1de5d653580d3c1b8dcd719a33477d 100644 --- a/src/maple_driver/defs/phases.def +++ b/src/maple_driver/defs/phases.def @@ -32,4 +32,5 @@ ADD_PHASE("GenNativeStubFunc", true) ADD_PHASE("clinit", true) ADD_PHASE("VtableImpl", true) ADD_PHASE("javaehlower", true) +ADD_PHASE("DecoupleStatic", true) ADD_PHASE("MUIDReplacement", true) diff --git a/src/maple_driver/src/mpl_options.cpp b/src/maple_driver/src/mpl_options.cpp index 3e37f3b5f0dde498b410f02855bcfb2f19a29c69..f73927423ebe673b03777cb4466f74f9b855a56e 100644 --- a/src/maple_driver/src/mpl_options.cpp +++ b/src/maple_driver/src/mpl_options.cpp @@ -806,8 +806,8 @@ const mapleOption::Descriptor USAGES[] = { namespace maple { using namespace mapleOption; -const std::string kMapleDriverVersion = "mapledriver " + std::to_string(Version::kMajorMplVersion) + "." + - std::to_string(Version::kMinorCompilerVersion) + " 20190712"; +const std::string kMapleDriverVersion = "MapleDriver " + std::to_string(Version::kMajorMplVersion) + "." + + std::to_string(Version::kMinorCompilerVersion) + " 20190929"; int MplOptions::Parse(int argc, char **argv) { optionParser.reset(new OptionParser(USAGES)); exeFolder = FileUtils::GetFileFolder(*argv); @@ -859,7 +859,7 @@ ErrorCode MplOptions::HandleGeneralOptions() { return ErrorCode::kErrorExitHelp; } case kVersion: { - INFO(kLncInfo, kMapleDriverVersion); + LogInfo::MapleLogger() << kMapleDriverVersion << "\n"; return ErrorCode::kErrorExitHelp; } case kMeOpt: diff --git a/src/maple_ir/src/mir_symbol.cpp b/src/maple_ir/src/mir_symbol.cpp index 48384c619688dfe52fc538ccb4dcff99a73d60a5..3e6bee81af01c1419b96bb0b0a69175fb1694c83 100644 --- a/src/maple_ir/src/mir_symbol.cpp +++ b/src/maple_ir/src/mir_symbol.cpp @@ -35,6 +35,7 @@ bool MIRSymbol::HasAddrOfValues() const { return StringUtils::StartsWith(GetName(), VTAB_PREFIX_STR) || StringUtils::StartsWith(GetName(), ITAB_PREFIX_STR) || StringUtils::StartsWith(GetName(), kVtabOffsetTabStr) || + StringUtils::StartsWith(GetName(), kDecoupleStaticKeyStr) || IsClassInitBridge() || IsReflectionInfo() || IsReflectionHashTabBucket() || IsReflectionStrTab() || IsITabConflictInfo() || IsRegJNITab() || IsRegJNIFuncTab() || IsLiteral(); diff --git a/src/maple_util/include/muid.h b/src/maple_util/include/muid.h index f1892607dec7640a58a9bcac643a9c6d34bc1f6f..37b286d547430203df868da0604f3d5aef1a5fc7 100644 --- a/src/maple_util/include/muid.h +++ b/src/maple_util/include/muid.h @@ -31,8 +31,10 @@ constexpr unsigned int kApkNamespace = 0x80; constexpr unsigned int kBitMask = 0x3f; // For Lazy decoupling load -const uint32_t kMplLazyLoadMagicNumber = 0x1a2; // For trigger SIGSEGV -const uint64_t kMplLazyLoadSentryNumber = 0x1a27b10d10810ade; +const uint32_t kMplLazyLoadMagicNumber = 0x1a2; // For trigger SIGSEGV +const uint32_t kMplStaticLazyLoadMagicNumber = 0x1a1; // For static lazy load trigger SIGSEGV +const uint64_t kMplLazyLoadSentryNumber = 0x1a27b10d10810ade; // Sentry for offset table +const uint64_t kMplStaticLazyLoadSentryNumber = 0x1a27b10d10810ad1; // Sentry for static offset table #ifdef USE_64BIT_MUID #undef MUID_LENGTH diff --git a/src/maple_util/include/name_mangler.h b/src/maple_util/include/name_mangler.h index a988b4df4b9333b2dfedfa31a79d4a10cedf84c6..1f719cbc5d5088df4aca14a7289b6bff1b487bda 100644 --- a/src/maple_util/include/name_mangler.h +++ b/src/maple_util/include/name_mangler.h @@ -75,6 +75,7 @@ static constexpr const char kMuidGlobalRootlistPrefixStr[] = "__muid_globalrootl static constexpr const char kMuidClassMetadataPrefixStr[] = "__muid_classmetadata"; static constexpr const char kMuidClassMetadataBucketPrefixStr[] = "__muid_classmetadata_bucket"; static constexpr const char kMuidJavatextPrefixStr[] = "java_text"; +static constexpr const char kMuidDataSectionStr[] = "__data_section"; static constexpr const char kMuidRangeTabPrefixStr[] = "__muid_range_tab"; static constexpr const char kMuidConststrPrefixStr[] = "__muid_conststr"; static constexpr const char kVtabOffsetTabStr[] = "__vtable_offset_table"; @@ -109,6 +110,10 @@ static constexpr const char kCompilerMfileStatus[] = "__compiler_mfile_status"; static constexpr const char kSourceMuid[] = "__sourceMuid"; static constexpr const char kSourceMuidSectionStr[] = "__sourceMuidTab"; +static constexpr const char kDecoupleStaticKeyStr[] = "__staticDecoupleKeyOffset"; +static constexpr const char kDecoupleStaticValueStr[] = "__staticDecoupleValueOffset"; +static constexpr const char kMarkDecoupleStaticStr[] = "decouple_static:"; +static constexpr const char kClassInfoPrefix[] = "__cinf"; static constexpr const char kStaticFieldNamePrefixStr[] = "__static_field_name"; static constexpr const char kPackageNameSplitterStr[] = "_2F"; diff --git a/src/maple_util/include/version.h b/src/maple_util/include/version.h index 640c6cea3437e7899898330be2c0118b3953e07c..c9cbaca24c481d8c91bf7726cc4e3e6d9ea21c18 100644 --- a/src/maple_util/include/version.h +++ b/src/maple_util/include/version.h @@ -16,9 +16,11 @@ #define MAPLE_UTIL_INCLUDE_VERSION_H namespace Version { -constexpr int kMajorMplVersion = 1; -constexpr int kMinorCompilerVersion = 0; -constexpr int kMinorRuntimeVersion = 0; + +static constexpr const int kMajorMplVersion = 2; +static constexpr const int kMinorCompilerVersion = 0; +static constexpr const int kMinorRuntimeVersion = 0; + } -#endif // MAPLE_UTIL_INCLUDE_VERSION_H +#endif diff --git a/src/mpl2mpl/include/muid_replacement.h b/src/mpl2mpl/include/muid_replacement.h index 51dc0e116832f211f68f7da164ab35b0f476bcdb..d6c0005c3523a70807886da2eb050b2ca6c05408 100644 --- a/src/mpl2mpl/include/muid_replacement.h +++ b/src/mpl2mpl/include/muid_replacement.h @@ -28,6 +28,7 @@ constexpr uint32 kDataDefAddrIndex = 0; constexpr uint32 kFuncDefSizeIndex = 0; constexpr uint32 kFuncDefNameIndex = 1; constexpr uint32 kRangeBeginIndex = 0; +constexpr int32_t kDecoupleAndLazy = 3; enum RangeIdx { // 0,1 entry is reserved for a stamp @@ -45,7 +46,10 @@ enum RangeIdx { kJavatext = 13, kJavajni = 14, kJavajniFunc = 15, - kMaxNum = 16 + kMaxNum = 16, + kDataSection = 17, + kDecoupleStaticKey = 18, + kDecoupleStaticValue = 19 }; class MUIDReplacement : public FuncOptimizeImpl { @@ -90,6 +94,7 @@ class MUIDReplacement : public FuncOptimizeImpl { void ReplaceDassign(MIRFunction ¤tFunc, DassignNode &dassignNode); void ReplaceDreadStmt(MIRFunction *currentFunc, StmtNode *stmt); void ClearVtabItab(const std::string &name); + void ReplaceDecoupleKeyTable(MIRAggConst *oldConst); BaseNode *ReplaceDreadExpr(MIRFunction *currentFunc, StmtNode *stmt, BaseNode *expr); BaseNode *ReplaceDread(MIRFunction ¤tFunc, StmtNode *stmt, BaseNode *opnd); void CollectDread(MIRFunction ¤tFunc, StmtNode &stmt, BaseNode &opnd); diff --git a/src/mpl2mpl/src/muid_replacement.cpp b/src/mpl2mpl/src/muid_replacement.cpp index 5213487c60b02d6ccaab706b720d0883e6c56a76..c5007d9d83ff4c8a0a995aaf6b4eed2ed9c81375 100644 --- a/src/mpl2mpl/src/muid_replacement.cpp +++ b/src/mpl2mpl/src/muid_replacement.cpp @@ -662,6 +662,7 @@ void MUIDReplacement::GenerateRangeTable() { rangeTabConst->PushBack(entryConst); } // Please refer to mrt/compiler-rt/include/mpl_linker.h for the layout + std::vector workList = { funcDefTabSym, funcDefOrigTabSym, @@ -689,6 +690,13 @@ void MUIDReplacement::GenerateRangeTable() { } rangeTabConst->PushBack(entryConst); } + for (int i = RangeIdx::kMaxNum + 1; i <= RangeIdx::kDecoupleStaticValue; ++i) { + uint32 fieldID = 1; + MIRAggConst *entryConst = GetMIRModule().GetMemPool()->New(GetMIRModule(), rangeTabEntryType); + builder->AddIntFieldConst(rangeTabEntryType, *entryConst, fieldID++, i); + builder->AddIntFieldConst(rangeTabEntryType, *entryConst, fieldID++, i); + rangeTabConst->PushBack(entryConst); + } if (!rangeTabConst->GetConstVec().empty()) { rangeArrayType.SetSizeArrayItem(0, rangeTabConst->GetConstVec().size()); std::string rangeTabName = NameMangler::kMuidRangeTabPrefixStr + GetMIRModule().GetFileNameAsPostfix(); @@ -821,6 +829,29 @@ void MUIDReplacement::ReplaceDataTable(const std::string &name) { } } +void MUIDReplacement::ReplaceDecoupleKeyTable(MIRAggConst* oldConst) { + if (oldConst == nullptr) { + return; + } + for (MIRConst *&oldTabEntry : oldConst->GetConstVec()) { + ASSERT(oldTabEntry != nullptr, "null ptr check!"); + if (oldTabEntry->GetKind() == kConstAggConst) { + auto *aggrC = static_cast(oldTabEntry); + for (size_t i = 0; i < aggrC->GetConstVec().size(); ++i) { + ASSERT(aggrC->GetConstVecItem(i) != nullptr, "null ptr check!"); + if (aggrC->GetConstVecItem(i)->GetKind() == kConstAggConst) { + ReplaceDecoupleKeyTable(static_cast(aggrC->GetConstVecItem(i))); + } else { + ReplaceAddrofConst(aggrC->GetConstVecItem(i)); + aggrC->GetConstVecItem(i)->SetFieldID(i + 1); + } + } + } else if (oldTabEntry->GetKind() == kConstAddrof) { + ReplaceAddrofConst(oldTabEntry); + } + } +} + void MUIDReplacement::ReplaceAddrofConst(MIRConst *&entry) { if (entry->GetKind() != kConstAddrof) { return;