summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Dmitrii Ishcheikin <ishcheikin@google.com> 2024-01-30 15:22:45 +0000
committer Dmitrii Ishcheikin <ishcheikin@google.com> 2024-02-06 18:58:33 +0000
commit8cd02095a2a3671a8d9aae3c36fd54a9a7d0787c (patch)
tree7b5ec7f8b1fadf5e3630dcef238f46728919c95b
parent074714261278039d6a99075d4dc71623f453a2c0 (diff)
Add visibility attributes in runtime/r*
Bug: 260881207 Test: presubmit Test: abtd app_compat_drm Test: abtd app_compat_top_100 Test: abtd app_compat_banking Change-Id: I9a12fe4d7c47090631415e813a00c2a2fdcaca62
-rw-r--r--libartbase/base/macros.h12
-rw-r--r--runtime/Android.bp3
-rw-r--r--runtime/read_barrier-inl.h2
-rw-r--r--runtime/read_barrier.cc2
-rw-r--r--runtime/read_barrier.h2
-rw-r--r--runtime/read_barrier_config.h7
-rw-r--r--runtime/read_barrier_option.h11
-rw-r--r--runtime/reference_table.cc2
-rw-r--r--runtime/reference_table.h5
-rw-r--r--runtime/reference_table_test.cc2
-rw-r--r--runtime/reflection-inl.h2
-rw-r--r--runtime/reflection.cc2
-rw-r--r--runtime/reflection.h21
-rw-r--r--runtime/reflection_test.cc2
-rw-r--r--runtime/reflective_handle.h3
-rw-r--r--runtime/reflective_handle_scope-inl.h2
-rw-r--r--runtime/reflective_handle_scope.cc2
-rw-r--r--runtime/reflective_handle_scope.h2
-rw-r--r--runtime/reflective_reference.h2
-rw-r--r--runtime/reflective_value_visitor.cc2
-rw-r--r--runtime/reflective_value_visitor.h6
-rw-r--r--runtime/runtime-inl.h2
-rw-r--r--runtime/runtime.cc4
-rw-r--r--runtime/runtime.h147
-rw-r--r--runtime/runtime_android.cc2
-rw-r--r--runtime/runtime_callbacks.cc2
-rw-r--r--runtime/runtime_callbacks.h4
-rw-r--r--runtime/runtime_callbacks_test.cc2
-rw-r--r--runtime/runtime_common.cc2
-rw-r--r--runtime/runtime_common.h3
-rw-r--r--runtime/runtime_globals.h3
-rw-r--r--runtime/runtime_image.cc2
-rw-r--r--runtime/runtime_image.h12
-rw-r--r--runtime/runtime_intrinsics.cc2
-rw-r--r--runtime/runtime_intrinsics.h5
-rw-r--r--runtime/runtime_linux.cc2
-rw-r--r--runtime/runtime_options.cc2
-rw-r--r--runtime/runtime_options.h5
-rw-r--r--runtime/runtime_stats.h4
-rw-r--r--runtime/runtime_test.cc2
40 files changed, 166 insertions, 135 deletions
diff --git a/libartbase/base/macros.h b/libartbase/base/macros.h
index ee2801825a..3b8b8ff89e 100644
--- a/libartbase/base/macros.h
+++ b/libartbase/base/macros.h
@@ -117,12 +117,24 @@ template<typename T> ART_FRIEND_TEST(test_set_name, individual_test)
// when changing the exported symbols.
#ifdef NDEBUG
#define HIDDEN __attribute__((visibility("hidden")))
+#define PROTECTED __attribute__((visibility("protected")))
#define EXPORT __attribute__((visibility("default")))
#else
#define HIDDEN
+#define PROTECTED
#define EXPORT
#endif
+// Protected symbols must be declared with "protected" visibility attribute when
+// building the library and "default" visibility when referred to from external
+// libraries/binaries. Otherwise, the external code will expect the symbol to be
+// defined locally and fail to link.
+#ifdef BUILDING_LIBART
+#define LIBART_PROTECTED PROTECTED
+#else
+#define LIBART_PROTECTED EXPORT
+#endif
+
// Some global variables shouldn't be visible outside libraries declaring them.
// The attribute allows hiding them, so preventing direct access.
#define ALWAYS_HIDDEN __attribute__((visibility("hidden")))
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 9983c24ece..d481d300a2 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -577,6 +577,9 @@ cc_defaults {
whole_static_libs: [
"libcpu_features",
],
+ cflags: [
+ "-DBUILDING_LIBART",
+ ],
}
cc_defaults {
diff --git a/runtime/read_barrier-inl.h b/runtime/read_barrier-inl.h
index 91406c620f..b3aa053131 100644
--- a/runtime/read_barrier-inl.h
+++ b/runtime/read_barrier-inl.h
@@ -28,7 +28,7 @@
#include "mirror/reference.h"
#include "runtime.h"
-namespace art {
+namespace art HIDDEN {
template <typename MirrorType, bool kIsVolatile, ReadBarrierOption kReadBarrierOption,
bool kAlwaysUpdateField>
diff --git a/runtime/read_barrier.cc b/runtime/read_barrier.cc
index 89ae91040a..db22d4694a 100644
--- a/runtime/read_barrier.cc
+++ b/runtime/read_barrier.cc
@@ -16,7 +16,7 @@
#include "read_barrier.h"
-namespace art {
+namespace art HIDDEN {
DEFINE_RUNTIME_DEBUG_FLAG(ReadBarrier, kEnableToSpaceInvariantChecks);
DEFINE_RUNTIME_DEBUG_FLAG(ReadBarrier, kEnableReadBarrierInvariantChecks);
diff --git a/runtime/read_barrier.h b/runtime/read_barrier.h
index be5a9a030a..4e53cd2d77 100644
--- a/runtime/read_barrier.h
+++ b/runtime/read_barrier.h
@@ -28,7 +28,7 @@
#include "offsets.h"
#include "read_barrier_config.h"
-namespace art {
+namespace art HIDDEN {
namespace mirror {
class Object;
template<typename MirrorType> class HeapReference;
diff --git a/runtime/read_barrier_config.h b/runtime/read_barrier_config.h
index 876e3d7d15..5a5fc05c31 100644
--- a/runtime/read_barrier_config.h
+++ b/runtime/read_barrier_config.h
@@ -53,8 +53,9 @@
#ifdef __cplusplus
#include "base/globals.h"
+#include "base/macros.h"
-namespace art {
+namespace art HIDDEN {
#ifdef USE_BAKER_READ_BARRIER
static constexpr bool kUseBakerReadBarrier = true;
@@ -86,8 +87,8 @@ constexpr bool gUseUserfaultfd = true;
constexpr bool gUseUserfaultfd = false;
#endif
#else
-extern const bool gUseReadBarrier;
-extern const bool gUseUserfaultfd;
+EXPORT extern const bool gUseReadBarrier;
+EXPORT extern const bool gUseUserfaultfd;
#endif
#endif
diff --git a/runtime/read_barrier_option.h b/runtime/read_barrier_option.h
index 36fc2d27b8..ad8297394b 100644
--- a/runtime/read_barrier_option.h
+++ b/runtime/read_barrier_option.h
@@ -16,7 +16,10 @@
#ifndef ART_RUNTIME_READ_BARRIER_OPTION_H_
#define ART_RUNTIME_READ_BARRIER_OPTION_H_
-namespace art {
+
+#include "base/macros.h"
+
+namespace art HIDDEN {
// Options for performing a read barrier or not.
//
@@ -81,9 +84,9 @@ namespace art {
//
// The superclass becomes constant during the ClassStatus::kIdx stage, so it's safe to treat it
// as constant when reading from locations that can reference only resolved classes.
-enum ReadBarrierOption {
- kWithReadBarrier, // Perform a read barrier.
- kWithoutReadBarrier, // Don't perform a read barrier.
+enum EXPORT ReadBarrierOption {
+ kWithReadBarrier, // Perform a read barrier.
+ kWithoutReadBarrier, // Don't perform a read barrier.
kWithFromSpaceBarrier, // Get the from-space address for the given to-space address. Used by CMC
};
diff --git a/runtime/reference_table.cc b/runtime/reference_table.cc
index 45f5633f3d..e777786cd9 100644
--- a/runtime/reference_table.cc
+++ b/runtime/reference_table.cc
@@ -32,7 +32,7 @@
#include "runtime-inl.h"
#include "thread.h"
-namespace art {
+namespace art HIDDEN {
using android::base::StringAppendF;
using android::base::StringPrintf;
diff --git a/runtime/reference_table.h b/runtime/reference_table.h
index b204533c36..6e559ca1f8 100644
--- a/runtime/reference_table.h
+++ b/runtime/reference_table.h
@@ -24,10 +24,11 @@
#include "base/allocator.h"
#include "base/locks.h"
+#include "base/macros.h"
#include "gc_root.h"
#include "obj_ptr.h"
-namespace art {
+namespace art HIDDEN {
namespace jni {
class LocalReferenceTable;
} // namespace jni
@@ -54,7 +55,7 @@ class ReferenceTable {
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!Locks::alloc_tracker_lock_);
- void VisitRoots(RootVisitor* visitor, const RootInfo& root_info)
+ EXPORT void VisitRoots(RootVisitor* visitor, const RootInfo& root_info)
REQUIRES_SHARED(Locks::mutator_lock_);
private:
diff --git a/runtime/reference_table_test.cc b/runtime/reference_table_test.cc
index 420543eb93..af8f4e50bc 100644
--- a/runtime/reference_table_test.cc
+++ b/runtime/reference_table_test.cc
@@ -36,7 +36,7 @@
#include "scoped_thread_state_change-inl.h"
#include "thread-current-inl.h"
-namespace art {
+namespace art HIDDEN {
using android::base::StringPrintf;
diff --git a/runtime/reflection-inl.h b/runtime/reflection-inl.h
index 8ad61f0cce..b05862bb87 100644
--- a/runtime/reflection-inl.h
+++ b/runtime/reflection-inl.h
@@ -28,7 +28,7 @@
#include "mirror/object-inl.h"
#include "obj_ptr-inl.h"
-namespace art {
+namespace art HIDDEN {
inline bool ConvertPrimitiveValueNoThrow(Primitive::Type srcType,
Primitive::Type dstType,
diff --git a/runtime/reflection.cc b/runtime/reflection.cc
index bfe9c8ff07..f368b5478a 100644
--- a/runtime/reflection.cc
+++ b/runtime/reflection.cc
@@ -36,7 +36,7 @@
#include "thread-inl.h"
#include "well_known_classes.h"
-namespace art {
+namespace art HIDDEN {
namespace {
using android::base::StringPrintf;
diff --git a/runtime/reflection.h b/runtime/reflection.h
index 13dc8e1466..552762bfb0 100644
--- a/runtime/reflection.h
+++ b/runtime/reflection.h
@@ -19,11 +19,12 @@
#include "base/enums.h"
#include "base/locks.h"
+#include "base/macros.h"
#include "dex/primitive.h"
#include "jni.h"
#include "obj_ptr.h"
-namespace art {
+namespace art HIDDEN {
namespace mirror {
class Class;
class Object;
@@ -34,19 +35,17 @@ union JValue;
class ScopedObjectAccessAlreadyRunnable;
class ShadowFrame;
-ObjPtr<mirror::Object> BoxPrimitive(Primitive::Type src_class, const JValue& value)
+EXPORT ObjPtr<mirror::Object> BoxPrimitive(Primitive::Type src_class, const JValue& value)
REQUIRES_SHARED(Locks::mutator_lock_);
-bool UnboxPrimitiveForField(ObjPtr<mirror::Object> o,
- ObjPtr<mirror::Class> dst_class,
- ArtField* f,
- JValue* unboxed_value)
- REQUIRES_SHARED(Locks::mutator_lock_);
+EXPORT bool UnboxPrimitiveForField(ObjPtr<mirror::Object> o,
+ ObjPtr<mirror::Class> dst_class,
+ ArtField* f,
+ JValue* unboxed_value) REQUIRES_SHARED(Locks::mutator_lock_);
-bool UnboxPrimitiveForResult(ObjPtr<mirror::Object> o,
- ObjPtr<mirror::Class> dst_class,
- JValue* unboxed_value)
- REQUIRES_SHARED(Locks::mutator_lock_);
+EXPORT bool UnboxPrimitiveForResult(ObjPtr<mirror::Object> o,
+ ObjPtr<mirror::Class> dst_class,
+ JValue* unboxed_value) REQUIRES_SHARED(Locks::mutator_lock_);
ALWAYS_INLINE bool ConvertPrimitiveValueNoThrow(Primitive::Type src_class,
Primitive::Type dst_class,
diff --git a/runtime/reflection_test.cc b/runtime/reflection_test.cc
index 4a24d2aab6..d6b58c0954 100644
--- a/runtime/reflection_test.cc
+++ b/runtime/reflection_test.cc
@@ -29,7 +29,7 @@
#include "nativehelper/scoped_local_ref.h"
#include "scoped_thread_state_change-inl.h"
-namespace art {
+namespace art HIDDEN {
class ReflectionTest : public CommonRuntimeTest {
protected:
diff --git a/runtime/reflective_handle.h b/runtime/reflective_handle.h
index c2dbf535b7..15abef9c8e 100644
--- a/runtime/reflective_handle.h
+++ b/runtime/reflective_handle.h
@@ -17,10 +17,11 @@
#ifndef ART_RUNTIME_REFLECTIVE_HANDLE_H_
#define ART_RUNTIME_REFLECTIVE_HANDLE_H_
+#include "base/macros.h"
#include "base/value_object.h"
#include "reflective_reference.h"
-namespace art {
+namespace art HIDDEN {
// This is a holder similar to Handle<T> that is used to hold reflective references to ArtField and
// ArtMethod structures. A reflective reference is one that must be updated if the underlying class
diff --git a/runtime/reflective_handle_scope-inl.h b/runtime/reflective_handle_scope-inl.h
index 64ea9f921a..2ffa73d9a2 100644
--- a/runtime/reflective_handle_scope-inl.h
+++ b/runtime/reflective_handle_scope-inl.h
@@ -23,7 +23,7 @@
#include "reflective_handle_scope.h"
#include "thread-current-inl.h"
-namespace art {
+namespace art HIDDEN {
template <size_t kNumFields, size_t kNumMethods>
StackReflectiveHandleScope<kNumFields, kNumMethods>::StackReflectiveHandleScope(Thread* self) : field_pos_(0), method_pos_(0) {
diff --git a/runtime/reflective_handle_scope.cc b/runtime/reflective_handle_scope.cc
index 2c3ae5e6c5..c340ec34b4 100644
--- a/runtime/reflective_handle_scope.cc
+++ b/runtime/reflective_handle_scope.cc
@@ -20,7 +20,7 @@
#include "thread.h"
-namespace art {
+namespace art HIDDEN {
void BaseReflectiveHandleScope::Describe(std::ostream& os) const {
diff --git a/runtime/reflective_handle_scope.h b/runtime/reflective_handle_scope.h
index 46cff8bce7..1f10521144 100644
--- a/runtime/reflective_handle_scope.h
+++ b/runtime/reflective_handle_scope.h
@@ -34,7 +34,7 @@
#include "reflective_reference.h"
#include "reflective_value_visitor.h"
-namespace art {
+namespace art HIDDEN {
class ArtField;
class ArtMethod;
diff --git a/runtime/reflective_reference.h b/runtime/reflective_reference.h
index f57c0301bc..ef1ff2e613 100644
--- a/runtime/reflective_reference.h
+++ b/runtime/reflective_reference.h
@@ -21,7 +21,7 @@
#include "base/macros.h"
#include "mirror/object_reference.h"
-namespace art {
+namespace art HIDDEN {
class ArtField;
class ArtMethod;
diff --git a/runtime/reflective_value_visitor.cc b/runtime/reflective_value_visitor.cc
index 5a288d38be..04e1af0fdb 100644
--- a/runtime/reflective_value_visitor.cc
+++ b/runtime/reflective_value_visitor.cc
@@ -22,7 +22,7 @@
#include "mirror/class.h"
#include "mirror/object-inl.h"
-namespace art {
+namespace art HIDDEN {
void HeapReflectiveSourceInfo::Describe(std::ostream& os) const {
Locks::mutator_lock_->AssertExclusiveHeld(Thread::Current());
diff --git a/runtime/reflective_value_visitor.h b/runtime/reflective_value_visitor.h
index 87c5fe7f91..db8fba6791 100644
--- a/runtime/reflective_value_visitor.h
+++ b/runtime/reflective_value_visitor.h
@@ -35,7 +35,7 @@
#include "mirror/dex_cache.h"
#include "obj_ptr.h"
-namespace art {
+namespace art HIDDEN {
class ArtField;
class ArtMethod;
@@ -98,7 +98,7 @@ enum ReflectionSourceType {
kSourceDexCacheResolvedField,
kSourceMiscInternal,
};
-std::ostream& operator<<(std::ostream& os, ReflectionSourceType type);
+EXPORT std::ostream& operator<<(std::ostream& os, ReflectionSourceType type);
class ReflectionSourceInfo : public ValueObject {
public:
@@ -123,7 +123,7 @@ inline std::ostream& operator<<(std::ostream& os, const ReflectionSourceInfo& in
return os;
}
-class ReflectiveHandleScopeSourceInfo : public ReflectionSourceInfo {
+class EXPORT ReflectiveHandleScopeSourceInfo : public ReflectionSourceInfo {
public:
explicit ReflectiveHandleScopeSourceInfo(BaseReflectiveHandleScope* source)
: ReflectionSourceInfo(kSourceThreadHandleScope), source_(source) {}
diff --git a/runtime/runtime-inl.h b/runtime/runtime-inl.h
index 0daa7769ed..f90dcd1d30 100644
--- a/runtime/runtime-inl.h
+++ b/runtime/runtime-inl.h
@@ -29,7 +29,7 @@
#include "obj_ptr-inl.h"
#include "thread_list.h"
-namespace art {
+namespace art HIDDEN {
inline bool Runtime::IsClearedJniWeakGlobal(ObjPtr<mirror::Object> obj) {
return obj == GetClearedJniWeakGlobal();
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 77a1130be8..e6f8c576dc 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -195,7 +195,7 @@ namespace apex = com::android::apex;
#include "asm_defines.def"
#undef ASM_DEFINE
-namespace art {
+namespace art HIDDEN {
// If a signal isn't handled properly, enable a handler that attempts to dump the Java stack.
static constexpr bool kEnableJavaStackTraceHandler = false;
@@ -234,7 +234,7 @@ inline char** GetEnviron() {
#else
// Some POSIX platforms expect you to declare environ. extern "C" makes
// it reside in the global namespace.
-extern "C" char** environ;
+EXPORT extern "C" char** environ;
inline char** GetEnviron() { return environ; }
#endif
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 9e815693bd..1a1c28bff5 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -54,7 +54,7 @@
#include "reflective_value_visitor.h"
#include "runtime_stats.h"
-namespace art {
+namespace art HIDDEN {
namespace gc {
class AbstractSystemWeakHolder;
@@ -127,16 +127,16 @@ using RuntimeOptions = std::vector<std::pair<std::string, const void*>>;
class Runtime {
public:
// Parse raw runtime options.
- static bool ParseOptions(const RuntimeOptions& raw_options,
- bool ignore_unrecognized,
- RuntimeArgumentMap* runtime_options);
+ EXPORT static bool ParseOptions(const RuntimeOptions& raw_options,
+ bool ignore_unrecognized,
+ RuntimeArgumentMap* runtime_options);
// Creates and initializes a new runtime.
- static bool Create(RuntimeArgumentMap&& runtime_options)
+ EXPORT static bool Create(RuntimeArgumentMap&& runtime_options)
SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_);
// Creates and initializes a new runtime.
- static bool Create(const RuntimeOptions& raw_options, bool ignore_unrecognized)
+ EXPORT static bool Create(const RuntimeOptions& raw_options, bool ignore_unrecognized)
SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_);
enum class RuntimeDebugState {
@@ -245,7 +245,7 @@ class Runtime {
// Starts a runtime, which may cause threads to be started and code to run.
bool Start() UNLOCK_FUNCTION(Locks::mutator_lock_);
- bool IsShuttingDown(Thread* self);
+ EXPORT bool IsShuttingDown(Thread* self);
bool IsShuttingDownLocked() const REQUIRES(Locks::runtime_shutdown_lock_) {
return shutting_down_.load(std::memory_order_relaxed);
}
@@ -264,7 +264,7 @@ class Runtime {
threads_being_born_++;
}
- void EndThreadBirth() REQUIRES(Locks::runtime_shutdown_lock_);
+ EXPORT void EndThreadBirth() REQUIRES(Locks::runtime_shutdown_lock_);
bool IsStarted() const {
return started_;
@@ -274,7 +274,7 @@ class Runtime {
return finished_starting_;
}
- void RunRootClinits(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
+ EXPORT void RunRootClinits(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
static Runtime* Current() {
return instance_;
@@ -293,25 +293,25 @@ class Runtime {
// Aborts semi-cleanly. Used in the implementation of LOG(FATAL), which most
// callers should prefer.
- NO_RETURN static void Abort(const char* msg) REQUIRES(!Locks::abort_lock_);
+ NO_RETURN EXPORT static void Abort(const char* msg) REQUIRES(!Locks::abort_lock_);
// Returns the "main" ThreadGroup, used when attaching user threads.
jobject GetMainThreadGroup() const;
// Returns the "system" ThreadGroup, used when attaching our internal threads.
- jobject GetSystemThreadGroup() const;
+ EXPORT jobject GetSystemThreadGroup() const;
// Returns the system ClassLoader which represents the CLASSPATH.
- jobject GetSystemClassLoader() const;
+ EXPORT jobject GetSystemClassLoader() const;
// Attaches the calling native thread to the runtime.
- bool AttachCurrentThread(const char* thread_name,
- bool as_daemon,
- jobject thread_group,
- bool create_peer,
- bool should_run_callbacks = true);
+ EXPORT bool AttachCurrentThread(const char* thread_name,
+ bool as_daemon,
+ jobject thread_group,
+ bool create_peer,
+ bool should_run_callbacks = true);
- void CallExitHook(jint status);
+ EXPORT void CallExitHook(jint status);
// Detaches the current native thread from the runtime.
void DetachCurrentThread(bool should_run_callbacks = true) REQUIRES(!Locks::mutator_lock_);
@@ -323,7 +323,7 @@ class Runtime {
void DumpForSigQuit(std::ostream& os);
void DumpLockHolders(std::ostream& os);
- ~Runtime();
+ EXPORT ~Runtime();
const std::vector<std::string>& GetBootClassPath() const {
return boot_class_path_;
@@ -336,26 +336,27 @@ class Runtime {
}
// Dynamically adds an element to boot class path.
- void AppendToBootClassPath(const std::string& filename,
- const std::string& location,
- const std::vector<std::unique_ptr<const art::DexFile>>& dex_files);
+ EXPORT void AppendToBootClassPath(
+ const std::string& filename,
+ const std::string& location,
+ const std::vector<std::unique_ptr<const art::DexFile>>& dex_files);
// Same as above, but takes raw pointers.
- void AppendToBootClassPath(const std::string& filename,
- const std::string& location,
- const std::vector<const art::DexFile*>& dex_files);
+ EXPORT void AppendToBootClassPath(const std::string& filename,
+ const std::string& location,
+ const std::vector<const art::DexFile*>& dex_files);
// Same as above, but also takes a dex cache for each dex file.
- void AppendToBootClassPath(
+ EXPORT void AppendToBootClassPath(
const std::string& filename,
const std::string& location,
const std::vector<std::pair<const art::DexFile*, ObjPtr<mirror::DexCache>>>&
dex_files_and_cache);
// Dynamically adds an element to boot class path and takes ownership of the dex files.
- void AddExtraBootDexFiles(const std::string& filename,
- const std::string& location,
- std::vector<std::unique_ptr<const art::DexFile>>&& dex_files);
+ EXPORT void AddExtraBootDexFiles(const std::string& filename,
+ const std::string& location,
+ std::vector<std::unique_ptr<const art::DexFile>>&& dex_files);
ArrayRef<File> GetBootClassPathFiles() { return ArrayRef<File>(boot_class_path_files_); }
@@ -428,14 +429,14 @@ class Runtime {
// Get the special object used to mark a cleared JNI weak global.
mirror::Object* GetClearedJniWeakGlobal() REQUIRES_SHARED(Locks::mutator_lock_);
- mirror::Throwable* GetPreAllocatedOutOfMemoryErrorWhenThrowingException()
+ EXPORT mirror::Throwable* GetPreAllocatedOutOfMemoryErrorWhenThrowingException()
REQUIRES_SHARED(Locks::mutator_lock_);
- mirror::Throwable* GetPreAllocatedOutOfMemoryErrorWhenThrowingOOME()
+ EXPORT mirror::Throwable* GetPreAllocatedOutOfMemoryErrorWhenThrowingOOME()
REQUIRES_SHARED(Locks::mutator_lock_);
- mirror::Throwable* GetPreAllocatedOutOfMemoryErrorWhenHandlingStackOverflow()
+ EXPORT mirror::Throwable* GetPreAllocatedOutOfMemoryErrorWhenHandlingStackOverflow()
REQUIRES_SHARED(Locks::mutator_lock_);
- mirror::Throwable* GetPreAllocatedNoClassDefFoundError()
+ EXPORT mirror::Throwable* GetPreAllocatedNoClassDefFoundError()
REQUIRES_SHARED(Locks::mutator_lock_);
const std::vector<std::string>& GetProperties() const {
@@ -463,13 +464,13 @@ class Runtime {
// Visit all the roots. If only_dirty is true then non-dirty roots won't be visited. If
// clean_dirty is true then dirty roots will be marked as non-dirty after visiting.
- void VisitRoots(RootVisitor* visitor, VisitRootFlags flags = kVisitRootFlagAllRoots)
+ EXPORT void VisitRoots(RootVisitor* visitor, VisitRootFlags flags = kVisitRootFlagAllRoots)
REQUIRES(!Locks::classlinker_classes_lock_, !Locks::trace_lock_)
REQUIRES_SHARED(Locks::mutator_lock_);
// Visit image roots, only used for hprof since the GC uses the image space mod union table
// instead.
- void VisitImageRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
+ EXPORT void VisitImageRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
// Visit all of the roots we can safely visit concurrently.
void VisitConcurrentRoots(RootVisitor* visitor,
@@ -486,11 +487,12 @@ class Runtime {
// Sweep system weaks, the system weak is deleted if the visitor return null. Otherwise, the
// system weak is updated to be the visitor's returned value.
- void SweepSystemWeaks(IsMarkedVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
+ EXPORT void SweepSystemWeaks(IsMarkedVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
// Walk all reflective objects and visit their targets as well as any method/fields held by the
// runtime threads that are marked as being reflective.
- void VisitReflectiveTargets(ReflectiveValueVisitor* visitor) REQUIRES(Locks::mutator_lock_);
+ EXPORT void VisitReflectiveTargets(ReflectiveValueVisitor* visitor)
+ REQUIRES(Locks::mutator_lock_);
// Helper for visiting reflective targets with lambdas for both field and method reflective
// targets.
template <typename FieldVis, typename MethodVis>
@@ -561,13 +563,13 @@ class Runtime {
return instruction_set_;
}
- void SetInstructionSet(InstructionSet instruction_set);
+ EXPORT void SetInstructionSet(InstructionSet instruction_set);
void ClearInstructionSet();
- void SetCalleeSaveMethod(ArtMethod* method, CalleeSaveType type);
+ EXPORT void SetCalleeSaveMethod(ArtMethod* method, CalleeSaveType type);
void ClearCalleeSaveMethods();
- ArtMethod* CreateCalleeSaveMethod() REQUIRES_SHARED(Locks::mutator_lock_);
+ EXPORT ArtMethod* CreateCalleeSaveMethod() REQUIRES_SHARED(Locks::mutator_lock_);
uint64_t GetStat(int kind);
@@ -598,7 +600,7 @@ class Runtime {
}
// Returns true if JIT compilations are enabled. GetJit() will be not null in this case.
- bool UseJitCompilation() const;
+ EXPORT bool UseJitCompilation() const;
void PreZygoteFork();
void PostZygoteFork();
@@ -625,11 +627,12 @@ class Runtime {
int32_t code_type);
// Transaction support.
- bool IsActiveTransaction() const;
+ EXPORT bool IsActiveTransaction() const;
// EnterTransactionMode may suspend.
- void EnterTransactionMode(bool strict, mirror::Class* root) REQUIRES_SHARED(Locks::mutator_lock_);
- void ExitTransactionMode();
- void RollbackAllTransactions() REQUIRES_SHARED(Locks::mutator_lock_);
+ EXPORT void EnterTransactionMode(bool strict, mirror::Class* root)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+ EXPORT void ExitTransactionMode();
+ EXPORT void RollbackAllTransactions() REQUIRES_SHARED(Locks::mutator_lock_);
// Transaction rollback and exit transaction are always done together, it's convenience to
// do them in one function.
void RollbackAndExitTransactionMode() REQUIRES_SHARED(Locks::mutator_lock_);
@@ -659,20 +662,19 @@ class Runtime {
MemberOffset field_offset,
int16_t value,
bool is_volatile);
- void RecordWriteField32(mirror::Object* obj,
- MemberOffset field_offset,
- uint32_t value,
- bool is_volatile);
+ EXPORT void RecordWriteField32(mirror::Object* obj,
+ MemberOffset field_offset,
+ uint32_t value,
+ bool is_volatile);
void RecordWriteField64(mirror::Object* obj,
MemberOffset field_offset,
uint64_t value,
bool is_volatile);
- void RecordWriteFieldReference(mirror::Object* obj,
- MemberOffset field_offset,
- ObjPtr<mirror::Object> value,
- bool is_volatile)
- REQUIRES_SHARED(Locks::mutator_lock_);
- void RecordWriteArray(mirror::Array* array, size_t index, uint64_t value)
+ EXPORT void RecordWriteFieldReference(mirror::Object* obj,
+ MemberOffset field_offset,
+ ObjPtr<mirror::Object> value,
+ bool is_volatile) REQUIRES_SHARED(Locks::mutator_lock_);
+ EXPORT void RecordWriteArray(mirror::Array* array, size_t index, uint64_t value)
REQUIRES_SHARED(Locks::mutator_lock_);
void RecordStrongStringInsertion(ObjPtr<mirror::String> s)
REQUIRES(Locks::intern_table_lock_);
@@ -705,7 +707,7 @@ class Runtime {
void DisableVerifier();
bool IsVerificationEnabled() const;
- bool IsVerificationSoftFail() const;
+ EXPORT bool IsVerificationSoftFail() const;
void SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy policy) {
hidden_api_policy_ = policy;
@@ -825,7 +827,7 @@ class Runtime {
return jit_arena_pool_.get();
}
- void ReclaimArenaPoolMemory();
+ EXPORT void ReclaimArenaPoolMemory();
LinearAlloc* GetLinearAlloc() {
return linear_alloc_.get();
@@ -864,10 +866,10 @@ class Runtime {
return is_profileable_;
}
- void SetRuntimeDebugState(RuntimeDebugState state);
+ EXPORT void SetRuntimeDebugState(RuntimeDebugState state);
// Deoptimize the boot image, called for Java debuggable apps.
- void DeoptimizeBootImage() REQUIRES(Locks::mutator_lock_);
+ EXPORT void DeoptimizeBootImage() REQUIRES(Locks::mutator_lock_);
bool IsNativeDebuggable() const {
return is_native_debuggable_;
@@ -904,8 +906,7 @@ class Runtime {
void SetSentinel(ObjPtr<mirror::Object> sentinel) REQUIRES_SHARED(Locks::mutator_lock_);
// For testing purpose only.
// TODO: Remove this when this is no longer needed (b/116087961).
- GcRoot<mirror::Object> GetSentinel() REQUIRES_SHARED(Locks::mutator_lock_);
-
+ EXPORT GcRoot<mirror::Object> GetSentinel() REQUIRES_SHARED(Locks::mutator_lock_);
// Use a sentinel for marking entries in a table that have been cleared.
// This helps diagnosing in case code tries to wrongly access such
@@ -915,7 +916,7 @@ class Runtime {
}
// Create a normal LinearAlloc or low 4gb version if we are 64 bit AOT compiler.
- LinearAlloc* CreateLinearAlloc();
+ EXPORT LinearAlloc* CreateLinearAlloc();
// Setup linear-alloc allocators to stop using the current arena so that the
// next allocations, which would be after zygote fork, happens in userfaultfd
// visited space.
@@ -942,7 +943,7 @@ class Runtime {
return dump_native_stack_on_sig_quit_;
}
- void UpdateProcessState(ProcessState process_state);
+ EXPORT void UpdateProcessState(ProcessState process_state);
// Returns true if we currently care about long mutator pause.
bool InJankPerceptibleProcessState() const {
@@ -961,7 +962,7 @@ class Runtime {
// Returns if the code can be deoptimized asynchronously. Code may be compiled with some
// optimization that makes it impossible to deoptimize.
- bool IsAsyncDeoptimizeable(ArtMethod* method, uintptr_t code) const
+ EXPORT bool IsAsyncDeoptimizeable(ArtMethod* method, uintptr_t code) const
REQUIRES_SHARED(Locks::mutator_lock_);
// Returns a saved copy of the environment (getenv/setenv values).
@@ -970,16 +971,16 @@ class Runtime {
return env_snapshot_.GetSnapshot();
}
- void AddSystemWeakHolder(gc::AbstractSystemWeakHolder* holder);
- void RemoveSystemWeakHolder(gc::AbstractSystemWeakHolder* holder);
+ EXPORT void AddSystemWeakHolder(gc::AbstractSystemWeakHolder* holder);
+ EXPORT void RemoveSystemWeakHolder(gc::AbstractSystemWeakHolder* holder);
- void AttachAgent(JNIEnv* env, const std::string& agent_arg, jobject class_loader);
+ EXPORT void AttachAgent(JNIEnv* env, const std::string& agent_arg, jobject class_loader);
const std::list<std::unique_ptr<ti::Agent>>& GetAgents() const {
return agents_;
}
- RuntimeCallbacks* GetRuntimeCallbacks();
+ EXPORT RuntimeCallbacks* GetRuntimeCallbacks();
bool HasLoadedPlugins() const {
return !plugins_.empty();
@@ -1042,7 +1043,7 @@ class Runtime {
// Changes the JniIdType to the given type. Only allowed if CanSetJniIdType(). All threads must be
// suspended to call this function.
- void SetJniIdType(JniIdType t);
+ EXPORT void SetJniIdType(JniIdType t);
uint32_t GetVerifierLoggingThresholdMs() const {
return verifier_logging_threshold_ms_;
@@ -1084,7 +1085,7 @@ class Runtime {
// Reset the startup completed status so that we can call NotifyStartupCompleted again. Should
// only be used for testing.
- void ResetStartupCompleted();
+ EXPORT void ResetStartupCompleted();
// Notify the runtime that application startup is considered completed. Only has effect for the
// first call. Returns whether this was the first call.
@@ -1095,7 +1096,7 @@ class Runtime {
void NotifyDexFileLoaded();
// Return true if startup is already completed.
- bool GetStartupCompleted() const;
+ EXPORT bool GetStartupCompleted() const;
bool IsVerifierMissingKThrowFatal() const {
return verifier_missing_kthrow_fatal_;
@@ -1233,8 +1234,10 @@ class Runtime {
void AppendToBootClassPath(const std::string& filename, const std::string& location);
+ // Don't use EXPORT ("default" visibility), because quick_entrypoints_x86.o
+ // refers to this symbol and it can't link with R_386_PC32 relocation.
// A pointer to the active runtime or null.
- static Runtime* instance_;
+ LIBART_PROTECTED static Runtime* instance_;
// NOTE: these must match the gc::ProcessState values as they come directly from the framework.
static constexpr int kProfileForground = 0;
diff --git a/runtime/runtime_android.cc b/runtime/runtime_android.cc
index 55ba293f52..043a833ccf 100644
--- a/runtime/runtime_android.cc
+++ b/runtime/runtime_android.cc
@@ -22,7 +22,7 @@
#include "runtime_common.h"
-namespace art {
+namespace art HIDDEN {
struct sigaction old_action;
diff --git a/runtime/runtime_callbacks.cc b/runtime/runtime_callbacks.cc
index 28c81a22c7..aad943020d 100644
--- a/runtime/runtime_callbacks.cc
+++ b/runtime/runtime_callbacks.cc
@@ -25,7 +25,7 @@
#include "monitor.h"
#include "thread-current-inl.h"
-namespace art {
+namespace art HIDDEN {
RuntimeCallbacks::RuntimeCallbacks()
: callback_lock_(new ReaderWriterMutex("Runtime callbacks lock",
diff --git a/runtime/runtime_callbacks.h b/runtime/runtime_callbacks.h
index 98584a8587..9d7e199bfa 100644
--- a/runtime/runtime_callbacks.h
+++ b/runtime/runtime_callbacks.h
@@ -24,7 +24,7 @@
#include "base/macros.h"
#include "handle.h"
-namespace art {
+namespace art HIDDEN {
namespace dex {
struct ClassDef;
@@ -158,7 +158,7 @@ class ReflectiveValueVisitCallback {
REQUIRES(Locks::mutator_lock_) = 0;
};
-class RuntimeCallbacks {
+class EXPORT RuntimeCallbacks {
public:
RuntimeCallbacks();
diff --git a/runtime/runtime_callbacks_test.cc b/runtime/runtime_callbacks_test.cc
index e08d919c34..719cae5e3c 100644
--- a/runtime/runtime_callbacks_test.cc
+++ b/runtime/runtime_callbacks_test.cc
@@ -46,7 +46,7 @@
#include "thread_list.h"
#include "well_known_classes-inl.h"
-namespace art {
+namespace art HIDDEN {
class RuntimeCallbacksTest : public CommonRuntimeTest {
protected:
diff --git a/runtime/runtime_common.cc b/runtime/runtime_common.cc
index c4a695f362..bc4d60564f 100644
--- a/runtime/runtime_common.cc
+++ b/runtime/runtime_common.cc
@@ -36,7 +36,7 @@
#include "thread-current-inl.h"
#include "thread_list.h"
-namespace art {
+namespace art HIDDEN {
using android::base::StringPrintf;
diff --git a/runtime/runtime_common.h b/runtime/runtime_common.h
index ec08907dae..803b1aa239 100644
--- a/runtime/runtime_common.h
+++ b/runtime/runtime_common.h
@@ -31,10 +31,11 @@
#include <iomanip>
#include "base/dumpable.h"
+#include "base/macros.h"
#include "base/utils.h"
#include "native_stack_dump.h"
-namespace art {
+namespace art HIDDEN {
struct Backtrace {
public:
diff --git a/runtime/runtime_globals.h b/runtime/runtime_globals.h
index 46d355ad0d..dc69063b97 100644
--- a/runtime/runtime_globals.h
+++ b/runtime/runtime_globals.h
@@ -21,8 +21,9 @@
#include "base/bit_utils.h"
#include "base/globals.h"
+#include "base/macros.h"
-namespace art {
+namespace art HIDDEN {
// Size of Dex virtual registers.
static constexpr size_t kVRegSize = 4;
diff --git a/runtime/runtime_image.cc b/runtime/runtime_image.cc
index cae4ef8015..0c85261829 100644
--- a/runtime/runtime_image.cc
+++ b/runtime/runtime_image.cc
@@ -51,7 +51,7 @@
#include "scoped_thread_state_change-inl.h"
#include "vdex_file.h"
-namespace art {
+namespace art HIDDEN {
using android::base::StringPrintf;
diff --git a/runtime/runtime_image.h b/runtime/runtime_image.h
index cea72a2479..1def1bab82 100644
--- a/runtime/runtime_image.h
+++ b/runtime/runtime_image.h
@@ -19,7 +19,9 @@
#include <string>
-namespace art {
+#include "base/macros.h"
+
+namespace art HIDDEN {
class RuntimeImage {
public:
@@ -30,9 +32,9 @@ class RuntimeImage {
//
// If any of the arguments is a valid glob (a pattern that contains '**' or those documented in
// glob(7)), returns a valid glob.
- static std::string GetRuntimeImagePath(const std::string& app_data_dir,
- const std::string& dex_location,
- const std::string& isa);
+ EXPORT static std::string GetRuntimeImagePath(const std::string& app_data_dir,
+ const std::string& dex_location,
+ const std::string& isa);
// Same as above, but takes data dir and ISA from the runtime.
static std::string GetRuntimeImagePath(const std::string& dex_location);
@@ -42,7 +44,7 @@ class RuntimeImage {
//
// If the argument is a valid glob (a pattern that contains '**' or those documented in glob(7)),
// returns a valid glob.
- static std::string GetRuntimeImageDir(const std::string& app_data_dir);
+ EXPORT static std::string GetRuntimeImageDir(const std::string& app_data_dir);
};
} // namespace art
diff --git a/runtime/runtime_intrinsics.cc b/runtime/runtime_intrinsics.cc
index 0f4fce1d68..40e6ace958 100644
--- a/runtime/runtime_intrinsics.cc
+++ b/runtime/runtime_intrinsics.cc
@@ -26,7 +26,7 @@
#include "scoped_thread_state_change-inl.h"
#include "thread.h"
-namespace art {
+namespace art HIDDEN {
namespace {
diff --git a/runtime/runtime_intrinsics.h b/runtime/runtime_intrinsics.h
index bf2cb2b500..d1b7d089f4 100644
--- a/runtime/runtime_intrinsics.h
+++ b/runtime/runtime_intrinsics.h
@@ -18,10 +18,11 @@
#define ART_RUNTIME_RUNTIME_INTRINSICS_H_
#include "base/locks.h"
+#include "base/macros.h"
-namespace art {
+namespace art HIDDEN {
-void InitializeIntrinsics() REQUIRES_SHARED(Locks::mutator_lock_);
+EXPORT void InitializeIntrinsics() REQUIRES_SHARED(Locks::mutator_lock_);
} // namespace art
diff --git a/runtime/runtime_linux.cc b/runtime/runtime_linux.cc
index cfa8ea6342..8c65ac8e62 100644
--- a/runtime/runtime_linux.cc
+++ b/runtime/runtime_linux.cc
@@ -23,7 +23,7 @@
#include "base/memory_tool.h"
#include "runtime_common.h"
-namespace art {
+namespace art HIDDEN {
void HandleUnexpectedSignalLinux(int signal_number, siginfo_t* info, void* raw_context) {
// Linux is mainly used for host testing. Under those conditions, react to the timeout signal,
diff --git a/runtime/runtime_options.cc b/runtime/runtime_options.cc
index e21587ad1b..a4ea859bda 100644
--- a/runtime/runtime_options.cc
+++ b/runtime/runtime_options.cc
@@ -28,7 +28,7 @@
#include "thread_list.h"
#include "trace.h"
-namespace art {
+namespace art HIDDEN {
// Specify storage for the RuntimeOptions keys.
diff --git a/runtime/runtime_options.h b/runtime/runtime_options.h
index 8fec9ea66f..6ece459dad 100644
--- a/runtime/runtime_options.h
+++ b/runtime/runtime_options.h
@@ -23,6 +23,7 @@
#include <vector>
#include "arch/instruction_set.h"
+#include "base/macros.h"
#include "base/variant_map.h"
#include "cmdline_types.h" // TODO: don't need to include this file here
#include "gc/collector_type.h"
@@ -33,7 +34,7 @@
#include "jit/profile_saver_options.h"
#include "verifier/verifier_enums.h"
-namespace art {
+namespace art HIDDEN {
class CompilerCallbacks;
class DexFile;
@@ -61,7 +62,7 @@ struct RuntimeArgumentMapKey : VariantMapKey<TValue> {
// map.Set(RuntimeArgumentMap::HeapTargetUtilization, 5.0);
// double *target_utilization = map.Get(RuntimeArgumentMap);
//
-struct RuntimeArgumentMap : VariantMap<RuntimeArgumentMap, RuntimeArgumentMapKey> {
+struct EXPORT RuntimeArgumentMap : VariantMap<RuntimeArgumentMap, RuntimeArgumentMapKey> {
// This 'using' line is necessary to inherit the variadic constructor.
using VariantMap<RuntimeArgumentMap, RuntimeArgumentMapKey>::VariantMap;
diff --git a/runtime/runtime_stats.h b/runtime/runtime_stats.h
index 6ed7fd50b5..0a71b61a32 100644
--- a/runtime/runtime_stats.h
+++ b/runtime/runtime_stats.h
@@ -19,7 +19,9 @@
#include <stdint.h>
-namespace art {
+#include "base/macros.h"
+
+namespace art HIDDEN {
// These must match the values in dalvik.system.VMDebug.
enum StatKinds {
diff --git a/runtime/runtime_test.cc b/runtime/runtime_test.cc
index 3fe281bd5f..210ad7d711 100644
--- a/runtime/runtime_test.cc
+++ b/runtime/runtime_test.cc
@@ -24,7 +24,7 @@
#include "runtime.h"
#include "thread-current-inl.h"
-namespace art {
+namespace art HIDDEN {
class RuntimeTest : public CommonRuntimeTest {};