ProfilingCategory.h (2386B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 2 * vim: set ts=8 sts=4 et sw=4 tw=99: 3 * This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef js_ProfilingCategory_h 8 #define js_ProfilingCategory_h 9 10 // The source lives in mozglue/baseprofiler/public/ProfilingCategoryList.h 11 #include "mozilla/ProfilingCategoryList.h" // MOZ_PROFILING_CATEGORY_LIST 12 13 #include "jstypes.h" // JS_PUBLIC_API 14 15 namespace JS { 16 17 // clang-format off 18 19 // An enum that lists all possible category pairs in one list. 20 // This is the enum that is used in profiler stack labels. Having one list that 21 // includes subcategories from all categories in one list allows assigning the 22 // category pair to a stack label with just one number. 23 #define CATEGORY_ENUM_BEGIN_CATEGORY(name, labelAsString, color) 24 #define CATEGORY_ENUM_SUBCATEGORY(supercategory, name, labelAsString) name, 25 #define CATEGORY_ENUM_END_CATEGORY 26 enum class ProfilingCategoryPair : uint32_t { 27 MOZ_PROFILING_CATEGORY_LIST(CATEGORY_ENUM_BEGIN_CATEGORY, 28 CATEGORY_ENUM_SUBCATEGORY, 29 CATEGORY_ENUM_END_CATEGORY) 30 COUNT, 31 LAST = COUNT - 1, 32 }; 33 #undef CATEGORY_ENUM_BEGIN_CATEGORY 34 #undef CATEGORY_ENUM_SUBCATEGORY 35 #undef CATEGORY_ENUM_END_CATEGORY 36 37 // An enum that lists just the categories without their subcategories. 38 #define SUPERCATEGORY_ENUM_BEGIN_CATEGORY(name, labelAsString, color) name, 39 #define SUPERCATEGORY_ENUM_SUBCATEGORY(supercategory, name, labelAsString) 40 #define SUPERCATEGORY_ENUM_END_CATEGORY 41 enum class ProfilingCategory : uint32_t { 42 MOZ_PROFILING_CATEGORY_LIST(SUPERCATEGORY_ENUM_BEGIN_CATEGORY, 43 SUPERCATEGORY_ENUM_SUBCATEGORY, 44 SUPERCATEGORY_ENUM_END_CATEGORY) 45 COUNT, 46 LAST = COUNT - 1, 47 }; 48 #undef SUPERCATEGORY_ENUM_BEGIN_CATEGORY 49 #undef SUPERCATEGORY_ENUM_SUBCATEGORY 50 #undef SUPERCATEGORY_ENUM_END_CATEGORY 51 52 // clang-format on 53 54 struct ProfilingCategoryPairInfo { 55 ProfilingCategory mCategory; 56 uint32_t mSubcategoryIndex; 57 const char* mLabel; 58 }; 59 60 JS_PUBLIC_API const ProfilingCategoryPairInfo& GetProfilingCategoryPairInfo( 61 ProfilingCategoryPair aCategoryPair); 62 63 } // namespace JS 64 65 #endif /* js_ProfilingCategory_h */