Browse Source

[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>
stable-4.2
Andrey Loskutov 9 years ago
parent
commit
79a7dd026f
  1. 32
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java
  2. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/DeltaBaseCache.java
  3. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
  4. 12
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
  5. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java
  6. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
  7. 6
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV1.java
  8. 10
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV2.java
  9. 6
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
  10. 12
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
  11. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaTask.java
  12. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
  13. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java

32
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java

@ -63,11 +63,11 @@ import org.eclipse.jgit.util.BlockList;
public class BitmapIndexImpl implements BitmapIndex {
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.
@ -96,7 +96,7 @@ public class BitmapIndexImpl implements BitmapIndex {
return new CompressedBitmapBuilder();
}
private int findPosition(AnyObjectId objectId) {
int findPosition(AnyObjectId objectId) {
int position = packIndex.findPosition(objectId);
if (position < 0) {
position = mutableIndex.findPosition(objectId);
@ -106,7 +106,7 @@ public class BitmapIndexImpl implements BitmapIndex {
return position;
}
private int addObject(AnyObjectId objectId, int type) {
int addObject(AnyObjectId objectId, int type) {
int position = findPosition(objectId);
if (position < 0) {
position = mutableIndex.addObject(objectId, type);
@ -122,11 +122,11 @@ public class BitmapIndexImpl implements BitmapIndex {
private BitSet toRemove;
private ComboBitset() {
ComboBitset() {
this(new EWAHCompressedBitmap());
}
private ComboBitset(EWAHCompressedBitmap bitmap) {
ComboBitset(EWAHCompressedBitmap bitmap) {
this.inflatingBitmap = new InflatingBitSet(bitmap);
}
@ -289,15 +289,15 @@ public class BitmapIndexImpl implements BitmapIndex {
return true;
}
private BitmapIndexImpl getBitmapIndex() {
BitmapIndexImpl getBitmapIndex() {
return BitmapIndexImpl.this;
}
}
final class CompressedBitmap implements Bitmap {
private final EWAHCompressedBitmap bitmap;
final EWAHCompressedBitmap bitmap;
private CompressedBitmap(EWAHCompressedBitmap bitmap) {
CompressedBitmap(EWAHCompressedBitmap bitmap) {
this.bitmap = bitmap;
}
@ -387,7 +387,7 @@ public class BitmapIndexImpl implements BitmapIndex {
return bitmap;
}
private BitmapIndexImpl getPackBitmapIndex() {
BitmapIndexImpl getPackBitmapIndex() {
return BitmapIndexImpl.this;
}
}
@ -429,9 +429,9 @@ public class BitmapIndexImpl implements BitmapIndex {
}
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) {
super(objectId);
@ -456,7 +456,7 @@ public class BitmapIndexImpl implements BitmapIndex {
}
}
private boolean isSameCompressedBitmap(Bitmap other) {
boolean isSameCompressedBitmap(Bitmap other) {
if (other instanceof CompressedBitmap) {
CompressedBitmap b = (CompressedBitmap) other;
return this == b.getPackBitmapIndex();
@ -464,7 +464,7 @@ public class BitmapIndexImpl implements BitmapIndex {
return false;
}
private boolean isSameCompressedBitmapBuilder(Bitmap other) {
boolean isSameCompressedBitmapBuilder(Bitmap other) {
if (other instanceof CompressedBitmapBuilder) {
CompressedBitmapBuilder b = (CompressedBitmapBuilder) other;
return this == b.getBitmapIndex();
@ -472,7 +472,7 @@ public class BitmapIndexImpl implements BitmapIndex {
return false;
}
private static final EWAHCompressedBitmap ones(int sizeInBits) {
static final EWAHCompressedBitmap ones(int sizeInBits) {
EWAHCompressedBitmap mask = new EWAHCompressedBitmap();
mask.addStreamOfEmptyWords(
true, sizeInBits / EWAHCompressedBitmap.wordinbits);

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/DeltaBaseCache.java

@ -50,7 +50,7 @@ import org.eclipse.jgit.storage.file.WindowCacheConfig;
class DeltaBaseCache {
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) {
return (((int) position) << 22) >>> 22;

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java

@ -120,11 +120,11 @@ public class LockFile {
private boolean haveLck;
private FileOutputStream os;
FileOutputStream os;
private boolean needSnapshot;
private boolean fsync;
boolean fsync;
private FileSnapshot commitSnapshot;

12
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java

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

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java

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

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java

@ -119,7 +119,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
private int activeCopyRawData;
private int packLastModified;
int packLastModified;
private volatile boolean invalid;

6
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV1.java

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

10
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV2.java

@ -75,16 +75,16 @@ class PackIndexV2 extends PackIndex {
private final long[] fanoutTable;
/** 256 arrays of contiguous object names. */
private int[][] names;
int[][] 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}. */
private byte[][] crc32;
/** 64 bit offset table. */
private byte[] offset64;
byte[] offset64;
PackIndexV2(final InputStream fd) throws IOException {
final byte[] fanoutRaw = new byte[4 * FANOUT];
@ -304,9 +304,9 @@ class PackIndexV2 extends PackIndex {
}
private class EntriesIteratorV2 extends EntriesIterator {
private int levelOne;
int levelOne;
private int levelTwo;
int levelTwo;
@Override
protected MutableEntry initEntry() {

6
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java

@ -138,7 +138,7 @@ public class RefDirectory extends RefDatabase {
private final File gitDir;
private final File refsDir;
final File refsDir;
private final ReflogWriter logWriter;
@ -155,7 +155,7 @@ public class RefDirectory extends RefDatabase {
private final AtomicReference<RefList<LooseRef>> looseRefs = new AtomicReference<RefList<LooseRef>>();
/** 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.
@ -901,7 +901,7 @@ public class RefDirectory extends RefDatabase {
return n;
}
private LooseRef scanRef(LooseRef ref, String name) throws IOException {
LooseRef scanRef(LooseRef ref, String name) throws IOException {
final File path = fileFor(name);
FileSnapshot currentSnapshot = null;

12
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java

@ -232,7 +232,7 @@ public class UnpackedObject {
}
}
private static void checkValidEndOfStream(InputStream in, Inflater inf,
static void checkValidEndOfStream(InputStream in, Inflater inf,
AnyObjectId id, final byte[] buf) throws IOException,
CorruptObjectException {
for (;;) {
@ -266,7 +266,7 @@ public class UnpackedObject {
}
}
private static boolean isStandardFormat(final byte[] hdr) {
static boolean isStandardFormat(final byte[] hdr) {
/*
* We must determine if the buffer contains the standard
* zlib-deflated stream or the experimental format based
@ -298,7 +298,7 @@ public class UnpackedObject {
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 Inflater inf = InflaterCache.get();
return new InflaterInputStream(in, inf) {
@ -334,11 +334,11 @@ public class UnpackedObject {
return new InflaterInputStream(in, inf, BUFFER_SIZE);
}
private static BufferedInputStream buffer(InputStream in) {
static BufferedInputStream buffer(InputStream in) {
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 avail = 0;
while (0 < cnt) {
@ -363,7 +363,7 @@ public class UnpackedObject {
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) {
this.type = type;
this.size = size;

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaTask.java

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

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java

@ -218,7 +218,7 @@ public class PackWriter implements AutoCloseable {
}
@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_TREE] = new BlockList<ObjectToPack>();
@ -249,7 +249,7 @@ public class PackWriter implements AutoCloseable {
/** {@link #reader} recast to the reuse interface, if it supports it. */
private final ObjectReuseAsIs reuseSupport;
private final PackConfig config;
final PackConfig config;
private final PackStatistics.Accumulator stats;

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java

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

Loading…
Cancel
Save