少年修仙传客户端基础资源
hch
2024-04-11 4c71d74b77c9eb62a0323698c9a0db3b641a917e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "il2cpp-config.h"
 
#include "icalls/System/System.Diagnostics/PerformanceCounter.h"
#include "PerformanceCounterUtils.h"
#include "os/Time.h"
#include "utils/Memory.h"
#include "utils/StringUtils.h"
#include "vm/Exception.h"
#include "vm-utils/VmStringUtils.h"
#include "il2cpp-runtime-stats.h"
 
namespace il2cpp
{
namespace icalls
{
namespace System
{
namespace System
{
namespace Diagnostics
{
    static void fill_sample(Il2CppCounterSample *sample)
    {
        sample->timeStamp = os::Time::GetTicksMillisecondsMonotonic();
        sample->timeStamp100nSec = sample->timeStamp;
        sample->counterTimeStamp = sample->timeStamp;
        sample->counterFrequency = 10000000;
        sample->systemFrequency = 10000000;
        // the real basevalue needs to be get from a different counter...
        sample->baseValue = 0;
    }
 
    static bool Il2CppMemoryCounter(ImplVtable *vtable, bool only_value, Il2CppCounterSample *sample)
    {
        int id = (int)(intptr_t)vtable->arg;
        if (!only_value)
        {
            fill_sample(sample);
            sample->baseValue = 1;
        }
        sample->counterType = predef_counters[predef_categories[CATEGORY_MONO_MEM].first_counter + id].type;
        switch (id)
        {
            case COUNTER_MEM_NUM_OBJECTS:
                sample->rawValue = il2cpp_runtime_stats.new_object_count;
                return true;
        }
        return false;
    }
 
    static void* Il2CppMemoryCounterImpl(Il2CppString* counter, Il2CppString* instance, int* type, bool* custom)
    {
        *custom = false;
        const CounterDesc *cdesc = get_counter_in_category(&predef_categories[CATEGORY_MONO_MEM], counter);
        if (cdesc)
        {
            *type = cdesc->type;
            return create_vtable((void*)(intptr_t)cdesc->id, Il2CppMemoryCounter, NULL);
        }
        return NULL;
    }
 
    intptr_t PerformanceCounter::GetImpl(Il2CppString* category, Il2CppString* counter, Il2CppString* instance, Il2CppString* machine, int* type, bool* custom)
    {
        intptr_t returnValue = {0};
        const CategoryDesc *cdesc;
        if (!utils::VmStringUtils::CaseInsensitiveEquals(machine, "."))
            return returnValue;
 
        cdesc = find_category(category);
        if (!cdesc)
        {
            return returnValue;
        }
        else
        {
            switch (cdesc->id)
            {
                case CATEGORY_MONO_MEM:
                    returnValue = reinterpret_cast<intptr_t>(Il2CppMemoryCounterImpl(counter, instance, type, custom));
            }
        }
 
        return returnValue;
    }
 
    bool PerformanceCounter::GetSample(intptr_t impl, bool only_value, Il2CppCounterSample* sample)
    {
        ImplVtable *vtable = (ImplVtable*)impl;
        if (vtable && vtable->sample)
            return vtable->sample(vtable, only_value, sample);
        return false;
    }
 
    int64_t PerformanceCounter::UpdateValue(intptr_t impl, bool do_incr, int64_t value)
    {
        IL2CPP_NOT_IMPLEMENTED_ICALL(PerformanceCounter::UpdateValue);
 
        return 0;
    }
 
    void PerformanceCounter::FreeData(intptr_t impl)
    {
        ImplVtable* vtable = (ImplVtable*)impl;
        if (vtable && vtable->cleanup)
            vtable->cleanup(vtable);
        IL2CPP_FREE(vtable);
    }
} /* namespace Diagnostics */
} /* namespace System */
} /* namespace System */
} /* namespace icalls */
} /* namespace il2cpp */