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

Quelle  stringbuffer-1.js

  Sprache: JAVA
 

// |jit-test| skip-if: !getBuildConfiguration("debug")
// stringRepresentation and the bufferRefCount field aren't available in
// all builds.

gczeal(0);

function representation(s) {
    return JSON.parse(stringRepresentation(s));
}

function testBasic(tenured) {
    var s = newString("abcdefghijklmnopqrstuvwxyz", {newStringBuffer: true, tenured});
    assertEq(representation(s).bufferRefCount, 1);
    assertEq(s, "abcdefghijklmnopqrstuvwxyz");
    assertEq(s.substring(1), "bcdefghijklmnopqrstuvwxyz");
    assertEq(s + s + s, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
}
testBasic(false);
testBasic(true);

function testAtomRef(tenured) {
    var s = newString("abcdefghijklmnopqrstuvwxyz", {newStringBuffer: true, tenured});
    var s2 = newString(s, {shareStringBuffer: true});
    assertEq(representation(s).bufferRefCount, 2);
    var o = {[s2]: 1};
    for (var i = 0; i < 10; i++) {
        o[s2]++;
    }
    minorgc();
    minorgc();
    finishBackgroundFree();
    // If s2 is now an AtomRef string, then only s holds a reference to
    // the buffer.
    if (representation(s2).flags.includes("ATOM_REF_BIT")) {
        assertEq(representation(s).bufferRefCount, 1);
    } else {
        assertEq(representation(s).bufferRefCount, 2);
    }
    return o;
}
testAtomRef(false);
testAtomRef(true);

function testDeduplication(tenured) {
    var arr = [];
    var s = newString("abcdefghijklmnopqrstuvwxyz" + "012345".substring(1), {newStringBuffer: true, tenured});
    for (var i = 0; i < 100; i++) {
        arr.push(newString(s, {shareStringBuffer: true, tenured}));
    }
    assertEq(representation(s).bufferRefCount, 101);
    gc()
    finishBackgroundFree();
    assertEq(representation(s).bufferRefCount, tenured ? 101 : 1);
    return arr;
}
testDeduplication(false);
testDeduplication(true);

Messung V0.5 in Prozent
C=92 H=87 G=89

¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© 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.