summaryrefslogtreecommitdiff
path: root/chapter32/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'chapter32/src/main/java')
-rw-r--r--chapter32/src/main/java/com/seaofnodes/simple/node/cpus/x86_64_v2/x86_64_v2.java7
-rw-r--r--chapter32/src/main/java/com/seaofnodes/simple/util/BAOS.java12
2 files changed, 10 insertions, 9 deletions
diff --git a/chapter32/src/main/java/com/seaofnodes/simple/node/cpus/x86_64_v2/x86_64_v2.java b/chapter32/src/main/java/com/seaofnodes/simple/node/cpus/x86_64_v2/x86_64_v2.java
index d4714953..9e0d864a 100644
--- a/chapter32/src/main/java/com/seaofnodes/simple/node/cpus/x86_64_v2/x86_64_v2.java
+++ b/chapter32/src/main/java/com/seaofnodes/simple/node/cpus/x86_64_v2/x86_64_v2.java
@@ -5,7 +5,7 @@ import com.seaofnodes.simple.node.*;
import com.seaofnodes.simple.type.*;
import com.seaofnodes.simple.util.Utils;
import com.seaofnodes.simple.util.Ary;
-import java.util.IdentityHashMap;
+import java.util.BitSet;
public class x86_64_v2 extends Machine {
public x86_64_v2( CodeGen code ) {}
@@ -461,12 +461,13 @@ public class x86_64_v2 extends Machine {
if( load.nOuts()!=1 ) return false;
Ary<Node> writers=load.antiDeps(new Ary<>(Node.class));
if( writers.isEmpty() ) return true;
- var seen=new IdentityHashMap<Node,Boolean>();
+ var seen=new BitSet();
Ary<Node> work=new Ary<>(Node.class);
work.push(value);
while( !work.isEmpty() ) {
Node n=work.pop();
- if( seen.put(n,Boolean.TRUE)!=null ) continue;
+ if( seen.get(n._nid) ) continue;
+ seen.set(n._nid);
if( writers.find(n)!=-1 ) return false;
for( Node def : n._inputs ) if( def!=null ) work.push(def);
}
diff --git a/chapter32/src/main/java/com/seaofnodes/simple/util/BAOS.java b/chapter32/src/main/java/com/seaofnodes/simple/util/BAOS.java
index 61ce7387..a4d1f183 100644
--- a/chapter32/src/main/java/com/seaofnodes/simple/util/BAOS.java
+++ b/chapter32/src/main/java/com/seaofnodes/simple/util/BAOS.java
@@ -1,6 +1,6 @@
package com.seaofnodes.simple.util;
-import java.util.HashMap;
+//import java.util.HashMap;
import java.util.Arrays;
// "ByteArrayOutputStream", and Input Stream and not synchronized and has
@@ -96,12 +96,12 @@ public class BAOS {
}
// -----------------------------------------------------------------------
- // Write a packed integer to the BAOS. Track a histogram to make more
- // intelligent choices in the future.
- private static final HashMap<Long,Integer> PACKED_HISTOGRAM = new HashMap<>();
+ // Optional profiling for choosing smaller packed representations. Leave
+ // disabled during normal compilation; re-enable when studying .simple size.
+ //private static final HashMap<Long,Integer> PACKED_HISTOGRAM = new HashMap<>();
private BAOS histo(long x) {
- Integer cnt = PACKED_HISTOGRAM.get(x);
- PACKED_HISTOGRAM.put(x,cnt==null ? 1 : cnt+1);
+ //Integer cnt = PACKED_HISTOGRAM.get(x);
+ //PACKED_HISTOGRAM.put(x,cnt==null ? 1 : cnt+1);
return this;
}