From c21026c5377429b11e285d251439407074fe3cd1 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Mon, 16 Nov 2026 09:15:19 -0800 Subject: One more qucik speedup item --- .../com/seaofnodes/simple/node/cpus/x86_64_v2/x86_64_v2.java | 7 ++++--- chapter32/src/main/java/com/seaofnodes/simple/util/BAOS.java | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'chapter32/src/main/java/com/seaofnodes') 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 writers=load.antiDeps(new Ary<>(Node.class)); if( writers.isEmpty() ) return true; - var seen=new IdentityHashMap(); + var seen=new BitSet(); Ary 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 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 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; } -- cgit v1.2.3