/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Population-based coding.
* See the section "Encodings of Uncorrelated Values" in the Pack200 spec.
* @author John Rose
*/
// This tactic alone reduces the final zipped rt.jar by about a percent.
int L = -1; //preferred L value for tokenCoding
// Note: {f} is allFavoredValues[1..fvlen], not [0..fvlen-1].
// This is because zero is an exceptional favored value index.
if (L >= 0) {
setL(L); // reassert
}
}
}
}
public void setL(int L) {
this.L = L;
assert(tokenCoding != null);
}
}
// Find the smallest B s.t. (B,H,0) covers fVlen.
if (fVlen < 256)
// H/L do not matter when B==1
return BandStructure.BYTE1;
return null; // failure; L is too sharp and fVlen too large
break;
}
return tc;
}
this.favoredCoding = favoredCoding;
}
this.tokenCoding = tokenCoding;
this.L = -1;
this.L = tc.L();
// Otherwise, it's a non-default coding.
}
}
this.unfavoredCoding = unfavoredCoding;
}
public int favoredValueMaxLength() {
if (L == 0)
else
}
public void resortFavoredValues() {
// Make a local copy before reordering.
// Resort favoredValues within each byte-size cadre.
for (int n = 1; n <= tc.B(); n++) {
break;
// Divide the values into cadres, and sort within each.
int prevCount = -1;
if (n == 1) {
// For the single-byte encoding, keep strict order
// among frequency groups.
// Find a single inflection point
// close to the middle of the byte-size cadre.
mid = i;
}
prevLimit = i;
}
}
if (n == 1) {
} else {
// Sort up to the midpoint, if any.
}
}
// Reset symtab.
}
symtab = makeSymtab();
else
return 0;
}
// Compute token sequence.
int nuv = 0;
if (tok != 0)
else
nuv += 1;
}
// Compute unfavored value sequence.
int[] unfavoredValues = new int[nuv];
}
return new int[][]{ tokens, unfavoredValues };
}
private long[] makeSymtab() {
}
// Index by value:
return lsymtab;
}
while (c instanceof AdaptiveCoding)
c = ((AdaptiveCoding)c).tailCoding;
return (Coding) c;
}
// CodingMethod methods.
}
}
int computeSentinelValue() {
// repeat the last favored value, using delta=0
return 0;
} else {
// else repeat the shorter of the min or last value
// (remember that fVlen is an inclusive limit in fValues)
for (int i = 2; i <= fVlen; i++) {
}
int endVal;
return min;
else
return last;
}
}
// Parameters are fCode, L, uCode.
// Read the tokens. Read them into the final array, for the moment.
// Decode the favored tokens.
int uVlen = 0;
int tok = a[i];
if (tok == 0) {
// Make a linked list, and decode in a second pass.
if (tailp < 0) {
headp = i;
} else {
a[tailp] = i;
}
tailp = i;
uVlen += 1;
} else {
}
}
// Walk the linked list of "zero" locations, decoding unfavored vals.
if (uVlen > 0)
for (int i = 0; i < uVlen; i++) {
}
}
// The set uniqueValuesForDebug records all favored values.
// As each new value is added, we assert that the value
// was not already in the set.
int fillp = 1;
maxForDebug += fillp;
//int min2 = Integer.MIN_VALUE; // emulate buggy 150.7 spec.
int last = 0;
while (fcm instanceof AdaptiveCoding) {
}
assert(fillp <= maxForDebug);
//min2 = moreCentral2(min2, val, min);
}
}
for (long state = 0;;) {
// Read a new value:
int val;
if (fc.isSubrange())
else
break;
assert(fillp <= maxForDebug);
//min2 = moreCentral(min2, val);
}
} else {
for (;;) {
break;
assert(fillp <= maxForDebug);
//min2 = moreCentral2(min2, val, min);
}
}
}
private static int moreCentral(int x, int y) {
// assert that this ALU-ish version is the same:
assert(xy == moreCentralSlow(x, y));
return xy;
}
// private static int moreCentral2(int x, int y, int min) {
// // Strict implementation of buggy 150.7 specification.
// // The bug is that the spec. says absolute-value ties are broken
// // in favor of positive numbers, but the suggested implementation
// // (also mentioned in the spec.) breaks ties in favor of negatives.
// if (x + y == 0) return (x > y? x : y);
// return min;
// }
private static int moreCentralSlow(int x, int y) {
int ax = x;
int ay = y;
// At this point the absolute values agree, and the negative wins.
return x < y ? x : y;
}
static final int[] LValuesCoded
= { -1, 4, 8, 16, 32, 64, 128, 192, 224, 240, 248, 252 };
int K = fVlen;
int LCoded = 0;
if (tokenCoding instanceof Coding) {
if (tc.B() == 1) {
LCoded = 1;
} else if (L >= 0) {
assert(L == tc.L());
if (LValuesCoded[i] == L) { LCoded = i; break; }
}
}
}
// A simple L value is enough to recover the tokenCoding.
}
try {
} catch (IOException ee) {
throw new RuntimeException(ee);
}
return bytes.toByteArray();
}
int L = LValuesCoded[TDefL];
if (FDef == 0)
if (TDef == 0)
if (UDef == 0)
pop.L = L; // might be -1
return pos;
}
if (m instanceof Coding)
if (m == null)
return "none";
return m.toString();
}
boolean verbose
for (int i = 1; i <= fVlen; i++) {
}
}
}
}