Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/native/clr/host/assembly-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ auto AssemblyStore::open_assembly (std::string_view const& name, int64_t &size)
return assembly_data;
}

void AssemblyStore::configure_from_payload (const void *payload_start, const std::function<std::string()>& get_full_store_path) noexcept
void AssemblyStore::configure_from_payload (const void *payload_start, const char *store_path) noexcept
{
auto header = static_cast<const AssemblyStoreHeader*>(payload_start);

Expand All @@ -800,7 +800,7 @@ void AssemblyStore::configure_from_payload (const void *payload_start, const std
LOG_ASSEMBLY,
std::source_location::current (),
"Assembly store '%s' is not a valid .NET for Android assembly store file",
get_full_store_path ().c_str ()
optional_string (store_path)
);
}

Expand All @@ -809,7 +809,7 @@ void AssemblyStore::configure_from_payload (const void *payload_start, const std
LOG_ASSEMBLY,
std::source_location::current (),
"Assembly store '%s' uses format version %x, instead of the expected %x",
get_full_store_path ().c_str (),
optional_string (store_path),
header->version,
ASSEMBLY_STORE_FORMAT_VERSION
);
Expand Down Expand Up @@ -841,5 +841,5 @@ void AssemblyStore::configure_from_payload (const void *payload_start, const std
names_cursor += name_length;
}

log_debugf (LOG_ASSEMBLY, "Mapped assembly store %s; content ID 0x%" PRIx64, get_full_store_path ().c_str (), assembly_store_content_id);
log_debugf (LOG_ASSEMBLY, "Mapped assembly store %s; content ID 0x%" PRIx64, optional_string (store_path), assembly_store_content_id);
}
3 changes: 1 addition & 2 deletions src/native/clr/host/host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void Host::map_assembly_store_via_dlopen (const char *store_path) noexcept
}

log_debugf (LOG_ASSEMBLY, "Assembly store payload via dynamic symbol: %p (%s)", payload, optional_string (store_path));
AssemblyStore::configure_from_payload (payload, [store_path]() -> std::string { return std::string { store_path }; });
AssemblyStore::configure_from_payload (payload, store_path);
found_assembly_store = true;
}

Expand Down Expand Up @@ -316,7 +316,6 @@ void Host::Java_mono_android_Runtime_initInternal (
FastTiming::initialize ((Logger::log_timing_categories() & LogTimingCategories::FastBare) != LogTimingCategories::FastBare);

if (FastTiming::enabled ()) [[unlikely]] {
_timing = std::make_shared<Timing> ();
internal_timing.start_event (TimingEventKind::TotalRuntimeInit);
}

Expand Down
15 changes: 3 additions & 12 deletions src/native/clr/host/internal-pinvokes-clr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,11 @@ _monodroid_lookup_replacement_method_info (const char *jniSourceType, const char

managed_timing_sequence* monodroid_timing_start (const char *message)
{
// Technically a reference here is against the idea of shared pointers, but
// in this instance it's fine since we know we won't be storing the pointer
// and this way things are slightly faster.
std::shared_ptr<Timing> const &timing = Host::get_timing ();
if (!timing) {
if (!FastTiming::enabled ()) [[likely]] {
return nullptr;
}

managed_timing_sequence *ret = timing->get_available_sequence ();
managed_timing_sequence *ret = Host::get_timing ().get_available_sequence ();
if (message != nullptr) {
log_write (LOG_TIMING, LogLevel::Info, message);
}
Expand All @@ -64,12 +60,7 @@ void monodroid_timing_stop (managed_timing_sequence *sequence, const char *messa
return;
}

std::shared_ptr<Timing> const &timing = Host::get_timing ();
if (!timing) [[unlikely]] {
return;
}

sequence->end = FastTiming::get_time ();
Timing::info (sequence, message == nullptr ? DEFAULT_MESSAGE.data () : message);
timing->release_sequence (sequence);
Host::get_timing ().release_sequence (sequence);
}
7 changes: 3 additions & 4 deletions src/native/clr/include/host/assembly-store.hh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <cstdint>
#include <functional>
#include <limits>
#include <pthread.h>
#include <string>
Expand All @@ -19,9 +18,9 @@ namespace xamarin::android {
// Configure the store directly from an in-memory payload pointer (obtained via
// dlopen()+dlsym() of the `_assembly_store` dynamic symbol). The payload is mapped
// read-only and is never modified, so it (and every pointer derived from it) is `const`.
// `get_full_store_path` is invoked only to build diagnostics if the payload turns out
// to be invalid.
static void configure_from_payload (const void *payload_start, const std::function<std::string()>& get_full_store_path) noexcept;
// `store_path` is used only in diagnostic messages and may be `nullptr` - every use of it
// goes through `optional_string ()`.
static void configure_from_payload (const void *payload_start, const char *store_path) noexcept;

private:
static void set_assembly_data_and_size (uint8_t* source_assembly_data, uint32_t source_assembly_data_size, uint8_t*& dest_assembly_data, uint32_t& dest_assembly_data_size) noexcept;
Expand Down
7 changes: 5 additions & 2 deletions src/native/clr/include/host/host.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace xamarin::android {
static void Java_mono_android_Runtime_registerNatives (JNIEnv *env, jclass nativeClass) noexcept;
static void propagate_uncaught_exception (JNIEnv *env, jobject javaThread, jthrowable javaException) noexcept;

static auto get_timing () -> std::shared_ptr<Timing>
static auto get_timing () noexcept -> Timing&
{
return _timing;
}
Expand Down Expand Up @@ -54,7 +54,10 @@ namespace xamarin::android {
private:
static inline void *clr_host = nullptr;
static inline unsigned int domain_id = 0;
static inline std::shared_ptr<Timing> _timing{};
// Constant-initialized and live for the whole lifetime of the process, so there is
// nothing to allocate or free. Only used when fast timing is enabled, which callers
// check with `FastTiming::enabled ()`.
static inline Timing _timing {};
static inline bool found_assembly_store = false;
static inline jnienv_register_jni_natives_fn jnienv_register_jni_natives = nullptr;
static inline jnienv_propagate_uncaught_exception_fn jnienv_propagate_uncaught_exception = nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <unistd.h>

#include <array>
#include <chrono>
#include <semaphore>
#include <string_view>

Expand Down
Loading
Loading