☠☠ backed out by 65e92478e09d ☠ ☠ | |
author | Steve Fink <sfink@mozilla.com> |
Wed, 21 Jun 2017 10:07:32 -0700 (2017-06-21) | |
changeset 398816 | 6d7d15b254896c00ef8e00a6b1d921980d661ac2 |
parent 398815 | 457008b194a87ec4dd57858d25fa94f2606492db |
child 398817 | fdb6431ea4ffbbc254e051f3f08eeef23d502062 |
push id | 98840 |
push user | sfink@mozilla.com |
push date | Thu, 11 Jan 2018 18:25:12 +0000 (2018-01-11) |
treeherder | mozilla-inbound@3f72f8747e29 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jimb |
bugs | 903519 |
milestone | 59.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
js/src/jit-test/tests/heap-analysis/byteSize-of-string.js | file | annotate | diff | comparison | revisions |
--- a/js/src/jit-test/tests/heap-analysis/byteSize-of-string.js +++ b/js/src/jit-test/tests/heap-analysis/byteSize-of-string.js @@ -13,22 +13,30 @@ var config = getBuildConfiguration(); if (!config['moz-memory']) quit(0); if (config['pointer-byte-size'] == 4) var s = (s32, s64) => s32 else var s = (s32, s64) => s64 -// Return the byte size of |obj|, ensuring that the size is not affected by -// being tenured. (We use 'survives a GC' as an approximation for 'tenuring'.) -function tByteSize(obj) { - var nurserySize = byteSize(obj); +// Convert an input string, which is probably an atom because it's a literal in +// the source text, to a regular (non-rope) string with the same contents. +function copyString(str) { + if (str.length == 0) + return str; // Nothing we can do here + return ensureFlatString(str.substr(0, 1) + str.substr(1)); +} + +// Return the tenured byte size of |str|. +function tByteSize(str) { + str = copyString(str); + let nurserySize = byteSize(str); minorgc(); - var tenuredSize = byteSize(obj); + var tenuredSize = byteSize(str); if (nurserySize != tenuredSize) { print("nursery size: " + nurserySize + " tenured size: " + tenuredSize); return -1; // make the stack trace point at the real test } return tenuredSize; } @@ -39,95 +47,107 @@ function tByteSize(obj) { // representation Latin-1 char16_t Latin-1 char16_t label // ======================================================================== // JSExternalString (cannot be tested in shell) - // JSThinInlineString 7 3 15 7 T // JSFatInlineString 23 11 23 11 F // JSExtensibleString - limited by available memory - X // JSUndependedString - same as JSExtensibleString - -// Note that atoms are 8 bytes larger than non-atoms, to store the atom's hash code. +// Notes: +// - labels are suffixed with A for atoms and N for non-atoms +// - atoms are 8 bytes larger than non-atoms, to store the atom's hash code. + +// Expected sizes based on type of string +const m32 = (config['pointer-byte-size'] == 4); +const TA = m32 ? 24 : 32; // ThinInlineString atom, includes a hash value +const TN = m32 ? 16 : 24; // ThinInlineString +const FN = m32 ? 32 : 32; // FatInlineString +const XN = m32 ? 16 : 24; // ExtensibleString, has additional storage buffer +const RN = m32 ? 16 : 24; // Rope +const DN = m32 ? 16 : 24; // DependentString // Latin-1 -assertEq(tByteSize(""), s(24, 32)); // T, T -assertEq(tByteSize("1"), s(24, 32)); // T, T -assertEq(tByteSize("1234567"), s(24, 32)); // T, T -assertEq(tByteSize("12345678"), s(40, 32)); // F, T -assertEq(tByteSize("123456789.12345"), s(40, 32)); // F, T -assertEq(tByteSize("123456789.123456"), s(40, 40)); // F, F -assertEq(tByteSize("123456789.123456789.123"), s(40, 40)); // F, F -assertEq(tByteSize("123456789.123456789.1234"), s(56, 64)); // X, X -assertEq(tByteSize("123456789.123456789.123456789.1"), s(56, 64)); // X, X -assertEq(tByteSize("123456789.123456789.123456789.12"), s(72, 80)); // X, X +assertEq(tByteSize(""), s(TA, TA)); +assertEq(tByteSize("1"), s(TA, TA)); +assertEq(tByteSize("1234567"), s(TN, TN)); +assertEq(tByteSize("12345678"), s(FN, TN)); +assertEq(tByteSize("123456789.12345"), s(FN, TN)); +assertEq(tByteSize("123456789.123456"), s(FN, FN)); +assertEq(tByteSize("123456789.123456789.123"), s(FN, FN)); +assertEq(tByteSize("123456789.123456789.1234"), s(XN+32, XN+32)); +assertEq(tByteSize("123456789.123456789.123456789.1"), s(XN+32, XN+32)); +assertEq(tByteSize("123456789.123456789.123456789.12"), s(XN+64, XN+64)); // Inline char16_t atoms. // "Impassionate gods have never seen the red that is the Tatsuta River." // - Ariwara no Narihira -assertEq(tByteSize("千"), s(24, 32)); // T, T -assertEq(tByteSize("千早"), s(24, 32)); // T, T -assertEq(tByteSize("千早ぶ"), s(24, 32)); // T, T -assertEq(tByteSize("千早ぶる"), s(40, 32)); // F, T -assertEq(tByteSize("千早ぶる神"), s(40, 32)); // F, T -assertEq(tByteSize("千早ぶる神代"), s(40, 32)); // F, T -assertEq(tByteSize("千早ぶる神代も"), s(40, 32)); // F, T -assertEq(tByteSize("千早ぶる神代もき"), s(40, 40)); // F, F -assertEq(tByteSize("千早ぶる神代もきかず龍"), s(40, 40)); // F, F -assertEq(tByteSize("千早ぶる神代もきかず龍田"), s(56, 64)); // X, X -assertEq(tByteSize("千早ぶる神代もきかず龍田川 か"), s(56, 64)); // X, X -assertEq(tByteSize("千早ぶる神代もきかず龍田川 から"), s(72, 80)); // X, X -assertEq(tByteSize("千早ぶる神代もきかず龍田川 からくれなゐに水く"), s(72, 80)); // X, X -assertEq(tByteSize("千早ぶる神代もきかず龍田川 からくれなゐに水くく"), s(88, 96)); // X, X -assertEq(tByteSize("千早ぶる神代もきかず龍田川 からくれなゐに水くくるとは"), s(88, 96)); // X, X +assertEq(tByteSize("千"), s(TA, TA)); +assertEq(tByteSize("千早"), s(TN, TN)); +assertEq(tByteSize("千早ぶ"), s(TN, TN)); +assertEq(tByteSize("千早ぶる"), s(FN, TN)); +assertEq(tByteSize("千早ぶる神"), s(FN, TN)); +assertEq(tByteSize("千早ぶる神代"), s(FN, TN)); +assertEq(tByteSize("千早ぶる神代も"), s(FN, TN)); +assertEq(tByteSize("千早ぶる神代もき"), s(FN, FN)); +assertEq(tByteSize("千早ぶる神代もきかず龍"), s(FN, FN)); +assertEq(tByteSize("千早ぶる神代もきかず龍田"), s(XN+32, XN+32)); +assertEq(tByteSize("千早ぶる神代もきかず龍田川 か"), s(XN+32, XN+32)); +assertEq(tByteSize("千早ぶる神代もきかず龍田川 から"), s(XN+64, XN+64)); +assertEq(tByteSize("千早ぶる神代もきかず龍田川 からくれなゐに水く"), s(XN+64, XN+64)); +assertEq(tByteSize("千早ぶる神代もきかず龍田川 からくれなゐに水くく"), s(XN+64, XN+64)); +assertEq(tByteSize("千早ぶる神代もきかず龍田川 からくれなゐに水くくるとは"), s(XN+64, XN+64)); // A Latin-1 rope. This changes size when flattened. // "In a village of La Mancha, the name of which I have no desire to call to mind" // - Miguel de Cervantes, Don Quixote var fragment8 = "En un lugar de la Mancha, de cuyo nombre no quiero acordarme"; // 60 characters var rope8 = fragment8; for (var i = 0; i < 10; i++) // 1024 repetitions rope8 = rope8 + rope8; -assertEq(tByteSize(rope8), s(16, 24)); + +assertEq(byteSize(rope8), s(RN, RN)); var matches8 = rope8.match(/(de cuyo nombre no quiero acordarme)/); -assertEq(tByteSize(rope8), s(16 + 65536, 24 + 65536)); +assertEq(byteSize(rope8), s(XN + 65536, XN + 65536)); // Test extensible strings. // // Appending another copy of the fragment should yield another rope. // // Flatting that should turn the original rope into a dependent string, and -// yield a new linear string, of the some size as the original. +// yield a new linear string, of the same size as the original. rope8a = rope8 + fragment8; -assertEq(tByteSize(rope8a), s(16, 24)); +assertEq(byteSize(rope8a), s(RN, RN)); rope8a.match(/x/, function() { assertEq(true, false); }); -assertEq(tByteSize(rope8a), s(16 + 65536, 24 + 65536)); -assertEq(tByteSize(rope8), s(16, 24)); +assertEq(byteSize(rope8a), s(XN + 65536, XN + 65536)); +assertEq(byteSize(rope8), s(RN, RN)); // A char16_t rope. This changes size when flattened. // "From the Heliconian Muses let us begin to sing" // --- Hesiod, Theogony var fragment16 = "μουσάων Ἑλικωνιάδων ἀρχώμεθ᾽ ἀείδειν"; var rope16 = fragment16; for (var i = 0; i < 10; i++) // 1024 repetitions rope16 = rope16 + rope16; -assertEq(tByteSize(rope16), s(16, 24)); +assertEq(byteSize(rope16), s(RN, RN)); let matches16 = rope16.match(/(Ἑλικωνιάδων ἀρχώμεθ᾽)/); -assertEq(tByteSize(rope16), s(16 + 131072, 24 + 131072)); +assertEq(byteSize(rope16), s(RN + 131072, RN + 131072)); // Latin-1 and char16_t dependent strings. -assertEq(tByteSize(rope8.substr(1000, 2000)), s(16, 24)); -assertEq(tByteSize(rope16.substr(1000, 2000)), s(16, 24)); -assertEq(tByteSize(matches8[0]), s(16, 24)); -assertEq(tByteSize(matches8[1]), s(16, 24)); -assertEq(tByteSize(matches16[0]), s(16, 24)); -assertEq(tByteSize(matches16[1]), s(16, 24)); +assertEq(byteSize(rope8.substr(1000, 2000)), s(DN, DN)); +assertEq(byteSize(rope16.substr(1000, 2000)), s(DN, DN)); +assertEq(byteSize(matches8[0]), s(DN, DN)); +assertEq(byteSize(matches8[1]), s(DN, DN)); +assertEq(byteSize(matches16[0]), s(DN, DN)); +assertEq(byteSize(matches16[1]), s(DN, DN)); // Test extensible strings. // // Appending another copy of the fragment should yield another rope. // // Flatting that should turn the original rope into a dependent string, and // yield a new linear string, of the some size as the original. rope16a = rope16 + fragment16; -assertEq(tByteSize(rope16a), s(16, 24)); +assertEq(byteSize(rope16a), s(RN, RN)); rope16a.match(/x/, function() { assertEq(true, false); }); -assertEq(tByteSize(rope16a), s(16 + 131072, 24 + 131072)); -assertEq(tByteSize(rope16), s(16, 24)); +assertEq(byteSize(rope16a), s(XN + 131072, XN + 131072)); +assertEq(byteSize(rope16), s(XN, XN));