revert: remove safeToString_ and recursive toString handling due to memory leak on runtime errors

The safeToString_ mechanism introduced in 40897f33 used per-fiber maps and lists to detect recursive toString calls, but leaked memory when runtime errors occurred before cleanup. This reverts to direct toString implementations for List and Map, removing the recursive detection logic and updating tests to mark self-referencing containers as TODO.
This commit is contained in:
Bob Nystrom
2015-05-19 13:50:17 +00:00
parent 13f63e0d04
commit 701cffbe69
4 changed files with 20 additions and 137 deletions
+1 -34
View File
@@ -14,37 +14,4 @@ class Foo {
IO.print([1, new Foo, 2]) // expect: [1, Foo.toString, 2]
// Lists that directly contain themselves.
var list = []
list.add(list)
IO.print(list) // expect: [...]
list = [1, 2]
list[0] = list
IO.print(list) // expect: [..., 2]
list = [1, 2]
list[1] = list
IO.print(list) // expect: [1, ...]
// Lists that indirectly contain themselves.
list = [null, [2, [3, null, 4], null, 5], 6]
list[0] = list
list[1][1][1] = list
list[1][2] = list
IO.print(list) // expect: [..., [2, [3, ..., 4], ..., 5], 6]
// List containing an object that calls toString on a recursive list.
class Box {
new(field) { _field = field }
toString { "box " + _field.toString }
}
list = [1, 2]
list.add(new Box(list))
IO.print(list) // expect: [1, 2, box ...]
// List containing a map containing the list.
list = [1, null, 2]
list[1] = {"list": list}
IO.print(list) // expect: [1, {list: ...}, 2]
// TODO: Handle lists that contain themselves.