Collect/use multicorejit app profile
authorTimur Mustafin <t.mustafin@partner.samsung.com>
Thu, 22 Apr 2021 22:56:28 +0000 (01:56 +0300)
committer조웅석/Common Platform Lab(SR)/Principal Engineer/삼성전자 <ws77.cho@samsung.com>
Fri, 11 Jun 2021 01:25:30 +0000 (10:25 +0900)
Turn off --profile mode for default build

Signed-off-by: Timur Mustafin <t.mustafin@partner.samsung.com>
NativeLauncher/dotnet-nui.launcher
NativeLauncher/dotnet-nui.loader
NativeLauncher/dotnet.launcher
NativeLauncher/dotnet.loader
NativeLauncher/inc/utils.h
NativeLauncher/launcher/exec/launcher.cc
NativeLauncher/launcher/exec/loader.cc
NativeLauncher/launcher/lib/core_runtime.cc
NativeLauncher/launcher/lib/core_runtime.h

index 6226c1d..311084d 100644 (file)
@@ -3,5 +3,6 @@ NAME         dotnet-nui-launcher
 EXE          /usr/bin/dotnet-launcher
 APP_TYPE     dotnet-nui
 EXTRA_ARG    --PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE
+# EXTRA_ARG    --profile
 EXTRA_ARG    --standalone
 
index 7e714cd..17b5125 100644 (file)
@@ -8,3 +8,4 @@ ON_BOOT                OFF
 HYDRA                  OFF
 EXTRA                  --appType               dotnet-nui
 EXTRA                  TIZEN_UIFW              NUI
+EXTRA                  --profile               false
index 4bcd42d..f9a89c0 100644 (file)
@@ -3,6 +3,7 @@ NAME         dotnet-launcher
 EXE          /usr/bin/dotnet-launcher
 APP_TYPE     dotnet
 EXTRA_ARG    --PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE
+# EXTRA_ARG    --profile
 EXTRA_ARG    --appType
 EXTRA_ARG    dotnet
 EXTRA_ARG    --standalone
index 94a3b37..573db41 100644 (file)
@@ -11,3 +11,4 @@ ON_BOOT                OFF
 HYDRA                  OFF
 EXTRA                  --appType                dotnet
 EXTRA                  TIZEN_UIFW              ElmSharp
+EXTRA                  --profile               false
index a6b1d2d..983eca8 100644 (file)
 #define PATH_SEPARATOR '/'
 #endif
 
+#ifndef PROFILE_BASENAME
+#define PROFILE_BASENAME ".__tizen_specific_profile_data"
+#endif
+
 namespace bf = boost::filesystem;
 namespace bs = boost::system;
 
index e52001e..a829dbe 100644 (file)
@@ -39,6 +39,7 @@ using tizen::runtime::dotnetcore::CoreRuntime;
 static std::string StandaloneOption("--standalone");
 static std::string PaddingOption("--PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE");
 static std::string AppTypeOption("--appType");
+static std::string ProfileOption("--profile");
 
 int main(int argc, char *argv[])
 {
@@ -46,6 +47,7 @@ int main(int argc, char *argv[])
 
        char* standalonePath = nullptr;
        bool paddingExist = false;
+       bool profile = false;
        const char* appType = NULL;
        const char* appRootPath = NULL;
        char appId[APPID_MAX_LENGTH] = {0,};
@@ -63,6 +65,8 @@ int main(int argc, char *argv[])
                        standalonePath = argv[i];
                } else if (PaddingOption.compare(argv[i]) == 0) {
                        paddingExist = true;
+               } else if (ProfileOption.compare(argv[i]) == 0) {
+                       profile = true;
                } else if (AppTypeOption.compare(argv[i]) == 0) {
                        if (i > argc - 1) {
                                _ERR("app type for launchpad must be after \"--appType\" option");
@@ -107,7 +111,7 @@ int main(int argc, char *argv[])
                _ERR("Failed to initialize");
        } else {
                // launch application
-               err = CoreRuntime::launch(appId, appRootPath, standalonePath, vargs.size(), &vargs[0]);
+               err = CoreRuntime::launch(appId, appRootPath, standalonePath, vargs.size(), &vargs[0], profile);
                if (err) {
                        _ERR("Failed to launch");
                }
index e7e1a76..af74eae 100644 (file)
@@ -34,6 +34,7 @@ using tizen::runtime::dotnetcore::CoreRuntime;
 
 static const char* KEY_APP_TYPE = "--appType";
 static const char* KEY_TIZEN_UIFW = "TIZEN_UIFW";
+static const char* KEY_PROFILE = "--profile";
 
 static Ecore_Fd_Handler *__fd_handler;
 static loader_receiver_cb __receiver;
@@ -53,6 +54,9 @@ typedef struct AppInfo {
 } AppInfo;
 static AppInfo __appInfo;
 
+// Collect/use multicorejit profile or not
+static bool profile;
+
 
 //################## Code for running event loop for loader ####################
 
@@ -129,6 +133,19 @@ static void __loader_create_cb(bundle *extra, int type, void *user_data)
                _INFO("TIZEN_UIFW is set to %s", uifw);
        }
 
+       char *profile_str = NULL;
+       profile = false;
+       bundle_get_str(extra, KEY_PROFILE, &profile_str);
+       if (profile_str != NULL) {
+               if (!strcmp(profile_str, "true")) {
+                       profile = true;
+               } else if (!strcmp(profile_str, "false")) {
+                       profile = false;
+               } else {
+                       _DBG("PROFILE value %s not recognized. Valid values: true, false. Turn off PROFILE mode as default", profile_str);
+           }
+       }
+
        // initialize CoreRuntime (launchmode, dlog redirection enable, root path NULL)
        if (CoreRuntime::initialize(appType ? appType : "dotnet", LaunchMode::loader) != 0) {
                _ERR("Failed to initialized");
@@ -160,7 +177,7 @@ static int __loader_terminate_cb(int argc, char **argv, void *user_data)
        // The launchpad pass the name of exe file to the first argument.
        // For the C# spec, we have to skip this first argument.
        if (CoreRuntime::launch(__appInfo.appid.c_str(), __appInfo.root.c_str(),
-                                               __appInfo.app_path.c_str(), argc - 1, argv + 1)) {
+                                               __appInfo.app_path.c_str(), argc - 1, argv + 1, profile)) {
                _ERR("Failed to launch");
                return -1;
        }
index 1e5fb5e..1dcbbc2 100644 (file)
@@ -503,7 +503,7 @@ void CoreRuntime::finalize()
        _INFO("CoreRuntime finalized");
 }
 
-int CoreRuntime::launch(const char* appId, const char* root, const char* path, int argc, char* argv[])
+int CoreRuntime::launch(const char* appId, const char* root, const char* path, int argc, char* argv[], bool profile)
 {
        if (!__initialized) {
                _ERR("Runtime is not initialized");
@@ -535,6 +535,18 @@ int CoreRuntime::launch(const char* appId, const char* root, const char* path, i
        char* localDataPath = app_get_data_path();
        if (localDataPath != nullptr) {
                setEnvironmentVariable("XDG_DATA_HOME", localDataPath);
+
+               // set profile.data path and collect/use it if it non-exists/exists.
+               if (profile) {
+                       char multiCoreJitProfile[strlen(localDataPath) + strlen(PROFILE_BASENAME)];
+                       strcpy(multiCoreJitProfile, localDataPath);
+                       strcat(multiCoreJitProfile, PROFILE_BASENAME);
+
+                       setEnvironmentVariable("COMPlus_MultiCoreJitProfile", multiCoreJitProfile);
+                       if (!access(multiCoreJitProfile, R_OK)) {
+                               setEnvironmentVariable("COMPlus_MultiCoreJitNoProfileGather", "1");
+                       }
+               }
                free(localDataPath);
        }
 
index c4aa53f..f341261 100644 (file)
@@ -37,7 +37,7 @@ class CoreRuntime
        public:
                static int initialize(const char* appType, LaunchMode launchMode);
                static void finalize();
-               static int launch(const char* appId, const char* root, const char* path, int argc, char* argv[]);
+               static int launch(const char* appId, const char* root, const char* path, int argc, char* argv[], bool profile);
 
        private:
                static PathManager* __pm;