Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElinor Fung <elfung@microsoft.com>2022-11-10 20:04:06 +0300
committerGitHub <noreply@github.com>2022-11-10 20:04:06 +0300
commitaa1ed19fb504c4871531ae452df8ba68f3f0d7e1 (patch)
tree4ff85ff2cb32d2626e0c35f1929fc0c006f683dd
parent003beb69fa9e71dfe34b55018a0d4ba0e1ae8306 (diff)
Reduce host memory usage: don't keep resolved deps around for app lifetime (#77987)
`hostpolicy` keeps a global `hostpolicy_init_t` around which has a list of `fx_definition_t` which each contain an associated `deps_json_t`. The deps are resolved/parsed on initialization of hostpolicy, updating the globally-stored information with all the resolved assets and computing properties that will be passed to the runtime. The only part of the deps resolution results we currently use after initialization / computing the properties is the rid fallback graph of the root framework (for component dependency resolution). Everything else we are just holding on to for the lifetime of the application. This separates `deps_json_t` from `fx_definition_t` such that we: - don't keep all the resolved deps around for the lifetime of the application - store only the one rid fallback graph we need for future resolutions - stop including/building deps parsing functionality in `hostfxr` (via `hostcommon`) For a blank console app (so no other dependencies, just NETCoreApp) running on Windows, this reduces the amount we keep on the native heap by ~200kB. The more dependencies, the more we were keeping around.
-rw-r--r--src/native/corehost/fx_definition.cpp11
-rw-r--r--src/native/corehost/fx_definition.h9
-rw-r--r--src/native/corehost/fxr/fx_muxer.cpp1
-rw-r--r--src/native/corehost/hostcommon/files.cmake4
-rw-r--r--src/native/corehost/hostpolicy/deps_entry.cpp (renamed from src/native/corehost/deps_entry.cpp)0
-rw-r--r--src/native/corehost/hostpolicy/deps_entry.h (renamed from src/native/corehost/deps_entry.h)0
-rw-r--r--src/native/corehost/hostpolicy/deps_format.cpp (renamed from src/native/corehost/deps_format.cpp)0
-rw-r--r--src/native/corehost/hostpolicy/deps_format.h (renamed from src/native/corehost/deps_format.h)26
-rw-r--r--src/native/corehost/hostpolicy/deps_resolver.cpp36
-rw-r--r--src/native/corehost/hostpolicy/deps_resolver.h73
-rw-r--r--src/native/corehost/hostpolicy/files.cmake4
-rw-r--r--src/native/corehost/hostpolicy/hostpolicy.cpp6
-rw-r--r--src/native/corehost/hostpolicy/hostpolicy_context.cpp27
-rw-r--r--src/native/corehost/hostpolicy/hostpolicy_init.h2
-rw-r--r--src/native/corehost/runtime_config.h2
15 files changed, 75 insertions, 126 deletions
diff --git a/src/native/corehost/fx_definition.cpp b/src/native/corehost/fx_definition.cpp
index 190105b7b88..8e69c4a10a9 100644
--- a/src/native/corehost/fx_definition.cpp
+++ b/src/native/corehost/fx_definition.cpp
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#include "deps_format.h"
#include "fx_definition.h"
#include "fx_ver.h"
#include "pal.h"
@@ -31,13 +30,3 @@ void fx_definition_t::parse_runtime_config(
{
m_runtime_config.parse(path, dev_path, override_settings);
}
-
-void fx_definition_t::parse_deps()
-{
- m_deps.parse(false, m_deps_file);
-}
-
-void fx_definition_t::parse_deps(const deps_json_t::rid_fallback_graph_t& graph)
-{
- m_deps.parse(true, m_deps_file, graph);
-}
diff --git a/src/native/corehost/fx_definition.h b/src/native/corehost/fx_definition.h
index 01a2aaee270..222fa07d659 100644
--- a/src/native/corehost/fx_definition.h
+++ b/src/native/corehost/fx_definition.h
@@ -5,7 +5,6 @@
#define __FX_DEFINITION_H__
#include "pal.h"
-#include "deps_format.h"
#include "runtime_config.h"
class fx_definition_t
@@ -25,20 +24,12 @@ public:
const runtime_config_t& get_runtime_config() const { return m_runtime_config; }
void parse_runtime_config(const pal::string_t& path, const pal::string_t& dev_path, const runtime_config_t::settings_t& override_settings);
- const pal::string_t& get_deps_file() const { return m_deps_file; }
- void set_deps_file(const pal::string_t value) { m_deps_file = value; }
- const deps_json_t& get_deps() const { return m_deps; }
- void parse_deps();
- void parse_deps(const deps_json_t::rid_fallback_graph_t& graph);
-
private:
pal::string_t m_name;
pal::string_t m_dir;
pal::string_t m_requested_version;
pal::string_t m_found_version;
runtime_config_t m_runtime_config;
- pal::string_t m_deps_file;
- deps_json_t m_deps;
};
typedef std::vector<std::unique_ptr<fx_definition_t>> fx_definition_vector_t;
diff --git a/src/native/corehost/fxr/fx_muxer.cpp b/src/native/corehost/fxr/fx_muxer.cpp
index 6d49a26c06f..20df9462abb 100644
--- a/src/native/corehost/fxr/fx_muxer.cpp
+++ b/src/native/corehost/fxr/fx_muxer.cpp
@@ -13,7 +13,6 @@
#include <corehost_context_contract.h>
#include <hostpolicy.h>
#include "corehost_init.h"
-#include "deps_format.h"
#include "framework_info.h"
#include "fx_definition.h"
#include "fx_muxer.h"
diff --git a/src/native/corehost/hostcommon/files.cmake b/src/native/corehost/hostcommon/files.cmake
index 12e094a0e50..a79ac208399 100644
--- a/src/native/corehost/hostcommon/files.cmake
+++ b/src/native/corehost/hostcommon/files.cmake
@@ -7,8 +7,6 @@ include_directories(${CMAKE_CURRENT_LIST_DIR}/../fxr)
# CMake does not recommend using globbing since it messes with the freshness checks
list(APPEND SOURCES
${CMAKE_CURRENT_LIST_DIR}/../json_parser.cpp
- ${CMAKE_CURRENT_LIST_DIR}/../deps_format.cpp
- ${CMAKE_CURRENT_LIST_DIR}/../deps_entry.cpp
${CMAKE_CURRENT_LIST_DIR}/../host_startup_info.cpp
${CMAKE_CURRENT_LIST_DIR}/../roll_forward_option.cpp
${CMAKE_CURRENT_LIST_DIR}/../fx_definition.cpp
@@ -24,8 +22,6 @@ list(APPEND SOURCES
list(APPEND HEADERS
${CMAKE_CURRENT_LIST_DIR}/../json_parser.h
- ${CMAKE_CURRENT_LIST_DIR}/../deps_format.h
- ${CMAKE_CURRENT_LIST_DIR}/../deps_entry.h
${CMAKE_CURRENT_LIST_DIR}/../host_startup_info.h
${CMAKE_CURRENT_LIST_DIR}/../roll_forward_option.h
${CMAKE_CURRENT_LIST_DIR}/../fx_definition.h
diff --git a/src/native/corehost/deps_entry.cpp b/src/native/corehost/hostpolicy/deps_entry.cpp
index 981d86305e6..981d86305e6 100644
--- a/src/native/corehost/deps_entry.cpp
+++ b/src/native/corehost/hostpolicy/deps_entry.cpp
diff --git a/src/native/corehost/deps_entry.h b/src/native/corehost/hostpolicy/deps_entry.h
index ae769f799f4..ae769f799f4 100644
--- a/src/native/corehost/deps_entry.h
+++ b/src/native/corehost/hostpolicy/deps_entry.h
diff --git a/src/native/corehost/deps_format.cpp b/src/native/corehost/hostpolicy/deps_format.cpp
index 9abf6ae8f69..9abf6ae8f69 100644
--- a/src/native/corehost/deps_format.cpp
+++ b/src/native/corehost/hostpolicy/deps_format.cpp
diff --git a/src/native/corehost/deps_format.h b/src/native/corehost/hostpolicy/deps_format.h
index ceed3147e08..d66b0a9fdd4 100644
--- a/src/native/corehost/deps_format.h
+++ b/src/native/corehost/hostpolicy/deps_format.h
@@ -26,31 +26,11 @@ class deps_json_t
public:
typedef str_to_vector_map_t rid_fallback_graph_t;
- deps_json_t()
+ deps_json_t(bool is_framework_dependent, const pal::string_t& deps_path, const rid_fallback_graph_t* graph)
: m_file_exists(false)
, m_valid(false)
{
- }
-
- deps_json_t(bool is_framework_dependent, const pal::string_t& deps_path)
- : deps_json_t(is_framework_dependent, deps_path, m_rid_fallback_graph /* dummy */)
- {
- }
-
- deps_json_t(bool is_framework_dependent, const pal::string_t& deps_path, const rid_fallback_graph_t& graph)
- : deps_json_t()
- {
- m_valid = load(is_framework_dependent, deps_path, graph);
- }
-
- void parse(bool is_framework_dependent, const pal::string_t& deps_path)
- {
- m_valid = load(is_framework_dependent, deps_path, m_rid_fallback_graph /* dummy */);
- }
-
- void parse(bool is_framework_dependent, const pal::string_t& deps_path, const rid_fallback_graph_t& graph)
- {
- m_valid = load(is_framework_dependent, deps_path, graph);
+ m_valid = load(is_framework_dependent, deps_path, graph == nullptr ? m_rid_fallback_graph : *graph);
}
const std::vector<deps_entry_t>& get_entries(deps_entry_t::asset_types type) const
@@ -76,7 +56,7 @@ public:
return m_rid_fallback_graph;
}
- pal::string_t get_deps_file() const
+ const pal::string_t& get_deps_file() const
{
return m_deps_file;
}
diff --git a/src/native/corehost/hostpolicy/deps_resolver.cpp b/src/native/corehost/hostpolicy/deps_resolver.cpp
index 7a9fa4f34f6..e8a18a99dc8 100644
--- a/src/native/corehost/hostpolicy/deps_resolver.cpp
+++ b/src/native/corehost/hostpolicy/deps_resolver.cpp
@@ -6,8 +6,8 @@
#include <cassert>
#include <trace.h>
-#include <deps_entry.h>
-#include <deps_format.h>
+#include "deps_entry.h"
+#include "deps_format.h"
#include "deps_resolver.h"
#include <utils.h>
#include <fx_ver.h>
@@ -253,7 +253,7 @@ void deps_resolver_t::setup_probe_config(
{
if (pal::directory_exists(m_fx_definitions[i]->get_dir()))
{
- m_probes.push_back(probe_config_t::fx(m_fx_definitions[i]->get_dir(), &m_fx_definitions[i]->get_deps(), i));
+ m_probes.push_back(probe_config_t::fx(m_fx_definitions[i]->get_dir(), m_fx_deps[i].get(), i));
}
}
@@ -546,7 +546,7 @@ bool deps_resolver_t::resolve_tpa_list(
}
// Add the app's entries
- const auto& deps_entries = get_deps().get_entries(deps_entry_t::asset_types::runtime);
+ const auto& deps_entries = get_app_deps().get_entries(deps_entry_t::asset_types::runtime);
for (const auto& entry : deps_entries)
{
if (!process_entry(m_app_dir, entry, 0))
@@ -558,7 +558,7 @@ bool deps_resolver_t::resolve_tpa_list(
// If the deps file wasn't present or has missing entries, then
// add the app local assemblies to the TPA. This is only valid
// in non-libhost scenarios (e.g. comhost).
- if (!get_deps().exists())
+ if (!get_app_deps().exists())
{
// Obtain the local assemblies in the app dir.
get_dir_assemblies(m_app_dir, _X("local"), &items);
@@ -588,7 +588,7 @@ bool deps_resolver_t::resolve_tpa_list(
{
for (int32_t i = 1; i < static_cast<int32_t>(m_fx_definitions.size()); ++i)
{
- const auto& deps_entries = m_fx_definitions[i]->get_deps().get_entries(deps_entry_t::asset_types::runtime);
+ const auto& deps_entries = m_fx_deps[i]->get_entries(deps_entry_t::asset_types::runtime);
for (const auto& entry : deps_entries)
{
if (!process_entry(m_fx_definitions[i]->get_dir(), entry, i))
@@ -627,7 +627,7 @@ void deps_resolver_t::init_known_entry_path(const deps_entry_t& entry, const pal
}
}
-void deps_resolver_t::resolve_additional_deps(const arguments_t& args, const deps_json_t::rid_fallback_graph_t& rid_fallback_graph)
+void deps_resolver_t::resolve_additional_deps(const arguments_t& args, const deps_json_t::rid_fallback_graph_t* rid_fallback_graph)
{
if (!m_is_framework_dependent
|| m_host_mode == host_mode_t::libhost)
@@ -740,12 +740,10 @@ void deps_resolver_t::resolve_additional_deps(const arguments_t& args, const dep
}
}
-void deps_resolver_t::get_app_context_deps_files_range(fx_definition_vector_t::iterator *begin, fx_definition_vector_t::iterator *end) const
+void deps_resolver_t::enum_app_context_deps_files(std::function<void(const pal::string_t&)> callback)
{
- assert(begin != nullptr && end != nullptr);
-
- auto begin_iter = m_fx_definitions.begin();
- auto end_iter = m_fx_definitions.end();
+ auto begin_iter = m_fx_deps.cbegin();
+ auto end_iter = m_fx_deps.cend();
if ((m_host_mode == host_mode_t::libhost
|| (bundle::info_t::is_single_file_bundle() && !bundle::runner_t::app()->is_netcoreapp3_compat_mode()))
@@ -754,12 +752,14 @@ void deps_resolver_t::get_app_context_deps_files_range(fx_definition_vector_t::i
// Neither in a libhost scenario nor in a bundled app
// the deps files should be exposed in the app context
// properties.
- assert(begin_iter->get() == &get_app(m_fx_definitions));
+ assert(begin_iter->get() == &get_app_deps());
++begin_iter;
}
- *begin = begin_iter;
- *end = end_iter;
+ for (auto it = begin_iter; it != m_fx_deps.cend(); ++it)
+ {
+ callback((*it)->get_deps_file());
+ }
}
/**
@@ -843,7 +843,7 @@ bool deps_resolver_t::resolve_probe_dirs(
};
// Add app entries
- const auto& entries = get_deps().get_entries(asset_type);
+ const auto& entries = get_app_deps().get_entries(asset_type);
for (const auto& entry : entries)
{
if (!add_package_cache_entry(entry, m_app_dir, 0))
@@ -853,7 +853,7 @@ bool deps_resolver_t::resolve_probe_dirs(
}
// If the deps file is missing add known locations.
- if (!get_deps().exists())
+ if (!get_app_deps().exists())
{
// App local path
add_unique_path(asset_type, m_app_dir, &items, output, &non_serviced, core_servicing);
@@ -877,7 +877,7 @@ bool deps_resolver_t::resolve_probe_dirs(
// Add fx package locations to fx_dir
for (int32_t i = 1; i < static_cast<int32_t>(m_fx_definitions.size()); ++i)
{
- const auto& fx_entries = m_fx_definitions[i]->get_deps().get_entries(asset_type);
+ const auto& fx_entries = m_fx_deps[i]->get_entries(asset_type);
for (const auto& entry : fx_entries)
{
diff --git a/src/native/corehost/hostpolicy/deps_resolver.h b/src/native/corehost/hostpolicy/deps_resolver.h
index 0c908205484..e4e3584d44e 100644
--- a/src/native/corehost/hostpolicy/deps_resolver.h
+++ b/src/native/corehost/hostpolicy/deps_resolver.h
@@ -43,7 +43,7 @@ public:
// doesn't contain the root framework at all.
deps_resolver_t(
const arguments_t& args,
- fx_definition_vector_t& fx_definitions,
+ const fx_definition_vector_t& fx_definitions,
const deps_json_t::rid_fallback_graph_t* root_framework_rid_fallback_graph,
bool is_framework_dependent)
: m_fx_definitions(fx_definitions)
@@ -54,40 +54,35 @@ public:
, m_is_framework_dependent(is_framework_dependent)
, m_needs_file_existence_checks(false)
{
- int lowest_framework = static_cast<int>(m_fx_definitions.size()) - 1;
- int root_framework = -1;
- if (root_framework_rid_fallback_graph == nullptr)
- {
- root_framework = lowest_framework;
- root_framework_rid_fallback_graph = &m_fx_definitions[root_framework]->get_deps().get_rid_fallback_graph();
- }
+ m_fx_deps.resize(m_fx_definitions.size());
+ // Process from lowest (root) to highest (app) framework.
+ // If we weren't explicitly given a rid fallback graph, that of
+ // the root framework is used for higher frameworks.
+ int lowest_framework = static_cast<int>(m_fx_definitions.size()) - 1;
for (int i = lowest_framework; i >= 0; --i)
{
- if (i == 0)
- {
- m_fx_definitions[i]->set_deps_file(args.deps_path);
- trace::verbose(_X("Using %s deps file"), m_fx_definitions[i]->get_deps_file().c_str());
- }
- else
- {
- pal::string_t fx_deps_file = get_fx_deps(m_fx_definitions[i]->get_dir(), m_fx_definitions[i]->get_name());
- m_fx_definitions[i]->set_deps_file(fx_deps_file);
- trace::verbose(_X("Using Fx %s deps file"), fx_deps_file.c_str());
- }
+ pal::string_t deps_file = i == 0
+ ? args.deps_path
+ : get_fx_deps(m_fx_definitions[i]->get_dir(), m_fx_definitions[i]->get_name());
+ trace::verbose(_X("Using %s deps file"), deps_file.c_str());
- if (i == root_framework)
+ if (root_framework_rid_fallback_graph == nullptr && i == lowest_framework)
{
- m_fx_definitions[i]->parse_deps();
+ m_fx_deps[i] = std::unique_ptr<deps_json_t>(new deps_json_t(false, deps_file, nullptr));
+
+ // The fx_definitions contains the root framework, so set the
+ // rid fallback graph that will be used for other frameworks.
+ root_framework_rid_fallback_graph = &m_fx_deps[lowest_framework]->get_rid_fallback_graph();
}
else
{
// The rid graph is obtained from the root framework
- m_fx_definitions[i]->parse_deps(*root_framework_rid_fallback_graph);
+ m_fx_deps[i] = std::unique_ptr<deps_json_t>(new deps_json_t(true, deps_file, root_framework_rid_fallback_graph));
}
}
- resolve_additional_deps(args, *root_framework_rid_fallback_graph);
+ resolve_additional_deps(args, root_framework_rid_fallback_graph);
setup_additional_probes(args.probe_paths);
setup_probe_config(args);
@@ -100,21 +95,21 @@ public:
bool valid(pal::string_t* errors)
{
- for (size_t i = 0; i < m_fx_definitions.size(); ++i)
+ for (size_t i = 0; i < m_fx_deps.size(); ++i)
{
// Verify the deps file exists. The app deps file does not need to exist
if (i != 0)
{
- if (!m_fx_definitions[i]->get_deps().exists())
+ if (!m_fx_deps[i]->exists())
{
- errors->assign(_X("A fatal error was encountered, missing dependencies manifest at: ") + m_fx_definitions[i]->get_deps_file());
+ errors->assign(_X("A fatal error was encountered, missing dependencies manifest at: ") + m_fx_deps[i]->get_deps_file());
return false;
}
}
- if (!m_fx_definitions[i]->get_deps().is_valid())
+ if (!m_fx_deps[i]->is_valid())
{
- errors->assign(_X("An error occurred while parsing: ") + m_fx_definitions[i]->get_deps_file());
+ errors->assign(_X("An error occurred while parsing: ") + m_fx_deps[i]->get_deps_file());
return false;
}
}
@@ -154,24 +149,19 @@ public:
void resolve_additional_deps(
const arguments_t& args,
- const deps_json_t::rid_fallback_graph_t& rid_fallback_graph);
+ const deps_json_t::rid_fallback_graph_t* rid_fallback_graph);
- const deps_json_t& get_deps() const
+ const deps_json_t& get_app_deps() const
{
- return get_app(m_fx_definitions).get_deps();
+ return *m_fx_deps[0];
}
- const pal::string_t& get_deps_file() const
+ const deps_json_t& get_root_deps() const
{
- return get_app(m_fx_definitions).get_deps_file();
+ return *m_fx_deps[m_fx_definitions.size() - 1];
}
- void get_app_context_deps_files_range(fx_definition_vector_t::iterator *begin, fx_definition_vector_t::iterator *end) const;
-
- const fx_definition_vector_t& get_fx_definitions() const
- {
- return m_fx_definitions;
- }
+ void enum_app_context_deps_files(std::function<void(const pal::string_t&)> callback);
bool is_framework_dependent() const
{
@@ -249,7 +239,10 @@ private:
pal::string_t* candidate,
bool &found_in_bundle);
- fx_definition_vector_t& m_fx_definitions;
+ const fx_definition_vector_t& m_fx_definitions;
+
+ // Resolved deps.json for each m_fx_definitions (corresponding indices)
+ std::vector<std::unique_ptr<deps_json_t>> m_fx_deps;
pal::string_t m_app_dir;
diff --git a/src/native/corehost/hostpolicy/files.cmake b/src/native/corehost/hostpolicy/files.cmake
index 3c2532bd0b2..ef3ada745fc 100644
--- a/src/native/corehost/hostpolicy/files.cmake
+++ b/src/native/corehost/hostpolicy/files.cmake
@@ -10,6 +10,8 @@ list(APPEND SOURCES
${CMAKE_CURRENT_LIST_DIR}/args.cpp
${CMAKE_CURRENT_LIST_DIR}/breadcrumbs.cpp
${CMAKE_CURRENT_LIST_DIR}/coreclr.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/deps_entry.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/deps_format.cpp
${CMAKE_CURRENT_LIST_DIR}/deps_resolver.cpp
${CMAKE_CURRENT_LIST_DIR}/hostpolicy_context.cpp
${CMAKE_CURRENT_LIST_DIR}/hostpolicy.cpp
@@ -25,6 +27,8 @@ list(APPEND HEADERS
${CMAKE_CURRENT_LIST_DIR}/args.h
${CMAKE_CURRENT_LIST_DIR}/breadcrumbs.h
${CMAKE_CURRENT_LIST_DIR}/coreclr.h
+ ${CMAKE_CURRENT_LIST_DIR}/deps_entry.h
+ ${CMAKE_CURRENT_LIST_DIR}/deps_format.h
${CMAKE_CURRENT_LIST_DIR}/deps_resolver.h
${CMAKE_CURRENT_LIST_DIR}/hostpolicy_context.h
${CMAKE_CURRENT_LIST_DIR}/hostpolicy_init.h
diff --git a/src/native/corehost/hostpolicy/hostpolicy.cpp b/src/native/corehost/hostpolicy/hostpolicy.cpp
index fbdd3cbd4c7..a1734810363 100644
--- a/src/native/corehost/hostpolicy/hostpolicy.cpp
+++ b/src/native/corehost/hostpolicy/hostpolicy.cpp
@@ -903,12 +903,12 @@ SHARED_API int HOSTPOLICY_CALLTYPE corehost_resolve_component_dependencies(
// TODO Review: Since we're only passing the one component framework, the resolver will not consider
// frameworks from the app for probing paths. So potential references to paths inside frameworks will not resolve.
- // The RID graph still has to come from the actual root framework, so take that from the g_init.fx_definitions
- // which are the frameworks for the app.
+ // The RID graph still has to come from the actual root framework, so take that from the g_init.root_rid_fallback_graph,
+ // which stores the fallback graph for the app's root framework.
deps_resolver_t resolver(
args,
component_fx_definitions,
- &get_root_framework(g_init.fx_definitions).get_deps().get_rid_fallback_graph(),
+ &g_init.root_rid_fallback_graph,
true);
pal::string_t resolver_errors;
diff --git a/src/native/corehost/hostpolicy/hostpolicy_context.cpp b/src/native/corehost/hostpolicy/hostpolicy_context.cpp
index 89a13928f31..1fbae76d0cd 100644
--- a/src/native/corehost/hostpolicy/hostpolicy_context.cpp
+++ b/src/native/corehost/hostpolicy/hostpolicy_context.cpp
@@ -127,6 +127,10 @@ int hostpolicy_context_t::initialize(hostpolicy_init_t &hostpolicy_init, const a
return StatusCode::ResolverInitFailure;
}
+ // Store the root framework's rid fallback graph so that we can
+ // use it for future dependency resolutions
+ hostpolicy_init.root_rid_fallback_graph = resolver.get_root_deps().get_rid_fallback_graph();
+
probe_paths_t probe_paths;
// Setup breadcrumbs.
@@ -191,42 +195,33 @@ int hostpolicy_context_t::initialize(hostpolicy_init_t &hostpolicy_init, const a
probe_paths.tpa.append(corelib_path);
}
- const fx_definition_vector_t &fx_definitions = resolver.get_fx_definitions();
-
pal::string_t fx_deps_str;
if (resolver.is_framework_dependent())
{
// Use the root fx to define FX_DEPS_FILE
- fx_deps_str = get_root_framework(fx_definitions).get_deps_file();
+ fx_deps_str = resolver.get_root_deps().get_deps_file();
}
- fx_definition_vector_t::iterator fx_begin;
- fx_definition_vector_t::iterator fx_end;
- resolver.get_app_context_deps_files_range(&fx_begin, &fx_end);
-
pal::string_t app_context_deps_str;
- fx_definition_vector_t::iterator fx_curr = fx_begin;
- while (fx_curr != fx_end)
+ resolver.enum_app_context_deps_files([&](const pal::string_t& deps_file)
{
- if (fx_curr != fx_begin)
+ if (!app_context_deps_str.empty())
app_context_deps_str += _X(';');
// For the application's .deps.json if this is single file, 3.1 backward compat
// then the path used internally is the bundle path, but externally we need to report
// the path to the extraction folder.
- if (fx_curr == fx_begin && bundle::info_t::is_single_file_bundle() && bundle::runner_t::app()->is_netcoreapp3_compat_mode())
+ if (app_context_deps_str.empty() && bundle::info_t::is_single_file_bundle() && bundle::runner_t::app()->is_netcoreapp3_compat_mode())
{
pal::string_t deps_path = bundle::runner_t::app()->extraction_path();
- append_path(&deps_path, get_filename((*fx_curr)->get_deps_file()).c_str());
+ append_path(&deps_path, get_filename(deps_file).c_str());
app_context_deps_str += deps_path;
}
else
{
- app_context_deps_str += (*fx_curr)->get_deps_file();
+ app_context_deps_str += deps_file;
}
-
- ++fx_curr;
- }
+ });
// Build properties for CoreCLR instantiation
pal::string_t app_base;
diff --git a/src/native/corehost/hostpolicy/hostpolicy_init.h b/src/native/corehost/hostpolicy/hostpolicy_init.h
index 5b0aeafc4e7..590f0101d16 100644
--- a/src/native/corehost/hostpolicy/hostpolicy_init.h
+++ b/src/native/corehost/hostpolicy/hostpolicy_init.h
@@ -25,6 +25,8 @@ struct hostpolicy_init_t
pal::string_t host_command;
host_startup_info_t host_info;
+ std::unordered_map<pal::string_t, std::vector<pal::string_t>> root_rid_fallback_graph;
+
static bool init(const host_interface_t* input, hostpolicy_init_t* init);
static void init_host_command(const host_interface_t* input, hostpolicy_init_t* init);
diff --git a/src/native/corehost/runtime_config.h b/src/native/corehost/runtime_config.h
index c7b01d40baa..820684460d2 100644
--- a/src/native/corehost/runtime_config.h
+++ b/src/native/corehost/runtime_config.h
@@ -7,8 +7,8 @@
#include <list>
#include "pal.h"
-#include <external/rapidjson/fwd.h>
#include "fx_reference.h"
+#include "json_parser.h"
class runtime_config_t
{