# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# flake8: noqa: F821
# Generate graph structures for GC statistics recording. # # Stats phases are nested and form a directed acyclic graph starting # from a set of root phases. Importantly, a phase may appear under more # than one parent phase. # # For example, the following arrangement is possible: # # +---+ # | A | # +---+ # | # +-------+-------+ # | | | # v v v # +---+ +---+ +---+ # | B | | C | | D | # +---+ +---+ +---+ # | | # +---+---+ # | # v # +---+ # | E | # +---+ # # This graph is expanded into a tree (or really a forest) and phases # with multiple parents are duplicated. # # For example, the input example above would be expanded to: # # +---+ # | A | # +---+ # | # +-------+-------+ # | | | # v v v # +---+ +---+ +---+ # | B | | C | | D | # +---+ +---+ +---+ # | | # v v # +---+ +---+ # | E | | E'| # +---+ +---+
# NOTE: If you add new phases here the current next phase kind number can be # found at the end of js/src/gc/StatsPhasesGenerated.inc
import collections import re
class PhaseKind: def __init__(self, name, descr, bucket, children=[]):
self.name = name
self.descr = descr # For telemetry
self.bucket = bucket
self.children = children
class Phase: # Expand the DAG into a tree, duplicating phases which have more than # one parent. def __init__(self, phaseKind, parent):
self.phaseKind = phaseKind
self.parent = parent
self.depth = parent.depth + 1 if parent else 0
self.children = []
self.nextSibling = None
self.nextInPhaseKind = None
def traverse(phaseKind, parent):
ep = Phase(phaseKind, parent)
phases.append(ep)
# Update list of expanded phases for this phase kind. if phasesForKind[phaseKind]:
phasesForKind[phaseKind][-1].nextInPhaseKind = ep
phasesForKind[phaseKind].append(ep)
# Recurse over children. for child in phaseKind.children:
child_ep = traverse(child, ep) if ep.children:
ep.children[-1].nextSibling = child_ep
ep.children.append(child_ep) return ep
for phaseKind in PhaseKindGraphRoots:
traverse(phaseKind, None)
return phases, phasesForKind
AllPhases, PhasesForPhaseKind = expandPhases()
# Name phases based on phase kind name and index if there are multiple phases # corresponding to a single phase kind.
for phaseKind in AllPhaseKinds:
phases = PhasesForPhaseKind[phaseKind] if len(phases) == 1:
phases[0].name = "%s" % phaseKind.name else: for index, phase in enumerate(phases):
phase.name = "%s_%d" % (phaseKind.name, index + 1)
# Find the maximum phase nesting.
MaxPhaseNesting = max(phase.depth for phase in AllPhases) + 1
# And the maximum bucket number.
MaxBucket = max(kind.bucket for kind in AllPhaseKinds)
# Generate code.
def writeList(out, items): if items:
out.write(",\n".join(" " + item for item in items) + "\n")
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.