If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

gcTriggerFactor math rounding causes GC with every allocation

RESOLVED DUPLICATE of bug 548405

Status

()

Core
JavaScript Engine
RESOLVED DUPLICATE of bug 548405
8 years ago
8 years ago

People

(Reporter: Mike Moening, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

8 years ago
In jsgc.cpp the following function has a math rounding issue that causes GC to fire for every allocation is gcTriggerFactor is set to a value like 150.

void
JSRuntime::setGCLastBytes(size_t lastBytes)
{
    gcLastBytes = lastBytes;
    uint64 triggerBytes = uint64(lastBytes) * uint64(gcTriggerFactor / 100);
    if (triggerBytes != size_t(triggerBytes))
        triggerBytes = size_t(-1);
    gcTriggerBytes = size_t(triggerBytes);
}

Specifically this snipet:    uint64(gcTriggerFactor / 100);
Will evaluate to 1 when gcTriggerFactor == 150.  The uint64 cast is the problem.

A quick fix would be:
uint64 triggerBytes = uint64(uint64(lastBytes) * (gcTriggerFactor / 100.0));

Which would allow floating point math and the correct result.

Per discussion in jsapi IRC it would be nice if it were possible to trigger this "Auto" GC from a background thread.  However, that might be topic for another bug...
(Reporter)

Updated

8 years ago
Status: NEW → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 548405
You need to log in before you can comment on or make changes to this bug.