Created
July 3, 2019 18:03
-
-
Save hotsphink/5552a2c01f9d2ad3d43366c27f5aba42 to your computer and use it in GitHub Desktop.
mkgist-created gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function makeExtensibleString() { | |
| var s = "x"; | |
| var t = "yyyyyyyyyyyyyyyyyyytyyyyyy"; | |
| var r1 = t + s; | |
| ensureFlatString(r1); | |
| return r1; | |
| } | |
| function test() { | |
| const s0 = makeExtensibleString(); | |
| const r0 = s0 + (s0 + "!"); | |
| ensureFlatString(r0); | |
| const s = makeExtensibleString(); | |
| const right = (s + "!"); | |
| const r = s + right; | |
| // print(r); | |
| dumpStringRepresentation(r); | |
| print(" ------------"); | |
| Math.sin(0, r); | |
| ensureFlatString(r); | |
| dumpStringRepresentation(right); // right should now be a dependent string with .base = r | |
| print(" ----- minor GC -------"); | |
| minorgc(); | |
| // Expect r0 to be marked first, added to deDupSet. Then r gets deduplicated to r0. | |
| // Now right is a dependent string pointing to r's old data, which gets freed. | |
| print(right); | |
| print(" --- r -----"); | |
| dumpStringRepresentation(r); | |
| print(" --- right, after minorgc -----"); | |
| dumpStringRepresentation(right); | |
| } | |
| test(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment