@@ -60,7 +60,7 @@ fun heightToNodes(h: Int32): Int64 {
6060}
6161
6262fun heightToBytes(h: Int32): Int64 {
63- return BYTES_PER_NODE.toInt64() * heightToNodes(h);
63+ return BYTES_PER_NODE.toInt64 * heightToNodes(h);
6464}
6565
6666fun nodesToHeight(nnodes: Int64): Int32 {
@@ -76,7 +76,7 @@ fun nodesToHeight(nnodes: Int64): Int32 {
7676}
7777
7878fun bytesToHeight(bytes: Int64): Int32 {
79- return nodesToHeight(bytes / BYTES_PER_NODE.toInt64() );
79+ return nodesToHeight(bytes / BYTES_PER_NODE.toInt64);
8080}
8181
8282fun makeTree(h: Int32): TreeNode {
@@ -91,7 +91,7 @@ fun makeTree(h: Int32): TreeNode {
9191}
9292
9393fun initialize(): Unit {
94- let ntrees = (size * MEG).toInt64() / treeSize;
94+ let ntrees = (size * MEG).toInt64 / treeSize;
9595 let default = TreeNode(Option[TreeNode]::None, Option[TreeNode]::None, 0i32);
9696 trees = Array[TreeNode]::fill(ntrees, default);
9797
@@ -133,17 +133,17 @@ fun replaceTreeWork(full: TreeNode, partial: TreeNode, dir: Bool): Unit {
133133
134134 if canGoLeft && canGoRight {
135135 if dir {
136- replaceTreeWork(full.left.getOrPanic(), partial, dir.not() );
136+ replaceTreeWork(full.left.getOrPanic(), partial, dir.not);
137137 } else {
138- replaceTreeWork(full.right.getOrPanic(), partial, dir.not() );
138+ replaceTreeWork(full.right.getOrPanic(), partial, dir.not);
139139 }
140- } else if canGoLeft.not() && canGoRight.not() {
140+ } else if canGoLeft.not && canGoRight.not {
141141 if dir {
142142 full.left = Option[TreeNode]::Some(partial);
143143 } else {
144144 full.right = Option[TreeNode]::Some(partial);
145145 }
146- } else if canGoLeft.not() {
146+ } else if canGoLeft.not {
147147 full.left = Option[TreeNode]::Some(partial);
148148 } else {
149149 full.right = Option[TreeNode]::Some(partial);
@@ -162,10 +162,10 @@ fun oldGenAlloc(n: Int64): Unit {
162162
163163 var i = 0i64;
164164 while i < full {
165- trees(where.toInt64() ) = makeTree(treeHeight);
165+ trees(where.toInt64) = makeTree(treeHeight);
166166 where = where + 1i32;
167167
168- if where.toInt64() == trees.size() {
168+ if where.toInt64 == trees.size() {
169169 where = 0i32;
170170 }
171171
@@ -175,10 +175,10 @@ fun oldGenAlloc(n: Int64): Unit {
175175 while partial > INSIGNIFICANT {
176176 let h = bytesToHeight(partial);
177177 let newTree = makeTree(h);
178- replaceTree(trees(where.toInt64() ), newTree);
178+ replaceTree(trees(where.toInt64), newTree);
179179 where = where + 1i32;
180180
181- if where.toInt64() == trees.size() {
181+ if where.toInt64 == trees.size() {
182182 where = 0i32;
183183 }
184184
@@ -187,13 +187,13 @@ fun oldGenAlloc(n: Int64): Unit {
187187}
188188
189189fun oldGenSwapSubtrees(): Unit {
190- let index1 = rnd.nextInt32WithBound(trees.size().toInt32() );
191- let index2 = rnd.nextInt32WithBound(trees.size().toInt32() );
190+ let index1 = rnd.nextInt32WithBound(trees.size().toInt32);
191+ let index2 = rnd.nextInt32WithBound(trees.size().toInt32);
192192 let depth = rnd.nextInt32WithBound(treeHeight);
193193 var path = rnd.nextInt32();
194194
195- var tn1 = trees(index1.toInt64() );
196- var tn2 = trees(index2.toInt64() );
195+ var tn1 = trees(index1.toInt64);
196+ var tn2 = trees(index2.toInt64);
197197
198198 var i = 0i32;
199199
@@ -233,7 +233,7 @@ fun oldGenMut(n: Int64): Unit {
233233
234234fun doMutWork(n: Int64): Unit {
235235 var sum = 0i32;
236- let limit = workUnits.toInt64() * n / 10i64;
236+ let limit = workUnits.toInt64 * n / 10i64;
237237
238238 var k = 0i64;
239239
@@ -242,16 +242,16 @@ fun doMutWork(n: Int64): Unit {
242242 k = k + 1i64;
243243 }
244244
245- mutatorSum = mutatorSum + sum.toInt64() ;
245+ mutatorSum = mutatorSum + sum.toInt64;
246246}
247247
248248fun doYoungGenAlloc(n: Int64, nwords: Int32): Unit {
249249 let nbytes = nwords * BYTES_PER_WORD;
250250 var allocated = 0i64;
251251
252252 while allocated < n {
253- aexport = Array[Int64]::zero(nwords.toInt64() );
254- allocated = allocated + nbytes.toInt64() ;
253+ aexport = Array[Int64]::zero(nwords.toInt64);
254+ allocated = allocated + nbytes.toInt64;
255255 }
256256
257257 youngBytes = youngBytes + allocated;
@@ -262,8 +262,8 @@ fun doStep(n: Int64): Unit {
262262
263263 doYoungGenAlloc(n, WORDS_DEAD);
264264 doMutWork(n);
265- oldGenAlloc(n / promoteRate.toInt64() );
266- oldGenMut(Int64::max(0i64, (mutations + ptrMutRate.toInt64() ) - actuallyMut));
265+ oldGenAlloc(n / promoteRate.toInt64);
266+ oldGenMut(Int64::max(0i64, (mutations + ptrMutRate.toInt64) - actuallyMut));
267267}
268268
269269fun main(): Unit {
@@ -281,11 +281,11 @@ fun main(): Unit {
281281
282282 treeSize = heightToBytes(treeHeight);
283283
284- size = std::argv(0i32).toInt32() .getOrPanic();
285- workUnits = std::argv(1i32).toInt32() .getOrPanic();
286- promoteRate = std::argv(2i32).toInt32() .getOrPanic();
287- ptrMutRate = std::argv(3i32).toInt32() .getOrPanic();
288- steps = std::argv(4i32).toInt32() .getOrPanic();
284+ size = std::argv(0i32).toInt32.getOrPanic();
285+ workUnits = std::argv(1i32).toInt32.getOrPanic();
286+ promoteRate = std::argv(2i32).toInt32.getOrPanic();
287+ ptrMutRate = std::argv(3i32).toInt32.getOrPanic();
288+ steps = std::argv(4i32).toInt32.getOrPanic();
289289
290290 println("GCOld: version 1.0");
291291 println(size.toString() + " megabytes of live storage");
@@ -306,28 +306,28 @@ fun main(): Unit {
306306 var step = 0i32;
307307
308308 while step < steps {
309- doStep(MEG.toInt64() );
309+ doStep(MEG.toInt64);
310310 step = step + 1i32;
311311 }
312312
313313 let end = std::timestamp();
314- let secs = (end - start).toFloat32() / 1000.0f32 / 1000.0f32 / 1000.0f32;
314+ let secs = (end - start).toFloat32 / 1000.0f32 / 1000.0f32 / 1000.0f32;
315315
316316 checkTrees();
317317
318318 println("\nTook " + secs.toString() + " sec in steady state.");
319319 println("Allocated " + steps.toString() + " Mb of young gen garbage"
320- + " (= " + (steps.toFloat32() / secs).toString() + " Mb/sec)");
320+ + " (= " + (steps.toFloat32 / secs).toString() + " Mb/sec)");
321321 println(" (actually allocated "
322- + (youngBytes.toFloat32() / MEG.toFloat32() ).toString() + " megabytes)");
323- let promoted = steps.toFloat32() / promoteRate.toFloat32() ;
322+ + (youngBytes.toFloat32 / MEG.toFloat32).toString() + " megabytes)");
323+ let promoted = steps.toFloat32 / promoteRate.toFloat32;
324324 println("Promoted " + promoted.toString()
325325 + " Mb (= " + (promoted / secs).toString() + " Mb/sec)");
326- println(" (actually promoted " + ((nodes * BYTES_PER_NODE.toInt64()) .toFloat32() / MEG.toFloat32() ).toString() + " megabytes)");
326+ println(" (actually promoted " + ((nodes * BYTES_PER_NODE.toInt64) .toFloat32 / MEG.toFloat32).toString() + " megabytes)");
327327
328328 if ptrMutRate != 0i32 {
329329 println("Mutated " + actuallyMut.toString() +
330- " pointers (= " + (actuallyMut.toFloat32() / secs).toString() + " ptrs/sec)");
330+ " pointers (= " + (actuallyMut.toFloat32 / secs).toString() + " ptrs/sec)");
331331 }
332332
333333 println("Checksum = " + (mutatorSum + aexport.size()).toString());
0 commit comments