Bug 1691920 - Add a systemPageSizeKB parameter. r=jonco

Add a read-only parameter systemPageSizeKB to get the same result from
js::Nursery::roundSize.

Differential Revision: https://phabricator.services.mozilla.com/D106188
This commit is contained in:
Yoshi Cheng-Hao Huang 2021-02-24 22:04:16 +00:00
parent b5cbcf36ee
commit 8fbec92c35
4 changed files with 13 additions and 2 deletions

View File

@ -405,6 +405,13 @@ typedef enum JSGCParamKey {
* Pref: None
*/
JSGC_NURSERY_TIMEOUT_FOR_IDLE_COLLECTION_MS = 46,
/**
* The system page size in KB.
*
* This parameter is read-only.
*/
JSGC_SYSTEM_PAGE_SIZE_KB = 47,
} JSGCParamKey;
/*

View File

@ -651,7 +651,8 @@ static bool MinorGC(JSContext* cx, unsigned argc, Value* vp) {
_("chunkBytes", JSGC_CHUNK_BYTES, false) \
_("helperThreadRatio", JSGC_HELPER_THREAD_RATIO, true) \
_("maxHelperThreads", JSGC_MAX_HELPER_THREADS, true) \
_("helperThreadCount", JSGC_HELPER_THREAD_COUNT, false)
_("helperThreadCount", JSGC_HELPER_THREAD_COUNT, false) \
_("systemPageSizeKB", JSGC_SYSTEM_PAGE_SIZE_KB, false)
static const struct ParamInfo {
const char* name;

View File

@ -1641,6 +1641,8 @@ uint32_t GCRuntime::getParameter(JSGCParamKey key, const AutoLockGC& lock) {
return maxHelperThreads;
case JSGC_HELPER_THREAD_COUNT:
return helperThreadCount;
case JSGC_SYSTEM_PAGE_SIZE_KB:
return SystemPageSize() / 1024;
default:
MOZ_CRASH("Unknown parameter key");
}

View File

@ -7,6 +7,7 @@
load(libdir + "asserts.js");
const chunkSizeKB = gcparam('chunkBytes') / 1024;
const pageSizeKB = gcparam('systemPageSizeKB');
var testSizesKB = [128, 129, 255, 256, 516, 1023, 1024, 3*1024, 4*1024+1, 16*1024];
@ -48,7 +49,7 @@ function allocateSomeThings() {
}
function nearestLegalSize(sizeKB) {
let step = sizeKB >= chunkSizeKB ? chunkSizeKB : 4;
let step = sizeKB >= chunkSizeKB ? chunkSizeKB : pageSizeKB;
return round(sizeKB, step);
}