[performance] Remove synthetic access$ methods in pack and file packages

Java compiler must generate synthetic access methods for private methods
and fields of the enclosing class if they are accessed from inner
classes and vice versa.

While invisible in the code, those synthetic access methods exist in the
bytecode and seem to produce some extra execution overhead at runtime
(compared with the direct access to this fields or methods), see
https://git.eclipse.org/r/58948/.

By removing the "private" access modifier from affected methods and
fields we help compiler to avoid generation of synthetic access methods
and hope to improve execution performance.

To validate changes, one can either use javap or use Bytecode Outline
plugin in Eclipse. In both cases one should look for "synthetic
access$<number>" methods at the end of the class and inner class files
in question - there should be none.

NB: don't mix this "synthetic access$" methods up with "public synthetic
bridge" methods generated to allow generic method override return types.

Change-Id: If53ec94145bae47b74e2561305afe6098012715c
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
This commit is contained in:
Andrey Loskutov 2015-10-27 23:51:21 +01:00
parent 94e31bc478
commit 79a7dd026f
13 changed files with 51 additions and 51 deletions

View File

@ -63,11 +63,11 @@
public class BitmapIndexImpl implements BitmapIndex { public class BitmapIndexImpl implements BitmapIndex {
private static final int EXTRA_BITS = 10 * 1024; private static final int EXTRA_BITS = 10 * 1024;
private final PackBitmapIndex packIndex; final PackBitmapIndex packIndex;
private final MutableBitmapIndex mutableIndex; final MutableBitmapIndex mutableIndex;
private final int indexObjectCount; final int indexObjectCount;
/** /**
* Creates a BitmapIndex that is back by Compressed bitmaps. * Creates a BitmapIndex that is back by Compressed bitmaps.
@ -96,7 +96,7 @@ public CompressedBitmapBuilder newBitmapBuilder() {
return new CompressedBitmapBuilder(); return new CompressedBitmapBuilder();
} }
private int findPosition(AnyObjectId objectId) { int findPosition(AnyObjectId objectId) {
int position = packIndex.findPosition(objectId); int position = packIndex.findPosition(objectId);
if (position < 0) { if (position < 0) {
position = mutableIndex.findPosition(objectId); position = mutableIndex.findPosition(objectId);
@ -106,7 +106,7 @@ private int findPosition(AnyObjectId objectId) {
return position; return position;
} }
private int addObject(AnyObjectId objectId, int type) { int addObject(AnyObjectId objectId, int type) {
int position = findPosition(objectId); int position = findPosition(objectId);
if (position < 0) { if (position < 0) {
position = mutableIndex.addObject(objectId, type); position = mutableIndex.addObject(objectId, type);
@ -122,11 +122,11 @@ private static final class ComboBitset {
private BitSet toRemove; private BitSet toRemove;
private ComboBitset() { ComboBitset() {
this(new EWAHCompressedBitmap()); this(new EWAHCompressedBitmap());
} }
private ComboBitset(EWAHCompressedBitmap bitmap) { ComboBitset(EWAHCompressedBitmap bitmap) {
this.inflatingBitmap = new InflatingBitSet(bitmap); this.inflatingBitmap = new InflatingBitSet(bitmap);
} }
@ -289,15 +289,15 @@ public boolean removeAllOrNone(PackBitmapIndex index) {
return true; return true;
} }
private BitmapIndexImpl getBitmapIndex() { BitmapIndexImpl getBitmapIndex() {
return BitmapIndexImpl.this; return BitmapIndexImpl.this;
} }
} }
final class CompressedBitmap implements Bitmap { final class CompressedBitmap implements Bitmap {
private final EWAHCompressedBitmap bitmap; final EWAHCompressedBitmap bitmap;
private CompressedBitmap(EWAHCompressedBitmap bitmap) { CompressedBitmap(EWAHCompressedBitmap bitmap) {
this.bitmap = bitmap; this.bitmap = bitmap;
} }
@ -387,7 +387,7 @@ EWAHCompressedBitmap getEwahCompressedBitmap() {
return bitmap; return bitmap;
} }
private BitmapIndexImpl getPackBitmapIndex() { BitmapIndexImpl getPackBitmapIndex() {
return BitmapIndexImpl.this; return BitmapIndexImpl.this;
} }
} }
@ -429,9 +429,9 @@ int addObject(AnyObjectId objectId, int type) {
} }
private static final class MutableEntry extends ObjectIdOwnerMap.Entry { private static final class MutableEntry extends ObjectIdOwnerMap.Entry {
private final int type; final int type;
private final int position; final int position;
MutableEntry(AnyObjectId objectId, int type, int position) { MutableEntry(AnyObjectId objectId, int type, int position) {
super(objectId); super(objectId);
@ -456,7 +456,7 @@ public int getType() {
} }
} }
private boolean isSameCompressedBitmap(Bitmap other) { boolean isSameCompressedBitmap(Bitmap other) {
if (other instanceof CompressedBitmap) { if (other instanceof CompressedBitmap) {
CompressedBitmap b = (CompressedBitmap) other; CompressedBitmap b = (CompressedBitmap) other;
return this == b.getPackBitmapIndex(); return this == b.getPackBitmapIndex();
@ -464,7 +464,7 @@ private boolean isSameCompressedBitmap(Bitmap other) {
return false; return false;
} }
private boolean isSameCompressedBitmapBuilder(Bitmap other) { boolean isSameCompressedBitmapBuilder(Bitmap other) {
if (other instanceof CompressedBitmapBuilder) { if (other instanceof CompressedBitmapBuilder) {
CompressedBitmapBuilder b = (CompressedBitmapBuilder) other; CompressedBitmapBuilder b = (CompressedBitmapBuilder) other;
return this == b.getBitmapIndex(); return this == b.getBitmapIndex();
@ -472,7 +472,7 @@ private boolean isSameCompressedBitmapBuilder(Bitmap other) {
return false; return false;
} }
private static final EWAHCompressedBitmap ones(int sizeInBits) { static final EWAHCompressedBitmap ones(int sizeInBits) {
EWAHCompressedBitmap mask = new EWAHCompressedBitmap(); EWAHCompressedBitmap mask = new EWAHCompressedBitmap();
mask.addStreamOfEmptyWords( mask.addStreamOfEmptyWords(
true, sizeInBits / EWAHCompressedBitmap.wordinbits); true, sizeInBits / EWAHCompressedBitmap.wordinbits);

View File

@ -50,7 +50,7 @@
class DeltaBaseCache { class DeltaBaseCache {
private static final int CACHE_SZ = 1024; private static final int CACHE_SZ = 1024;
private static final SoftReference<Entry> DEAD; static final SoftReference<Entry> DEAD;
private static int hash(final long position) { private static int hash(final long position) {
return (((int) position) << 22) >>> 22; return (((int) position) << 22) >>> 22;

View File

@ -120,11 +120,11 @@ public boolean accept(File dir, String name) {
private boolean haveLck; private boolean haveLck;
private FileOutputStream os; FileOutputStream os;
private boolean needSnapshot; private boolean needSnapshot;
private boolean fsync; boolean fsync;
private FileSnapshot commitSnapshot; private FileSnapshot commitSnapshot;

View File

@ -74,9 +74,9 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
private final EWAHCompressedBitmap blobs; private final EWAHCompressedBitmap blobs;
private final EWAHCompressedBitmap tags; private final EWAHCompressedBitmap tags;
private final BlockList<PositionEntry> byOffset; private final BlockList<PositionEntry> byOffset;
private final BlockList<StoredBitmap> final BlockList<StoredBitmap>
byAddOrder = new BlockList<StoredBitmap>(); byAddOrder = new BlockList<StoredBitmap>();
private final ObjectIdOwnerMap<PositionEntry> final ObjectIdOwnerMap<PositionEntry>
positionEntries = new ObjectIdOwnerMap<PositionEntry>(); positionEntries = new ObjectIdOwnerMap<PositionEntry>();
/** /**
@ -330,7 +330,7 @@ public static final class StoredEntry {
private final int xorOffset; private final int xorOffset;
private final int flags; private final int flags;
private StoredEntry(long objectId, EWAHCompressedBitmap bitmap, StoredEntry(long objectId, EWAHCompressedBitmap bitmap,
int xorOffset, int flags) { int xorOffset, int flags) {
this.objectId = objectId; this.objectId = objectId;
this.bitmap = bitmap; this.bitmap = bitmap;
@ -360,11 +360,11 @@ public long getObjectId() {
} }
private static final class PositionEntry extends ObjectIdOwnerMap.Entry { private static final class PositionEntry extends ObjectIdOwnerMap.Entry {
private final int namePosition; final int namePosition;
private int offsetPosition; int offsetPosition;
private PositionEntry(AnyObjectId objectId, int namePosition) { PositionEntry(AnyObjectId objectId, int namePosition) {
super(objectId); super(objectId);
this.namePosition = namePosition; this.namePosition = namePosition;
} }

View File

@ -66,7 +66,7 @@ public class PackBitmapIndexRemapper extends PackBitmapIndex
implements Iterable<PackBitmapIndexRemapper.Entry> { implements Iterable<PackBitmapIndexRemapper.Entry> {
private final BasePackBitmapIndex oldPackIndex; private final BasePackBitmapIndex oldPackIndex;
private final PackBitmapIndex newPackIndex; final PackBitmapIndex newPackIndex;
private final ObjectIdOwnerMap<StoredBitmap> convertedBitmaps; private final ObjectIdOwnerMap<StoredBitmap> convertedBitmaps;
private final BitSet inflated; private final BitSet inflated;
private final int[] prevToNewMapping; private final int[] prevToNewMapping;
@ -199,7 +199,7 @@ public EWAHCompressedBitmap getBitmap(AnyObjectId objectId) {
public final class Entry extends ObjectId { public final class Entry extends ObjectId {
private final int flags; private final int flags;
private Entry(AnyObjectId src, int flags) { Entry(AnyObjectId src, int flags) {
super(src); super(src);
this.flags = flags; this.flags = flags;
} }

View File

@ -119,7 +119,7 @@ public int compare(final PackFile a, final PackFile b) {
private int activeCopyRawData; private int activeCopyRawData;
private int packLastModified; int packLastModified;
private volatile boolean invalid; private volatile boolean invalid;

View File

@ -67,7 +67,7 @@ class PackIndexV1 extends PackIndex {
private final long[] idxHeader; private final long[] idxHeader;
private byte[][] idxdata; byte[][] idxdata;
private long objectCnt; private long objectCnt;
@ -233,9 +233,9 @@ private static int idOffset(int mid) {
} }
private class IndexV1Iterator extends EntriesIterator { private class IndexV1Iterator extends EntriesIterator {
private int levelOne; int levelOne;
private int levelTwo; int levelTwo;
@Override @Override
protected MutableEntry initEntry() { protected MutableEntry initEntry() {

View File

@ -75,16 +75,16 @@ class PackIndexV2 extends PackIndex {
private final long[] fanoutTable; private final long[] fanoutTable;
/** 256 arrays of contiguous object names. */ /** 256 arrays of contiguous object names. */
private int[][] names; int[][] names;
/** 256 arrays of the 32 bit offset data, matching {@link #names}. */ /** 256 arrays of the 32 bit offset data, matching {@link #names}. */
private byte[][] offset32; byte[][] offset32;
/** 256 arrays of the CRC-32 of objects, matching {@link #names}. */ /** 256 arrays of the CRC-32 of objects, matching {@link #names}. */
private byte[][] crc32; private byte[][] crc32;
/** 64 bit offset table. */ /** 64 bit offset table. */
private byte[] offset64; byte[] offset64;
PackIndexV2(final InputStream fd) throws IOException { PackIndexV2(final InputStream fd) throws IOException {
final byte[] fanoutRaw = new byte[4 * FANOUT]; final byte[] fanoutRaw = new byte[4 * FANOUT];
@ -304,9 +304,9 @@ else if (cmp == 0) {
} }
private class EntriesIteratorV2 extends EntriesIterator { private class EntriesIteratorV2 extends EntriesIterator {
private int levelOne; int levelOne;
private int levelTwo; int levelTwo;
@Override @Override
protected MutableEntry initEntry() { protected MutableEntry initEntry() {

View File

@ -138,7 +138,7 @@ public class RefDirectory extends RefDatabase {
private final File gitDir; private final File gitDir;
private final File refsDir; final File refsDir;
private final ReflogWriter logWriter; private final ReflogWriter logWriter;
@ -155,7 +155,7 @@ public class RefDirectory extends RefDatabase {
private final AtomicReference<RefList<LooseRef>> looseRefs = new AtomicReference<RefList<LooseRef>>(); private final AtomicReference<RefList<LooseRef>> looseRefs = new AtomicReference<RefList<LooseRef>>();
/** Immutable sorted list of packed references. */ /** Immutable sorted list of packed references. */
private final AtomicReference<PackedRefList> packedRefs = new AtomicReference<PackedRefList>(); final AtomicReference<PackedRefList> packedRefs = new AtomicReference<PackedRefList>();
/** /**
* Number of modifications made to this database. * Number of modifications made to this database.
@ -901,7 +901,7 @@ private Ref readRef(String name, RefList<Ref> packed) throws IOException {
return n; return n;
} }
private LooseRef scanRef(LooseRef ref, String name) throws IOException { LooseRef scanRef(LooseRef ref, String name) throws IOException {
final File path = fileFor(name); final File path = fileFor(name);
FileSnapshot currentSnapshot = null; FileSnapshot currentSnapshot = null;

View File

@ -232,7 +232,7 @@ static long getSize(InputStream in, AnyObjectId id, WindowCursor wc)
} }
} }
private static void checkValidEndOfStream(InputStream in, Inflater inf, static void checkValidEndOfStream(InputStream in, Inflater inf,
AnyObjectId id, final byte[] buf) throws IOException, AnyObjectId id, final byte[] buf) throws IOException,
CorruptObjectException { CorruptObjectException {
for (;;) { for (;;) {
@ -266,7 +266,7 @@ private static void checkValidEndOfStream(InputStream in, Inflater inf,
} }
} }
private static boolean isStandardFormat(final byte[] hdr) { static boolean isStandardFormat(final byte[] hdr) {
/* /*
* We must determine if the buffer contains the standard * We must determine if the buffer contains the standard
* zlib-deflated stream or the experimental format based * zlib-deflated stream or the experimental format based
@ -298,7 +298,7 @@ private static boolean isStandardFormat(final byte[] hdr) {
return (fb & 0x8f) == 0x08 && (((fb << 8) | hdr[1] & 0xff) % 31) == 0; return (fb & 0x8f) == 0x08 && (((fb << 8) | hdr[1] & 0xff) % 31) == 0;
} }
private static InputStream inflate(final InputStream in, final long size, static InputStream inflate(final InputStream in, final long size,
final ObjectId id) { final ObjectId id) {
final Inflater inf = InflaterCache.get(); final Inflater inf = InflaterCache.get();
return new InflaterInputStream(in, inf) { return new InflaterInputStream(in, inf) {
@ -334,11 +334,11 @@ private static InflaterInputStream inflate(InputStream in, Inflater inf) {
return new InflaterInputStream(in, inf, BUFFER_SIZE); return new InflaterInputStream(in, inf, BUFFER_SIZE);
} }
private static BufferedInputStream buffer(InputStream in) { static BufferedInputStream buffer(InputStream in) {
return new BufferedInputStream(in, BUFFER_SIZE); return new BufferedInputStream(in, BUFFER_SIZE);
} }
private static int readSome(InputStream in, final byte[] hdr, int off, static int readSome(InputStream in, final byte[] hdr, int off,
int cnt) throws IOException { int cnt) throws IOException {
int avail = 0; int avail = 0;
while (0 < cnt) { while (0 < cnt) {
@ -363,7 +363,7 @@ private static final class LargeObject extends ObjectLoader {
private final FileObjectDatabase source; private final FileObjectDatabase source;
private LargeObject(int type, long size, File path, AnyObjectId id, LargeObject(int type, long size, File path, AnyObjectId id,
FileObjectDatabase db) { FileObjectDatabase db) {
this.type = type; this.type = type;
this.size = size; this.size = size;

View File

@ -73,7 +73,7 @@ static final class Block {
final int endIndex; final int endIndex;
private long totalWeight; private long totalWeight;
private long bytesPerUnit; long bytesPerUnit;
Block(int threads, PackConfig config, ObjectReader reader, Block(int threads, PackConfig config, ObjectReader reader,
DeltaCache dc, ThreadSafeProgressMonitor pm, DeltaCache dc, ThreadSafeProgressMonitor pm,
@ -250,7 +250,7 @@ final int size() {
} }
private final Block block; private final Block block;
private final LinkedList<Slice> slices; final LinkedList<Slice> slices;
private ObjectReader or; private ObjectReader or;
private DeltaWindow dw; private DeltaWindow dw;

View File

@ -218,7 +218,7 @@ public static Iterable<PackWriter> getInstances() {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private BlockList<ObjectToPack> objectsLists[] = new BlockList[OBJ_TAG + 1]; BlockList<ObjectToPack> objectsLists[] = new BlockList[OBJ_TAG + 1];
{ {
objectsLists[OBJ_COMMIT] = new BlockList<ObjectToPack>(); objectsLists[OBJ_COMMIT] = new BlockList<ObjectToPack>();
objectsLists[OBJ_TREE] = new BlockList<ObjectToPack>(); objectsLists[OBJ_TREE] = new BlockList<ObjectToPack>();
@ -249,7 +249,7 @@ public static Iterable<PackWriter> getInstances() {
/** {@link #reader} recast to the reuse interface, if it supports it. */ /** {@link #reader} recast to the reuse interface, if it supports it. */
private final ObjectReuseAsIs reuseSupport; private final ObjectReuseAsIs reuseSupport;
private final PackConfig config; final PackConfig config;
private final PackStatistics.Accumulator stats; private final PackStatistics.Accumulator stats;

View File

@ -512,8 +512,8 @@ private static final class CommitSelectionHelper implements Iterable<RevCommit>
final List<BitmapBuilderEntry> tipCommitBitmaps; final List<BitmapBuilderEntry> tipCommitBitmaps;
final Iterable<BitmapCommit> reusedCommits; final Iterable<BitmapCommit> reusedCommits;
private final RevCommit[] commitsByOldest; final RevCommit[] commitsByOldest;
private final int commitStartPos; final int commitStartPos;
CommitSelectionHelper(Set<? extends ObjectId> peeledWant, CommitSelectionHelper(Set<? extends ObjectId> peeledWant,
RevCommit[] commitsByOldest, int commitStartPos, RevCommit[] commitsByOldest, int commitStartPos,