diff options
| author | Cliff Click <cliffc@acm.org> | 2026-11-16 09:15:19 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-11-16 09:15:19 -0800 |
| commit | c21026c5377429b11e285d251439407074fe3cd1 (patch) | |
| tree | 7bb440f01ade1265b39acb96c98481b33241a67b /chapter32/src/main/java | |
| parent | 6643e8fda31a81ec40f33caa5c866b821fd04910 (diff) | |
| download | Simple-c21026c5377429b11e285d251439407074fe3cd1.tar.gz Simple-c21026c5377429b11e285d251439407074fe3cd1.zip | |
One more qucik speedup item
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.java | 7 | ||||
| -rw-r--r-- | chapter32/src/main/java/com/seaofnodes/simple/util/BAOS.java | 12 |
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; } |
