summaryrefslogtreecommitdiff
path: root/chapter21/src/main/java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2025-03-29 14:47:33 -0700
committerCliff Click <cliffc@acm.org>2025-03-29 14:47:33 -0700
commit99d3fe964eb556370d0f23327b29c26cee9b3edb (patch)
tree3bcbffe0d5cb87e24f0f8d33d70bd91ed0280d83 /chapter21/src/main/java
parentb09370af9db2be3b763eb72a61a34aecb743dcd9 (diff)
downloadSimple-99d3fe964eb556370d0f23327b29c26cee9b3edb.tar.gz
Simple-99d3fe964eb556370d0f23327b29c26cee9b3edb.zip
Fix non-deterministic bug
Diffstat (limited to 'chapter21/src/main/java')
-rw-r--r--chapter21/src/main/java/com/seaofnodes/simple/codegen/RegAlloc.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/chapter21/src/main/java/com/seaofnodes/simple/codegen/RegAlloc.java b/chapter21/src/main/java/com/seaofnodes/simple/codegen/RegAlloc.java
index 6ffb42c9..fa3c2b81 100644
--- a/chapter21/src/main/java/com/seaofnodes/simple/codegen/RegAlloc.java
+++ b/chapter21/src/main/java/com/seaofnodes/simple/codegen/RegAlloc.java
@@ -151,7 +151,6 @@ public class RegAlloc {
if( bb instanceof CallNode ) lastFun._hasCalls = true;
}
-
// Top driver: repeated rounds of coloring and splitting.
byte round=0;
while( !graphColor(round) ) {
@@ -203,7 +202,11 @@ public class RegAlloc {
// independently... which generally requires a full pass over the
// program for each failing live range. i.e., might be a lot of
// passes.
- for( LRG lrg : _failed.keySet() )
+
+ // Sort, to avoid non-deterministic HashMap ordering
+ LRG[] splits = _failed.keySet().toArray(new LRG[0]);
+ Arrays.sort(splits, (x,y) -> x._lrg - y._lrg );
+ for( LRG lrg : splits )
split(round,lrg);
}