Debian Codegraph @

js/src/jit-test/tests/basic/stringbuffer-3.js

raw
1 // |jit-test| skip-if: !getBuildConfiguration("debug")
2 // stringRepresentation and the bufferRefCount field aren't available in
3 // all builds.
4
5 // When a JS string with a StringBuffer is passed to a different zone, the buffer
6 // should be shared instead of copied.
7
8 gczeal(0);
9
10 let g = newGlobal({newCompartment: true}); // Implies new-zone.
11 let s1 = newString("abcdefghijklmnopqrstuvwxyz", {newStringBuffer: true, tenured: true});
12 assertEq(JSON.parse(stringRepresentation(s1)).bufferRefCount, 1);
13 g.s2 = s1;
14 assertEq(JSON.parse(stringRepresentation(s1)).bufferRefCount, 2);
15 let s3 = g.s2;
16 assertEq(JSON.parse(stringRepresentation(s1)).bufferRefCount, 3);