From 1589b9a351ee2eb2fb1769054ce5fc97611add36 Mon Sep 17 00:00:00 2001 From: David Miller Date: Fri, 24 Apr 2020 19:35:59 -0400 Subject: [PATCH 1/4] Added EnvLoader to frontend binaries, called prior to ArgLoader --- Source/Tests/ELFLoader.cpp | 2 ++ Source/Tests/LockstepRunner.cpp | 4 +++- Source/Tests/TestHarnessRunner.cpp | 4 +++- Source/Tests/TestSingleStepHardware.cpp | 4 +++- Source/Tests/UnitTestGenerator.cpp | 4 +++- Source/Tools/Debugger/Main.cpp | 4 +++- Source/Tools/Opt.cpp | 4 +++- 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Source/Tests/ELFLoader.cpp b/Source/Tests/ELFLoader.cpp index 2313df297..e63abd1e3 100644 --- a/Source/Tests/ELFLoader.cpp +++ b/Source/Tests/ELFLoader.cpp @@ -1,4 +1,5 @@ #include "Common/ArgumentLoader.h" +#include "Common/EnvironmentLoader.h" #include "CommonCore/VMFactory.h" #include "Common/Config.h" #include "ELFLoader.h" @@ -83,6 +84,7 @@ int main(int argc, char **argv, char **const envp) { } FEX::Config::Init(); + FEX::EnvLoader::Load(envp); FEX::ArgLoader::Load(argc, argv); FEX::Config::Value CoreConfig{"Core", 0}; diff --git a/Source/Tests/LockstepRunner.cpp b/Source/Tests/LockstepRunner.cpp index 47076f136..cb83c011b 100644 --- a/Source/Tests/LockstepRunner.cpp +++ b/Source/Tests/LockstepRunner.cpp @@ -1,4 +1,5 @@ #include "Common/ArgumentLoader.h" +#include "Common/EnvironmentLoader.h" #include "Common/Config.h" #include "CommonCore/VMFactory.h" #include "HarnessHelpers.h" @@ -506,10 +507,11 @@ private: const std::chrono::milliseconds HeartBeatRate = std::chrono::seconds(1); }; -int main(int argc, char **argv) { +int main(int argc, char **argv, char **const envp) { LogMan::Throw::InstallHandler(AssertHandler); LogMan::Msg::InstallHandler(MsgHandler); FEX::Config::Init(); + FEX::EnvLoader::Load(envp); FEX::ArgLoader::Load(argc, argv); auto Args = FEX::ArgLoader::Get(); diff --git a/Source/Tests/TestHarnessRunner.cpp b/Source/Tests/TestHarnessRunner.cpp index 7256651f1..914bfc31a 100644 --- a/Source/Tests/TestHarnessRunner.cpp +++ b/Source/Tests/TestHarnessRunner.cpp @@ -1,4 +1,5 @@ #include "Common/ArgumentLoader.h" +#include "Common/EnvironmentLoader.h" #include "CommonCore/VMFactory.h" #include "HarnessHelpers.h" #include "LogManager.h" @@ -48,10 +49,11 @@ void AssertHandler(char const *Message) { printf("[ASSERT] %s\n", Message); } -int main(int argc, char **argv) { +int main(int argc, char **argv, char **const envp) { LogMan::Throw::InstallHandler(AssertHandler); LogMan::Msg::InstallHandler(MsgHandler); FEX::Config::Init(); + FEX::EnvLoader::Load(envp); FEX::ArgLoader::Load(argc, argv); FEX::Config::Value CoreConfig{"Core", 0}; diff --git a/Source/Tests/TestSingleStepHardware.cpp b/Source/Tests/TestSingleStepHardware.cpp index 484a7f04e..63aa09faf 100644 --- a/Source/Tests/TestSingleStepHardware.cpp +++ b/Source/Tests/TestSingleStepHardware.cpp @@ -1,4 +1,5 @@ #include "Common/ArgumentLoader.h" +#include "Common/EnvironmentLoader.h" #include "Common/Config.h" #include "ELFLoader.h" #include "HarnessHelpers.h" @@ -91,10 +92,11 @@ void AssertHandler(char const *Message) { printf("[ASSERT] %s\n", Message); } -int main(int argc, char **argv) { +int main(int argc, char **argv, char **const envp) { LogMan::Throw::InstallHandler(AssertHandler); LogMan::Msg::InstallHandler(MsgHandler); FEX::Config::Init(); + FEX::EnvLoader::Load(envp); FEX::ArgLoader::Load(argc, argv); FEX::Config::Value CoreConfig{"Core", 0}; diff --git a/Source/Tests/UnitTestGenerator.cpp b/Source/Tests/UnitTestGenerator.cpp index 6d27edafc..4f98d5420 100644 --- a/Source/Tests/UnitTestGenerator.cpp +++ b/Source/Tests/UnitTestGenerator.cpp @@ -1,4 +1,5 @@ #include "Common/ArgumentLoader.h" +#include "Common/EnvironmentLoader.h" #include "Common/Config.h" #include "LogManager.h" @@ -2385,11 +2386,12 @@ void GenerateSSEInstructions() { printf("SSE NumInsts: %d\n", numInst); } -int main(int argc, char **argv) { +int main(int argc, char **argv, char **const envp) { LogMan::Throw::InstallHandler(AssertHandler); LogMan::Msg::InstallHandler(MsgHandler); FEX::Config::Init(); + FEX::EnvLoader::Load(envp); FEX::ArgLoader::Load(argc, argv); auto Args = FEX::ArgLoader::Get(); diff --git a/Source/Tools/Debugger/Main.cpp b/Source/Tools/Debugger/Main.cpp index 47275f2a2..ceac45d67 100644 --- a/Source/Tools/Debugger/Main.cpp +++ b/Source/Tools/Debugger/Main.cpp @@ -1,4 +1,5 @@ #include "Common/ArgumentLoader.h" +#include "Common/EnvironmentLoader.h" #include "Common/Config.h" #include "CommonCore/VMFactory.h" #include "Tests/HarnessHelpers.h" @@ -128,8 +129,9 @@ void GetIRCallback(std::stringstream *out, uint64_t PC) { // } } -int main(int argc, char **argv) { +int main(int argc, char **argv, char **const envp) { FEX::Config::Init(); + FEX::EnvLoader::Load(envp); FEX::ArgLoader::Load(argc, argv); FEXCore::Context::InitializeStaticTables(); diff --git a/Source/Tools/Opt.cpp b/Source/Tools/Opt.cpp index 5be21258e..169fd9c1f 100644 --- a/Source/Tools/Opt.cpp +++ b/Source/Tools/Opt.cpp @@ -1,10 +1,12 @@ #include "Common/ArgumentLoader.h" +#include "Common/EnvironmentLoader.h" #include "Common/Config.h" #include -int main(int argc, char **argv) { +int main(int argc, char **argv, char **const envp) { FEX::Config::Init(); + FEX::EnvLoader::Load(envp); FEX::ArgLoader::Load(argc, argv); FEX::Config::Shutdown(); From 0c51baf7a8b23c944d823ed41b439bd17df06ec5 Mon Sep 17 00:00:00 2001 From: David Miller Date: Sat, 25 Apr 2020 12:49:41 -0400 Subject: [PATCH 2/4] Added default Config::UnifiedMemory value to true --- Source/Common/EnvironmentLoader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Common/EnvironmentLoader.cpp b/Source/Common/EnvironmentLoader.cpp index 77f9e1b12..ddc0175da 100644 --- a/Source/Common/EnvironmentLoader.cpp +++ b/Source/Common/EnvironmentLoader.cpp @@ -87,6 +87,9 @@ namespace FEX::EnvLoader { if ((Value = GetVar("FEX_UNIFIED_MEM")).size()) { if (isdigit(Value[0])) Config::Add("UnifiedMemory", Value); } + else { // Most convenient place for a default as it's run before ArgLoader + Config::Add("UnifiedMemory", string_view("1")); + } } { From e9003acf36fa2148d1e05077efe35511f5479bbb Mon Sep 17 00:00:00 2001 From: David Miller Date: Sat, 25 Apr 2020 12:56:37 -0400 Subject: [PATCH 3/4] Ensure TestHarnessRunner doesn't enable UnifiedMemory. --- Source/Tests/TestHarnessRunner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Tests/TestHarnessRunner.cpp b/Source/Tests/TestHarnessRunner.cpp index 914bfc31a..7fdd882ec 100644 --- a/Source/Tests/TestHarnessRunner.cpp +++ b/Source/Tests/TestHarnessRunner.cpp @@ -70,6 +70,7 @@ int main(int argc, char **argv, char **const envp) { auto CTX = FEXCore::Context::CreateNewContext(); FEXCore::Context::SetCustomCPUBackendFactory(CTX, VMFactory::CPUCreationFactory); + FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_UNIFIED_MEMORY, 0); // ensure TestHarnessRunner doesn't enable UnifiedMemory. FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_DEFAULTCORE, CoreConfig() > 3 ? FEXCore::Config::CONFIG_CUSTOM : CoreConfig()); FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_MULTIBLOCK, MultiblockConfig()); FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_SINGLESTEP, SingleStepConfig()); From c77a3c0c02e16d44e30def0cffbc1c7dc071e58c Mon Sep 17 00:00:00 2001 From: David Miller Date: Sat, 25 Apr 2020 14:34:34 -0400 Subject: [PATCH 4/4] changed default value of FEXCore::Context::Config::UnifiedMemory to proper location --- External/FEXCore/Source/Interface/Context/Context.h | 2 +- Source/Common/EnvironmentLoader.cpp | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/External/FEXCore/Source/Interface/Context/Context.h b/External/FEXCore/Source/Interface/Context/Context.h index f8f228bb3..33a822f07 100644 --- a/External/FEXCore/Source/Interface/Context/Context.h +++ b/External/FEXCore/Source/Interface/Context/Context.h @@ -49,7 +49,7 @@ namespace FEXCore::Context { uint64_t VirtualMemSize {1ULL << 36}; FEXCore::Config::ConfigCore Core {FEXCore::Config::CONFIG_INTERPRETER}; bool GdbServer {false}; - bool UnifiedMemory {false}; + bool UnifiedMemory {true}; std::string RootFSPath; // LLVM JIT options diff --git a/Source/Common/EnvironmentLoader.cpp b/Source/Common/EnvironmentLoader.cpp index ddc0175da..77f9e1b12 100644 --- a/Source/Common/EnvironmentLoader.cpp +++ b/Source/Common/EnvironmentLoader.cpp @@ -87,9 +87,6 @@ namespace FEX::EnvLoader { if ((Value = GetVar("FEX_UNIFIED_MEM")).size()) { if (isdigit(Value[0])) Config::Add("UnifiedMemory", Value); } - else { // Most convenient place for a default as it's run before ArgLoader - Config::Add("UnifiedMemory", string_view("1")); - } } {