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

Comparing jsr166/src/jdk7/java/util/concurrent/ForkJoinPool.java (file contents):
Revision 1.7 by jsr166, Sun Jan 13 21:56:12 2013 UTC vs.
Revision 1.8 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 = sun.misc.Unsafe.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 3287 | Line 3286 | public class ForkJoinPool extends Abstra
3286      private static final long QLOCK;
3287  
3288      static {
3289 <        int s; // initialize field offsets for CAS etc
3289 >        // initialize field offsets for CAS etc
3290          try {
3291              U = sun.misc.Unsafe.getUnsafe();
3292              Class<?> k = ForkJoinPool.class;
# Line 3307 | Line 3306 | public class ForkJoinPool extends Abstra
3306                  (wk.getDeclaredField("qlock"));
3307              Class<?> ak = ForkJoinTask[].class;
3308              ABASE = U.arrayBaseOffset(ak);
3309 <            s = U.arrayIndexScale(ak);
3310 <            ASHIFT = 31 - Integer.numberOfLeadingZeros(s);
3309 >            int scale = U.arrayIndexScale(ak);
3310 >            if ((scale & (scale - 1)) != 0)
3311 >                throw new Error("data type scale not a power of two");
3312 >            ASHIFT = 31 - Integer.numberOfLeadingZeros(scale);
3313          } catch (Exception e) {
3314              throw new Error(e);
3315          }
3315        if ((s & (s-1)) != 0)
3316            throw new Error("data type scale not a power of two");
3316  
3317          submitters = new ThreadLocal<Submitter>();
3318          ForkJoinWorkerThreadFactory fac = defaultForkJoinWorkerThreadFactory =

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines