Skip to content
Merged
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
3 changes: 0 additions & 3 deletions src/Mono.Android/Android.Runtime/RuntimeNativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ enum TraceKind : uint

internal static class RuntimeNativeMethods
{
[DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)]
internal extern static void monodroid_log_traces (TraceKind kind, string first_line);

[DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)]
internal extern static void monodroid_log (LogLevel level, LogCategories category, string message);

Expand Down
2 changes: 2 additions & 0 deletions src/native/clr/host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ set(XAMARIN_MONODROID_SOURCES
jni-remapping.cc
os-bridge.cc
pinvoke-override.cc
runtime-util.cc
typemap.cc
xamarin_getifaddrs.cc
)

list(APPEND LOCAL_CLANG_CHECK_SOURCES
Expand Down
26 changes: 13 additions & 13 deletions src/native/clr/host/generate-pinvoke-tables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ const std::vector<std::string> internal_pinvoke_names = {
// "java_interop_free",
// "monodroid_clear_gdb_wait",
// "_monodroid_counters_dump",
// "_monodroid_detect_cpu_and_architecture",
"_monodroid_detect_cpu_and_architecture",
// "monodroid_dylib_mono_free",
// "monodroid_dylib_mono_init",
// "monodroid_dylib_mono_new",
// "monodroid_embedded_assemblies_set_assemblies_prefix",
// "monodroid_fopen",
"monodroid_free",
// "_monodroid_freeifaddrs",
// "_monodroid_gc_wait_for_bridge_processing",
"_monodroid_freeifaddrs",
"_monodroid_gc_wait_for_bridge_processing",
// "_monodroid_get_dns_servers",
// "monodroid_get_dylib",
// "_monodroid_getifaddrs",
"_monodroid_getifaddrs",
// "monodroid_get_namespaced_system_property",
// "_monodroid_get_network_interface_supports_multicast",
// "_monodroid_get_network_interface_up_state",
Expand All @@ -60,21 +60,21 @@ const std::vector<std::string> internal_pinvoke_names = {
// "monodroid_log_traces",
"_monodroid_lookup_replacement_type",
"_monodroid_lookup_replacement_method_info",
// "_monodroid_lref_log_delete",
// "_monodroid_lref_log_new",
// "_monodroid_max_gref_get",
"_monodroid_lref_log_delete",
"_monodroid_lref_log_new",
"_monodroid_max_gref_get",
// "monodroid_strdup_printf",
// "monodroid_strfreev",
// "monodroid_strsplit",
// "_monodroid_timezone_get_default_id",
// "monodroid_timing_start",
// "monodroid_timing_stop",
"_monodroid_timezone_get_default_id",
"monodroid_timing_start",
"monodroid_timing_stop",
"monodroid_TypeManager_get_java_class_name",
"clr_typemap_managed_to_java",
"clr_typemap_java_to_managed",
// "_monodroid_weak_gref_delete",
// "_monodroid_weak_gref_get",
// "_monodroid_weak_gref_new",
"_monodroid_weak_gref_delete",
"_monodroid_weak_gref_get",
"_monodroid_weak_gref_new",
// "path_combine",
// "recv_uninterrupted",
// "send_uninterrupted",
Expand Down
5 changes: 4 additions & 1 deletion src/native/clr/host/host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <host/host-jni.hh>
#include <host/host-util.hh>
#include <host/os-bridge.hh>
#include <host/runtime-util.hh>
#include <runtime-base/android-system.hh>
#include <runtime-base/jni-wrappers.hh>
#include <runtime-base/logger.hh>
Expand Down Expand Up @@ -264,7 +265,7 @@ void Host::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass runtimeCl

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

Expand All @@ -278,6 +279,8 @@ void Host::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass runtimeCl
Util::set_environment_variable_for_directory ("HOME", home);
create_xdg_directories_and_environment (home);

java_TimeZone = RuntimeUtil::get_class_from_runtime_field (env, runtimeClass, "java_util_TimeZone", true);

AndroidSystem::detect_embedded_dso_mode (applicationDirs);
AndroidSystem::set_running_in_emulator (isEmulator);
AndroidSystem::set_primary_override_dir (home);
Expand Down
104 changes: 104 additions & 0 deletions src/native/clr/host/internal-pinvokes.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <host/host.hh>
#include <host/os-bridge.hh>
#include <host/typemap.hh>
#include <runtime-base/android-system.hh>
#include <runtime-base/cpu-arch.hh>
#include <runtime-base/internal-pinvokes.hh>
#include <runtime-base/jni-remapping.hh>

Expand Down Expand Up @@ -88,3 +90,105 @@ _monodroid_lookup_replacement_method_info (const char *jniSourceType, const char
{
return JniRemapping::lookup_replacement_method_info (jniSourceType, jniMethodName, jniMethodSignature);
}

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) {
return nullptr;
}

managed_timing_sequence *ret = timing->get_available_sequence ();
if (message != nullptr) {
log_write (LOG_TIMING, LogLevel::Info, message);
}
ret->period.mark_start ();
return ret;
}

void monodroid_timing_stop (managed_timing_sequence *sequence, const char *message)
{
static constexpr const char DEFAULT_MESSAGE[] = "Managed Timing";
if (sequence == nullptr) {
return;
}

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

sequence->period.mark_end ();
Timing::info (sequence->period, message == nullptr ? DEFAULT_MESSAGE : message);
timing->release_sequence (sequence);
}

void _monodroid_weak_gref_new (jobject curHandle, char curType, jobject newHandle, char newType, const char *threadName, int threadId, const char *from, int from_writable)
{
OSBridge::_monodroid_weak_gref_new (curHandle, curType, newHandle, newType, threadName, threadId, from, from_writable);
}

int _monodroid_weak_gref_get ()
{
return OSBridge::get_gc_weak_gref_count ();
}

int _monodroid_max_gref_get ()
{
return static_cast<int>(AndroidSystem::get_max_gref_count ());
}

void _monodroid_weak_gref_delete (jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable)
{
OSBridge::_monodroid_weak_gref_delete (handle, type, threadName, threadId, from, from_writable);
}

void _monodroid_lref_log_new (int lrefc, jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable)
{
OSBridge::_monodroid_lref_log_new (lrefc, handle, type, threadName, threadId, from, from_writable);
}

void _monodroid_lref_log_delete (int lrefc, jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable)
{
OSBridge::_monodroid_lref_log_delete (lrefc, handle, type, threadName, threadId, from, from_writable);
}

void _monodroid_gc_wait_for_bridge_processing ()
{
// mono_gc_wait_for_bridge_processing (); - replace with the new GC bridge call, when we have it
}

void _monodroid_detect_cpu_and_architecture (uint16_t *built_for_cpu, uint16_t *running_on_cpu, unsigned char *is64bit)
{
abort_if_invalid_pointer_argument (built_for_cpu, "built_for_cpu");
abort_if_invalid_pointer_argument (running_on_cpu, "running_on_cpu");
abort_if_invalid_pointer_argument (is64bit, "is64bit");

bool _64bit;
monodroid_detect_cpu_and_architecture (*built_for_cpu, *running_on_cpu, _64bit);
*is64bit = _64bit;
}

void* _monodroid_timezone_get_default_id ()
{
JNIEnv *env = OSBridge::ensure_jnienv ();
jmethodID getDefault = env->GetStaticMethodID (Host::get_java_class_TimeZone (), "getDefault", "()Ljava/util/TimeZone;");
jmethodID getID = env->GetMethodID (Host::get_java_class_TimeZone (), "getID", "()Ljava/lang/String;");
jobject d = env->CallStaticObjectMethod (Host::get_java_class_TimeZone (), getDefault);
jstring id = reinterpret_cast<jstring> (env->CallObjectMethod (d, getID));
const char *mutf8 = env->GetStringUTFChars (id, nullptr);
if (mutf8 == nullptr) {
log_error (LOG_DEFAULT, "Failed to convert Java TimeZone ID to UTF8 (out of memory?)"sv);
env->DeleteLocalRef (id);
env->DeleteLocalRef (d);
return nullptr;
}
char *def_id = strdup (mutf8);
env->ReleaseStringUTFChars (id, mutf8);
env->DeleteLocalRef (id);
env->DeleteLocalRef (d);
return def_id;
}
Loading
Loading