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

Comparing jsr166/src/jsr166y/ForkJoinPool.java (file contents):
Revision 1.174 by jsr166, Sun Jan 13 21:56:12 2013 UTC vs.
Revision 1.175 by jsr166, Sat Jan 19 20:39:43 2013 UTC

# Line 1026 | Line 1026 | public class ForkJoinPool extends Abstra
1026          private static final int ABASE;
1027          private static final int ASHIFT;
1028          static {
1029            int s;
1029              try {
1030                  U = getUnsafe();
1031                  Class<?> k = WorkQueue.class;
# Line 1034 | Line 1033 | public class ForkJoinPool extends Abstra
1033                  QLOCK = U.objectFieldOffset
1034                      (k.getDeclaredField("qlock"));
1035                  ABASE = U.arrayBaseOffset(ak);
1036 <                s = U.arrayIndexScale(ak);
1036 >                int scale = U.arrayIndexScale(ak);
1037 >                if ((scale & (scale - 1)) != 0)
1038 >                    throw new Error("data type scale not a power of two");
1039 >                ASHIFT = 31 - Integer.numberOfLeadingZeros(scale);
1040              } catch (Exception e) {
1041                  throw new Error(e);
1042              }
1041            if ((s & (s-1)) != 0)
1042                throw new Error("data type scale not a power of two");
1043            ASHIFT = 31 - Integer.numberOfLeadingZeros(s);
1043          }
1044      }
1045  
# Line 3330 | Line 3329 | public class ForkJoinPool extends Abstra
3329      private static final long QLOCK;
3330  
3331      static {
3332 <        int s; // initialize field offsets for CAS etc
3332 >        // initialize field offsets for CAS etc
3333          try {
3334              U = getUnsafe();
3335              Class<?> k = ForkJoinPool.class;
# Line 3350 | Line 3349 | public class ForkJoinPool extends Abstra
3349                  (wk.getDeclaredField("qlock"));
3350              Class<?> ak = ForkJoinTask[].class;
3351              ABASE = U.arrayBaseOffset(ak);
3352 <            s = U.arrayIndexScale(ak);
3353 <            ASHIFT = 31 - Integer.numberOfLeadingZeros(s);
3352 >            int scale = U.arrayIndexScale(ak);
3353 >            if ((scale & (scale - 1)) != 0)
3354 >                throw new Error("data type scale not a power of two");
3355 >            ASHIFT = 31 - Integer.numberOfLeadingZeros(scale);
3356          } catch (Exception e) {
3357              throw new Error(e);
3358          }
3358        if ((s & (s-1)) != 0)
3359            throw new Error("data type scale not a power of two");
3359  
3360          submitters = new ThreadLocal<Submitter>();
3361          ForkJoinWorkerThreadFactory fac = defaultForkJoinWorkerThreadFactory =

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines