Revert^4 "Merge libart and libart-compiler into a single library"
This reverts commit 61b1c151163a09ad49c0b74c19ee84caeb4d0345.
Reason for revert: reland with dex2oat PGO removed.
Previous attempts at merging libart-compiler into libart showed some
performance regressions, which were caused by incompatibilities between
AFDO and PGO optimization pipelines when used within a single library.
This change removes dex2oat PGO and leaves only AFDO for libart.so.
Change-Id: I75a844f53663385ef98351f60d3adb900157f5e5
Bug: 303042202
Bug: 186902856
Test: art/test.py -b --host
Test: atest art_standalone_\*_tests
Test: art/build/apex/runtests.sh
Test: atest art-apex-update-rollback
Test: (chroot) art/tools/run-gtests.sh -j4
Test: (chroot) art/test/testrunner/testrunner.py --target
Test: (chroot) art/tools/run-libcore-tests.sh --mode=device
Test: (chroot) art/tools/run-libjdwp-tests.sh --mode=device
diff --git a/Android.mk b/Android.mk
index 13aeb15..e47c9ce 100644
--- a/Android.mk
+++ b/Android.mk
@@ -409,7 +409,6 @@
lib/libadbconnection.so \
lib/libandroidio.so \
lib/libartbase.so \
- lib/libart-compiler.so \
lib/libart-dexlayout.so \
lib/libart-disassembler.so \
lib/libartpalette.so \
@@ -437,7 +436,6 @@
lib64/libadbconnection.so \
lib64/libandroidio.so \
lib64/libartbase.so \
- lib64/libart-compiler.so \
lib64/libart-dexlayout.so \
lib64/libart-disassembler.so \
lib64/libartpalette.so \
diff --git a/build/apex/Android.bp b/build/apex/Android.bp
index c0f44df..03bd964 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -58,7 +58,6 @@
"libadbconnection",
// TODO(b/124476339): Clean up the following libraries once "required"
// dependencies work with APEX libraries.
- "libart-compiler",
"libdt_fd_forward",
"libdt_socket",
"libjdwp",
@@ -81,7 +80,6 @@
art_runtime_debug_native_shared_libs = [
"libadbconnectiond",
"libartd",
- "libartd-compiler",
"libdexfiled",
"libopenjdkjvmd",
"libopenjdkjvmtid",
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py
index 3887b50..893c039 100755
--- a/build/apex/art_apex_test.py
+++ b/build/apex/art_apex_test.py
@@ -475,7 +475,6 @@
# Check internal libraries for ART.
self._checker.check_native_library('libadbconnection')
self._checker.check_native_library('libart')
- self._checker.check_native_library('libart-compiler')
self._checker.check_native_library('libart-dexlayout')
self._checker.check_native_library('libart-disassembler')
self._checker.check_native_library('libartbase')
@@ -622,7 +621,6 @@
self._checker.check_native_library('libadbconnectiond')
self._checker.check_native_library('libartbased')
self._checker.check_native_library('libartd')
- self._checker.check_native_library('libartd-compiler')
self._checker.check_native_library('libartd-dexlayout')
self._checker.check_native_library('libartd-disassembler')
self._checker.check_native_library('libopenjdkjvmd')
diff --git a/compiler/Android.bp b/compiler/Android.bp
index 6472613..e49f570 100644
--- a/compiler/Android.bp
+++ b/compiler/Android.bp
@@ -37,6 +37,7 @@
"libartpalette",
],
header_libs: [
+ "libart_headers",
"libart_generated_headers",
],
}
@@ -65,11 +66,23 @@
],
},
},
- runtime_libs: [
- // `art::HGraphVisualizerDisassembler::HGraphVisualizerDisassembler` may dynamically load
- // `libart-disassembler.so`.
- "libart-disassembler",
- ],
+ // In order to save memory on device `art::HGraphVisualizerDisassembler` loads
+ // `libart-disassembler.so` dynamically. Host builds of `libart-compiler` depend on
+ // `libart-disassembler` directly with `shared_libs` or `static_libs`.
+ target: {
+ host: {
+ shared: {
+ shared_libs: [
+ "libart-disassembler",
+ ],
+ },
+ },
+ android: {
+ runtime_libs: [
+ "libart-disassembler",
+ ],
+ },
+ },
}
// Dependencies of libartd-compiler, used to propagate libartd-compiler deps when static linking.
@@ -96,11 +109,23 @@
],
},
},
- runtime_libs: [
- // `art::HGraphVisualizerDisassembler::HGraphVisualizerDisassembler` may dynamically load
- // `libartd-disassembler.so`.
- "libartd-disassembler",
- ],
+ // In order to save memory on device `art::HGraphVisualizerDisassembler` loads
+ // `libartd-disassembler.so` dynamically. Host builds of `libartd-compiler` depend on
+ // `libartd-disassembler` directly with `shared_libs` or `static_libs`.
+ target: {
+ host: {
+ shared: {
+ shared_libs: [
+ "libartd-disassembler",
+ ],
+ },
+ },
+ android: {
+ runtime_libs: [
+ "libartd-disassembler",
+ ],
+ },
+ },
}
art_cc_defaults {
@@ -244,14 +269,7 @@
],
},
},
- static: {
- cflags: ["-DART_STATIC_LIBART_COMPILER"],
- },
generated_sources: ["art_compiler_operator_srcs"],
- shared_libs: [
- "libbase",
- "liblzma", // libelffile(d) dependency; must be repeated here since it's a static lib.
- ],
header_libs: [
"art_cmdlineparser_headers", // For compiler_options.
"art_disassembler_headers",
@@ -259,8 +277,6 @@
],
export_include_dirs: ["."],
- // Not using .map.txt because this is an internal API
- version_script: "libart-compiler.map",
}
cc_defaults {
@@ -285,19 +301,12 @@
output_extension: "operator_out.cc",
}
-art_cc_library {
+art_cc_library_static {
name: "libart-compiler",
defaults: [
"libart-compiler-defaults",
- "dex2oat-pgo-defaults",
- "art_hugepage_defaults",
"libart-compiler_deps",
],
- shared_libs: [
- // libart is not included in libart-compiler_deps to allow libart-compiler(-for-test)
- // select suitable libart library (either with or without LTO).
- "libart",
- ],
target: {
android: {
lto: {
@@ -319,13 +328,8 @@
name: "libart-compiler-for-test",
defaults: [
"libart-compiler-defaults",
- "dex2oat-pgo-defaults",
- "art_hugepage_defaults",
"libart-compiler_deps",
],
- header_libs: [
- "libart_headers",
- ],
}
cc_defaults {
@@ -333,7 +337,6 @@
defaults: [
"libart-compiler_static_base_defaults",
"libart-disassembler_static_defaults",
- "libart_static_defaults",
"libartbase_static_defaults",
"libdexfile_static_defaults",
"libprofile_static_defaults",
@@ -349,7 +352,6 @@
defaults: [
"libart-compiler_static_base_defaults",
"libart-disassembler_static_defaults",
- "libart-for-test_static_defaults",
"libartbase_static_defaults",
"libdexfile_static_defaults",
"libprofile_static_defaults",
@@ -357,16 +359,13 @@
whole_static_libs: ["libart-compiler-for-test"],
}
-art_cc_library {
+art_cc_library_static {
name: "libartd-compiler",
defaults: [
"art_debug_defaults",
"libart-compiler-defaults",
"libartd-compiler_deps",
],
- shared_libs: [
- "libartd",
- ],
apex_available: [
"com.android.art.debug",
// TODO(b/183882457): This lib doesn't go into com.android.art, but
@@ -382,7 +381,6 @@
"libart-compiler_static_base_defaults",
"libartbased_static_defaults",
"libartd-disassembler_static_defaults",
- "libartd_static_defaults",
"libdexfiled_static_defaults",
"libprofiled_static_defaults",
],
@@ -399,19 +397,34 @@
"libart-compiler_static_base_defaults",
"libartbased_static_defaults",
"libartd-disassembler_static_defaults",
- "libartd-for-test_static_defaults",
"libdexfiled_static_defaults",
"libprofiled_static_defaults",
],
whole_static_libs: ["libartd-compiler"],
}
+// Export headers required by `libart-runtime` to use JIT from `libart-compiler`.
+cc_library_headers {
+ name: "libart-compiler_jit_headers",
+ defaults: ["art_defaults"],
+ host_supported: true,
+ export_include_dirs: ["export"],
+ apex_available: [
+ "com.android.art",
+ "com.android.art.debug",
+ "test_broken_com.android.art",
+ ],
+}
+
// Properties common to `libart-compiler-gtest` and `libartd-compiler-gtest`.
art_cc_defaults {
name: "libart-compiler-gtest-common",
srcs: [
"common_compiler_test.cc",
],
+ header_libs: [
+ "libart_headers",
+ ],
}
art_cc_library_static {
diff --git a/compiler/export/jit_create.h b/compiler/export/jit_create.h
new file mode 100644
index 0000000..53dd45e
--- /dev/null
+++ b/compiler/export/jit_create.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_COMPILER_EXPORT_JIT_CREATE_H_
+#define ART_COMPILER_EXPORT_JIT_CREATE_H_
+
+#include "base/macros.h"
+
+namespace art HIDDEN {
+namespace jit {
+
+class JitCompilerInterface;
+
+// Used in `libart-runtime` to create `libart-compiler` JIT.
+JitCompilerInterface* jit_create();
+
+} // namespace jit
+} // namespace art
+
+#endif // ART_COMPILER_EXPORT_JIT_CREATE_H_
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc
index e672367..86c0f80 100644
--- a/compiler/jit/jit_compiler.cc
+++ b/compiler/jit/jit_compiler.cc
@@ -17,7 +17,6 @@
#include "jit_compiler.h"
#include "android-base/stringprintf.h"
-
#include "arch/instruction_set.h"
#include "arch/instruction_set_features.h"
#include "art_method-inl.h"
@@ -29,6 +28,7 @@
#include "compiler.h"
#include "debug/elf_debug_writer.h"
#include "driver/compiler_options.h"
+#include "export/jit_create.h"
#include "jit/debugger_interface.h"
#include "jit/jit.h"
#include "jit/jit_code_cache.h"
@@ -125,7 +125,7 @@
}
}
-EXPORT extern "C" JitCompilerInterface* jit_load() {
+JitCompilerInterface* jit_create() {
VLOG(jit) << "Create jit compiler";
auto* const jit_compiler = JitCompiler::Create();
CHECK(jit_compiler != nullptr);
diff --git a/compiler/libart-compiler.map b/compiler/libart-compiler.map
deleted file mode 100644
index f66052a..0000000
--- a/compiler/libart-compiler.map
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Copyright (C) 2022 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-ART_COMPILER {
- global:
- extern "C++" {
- art::debug::MakeMiniDebugInfo*;
- *art::debug::WriteDebugInfo*;
- art::Compiler::Create*;
- art::CompilerOptions::*;
- art::CreateTrampoline*;
- art::IntrinsicObjects::*;
- art::linker::operator*art::linker::LinkerPatch::Type*;
- art::operator*art::Whence*;
- };
-
- jit_load;
-
- local:
- *;
-};
diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc
index bd33fde..c2c0953 100644
--- a/compiler/optimizing/graph_visualizer.cc
+++ b/compiler/optimizing/graph_visualizer.cc
@@ -115,7 +115,9 @@
}
}
-#ifndef ART_STATIC_LIBART_COMPILER
+// On target: load `libart-disassembler` only when required (to save on memory).
+// On host: `libart-disassembler` should be linked directly (either as a static or dynamic lib)
+#ifdef ART_TARGET
using create_disasm_prototype = Disassembler*(InstructionSet, DisassemblerOptions*);
#endif
@@ -125,7 +127,7 @@
const uint8_t* base_address,
const uint8_t* end_address)
: instruction_set_(instruction_set), disassembler_(nullptr) {
-#ifndef ART_STATIC_LIBART_COMPILER
+#ifdef ART_TARGET
constexpr const char* libart_disassembler_so_name =
kIsDebugBuild ? "libartd-disassembler.so" : "libart-disassembler.so";
libart_disassembler_handle_ = dlopen(libart_disassembler_so_name, RTLD_NOW);
@@ -159,7 +161,7 @@
~HGraphVisualizerDisassembler() {
// We need to call ~Disassembler() before we close the library.
disassembler_.reset();
-#ifndef ART_STATIC_LIBART_COMPILER
+#ifdef ART_TARGET
if (libart_disassembler_handle_ != nullptr) {
dlclose(libart_disassembler_handle_);
}
@@ -184,7 +186,7 @@
InstructionSet instruction_set_;
std::unique_ptr<Disassembler> disassembler_;
-#ifndef ART_STATIC_LIBART_COMPILER
+#ifdef ART_TARGET
void* libart_disassembler_handle_;
#endif
};
diff --git a/dex2oat/Android.bp b/dex2oat/Android.bp
index 7f8bd05..83a3554 100644
--- a/dex2oat/Android.bp
+++ b/dex2oat/Android.bp
@@ -109,7 +109,6 @@
name: "libart-dex2oat",
defaults: ["libart-dex2oat-defaults"],
shared_libs: [
- "libart-compiler",
"libart-dexlayout",
"libart",
"libartpalette",
@@ -132,7 +131,6 @@
"libprofile_static_defaults",
],
whole_static_libs: [
- "libart-compiler",
"libart-dexlayout",
"libart-dex2oat",
],
@@ -146,7 +144,6 @@
host_supported: true,
defaults: [
"art_defaults",
- "libart-compiler_static_defaults",
"libart-dex2oat_static_defaults",
"libart-dexlayout_static_defaults",
"libart_static_defaults",
@@ -163,7 +160,6 @@
"libart-dex2oat-defaults",
],
shared_libs: [
- "libartd-compiler",
"libartd-dexlayout",
"libartd",
"libartpalette",
@@ -185,7 +181,6 @@
"libprofiled_static_defaults",
],
whole_static_libs: [
- "libartd-compiler",
"libartd-dexlayout",
"libartd-dex2oat",
],
@@ -198,7 +193,6 @@
defaults: [
"art_debug_defaults",
"libartbased_static_defaults",
- "libartd-compiler_static_defaults",
"libartd-dex2oat_static_defaults",
"libartd-dexlayout_static_defaults",
"libartd_static_defaults",
@@ -236,51 +230,19 @@
},
}
+// TODO(b/303042202): remove from vixl
cc_defaults {
name: "dex2oat-pgo-defaults",
defaults_visibility: [
"//art:__subpackages__",
"//external/vixl",
],
- pgo: {
- instrumentation: true,
- benchmarks: ["dex2oat"],
- },
- target: {
- android_arm64: {
- pgo: {
- profile_file: "art/dex2oat_arm_arm64.profdata",
- },
- },
- android_arm: {
- pgo: {
- profile_file: "art/dex2oat_arm_arm64.profdata",
- },
- },
- android_riscv64: {
- pgo: {
- enable_profile_use: false,
- profile_file: "",
- },
- },
- android_x86_64: {
- pgo: {
- profile_file: "art/dex2oat_x86_x86_64.profdata",
- },
- },
- android_x86: {
- pgo: {
- profile_file: "art/dex2oat_x86_x86_64.profdata",
- },
- },
- },
}
art_cc_binary {
name: "dex2oat",
defaults: [
"dex2oat-defaults",
- "dex2oat-pgo-defaults",
],
// Modules that do dexpreopting, e.g. android_app, depend implicitly on
// either dex2oat or dex2oatd in ART source builds.
@@ -296,20 +258,10 @@
},
symlink_preferred_arch: true,
- pgo: {
- // Additional cflags just for dex2oat during PGO instrumentation
- cflags: [
- // Ignore frame-size increase resulting from instrumentation.
- "-Wno-frame-larger-than=",
- "-DART_PGO_INSTRUMENTATION",
- ],
- },
-
target: {
android: {
shared_libs: [
"libart",
- "libart-compiler",
"libart-dexlayout",
"libartbase",
"libdexfile",
@@ -371,7 +323,6 @@
shared_libs: [
"libartbased",
"libartd",
- "libartd-compiler",
"libartd-dexlayout",
"libdexfiled",
"libprofiled",
diff --git a/dexlayout/Android.bp b/dexlayout/Android.bp
index ec7fdf6..7c69c22 100644
--- a/dexlayout/Android.bp
+++ b/dexlayout/Android.bp
@@ -71,7 +71,6 @@
name: "libart-dexlayout",
defaults: [
"libart-dexlayout-defaults",
- "dex2oat-pgo-defaults",
],
target: {
android: {
diff --git a/imgdiag/Android.bp b/imgdiag/Android.bp
index 573fea5..7d1869f 100644
--- a/imgdiag/Android.bp
+++ b/imgdiag/Android.bp
@@ -69,7 +69,6 @@
shared_libs: [
"libart",
"libartbase",
- "libart-compiler",
],
apex_available: [
"com.android.art",
@@ -86,7 +85,6 @@
shared_libs: [
"libartd",
"libartbased",
- "libartd-compiler",
"libdexfiled",
],
apex_available: [
diff --git a/oatdump/Android.bp b/oatdump/Android.bp
index dacd647..9c749a6 100644
--- a/oatdump/Android.bp
+++ b/oatdump/Android.bp
@@ -40,7 +40,6 @@
device_supported: false,
host_supported: true,
defaults: [
- "libart-compiler_static_defaults",
"libart-dexlayout_static_defaults",
"libart-disassembler_static_defaults",
"libart_static_defaults",
@@ -62,7 +61,6 @@
android: {
shared_libs: [
"libart",
- "libart-compiler",
"libart-dexlayout",
"libart-disassembler",
"libartbase",
@@ -95,7 +93,6 @@
device_supported: false,
host_supported: true,
defaults: [
- "libartd-compiler_static_defaults",
"libartd-dexlayout_static_defaults",
"libartd-disassembler_static_defaults",
"libartd_static_defaults",
@@ -121,7 +118,6 @@
shared_libs: [
"libartbased",
"libartd",
- "libartd-compiler",
"libartd-dexlayout",
"libartd-disassembler",
"libbase",
@@ -174,7 +170,6 @@
"libartbase_static_defaults",
"libdexfile_static_defaults",
"libprofile_static_defaults",
- "libart-compiler_static_defaults",
"libart-dexlayout_static_defaults",
"oatdumps-defaults",
],
@@ -192,7 +187,6 @@
"libartbased_static_defaults",
"libdexfiled_static_defaults",
"libprofiled_static_defaults",
- "libartd-compiler_static_defaults",
"libartd-dexlayout_static_defaults",
"oatdumps-defaults",
],
diff --git a/openjdkjvmti/Android.bp b/openjdkjvmti/Android.bp
index 87dd681..2e2ce19 100644
--- a/openjdkjvmti/Android.bp
+++ b/openjdkjvmti/Android.bp
@@ -114,7 +114,6 @@
defaults: ["libopenjdkjvmti_defaults"],
shared_libs: [
"libart",
- "libart-compiler",
"libdexfile",
"libartbase",
],
@@ -133,7 +132,6 @@
],
shared_libs: [
"libartd",
- "libartd-compiler",
"libdexfiled",
"libartbased",
],
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 9093c08..a786c74 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -101,10 +101,135 @@
],
}
+// Common dependencies for `libart-runtime_deps` and `libartd-runtime_deps`.
cc_defaults {
- name: "libart_defaults",
+ name: "libart-runtime_common_deps",
defaults: ["art_defaults"],
host_supported: true,
+ target: {
+ android: {
+ header_libs: [
+ "libnativeloader-headers", // For dlext_namespaces.h
+ ],
+ shared_libs: [
+ "libdl_android",
+ "libstatssocket",
+ "libz", // For adler32.
+ "heapprofd_client_api",
+ ],
+ static_libs: [
+ "libmodules-utils-build",
+ "libstatslog_art",
+ ],
+ },
+ host: {
+ shared_libs: [
+ "libz", // For adler32.
+ ],
+ },
+ },
+ header_libs: [
+ "art_cmdlineparser_headers",
+ "cpp-define-generator-definitions",
+ "jni_platform_headers",
+ "libart_headers",
+ "libnativehelper_header_only",
+ "libart_generated_headers",
+ // `libart-runtime` doesn't depend on all `libart-compiler` headers, it only requires
+ // `jit_create` to initialize the JIT compiler.
+ "libart-compiler_jit_headers",
+ ],
+ export_header_lib_headers: [
+ "libart_headers",
+ "libart_generated_headers",
+ ],
+ shared_libs: [
+ "libartpalette",
+ "libbase", // For common macros.
+ "liblog",
+ "liblz4",
+ "liblzma", // libelffile(d) dependency; must be repeated here since it's a static lib.
+ "libnativebridge",
+ "libnativeloader",
+ "libsigchain",
+ "libunwindstack",
+ ],
+ static_libs: ["libodrstatslog"],
+}
+
+cc_defaults {
+ name: "libart-runtime_deps",
+ defaults: ["libart-runtime_common_deps"],
+ static_libs: [
+ "libelffile",
+ ],
+ shared_libs: [
+ "libartbase",
+ "libdexfile",
+ "libprofile",
+ ],
+ export_shared_lib_headers: [
+ "libdexfile",
+ ],
+}
+
+cc_defaults {
+ name: "libartd-runtime_deps",
+ defaults: ["libart-runtime_common_deps"],
+ static_libs: [
+ "libelffiled",
+ ],
+ shared_libs: [
+ "libartbased",
+ "libdexfiled",
+ "libprofiled",
+ ],
+ export_shared_lib_headers: [
+ "libdexfiled",
+ ],
+}
+
+// Common defaults for `libart_defaults`, `libartd_defaults` and `libart-runtime_common_defaults`.
+cc_defaults {
+ name: "libart_common_defaults",
+ defaults: [
+ "art_defaults",
+ "libart_nativeunwind_defaults",
+ "art_hugepage_defaults",
+ ],
+ host_supported: true,
+ target: {
+ android_arm: {
+ ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
+ },
+ android_arm64: {
+ ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
+ },
+ android_x86: {
+ ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
+ },
+ android_x86_64: {
+ ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
+ },
+ },
+ runtime_libs: [
+ // Libraries loaded at runtime. Exceptions:
+ // - libart(d)-compiler.so and libopenjdk(d).so cannot be listed here
+ // due to cyclic dependency.
+ // - libicu_jni.so is only loaded to handle dependency order in VM
+ // startup (see Runtime::InitNativeMethods), but its API is internal
+ // to com.android.i18n and not used by ART/libcore. Therefore it's not
+ // listed here to avoid visibility issues. Instead it's linked from
+ // the ART module namespace through an entry in requireNativeLibs in
+ // manifest-art.json.
+ "libjavacore",
+ ],
+}
+
+// Common defaults for `libart-runtime_defaults` and `libartd-runtime_defaults`.
+cc_defaults {
+ name: "libart-runtime_common_defaults",
+ defaults: ["libart_common_defaults"],
srcs: [
"app_info.cc",
"aot_class_linker.cc",
@@ -427,37 +552,12 @@
"thread_android.cc",
"metrics/statsd.cc",
],
- header_libs: [
- "libnativeloader-headers", // For dlext_namespaces.h
- ],
- shared_libs: [
- "libdl_android",
- "libstatssocket",
- "libz", // For adler32.
- "heapprofd_client_api",
- ],
- static_libs: [
- "libmodules-utils-build",
- "libstatslog_art",
- ],
generated_sources: [
"apex-info-list-tinyxml",
"art-apex-cache-info",
],
tidy_disabled_srcs: [":art-apex-cache-info"],
},
- android_arm: {
- ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
- },
- android_arm64: {
- ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
- },
- android_x86: {
- ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
- },
- android_x86_64: {
- ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
- },
host: {
srcs: [
"monitor_linux.cc",
@@ -468,56 +568,49 @@
"-fsanitize-address-use-after-return=never",
"-Wno-unused-command-line-argument",
],
- shared_libs: [
- "libz", // For adler32.
- ],
},
},
- static: {
- cflags: ["-DART_STATIC_LIBART"],
- },
generated_sources: [
"art_operator_srcs",
],
- header_libs: [
- "art_cmdlineparser_headers",
- "cpp-define-generator-definitions",
- "jni_platform_headers",
- "libart_headers",
- "libnativehelper_header_only",
- "libart_generated_headers",
- ],
- export_header_lib_headers: [
- "libart_headers",
- "libart_generated_headers",
- ],
whole_static_libs: [
"libcpu_features",
],
- shared_libs: [
- "libartpalette",
- "libbase", // For common macros.
- "liblog",
- "liblz4",
- "liblzma", // libelffile(d) dependency; must be repeated here since it's a static lib.
- "libnativebridge",
- "libnativeloader",
- "libsigchain",
- "libunwindstack",
- ],
- static_libs: ["libodrstatslog"],
+}
- runtime_libs: [
- // Libraries loaded at runtime. Exceptions:
- // - libart(d)-compiler.so and libopenjdk(d).so cannot be listed here
- // due to cyclic dependency.
- // - libicu_jni.so is only loaded to handle dependency order in VM
- // startup (see Runtime::InitNativeMethods), but its API is internal
- // to com.android.i18n and not used by ART/libcore. Therefore it's not
- // listed here to avoid visibility issues. Instead it's linked from
- // the ART module namespace through an entry in requireNativeLibs in
- // manifest-art.json.
- "libjavacore",
+cc_defaults {
+ name: "libart-runtime_defaults",
+ defaults: [
+ "libart-runtime_common_defaults",
+ "libart-runtime_deps",
+ ],
+}
+
+cc_defaults {
+ name: "libartd-runtime_defaults",
+ defaults: [
+ "art_debug_defaults",
+ "libart-runtime_common_defaults",
+ "libartd-runtime_deps",
+ ],
+}
+
+cc_defaults {
+ name: "libart_defaults",
+ defaults: [
+ "libart_common_defaults",
+ "libart-runtime_deps",
+ "libart-compiler_deps",
+ ],
+}
+
+cc_defaults {
+ name: "libartd_defaults",
+ defaults: [
+ "art_debug_defaults",
+ "libart_common_defaults",
+ "libartd-runtime_deps",
+ "libartd-compiler_deps",
],
}
@@ -557,9 +650,10 @@
"libdexfile_static_defaults",
"libdexfile_support_static_defaults",
"libprofile_static_defaults",
+ "libart-compiler_static_defaults",
],
whole_static_libs: [
- "libart",
+ "libart-runtime",
"libelffile",
"libsigchain_fake",
"libnativeloader",
@@ -574,9 +668,10 @@
"libdexfiled_static_defaults",
"libdexfiled_support_static_defaults",
"libprofiled_static_defaults",
+ "libartd-compiler_static_defaults",
],
whole_static_libs: [
- "libartd",
+ "libartd-runtime",
"libelffiled",
"libsigchain_fake",
"libnativeloader",
@@ -585,7 +680,7 @@
// libart_static_defaults for standalone gtests.
// Doesn't link libsigchain_fake.
-// Uses libart-for-test instead of libart.
+// Uses libart-(runtime/compiler)-for-test instead of libart-runtime/compiler.
cc_defaults {
name: "libart-for-test_static_defaults",
defaults: [
@@ -594,16 +689,18 @@
"libdexfile_static_defaults",
"libdexfile_support_static_defaults",
"libprofile_static_defaults",
+ "libart-compiler-for-test_static_defaults",
],
whole_static_libs: [
- "libart-for-test",
+ "libart-runtime-for-test",
"libelffile",
],
}
// libartd_static_defaults for gtests.
// Doesn't link libsigchain_fake.
-// Note that `libartd-for-test` is not required here, because `libartd` doesn't use LTO.
+// Note that `libartd-runtime-for-test` is not required here, because `libartd-runtime`
+// doesn't use LTO.
cc_defaults {
name: "libartd-for-test_static_defaults",
defaults: [
@@ -612,9 +709,10 @@
"libdexfiled_static_defaults",
"libdexfiled_support_static_defaults",
"libprofiled_static_defaults",
+ "libartd-compiler-for-test_static_defaults",
],
whole_static_libs: [
- "libartd",
+ "libartd-runtime",
"libelffiled",
],
}
@@ -661,37 +759,62 @@
// We always build dex2oat and dependencies, even if the host build is otherwise disabled, since
// they are used to cross compile for the target.
-// Properties common to `libart` and `libart-broken`.
-art_cc_defaults {
- name: "libart_common_defaults",
- defaults: [
- "libart_defaults",
- "libart_nativeunwind_defaults",
- "art_hugepage_defaults",
- ],
- whole_static_libs: [
- ],
- static_libs: [
- "libelffile",
- ],
- shared_libs: [
- "libartbase",
- "libdexfile",
- "libprofile",
- ],
- export_shared_lib_headers: [
- "libdexfile",
- ],
-}
-
// Release version of the ART runtime library.
-art_cc_library {
- name: "libart",
- defaults: ["libart_common_defaults"],
+art_cc_library_static {
+ name: "libart-runtime",
+ defaults: ["libart-runtime_defaults"],
apex_available: [
"com.android.art",
"com.android.art.debug",
- // libart doesn't go into test_broken_com.android.art, but the libart-broken
+ // This lib doesn't go into test_broken_com.android.art, but the libart-broken
+ // needs to have the same apex_available list as its dependencies in order
+ // to compile against their sources. Then that change comes back up to affect
+ // libart as well, because it also needs to have the same apex_available as its
+ // dependencies.
+ "test_broken_com.android.art",
+ ],
+ target: {
+ android: {
+ lto: {
+ thin: true,
+ },
+ },
+ },
+}
+
+// For static linking with gtests. Same as `libart-runtime`, but without LTO.
+// When gtests static link a library with LTO enabled, they are also built with LTO.
+// This makes the build process use a lot of memory. b/277207452
+art_cc_library_static {
+ name: "libart-runtime-for-test",
+ defaults: ["libart-runtime_defaults"],
+}
+
+// Debug version of the ART runtime library.
+art_cc_library_static {
+ name: "libartd-runtime",
+ defaults: ["libartd-runtime_defaults"],
+ apex_available: [
+ "com.android.art.debug",
+ // TODO(b/183882457): This lib doesn't go into com.android.art, but
+ // apex_available lists need to be the same for internal libs to avoid
+ // stubs, and this depends on libsigchain.
+ "com.android.art",
+ ],
+}
+
+// Release version of the ART runtime library, bundled with `libart-compiler` for JIT support.
+art_cc_library {
+ name: "libart",
+ defaults: ["libart_defaults"],
+ whole_static_libs: [
+ "libart-compiler",
+ "libart-runtime",
+ ],
+ apex_available: [
+ "com.android.art.debug",
+ "com.android.art",
+ // This lib doesn't go into test_broken_com.android.art, but the libart-broken
// needs to have the same apex_available list as its dependencies in order
// to compile against their sources. Then that change comes back up to affect
// libart as well, because it also needs to have the same apex_available as its
@@ -710,11 +833,15 @@
art_cc_library {
name: "libart-unstripped",
- defaults: ["libart_common_defaults"],
+ defaults: ["libart_defaults"],
+ whole_static_libs: [
+ "libart-compiler",
+ "libart-runtime",
+ ],
apex_available: [
"com.android.art",
"com.android.art.debug",
- // libart doesn't go into test_broken_com.android.art, but the libart-broken
+ // This lib doesn't go into test_broken_com.android.art, but the libart-broken
// needs to have the same apex_available list as its dependencies in order
// to compile against their sources. Then that change comes back up to affect
// libart as well, because it also needs to have the same apex_available as its
@@ -726,13 +853,19 @@
},
}
-// "Broken" version of the ART runtime library, used only for testing.
+// "Broken" version of the libart, used only for testing.
art_cc_test_library {
name: "libart-broken",
- defaults: ["libart_common_defaults"],
+ defaults: [
+ "libart-runtime_defaults",
+ "libart_defaults",
+ ],
+ cflags: ["-DART_CRASH_RUNTIME_DELIBERATELY"],
stem: "libart",
gtest: false,
- cflags: ["-DART_CRASH_RUNTIME_DELIBERATELY"],
+ whole_static_libs: [
+ "libart-compiler",
+ ],
apex_available: [
// libart-broken only goes into test_broken_com.android.art, but the libart-broken
// needs to have the same apex_available list as its dependencies in order
@@ -743,38 +876,13 @@
],
}
-// For static linking with gtests. Same as `libart`, but without LTO.
-// When gtests static link a library with LTO enabled, they are also built with LTO.
-// This makes the build process use a lot of memory. b/277207452
-art_cc_library_static {
- name: "libart-for-test",
- defaults: ["libart_common_defaults"],
- shared_libs: [
- "libartbase",
- "libdexfile",
- "libprofile",
- ],
-}
-
-// Debug version of the ART runtime library.
+// Debug version of the ART runtime library, bundled with `libartd-compiler` for JIT support.
art_cc_library {
name: "libartd",
- defaults: [
- "art_debug_defaults",
- "libart_defaults",
- ],
+ defaults: ["libartd_defaults"],
whole_static_libs: [
- ],
- static_libs: [
- "libelffiled",
- ],
- shared_libs: [
- "libartbased",
- "libdexfiled",
- "libprofiled",
- ],
- export_shared_lib_headers: [
- "libdexfiled",
+ "libartd-compiler",
+ "libartd-runtime",
],
apex_available: [
"com.android.art.debug",
@@ -946,7 +1054,6 @@
"intern_table_test.cc",
"interpreter/safe_math_test.cc",
"interpreter/unstarted_runtime_test.cc",
- "jit/jit_load_test.cc",
"jit/jit_memory_region_test.cc",
"jit/profile_saver_test.cc",
"jit/profiling_info_test.cc",
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 968570c..c4877f5 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -38,6 +38,7 @@
#include "interpreter/interpreter.h"
#include "jit-inl.h"
#include "jit_code_cache.h"
+#include "jit_create.h"
#include "small_pattern_matcher.h"
#include "jni/java_vm_ext.h"
#include "mirror/method_handle_impl.h"
@@ -82,9 +83,7 @@
DEFINE_RUNTIME_DEBUG_FLAG(Jit, kSlowMode);
// JIT compiler
-void* Jit::jit_library_handle_ = nullptr;
JitCompilerInterface* Jit::jit_compiler_ = nullptr;
-JitCompilerInterface* (*Jit::jit_load_)(void) = nullptr;
JitOptions* JitOptions::CreateFromRuntimeArguments(const RuntimeArgumentMap& options) {
auto* jit_options = new JitOptions;
@@ -188,16 +187,8 @@
fd_methods_(-1),
fd_methods_size_(0) {}
-Jit* Jit::Create(JitCodeCache* code_cache, JitOptions* options) {
- if (jit_load_ == nullptr) {
- LOG(WARNING) << "Not creating JIT: library not loaded";
- return nullptr;
- }
- jit_compiler_ = (jit_load_)();
- if (jit_compiler_ == nullptr) {
- LOG(WARNING) << "Not creating JIT: failed to allocate a compiler";
- return nullptr;
- }
+std::unique_ptr<Jit> Jit::Create(JitCodeCache* code_cache, JitOptions* options) {
+ jit_compiler_ = jit_create();
std::unique_ptr<Jit> jit(new Jit(code_cache, options));
// If the code collector is enabled, check if that still holds:
@@ -230,42 +221,8 @@
// Notify native debugger about the classes already loaded before the creation of the jit.
jit->DumpTypeInfoForLoadedTypes(Runtime::Current()->GetClassLinker());
- return jit.release();
-}
-template <typename T>
-bool Jit::LoadSymbol(T* address, const char* name, std::string* error_msg) {
- *address = reinterpret_cast<T>(dlsym(jit_library_handle_, name));
- if (*address == nullptr) {
- *error_msg = std::string("JIT couldn't find ") + name + std::string(" entry point");
- return false;
- }
- return true;
-}
-
-#ifdef ART_STATIC_LIBART
-extern "C" JitCompilerInterface* jit_load();
-#endif
-
-bool Jit::LoadCompilerLibrary([[maybe_unused]] /*out*/ std::string* error_msg) {
-#ifdef ART_STATIC_LIBART
- jit_load_ = &jit_load;
- return true;
-#else
- jit_library_handle_ = dlopen(
- kIsDebugBuild ? "libartd-compiler.so" : "libart-compiler.so", RTLD_NOW);
- if (jit_library_handle_ == nullptr) {
- std::ostringstream oss;
- oss << "JIT could not load libart-compiler.so: " << dlerror();
- *error_msg = oss.str();
- return false;
- }
- if (!LoadSymbol(&jit_load_, "jit_load", error_msg)) {
- dlclose(jit_library_handle_);
- return false;
- }
- return true;
-#endif
+ return jit;
}
bool Jit::CompileMethodInternal(ArtMethod* method,
@@ -435,10 +392,6 @@
delete jit_compiler_;
jit_compiler_ = nullptr;
}
- if (jit_library_handle_ != nullptr) {
- dlclose(jit_library_handle_);
- jit_library_handle_ = nullptr;
- }
}
void Jit::NewTypeLoadedIfUsingJit(mirror::Class* type) {
diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h
index c95fd9d..d5fcd35 100644
--- a/runtime/jit/jit.h
+++ b/runtime/jit/jit.h
@@ -240,7 +240,7 @@
virtual ~Jit();
// Create JIT itself.
- static Jit* Create(JitCodeCache* code_cache, JitOptions* options);
+ static std::unique_ptr<Jit> Create(JitCodeCache* code_cache, JitOptions* options);
bool CompileMethod(ArtMethod* method, Thread* self, CompilationKind compilation_kind, bool prejit)
REQUIRES_SHARED(Locks::mutator_lock_);
@@ -364,9 +364,6 @@
JValue* result)
REQUIRES_SHARED(Locks::mutator_lock_);
- // Load the compiler library.
- static bool LoadCompilerLibrary(std::string* error_msg);
-
ThreadPool* GetThreadPool() const {
return thread_pool_.get();
}
@@ -475,10 +472,7 @@
REQUIRES_SHARED(Locks::mutator_lock_);
// JIT compiler
- static void* jit_library_handle_;
static JitCompilerInterface* jit_compiler_;
- static JitCompilerInterface* (*jit_load_)(void);
- template <typename T> static bool LoadSymbol(T*, const char* symbol, std::string* error_msg);
// JIT resources owned by runtime.
jit::JitCodeCache* const code_cache_;
diff --git a/runtime/jit/jit_load_test.cc b/runtime/jit/jit_load_test.cc
deleted file mode 100644
index 4b080a5..0000000
--- a/runtime/jit/jit_load_test.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "common_runtime_test.h"
-#include "compiler_callbacks.h"
-
-namespace art {
-
-class JitLoadTest : public CommonRuntimeTest {
- protected:
- void SetUpRuntimeOptions(RuntimeOptions *options) override {
- callbacks_.reset();
- CommonRuntimeTest::SetUpRuntimeOptions(options);
- options->push_back(std::make_pair("-Xusejit:true", nullptr));
- }
-};
-
-
-TEST_F(JitLoadTest, JitLoad) {
- Thread::Current()->TransitionFromSuspendedToRunnable();
- runtime_->Start();
- ASSERT_NE(runtime_->GetJit(), nullptr);
-}
-
-} // namespace art
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index b1c40ec..9c3b9de 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1055,11 +1055,6 @@
// recoding profiles. Maybe we should consider changing the name to be more clear it's
// not only about compiling. b/28295073.
if (jit_options_->UseJitCompilation() || jit_options_->GetSaveProfilingInfo()) {
- // Try to load compiler pre zygote to reduce PSS. b/27744947
- std::string error_msg;
- if (!jit::Jit::LoadCompilerLibrary(&error_msg)) {
- LOG(WARNING) << "Failed to load JIT compiler with error " << error_msg;
- }
CreateJit();
#ifdef ADDRESS_SANITIZER
// (b/238730394): In older implementations of sanitizer + glibc there is a race between
@@ -3152,15 +3147,8 @@
return;
}
- jit::Jit* jit = jit::Jit::Create(jit_code_cache_.get(), jit_options_.get());
- jit_.reset(jit);
- if (jit == nullptr) {
- LOG(WARNING) << "Failed to allocate JIT";
- // Release JIT code cache resources (several MB of memory).
- jit_code_cache_.reset();
- } else {
- jit->CreateThreadPool();
- }
+ jit_ = jit::Jit::Create(jit_code_cache_.get(), jit_options_.get());
+ jit_->CreateThreadPool();
}
bool Runtime::CanRelocate() const {
diff --git a/tools/art_verifier/Android.bp b/tools/art_verifier/Android.bp
index 19498e0..5d19215 100644
--- a/tools/art_verifier/Android.bp
+++ b/tools/art_verifier/Android.bp
@@ -59,8 +59,6 @@
defaults: [
"art_verifier-defaults",
"libart_static_defaults",
- // TODO(b/186902856): remove once libart-compiler is merged into libart
- "libart-compiler_static_defaults",
],
}
@@ -70,7 +68,5 @@
"art_debug_defaults",
"art_verifier-defaults",
"libartd_static_defaults",
- // TODO(b/186902856): remove once libart-compiler is merged into libart
- "libartd-compiler_static_defaults",
],
}
diff --git a/tools/fuzzer/Android.bp b/tools/fuzzer/Android.bp
index c3f35d2..8ac2086 100644
--- a/tools/fuzzer/Android.bp
+++ b/tools/fuzzer/Android.bp
@@ -30,8 +30,6 @@
defaults: [
// Run in release mode since debug is too slow.
"libart_static_defaults",
- // TODO(b/186902856): remove once libart-compiler is merged into libart
- "libart-compiler_static_defaults",
// To allow the ART module to build correctly.
"art_module_source_build_defaults",
],