ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ForkJoinPool.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/ForkJoinPool.java (file contents):
Revision 1.141 by jsr166, Wed Jan 16 22:10:06 2013 UTC vs.
Revision 1.142 by jsr166, Sat Jan 19 20:39:43 2013 UTC

# Line 1006 | Line 1006 | public class ForkJoinPool extends Abstra
1006          private static final int ABASE;
1007          private static final int ASHIFT;
1008          static {
1009            int s;
1009              try {
1010                  U = sun.misc.Unsafe.getUnsafe();
1011                  Class<?> k = WorkQueue.class;
# Line 1014 | Line 1013 | public class ForkJoinPool extends Abstra
1013                  QLOCK = U.objectFieldOffset
1014                      (k.getDeclaredField("qlock"));
1015                  ABASE = U.arrayBaseOffset(ak);
1016 <                s = U.arrayIndexScale(ak);
1016 >                int scale = U.arrayIndexScale(ak);
1017 >                if ((scale & (scale - 1)) != 0)
1018 >                    throw new Error("data type scale not a power of two");
1019 >                ASHIFT = 31 - Integer.numberOfLeadingZeros(scale);
1020              } catch (Exception e) {
1021                  throw new Error(e);
1022              }
1021            if ((s & (s-1)) != 0)
1022                throw new Error("data type scale not a power of two");
1023            ASHIFT = 31 - Integer.numberOfLeadingZeros(s);
1023          }
1024      }
1025  
# Line 3286 | Line 3285 | public class ForkJoinPool extends Abstra
3285      private static final long QLOCK;
3286  
3287      static {
3288 <        int s; // initialize field offsets for CAS etc
3288 >        // initialize field offsets for CAS etc
3289          try {
3290              U = sun.misc.Unsafe.getUnsafe();
3291              Class<?> k = ForkJoinPool.class;
# Line 3306 | Line 3305 | public class ForkJoinPool extends Abstra
3305                  (wk.getDeclaredField("qlock"));
3306              Class<?> ak = ForkJoinTask[].class;
3307              ABASE = U.arrayBaseOffset(ak);
3308 <            s = U.arrayIndexScale(ak);
3309 <            ASHIFT = 31 - Integer.numberOfLeadingZeros(s);
3308 >            int scale = U.arrayIndexScale(ak);
3309 >            if ((scale & (scale - 1)) != 0)
3310 >                throw new Error("data type scale not a power of two");
3311 >            ASHIFT = 31 - Integer.numberOfLeadingZeros(scale);
3312          } catch (Exception e) {
3313              throw new Error(e);
3314          }
3314        if ((s & (s-1)) != 0)
3315            throw new Error("data type scale not a power of two");
3315  
3316          ForkJoinWorkerThreadFactory fac = defaultForkJoinWorkerThreadFactory =
3317              new DefaultForkJoinWorkerThreadFactory();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines