Implement StringBuilder.setLength

Doesn't differ at all from @alexander-myltsev's original PR (#771), except for the squashing of the commits. The increase in size from #780 also accounts for the additional size this PR introduces.