| 194 | } |
| 195 | |
| 196 | static void PushLuaProfilerScope(lua_State* L, const char* name, uint32_t name_length) |
| 197 | { |
| 198 | LuaProfilerScopeState* state = GetOrCreateLuaProfilerScopeState(L); |
| 199 | EnsureLuaProfilerCapacity(&state->m_Scopes, 1, 4); |
| 200 | EnsureLuaProfilerCapacity(&state->m_Names, name_length + 1, 64); |
| 201 | |
| 202 | LuaProfilerScope scope; |
| 203 | scope.m_NameOffset = state->m_Names.Size(); |
| 204 | uint64_t name_hash = 0; |
| 205 | ProfileResult result = ProfileScopeBegin(name, &name_hash); |
| 206 | scope.m_NameHash = name_hash; |
| 207 | |
| 208 | if (result == PROFILE_RESULT_OUT_OF_SAMPLES) |
| 209 | { |
| 210 | dmLogWarning("Lua profiler scope '%s' exceeded the profiler sample limit for the current thread/frame. Additional Lua profiler scopes will be dropped until the stack unwinds.", name); |
| 211 | } |
| 212 | |
| 213 | uint32_t name_size = name_length + 1; |
| 214 | uint32_t names_size = state->m_Names.Size(); |
| 215 | state->m_Names.SetSize(names_size + name_size); |
| 216 | memcpy(state->m_Names.Begin() + scope.m_NameOffset, name, name_length); |
| 217 | state->m_Names[scope.m_NameOffset + name_length] = 0; |
| 218 | state->m_Scopes.Push(scope); |
| 219 | } |
| 220 | |
| 221 | static LuaProfilerScopeState* PopLuaProfilerScope(lua_State* L, LuaProfilerScope* out_scope) |
| 222 | { |
no test coverage detected