jdk/src/java.desktop/share/classes/sun/java2d/marlin/IntArrayCache.java
changeset 47126 188ef162f019
parent 40421 d5ee65e2b0fb
equal deleted inserted replaced
45093:c42dc7b58b4d 47126:188ef162f019
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    20  *
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    23  * questions.
    24  */
    24  */
       
    25 
    25 package sun.java2d.marlin;
    26 package sun.java2d.marlin;
    26 
    27 
    27 import static sun.java2d.marlin.ArrayCacheConst.ARRAY_SIZES;
    28 import static sun.java2d.marlin.ArrayCacheConst.ARRAY_SIZES;
    28 import static sun.java2d.marlin.ArrayCacheConst.BUCKETS;
    29 import static sun.java2d.marlin.ArrayCacheConst.BUCKETS;
    29 import static sun.java2d.marlin.ArrayCacheConst.MAX_ARRAY_SIZE;
    30 import static sun.java2d.marlin.ArrayCacheConst.MAX_ARRAY_SIZE;
    35 
    36 
    36 import sun.java2d.marlin.ArrayCacheConst.BucketStats;
    37 import sun.java2d.marlin.ArrayCacheConst.BucketStats;
    37 import sun.java2d.marlin.ArrayCacheConst.CacheStats;
    38 import sun.java2d.marlin.ArrayCacheConst.CacheStats;
    38 
    39 
    39 /*
    40 /*
    40  * Note that the [BYTE/INT/FLOAT]ArrayCache files are nearly identical except
    41  * Note that the [BYTE/INT/FLOAT/DOUBLE]ArrayCache files are nearly identical except
    41  * for a few type and name differences. Typically, the [BYTE]ArrayCache.java file
    42  * for a few type and name differences. Typically, the [BYTE]ArrayCache.java file
    42  * is edited manually and then [INT]ArrayCache.java and [FLOAT]ArrayCache.java
    43  * is edited manually and then [INT/FLOAT/DOUBLE]ArrayCache.java
    43  * files are generated with the following command lines:
    44  * files are generated with the following command lines:
    44  */
    45  */
    45 // % sed -e 's/(b\yte)[ ]*//g' -e 's/b\yte/int/g' -e 's/B\yte/Int/g' < B\yteArrayCache.java > IntArrayCache.java
    46 // % sed -e 's/(b\yte)[ ]*//g' -e 's/b\yte/int/g' -e 's/B\yte/Int/g' < B\yteArrayCache.java > IntArrayCache.java
    46 // % sed -e 's/(b\yte)[ ]*/(float) /g' -e 's/b\yte/float/g' -e 's/B\yte/Float/g' < B\yteArrayCache.java > FloatArrayCache.java
    47 // % sed -e 's/(b\yte)[ ]*0/0.0f/g' -e 's/(b\yte)[ ]*/(float) /g' -e 's/b\yte/float/g' -e 's/B\yte/Float/g' < B\yteArrayCache.java > FloatArrayCache.java
       
    48 // % sed -e 's/(b\yte)[ ]*0/0.0d/g' -e 's/(b\yte)[ ]*/(double) /g' -e 's/b\yte/double/g' -e 's/B\yte/Double/g' < B\yteArrayCache.java > DoubleArrayCache.java
    47 
    49 
    48 final class IntArrayCache implements MarlinConst {
    50 final class IntArrayCache implements MarlinConst {
    49 
    51 
    50     final boolean clean;
    52     final boolean clean;
    51     private final int bucketCapacity;
    53     private final int bucketCapacity;
   229 
   231 
   230     static int[] createArray(final int length, final boolean clean) {
   232     static int[] createArray(final int length, final boolean clean) {
   231         if (clean) {
   233         if (clean) {
   232             return new int[length];
   234             return new int[length];
   233         }
   235         }
   234        // use JDK9 Unsafe.allocateUninitializedArray(class, length):
   236         // use JDK9 Unsafe.allocateUninitializedArray(class, length):
   235        return (int[]) OffHeapArray.UNSAFE.allocateUninitializedArray(int.class, length);
   237         return (int[]) OffHeapArray.UNSAFE.allocateUninitializedArray(int.class, length);
   236     }
   238     }
   237 
   239 
   238     static void fill(final int[] array, final int fromIndex,
   240     static void fill(final int[] array, final int fromIndex,
   239                      final int toIndex, final int value)
   241                      final int toIndex, final int value)
   240     {
   242     {