From a09d8b7d4cb6f35f12f2bd2ed4e04a0eb129eeea Mon Sep 17 00:00:00 2001 From: Victor Hsieh Date: Mon, 24 May 2021 14:21:55 -0700 Subject: Add runtime option -Xbootclasspathfds: for pre-opened fds The new option allows the client to pass a pre-opened fds to the runtime. The number of elements must match the number of BCP jars specified in -Xbootclasspath. An fd of negative number is a valid option, in such case the runtime will still open the jar in the corresponding path in -Xbootclasspath. Example: -Xbootclasspathfds:10:11:-1:12 The option is currently only used in "unstarted runtime", but will also be used elsewhere in the follow-up changes. Bug: 187327262 Test: patch odrefresh to use the option, no longer seeing such openat(2) Test: m test-art-host-gtest Change-Id: I1bebbd80136419c03ac1309a8cb8229a0fd69838 --- runtime/runtime.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'runtime/runtime.cc') diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 35b7055275..d54ef6bd30 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -1394,6 +1394,13 @@ bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) { } } + boot_class_path_fds_ = runtime_options.ReleaseOrDefault(Opt::BootClassPathFds); + if (!boot_class_path_fds_.empty() && boot_class_path_fds_.size() != boot_class_path_.size()) { + LOG(ERROR) << "Number of FDs specified in -Xbootclasspathfds must match the number of JARs in " + << "-Xbootclasspath."; + return false; + } + class_path_string_ = runtime_options.ReleaseOrDefault(Opt::ClassPath); properties_ = runtime_options.ReleaseOrDefault(Opt::PropertiesList); @@ -1517,6 +1524,7 @@ bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) { runtime_options.GetOrDefault(Opt::NonMovingSpaceCapacity), GetBootClassPath(), GetBootClassPathLocations(), + GetBootClassPathFds(), image_locations_, instruction_set_, // Override the collector type to CC if the read barrier config. -- cgit v1.2.3-59-g8ed1b