Add MemoryCompare, MemoryClear and MemoryCopy for direct memory access in C#

This commit is contained in:
Wojtek Figat
2021-05-30 14:11:25 +02:00
parent 1bd109395a
commit 9c66ac4656
6 changed files with 56 additions and 26 deletions

View File

@@ -8,11 +8,6 @@
namespace UtilsInternal
{
void MemoryCopy(void* source, void* destination, int32 length)
{
Platform::MemoryCopy(destination, source, length);
}
MonoObject* ExtractArrayFromList(MonoObject* obj)
{
auto klass = mono_object_get_class(obj);
@@ -78,7 +73,9 @@ namespace FlaxLogWriterInternal
void registerFlaxEngineInternalCalls()
{
AnimGraphExecutor::initRuntime();
ADD_INTERNAL_CALL("FlaxEngine.Utils::MemoryCopy", &UtilsInternal::MemoryCopy);
ADD_INTERNAL_CALL("FlaxEngine.Utils::MemoryCopy", &Platform::MemoryCopy);
ADD_INTERNAL_CALL("FlaxEngine.Utils::MemoryClear", &Platform::MemoryClear);
ADD_INTERNAL_CALL("FlaxEngine.Utils::MemoryCompare", &Platform::MemoryCompare);
ADD_INTERNAL_CALL("FlaxEngine.Utils::Internal_ExtractArrayFromList", &UtilsInternal::ExtractArrayFromList);
ADD_INTERNAL_CALL("FlaxEngine.DebugLogHandler::Internal_LogWrite", &DebugLogHandlerInternal::LogWrite);
ADD_INTERNAL_CALL("FlaxEngine.DebugLogHandler::Internal_Log", &DebugLogHandlerInternal::Log);

View File

@@ -169,18 +169,20 @@ void OnGCAllocation(MonoProfiler* profiler, MonoObject* obj)
//LOG(Info, "GC new: {0}.{1} ({2} bytes)", name_space, name, size);
#if 0
if (ProfilerCPU::IsProfilingCurrentThread())
{
static int details = 0;
if (details)
{
StackWalkDataResult stackTrace;
stackTrace.Buffer.SetCapacity(1024);
mono_stack_walk(&OnStackWalk, &stackTrace);
if (ProfilerCPU::IsProfilingCurrentThread())
{
static int details = 0;
if (details)
{
StackWalkDataResult stackTrace;
stackTrace.Buffer.SetCapacity(1024);
mono_stack_walk(&OnStackWalk, &stackTrace);
LOG(Info, "GC new: {0}.{1} ({2} bytes). Stack Trace:\n{3}", String(name_space), String(name), size, stackTrace.Buffer.ToStringView());
}
}
const auto msg = String::Format(TEXT("GC new: {0}.{1} ({2} bytes). Stack Trace:\n{3}"), String(name_space), String(name), size, stackTrace.Buffer.ToStringView());
Platform::Log(*msg);
//LOG_STR(Info, msg);
}
}
#endif
#if COMPILE_WITH_PROFILER