Changeset View
Changeset View
Standalone View
Standalone View
source/scriptinterface/ScriptContext.cpp
/* Copyright (C) 2021 Wildfire Games. | /* Copyright (C) 2022 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
Show All 26 Lines | void GCSliceCallbackHook(JSContext* UNUSED(cx), JS::GCProgress progress, const JS::GCDescription& UNUSED(desc)) | ||||
* Thus, to safely monitor GCs, we need to profile SLICE_X calls. | * Thus, to safely monitor GCs, we need to profile SLICE_X calls. | ||||
*/ | */ | ||||
if (progress == JS::GC_SLICE_BEGIN) | if (progress == JS::GC_SLICE_BEGIN) | ||||
{ | { | ||||
if (CProfileManager::IsInitialised() && Threading::IsMainThread()) | if (CProfileManager::IsInitialised() && Threading::IsMainThread()) | ||||
g_Profiler.Start("GCSlice"); | g_Profiler.Start("GCSlice"); | ||||
g_Profiler2.RecordRegionEnter("GCSlice"); | g_Profiler2->RecordRegionEnter("GCSlice"); | ||||
} | } | ||||
else if (progress == JS::GC_SLICE_END) | else if (progress == JS::GC_SLICE_END) | ||||
{ | { | ||||
if (CProfileManager::IsInitialised() && Threading::IsMainThread()) | if (CProfileManager::IsInitialised() && Threading::IsMainThread()) | ||||
g_Profiler.Stop(); | g_Profiler.Stop(); | ||||
g_Profiler2.RecordRegionLeave(); | g_Profiler2->RecordRegionLeave(); | ||||
} | } | ||||
// The following code can be used to print some information aobut garbage collection | // The following code can be used to print some information aobut garbage collection | ||||
// Search for "Nonincremental reason" if there are problems running GC incrementally. | // Search for "Nonincremental reason" if there are problems running GC incrementally. | ||||
#if 0 | #if 0 | ||||
if (progress == JS::GCProgress::GC_CYCLE_BEGIN) | if (progress == JS::GCProgress::GC_CYCLE_BEGIN) | ||||
printf("starting cycle ===========================================\n"); | printf("starting cycle ===========================================\n"); | ||||
▲ Show 20 Lines • Show All 207 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator