本文整理汇总了C++中JSRuntime::meterEmptyShapes方法的典型用法代码示例。如果您正苦于以下问题:C++ JSRuntime::meterEmptyShapes方法的具体用法?C++ JSRuntime::meterEmptyShapes怎么用?C++ JSRuntime::meterEmptyShapes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSRuntime
的用法示例。
在下文中一共展示了JSRuntime::meterEmptyShapes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fopen
void
js::PropertyTree::sweepShapes(JSContext *cx)
{
JSRuntime *rt = compartment->rt;
#ifdef DEBUG
JSBasicStats bs;
uint32 livePropCapacity = 0, totalLiveCount = 0;
static FILE *logfp;
if (!logfp) {
if (const char *filename = rt->propTreeStatFilename)
logfp = fopen(filename, "w");
}
if (logfp) {
JS_BASIC_STATS_INIT(&bs);
uint32 empties;
{
typedef JSCompartment::EmptyShapeSet HS;
HS &h = compartment->emptyShapes;
empties = h.count();
MeterKidCount(&bs, empties);
for (HS::Range r = h.all(); !r.empty(); r.popFront())
meter(&bs, r.front());
}
double props = rt->liveObjectPropsPreSweep;
double nodes = compartment->livePropTreeNodes;
double dicts = compartment->liveDictModeNodes;
/* Empty scope nodes are never hashed, so subtract them from nodes. */
JS_ASSERT(nodes - dicts == bs.sum);
nodes -= empties;
double sigma;
double mean = JS_MeanAndStdDevBS(&bs, &sigma);
fprintf(logfp,
"props %g nodes %g (dicts %g) beta %g meankids %g sigma %g max %u\n",
props, nodes, dicts, nodes / props, mean, sigma, bs.max);
JS_DumpHistogram(&bs, logfp);
}
#endif
/*
* Sweep the heap clean of all unmarked nodes. Here we will find nodes
* already GC'ed from the root ply, but we will avoid re-orphaning their
* kids, because the kids member will already be null.
*/
JSArena **ap = &arenaPool.first.next;
while (JSArena *a = *ap) {
Shape *limit = (Shape *) a->avail;
uintN liveCount = 0;
for (Shape *shape = (Shape *) a->base; shape < limit; shape++) {
/* If the id is null, shape is already on the freelist. */
if (JSID_IS_VOID(shape->id))
continue;
/*
* If the mark bit is set, shape is alive, so clear the mark bit
* and continue the while loop.
*
* Regenerate shape->shape if it hasn't already been refreshed
* during the mark phase, when live scopes' lastProp members are
* followed to update both scope->shape and lastProp->shape.
*/
if (shape->marked()) {
shape->clearMark();
if (rt->gcRegenShapes) {
if (shape->hasRegenFlag())
shape->clearRegenFlag();
else
shape->shape = js_RegenerateShapeForGC(rt);
}
liveCount++;
continue;
}
#ifdef DEBUG
if ((shape->flags & Shape::SHARED_EMPTY) &&
rt->meterEmptyShapes()) {
compartment->emptyShapes.remove((EmptyShape *) shape);
}
#endif
if (shape->inDictionary()) {
JS_COMPARTMENT_METER(compartment->liveDictModeNodes--);
} else {
/*
* Here, shape is garbage to collect, but its parent might not
* be, so we may have to remove it from its parent's kids hash
* or kid singleton pointer set.
*
* Without a separate mark-clearing pass, we can't tell whether
* shape->parent is live at this point, so we must remove shape
* if its parent member is non-null. A saving grace: if shape's
//.........这里部分代码省略.........