Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/js/src/jit-test/tests/gc/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 2 kB image not shown  

Quelle  finalizationRegistry-ccw.js

  Sprache: JAVA
 

// Test combinations of arguments in different compartments.

gczeal(0);

let heldValues = [];

function ccwToObject() {
    return evalcx('({})', newGlobal({newCompartment: true}));
}

function newRegistry() {
  return new FinalizationRegistry(value => {
    heldValues.push(value);
  });
}

function ccwToRegistry() {
  let global = newGlobal({newCompartment: true});
  global.heldValues = heldValues;
  return global.eval(
    `new FinalizationRegistry(value => heldValues.push(value))`);
}

function incrementalGC() {
  startgc(1);
  while (gcstate() !== "NotActive") {
    gcslice(1000);
  }
}

const RegistryKinds = ['SameZoneRegistry''OtherZoneRegistry'];
function makeRegistry(kind) {
  if (kind === 'SameZoneRegistry') {
    return new FinalizationRegistry(value => {
      heldValues.push(value);
    });
  }

  assertEq(kind, 'OtherZoneRegistry');
  let global = newGlobal({newCompartment: true});
  global.heldValues = heldValues;
  return global.eval(
    `new FinalizationRegistry(value => heldValues.push(value))`);
  return evalcx('({})', newGlobal({newCompartment: true}));
}

const ObjectKinds = ['SameZoneObject''OtherZoneObject'];
function makeObject(kind) {
  if (kind === 'SameZoneObject') {
    return {};
  }

  assertEq(kind, 'OtherZoneObject');
  return evalcx('({})', newGlobal({newCompartment: true}));
}

for (let registryReachable of [falsetrue]) {
  for (let registryKind of RegistryKinds) {
    for (let targetKind of ObjectKinds) {
      for (let heldValueKind of ObjectKinds) {
        for (let tokenKind of ObjectKinds) {
          let registry = makeRegistry(registryKind);
          let target = makeObject(targetKind);
          let heldValue = makeObject(heldValueKind);
          let token = makeObject(tokenKind);

          registry.register(target, heldValue, token);
          registry.unregister(token);

          registry.register(target, heldValue, token);

          target = undefined;
          token = undefined;
          heldValue = undefined;
          if (!registryReachable) {
            registry = undefined;
          }
          incrementalGC();
          heldValues.length = 0// Clear, don't replace.
          drainJobQueue();

          if (registryReachable) {
            assertEq(heldValues.length, 1);
          } else {
            // The cleanup callback may or may not be run depending on
            // which order the zones are swept in, which itself depends on
            // the arrangement of CCWs.
            assertEq(heldValues.length <= 1true);
          }
        }
      }
    }
  }
}

Messung V0.5 in Prozent
C=89 H=83 G=85

¤ Dauer der Verarbeitung: 0.4 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.