115 lines
4.5 KiB
Java
115 lines
4.5 KiB
Java
|
package com.esotericsoftware.kryo.serializers;
|
||
|
|
||
|
import c.e.a.a;
|
||
|
import c.e.b.c;
|
||
|
import com.esotericsoftware.kryo.serializers.FieldSerializer;
|
||
|
import com.esotericsoftware.kryo.serializers.UnsafeCacheFields;
|
||
|
import com.esotericsoftware.kryo.util.IntArray;
|
||
|
import com.esotericsoftware.kryo.util.UnsafeUtil;
|
||
|
import java.lang.reflect.Field;
|
||
|
import java.util.List;
|
||
|
public final class FieldSerializerUnsafeUtilImpl implements FieldSerializerUnsafeUtil {
|
||
|
private FieldSerializer serializer;
|
||
|
|
||
|
public FieldSerializerUnsafeUtilImpl(FieldSerializer fieldSerializer) {
|
||
|
this.serializer = fieldSerializer;
|
||
|
}
|
||
|
|
||
|
private int fieldSizeOf(Class<?> cls) {
|
||
|
if (cls == Integer.TYPE || cls == Float.TYPE) {
|
||
|
return 4;
|
||
|
}
|
||
|
if (cls == Long.TYPE || cls == Double.TYPE) {
|
||
|
return 8;
|
||
|
}
|
||
|
if (cls == Byte.TYPE || cls == Boolean.TYPE) {
|
||
|
return 1;
|
||
|
}
|
||
|
if (cls == Short.TYPE || cls == Character.TYPE) {
|
||
|
return 2;
|
||
|
}
|
||
|
return UnsafeUtil.unsafe().addressSize();
|
||
|
}
|
||
|
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:21:0x009c */
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:22:0x00aa */
|
||
|
@Override // com.esotericsoftware.kryo.serializers.FieldSerializerUnsafeUtil
|
||
|
public void createUnsafeCacheFieldsAndRegions(List<Field> list, List<FieldSerializer.CachedField> list2, int i, IntArray intArray) {
|
||
|
int i2;
|
||
|
int i3;
|
||
|
int size = list.size();
|
||
|
long j = 0;
|
||
|
Field field = null;
|
||
|
long j2 = -1;
|
||
|
int i4 = 0;
|
||
|
boolean z2 = false;
|
||
|
int i5 = 0;
|
||
|
int i6 = -1;
|
||
|
while (i4 < size) {
|
||
|
Field field2 = list.get(i4);
|
||
|
if (this.serializer.access != null) {
|
||
|
i2 = size;
|
||
|
if (intArray.get(i + i4) == 1) {
|
||
|
i3 = ((c) this.serializer.access).h(field2.getName());
|
||
|
long objectFieldOffset = UnsafeUtil.unsafe().objectFieldOffset(field2);
|
||
|
long fieldSizeOf = objectFieldOffset + ((long) fieldSizeOf(field2.getType()));
|
||
|
if (field2.getType().isPrimitive() && z2) {
|
||
|
if (i5 > 1) {
|
||
|
a.C0053a aVar = a.a;
|
||
|
UnsafeCacheFields.UnsafeRegionField unsafeRegionField = new UnsafeCacheFields.UnsafeRegionField(j, j2 - j);
|
||
|
unsafeRegionField.field = field;
|
||
|
list2.add(unsafeRegionField);
|
||
|
} else if (field != null) {
|
||
|
list2.add(this.serializer.newCachedField(field, list2.size(), i6));
|
||
|
}
|
||
|
list2.add(this.serializer.newCachedField(field2, list2.size(), i3));
|
||
|
z2 = false;
|
||
|
} else if (field2.getType().isPrimitive()) {
|
||
|
list2.add(this.serializer.newCachedField(field2, list2.size(), i3));
|
||
|
} else if (!z2) {
|
||
|
j = objectFieldOffset;
|
||
|
z2 = true;
|
||
|
i5 = 1;
|
||
|
} else {
|
||
|
i5++;
|
||
|
}
|
||
|
i4++;
|
||
|
field = field2;
|
||
|
i6 = i3;
|
||
|
j2 = fieldSizeOf;
|
||
|
size = i2;
|
||
|
}
|
||
|
} else {
|
||
|
i2 = size;
|
||
|
}
|
||
|
i3 = -1;
|
||
|
long objectFieldOffset = UnsafeUtil.unsafe().objectFieldOffset(field2);
|
||
|
long fieldSizeOf = objectFieldOffset + ((long) fieldSizeOf(field2.getType()));
|
||
|
if (field2.getType().isPrimitive()) {
|
||
|
}
|
||
|
if (field2.getType().isPrimitive()) {
|
||
|
}
|
||
|
i4++;
|
||
|
field = field2;
|
||
|
i6 = i3;
|
||
|
j2 = fieldSizeOf;
|
||
|
size = i2;
|
||
|
}
|
||
|
if (!this.serializer.getUseAsmEnabled() && this.serializer.getUseMemRegions() && z2) {
|
||
|
if (i5 > 1) {
|
||
|
a.C0053a aVar2 = a.a;
|
||
|
UnsafeCacheFields.UnsafeRegionField unsafeRegionField2 = new UnsafeCacheFields.UnsafeRegionField(j, j2 - j);
|
||
|
unsafeRegionField2.field = field;
|
||
|
list2.add(unsafeRegionField2);
|
||
|
} else if (field != null) {
|
||
|
list2.add(this.serializer.newCachedField(field, list2.size(), i6));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.esotericsoftware.kryo.serializers.FieldSerializerUnsafeUtil
|
||
|
public long getObjectFieldOffset(Field field) {
|
||
|
return UnsafeUtil.unsafe().objectFieldOffset(field);
|
||
|
}
|
||
|
}
|