package o; import com.google.android.libraries.places.api.model.PlaceTypes; import com.google.common.primitives.UnsignedBytes; import java.lang.reflect.Field; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.security.AccessController; import java.security.PrivilegedExceptionAction; import java.util.logging.Level; import java.util.logging.Logger; import sun.misc.Unsafe; /* loaded from: classes.dex */ public final class vqr { static final boolean a; private static final long b; static final long c; private static final boolean d; private static final boolean e; private static final boolean f; private static final Unsafe g; private static final Class h; private static final RVV i; private static final boolean j; static /* synthetic */ Field d() { return a(); } static { Unsafe c2 = c(); g = c2; h = zRL.c(); boolean b2 = b(Long.TYPE); j = b2; boolean b3 = b(Integer.TYPE); f = b3; RVV rvv = null; if (c2 != null) { if (!zRL.d()) { rvv = new IeS(c2); } else if (b2) { rvv = new LWm(c2); } else if (b3) { rvv = new HBt(c2); } } i = rvv; e = rvv == null ? false : rvv.c(); boolean b4 = rvv == null ? false : rvv.b(); d = b4; c = b4 ? rvv.c.arrayBaseOffset(byte[].class) : -1; if (b4) { rvv.c.arrayBaseOffset(boolean[].class); } if (b4) { rvv.c.arrayIndexScale(boolean[].class); } if (b4) { rvv.c.arrayBaseOffset(int[].class); } if (b4) { rvv.c.arrayIndexScale(int[].class); } if (b4) { rvv.c.arrayBaseOffset(long[].class); } if (b4) { rvv.c.arrayIndexScale(long[].class); } if (b4) { rvv.c.arrayBaseOffset(float[].class); } if (b4) { rvv.c.arrayIndexScale(float[].class); } if (b4) { rvv.c.arrayBaseOffset(double[].class); } if (b4) { rvv.c.arrayIndexScale(double[].class); } if (b4) { rvv.c.arrayBaseOffset(Object[].class); } if (b4) { rvv.c.arrayIndexScale(Object[].class); } Field a2 = a(); b = (a2 == null || rvv == null) ? -1L : rvv.c.objectFieldOffset(a2); a = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN; } private vqr() { } /* JADX INFO: Access modifiers changed from: package-private */ public static T a(Class cls) { try { return (T) g.allocateInstance(cls); } catch (InstantiationException e2) { throw new IllegalStateException(e2); } } /* JADX INFO: Access modifiers changed from: package-private */ public static int g(Object obj, long j2) { return i.c.getInt(obj, j2); } /* JADX INFO: Access modifiers changed from: package-private */ public static void c(Object obj, long j2, int i2) { i.c.putInt(obj, j2, i2); } /* JADX INFO: Access modifiers changed from: package-private */ public static long i(Object obj, long j2) { return i.c.getLong(obj, j2); } /* JADX INFO: Access modifiers changed from: package-private */ public static void d(Object obj, long j2, long j3) { i.c.putLong(obj, j2, j3); } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean c(Object obj, long j2) { return i.c(obj, j2); } /* JADX INFO: Access modifiers changed from: package-private */ public static void d(Object obj, long j2, boolean z) { i.d(obj, j2, z); } /* JADX INFO: Access modifiers changed from: package-private */ public static float f(Object obj, long j2) { return i.d(obj, j2); } /* JADX INFO: Access modifiers changed from: package-private */ public static void e(Object obj, long j2, float f2) { i.c(obj, j2, f2); } /* JADX INFO: Access modifiers changed from: package-private */ public static double h(Object obj, long j2) { return i.a(obj, j2); } /* JADX INFO: Access modifiers changed from: package-private */ public static void e(Object obj, long j2, double d2) { i.b(obj, j2, d2); } /* JADX INFO: Access modifiers changed from: package-private */ public static Object j(Object obj, long j2) { return i.c.getObject(obj, j2); } /* JADX INFO: Access modifiers changed from: package-private */ public static void e(Object obj, long j2, Object obj2) { i.c.putObject(obj, j2, obj2); } /* JADX INFO: Access modifiers changed from: package-private */ public static byte b(byte[] bArr, long j2) { return i.b(bArr, c + j2); } public static void b(byte[] bArr, long j2, byte b2) { i.d(bArr, c + j2, b2); } /* JADX INFO: Access modifiers changed from: package-private */ public static void e(long j2, byte[] bArr, long j3, long j4) { i.a(j2, bArr, j3, j4); } /* JADX INFO: Access modifiers changed from: package-private */ public static byte d(long j2) { return i.a(j2); } /* JADX INFO: Access modifiers changed from: package-private */ public static long d(ByteBuffer byteBuffer) { RVV rvv = i; return rvv.c.getLong(byteBuffer, b); } /* JADX INFO: Access modifiers changed from: package-private */ public static Unsafe c() { try { return (Unsafe) AccessController.doPrivileged(new PrivilegedExceptionAction() { // from class: o.vqr.5 @Override // java.security.PrivilegedExceptionAction public final /* synthetic */ Unsafe run() throws Exception { for (Field field : Unsafe.class.getDeclaredFields()) { field.setAccessible(true); Object obj = field.get(null); if (Unsafe.class.isInstance(obj)) { return (Unsafe) Unsafe.class.cast(obj); } } return null; } }); } catch (Throwable unused) { return null; } } private static boolean b(Class cls) { if (!zRL.d()) { return false; } try { Class cls2 = h; cls2.getMethod("peekLong", cls, Boolean.TYPE); cls2.getMethod("pokeLong", cls, Long.TYPE, Boolean.TYPE); cls2.getMethod("pokeInt", cls, Integer.TYPE, Boolean.TYPE); cls2.getMethod("peekInt", cls, Boolean.TYPE); cls2.getMethod("pokeByte", cls, Byte.TYPE); cls2.getMethod("peekByte", cls); cls2.getMethod("pokeByteArray", cls, byte[].class, Integer.TYPE, Integer.TYPE); cls2.getMethod("peekByteArray", cls, byte[].class, Integer.TYPE, Integer.TYPE); return true; } catch (Throwable unused) { return false; } } private static Field a() { Field c2; if (zRL.d() && (c2 = c((Class) Buffer.class, "effectiveDirectAddress")) != null) { return c2; } Field c3 = c((Class) Buffer.class, PlaceTypes.ADDRESS); if (c3 == null || c3.getType() != Long.TYPE) { return null; } return c3; } private static Field c(Class cls, String str) { try { return cls.getDeclaredField(str); } catch (Throwable unused) { return null; } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public static abstract class RVV { Unsafe c; public abstract byte a(long j); public abstract double a(Object obj, long j); public abstract void a(long j, byte[] bArr, long j2, long j3); public abstract byte b(Object obj, long j); public abstract void b(Object obj, long j, double d); public abstract void c(Object obj, long j, float f); public abstract boolean c(Object obj, long j); public abstract float d(Object obj, long j); public abstract void d(Object obj, long j, byte b); public abstract void d(Object obj, long j, boolean z); RVV(Unsafe unsafe) { this.c = unsafe; } public boolean b() { Unsafe unsafe = this.c; if (unsafe == null) { return false; } try { Class cls = unsafe.getClass(); cls.getMethod("objectFieldOffset", Field.class); cls.getMethod("arrayBaseOffset", Class.class); cls.getMethod("arrayIndexScale", Class.class); cls.getMethod("getInt", Object.class, Long.TYPE); cls.getMethod("putInt", Object.class, Long.TYPE, Integer.TYPE); cls.getMethod("getLong", Object.class, Long.TYPE); cls.getMethod("putLong", Object.class, Long.TYPE, Long.TYPE); cls.getMethod("getObject", Object.class, Long.TYPE); cls.getMethod("putObject", Object.class, Long.TYPE, Object.class); return true; } catch (Throwable th) { vqr.a(th); return false; } } public boolean c() { Unsafe unsafe = this.c; if (unsafe == null) { return false; } try { Class cls = unsafe.getClass(); cls.getMethod("objectFieldOffset", Field.class); cls.getMethod("getLong", Object.class, Long.TYPE); return vqr.d() != null; } catch (Throwable th) { vqr.a(th); return false; } } } /* loaded from: classes.dex */ static final class IeS extends RVV { IeS(Unsafe unsafe) { super(unsafe); } @Override // o.vqr.RVV public final boolean b() { if (!super.b()) { return false; } try { Class cls = this.c.getClass(); cls.getMethod("getByte", Object.class, Long.TYPE); cls.getMethod("putByte", Object.class, Long.TYPE, Byte.TYPE); cls.getMethod("getBoolean", Object.class, Long.TYPE); cls.getMethod("putBoolean", Object.class, Long.TYPE, Boolean.TYPE); cls.getMethod("getFloat", Object.class, Long.TYPE); cls.getMethod("putFloat", Object.class, Long.TYPE, Float.TYPE); cls.getMethod("getDouble", Object.class, Long.TYPE); cls.getMethod("putDouble", Object.class, Long.TYPE, Double.TYPE); return true; } catch (Throwable th) { vqr.a(th); return false; } } @Override // o.vqr.RVV public final byte b(Object obj, long j) { return this.c.getByte(obj, j); } @Override // o.vqr.RVV public final void d(Object obj, long j, byte b) { this.c.putByte(obj, j, b); } @Override // o.vqr.RVV public final boolean c(Object obj, long j) { return this.c.getBoolean(obj, j); } @Override // o.vqr.RVV public final void d(Object obj, long j, boolean z) { this.c.putBoolean(obj, j, z); } @Override // o.vqr.RVV public final float d(Object obj, long j) { return this.c.getFloat(obj, j); } @Override // o.vqr.RVV public final void c(Object obj, long j, float f) { this.c.putFloat(obj, j, f); } @Override // o.vqr.RVV public final double a(Object obj, long j) { return this.c.getDouble(obj, j); } @Override // o.vqr.RVV public final void b(Object obj, long j, double d) { this.c.putDouble(obj, j, d); } @Override // o.vqr.RVV public final boolean c() { if (!super.c()) { return false; } try { Class cls = this.c.getClass(); cls.getMethod("getByte", Long.TYPE); cls.getMethod("putByte", Long.TYPE, Byte.TYPE); cls.getMethod("getInt", Long.TYPE); cls.getMethod("putInt", Long.TYPE, Integer.TYPE); cls.getMethod("getLong", Long.TYPE); cls.getMethod("putLong", Long.TYPE, Long.TYPE); cls.getMethod("copyMemory", Long.TYPE, Long.TYPE, Long.TYPE); cls.getMethod("copyMemory", Object.class, Long.TYPE, Object.class, Long.TYPE, Long.TYPE); return true; } catch (Throwable th) { vqr.a(th); return false; } } @Override // o.vqr.RVV public final byte a(long j) { return this.c.getByte(j); } @Override // o.vqr.RVV public final void a(long j, byte[] bArr, long j2, long j3) { this.c.copyMemory((Object) null, j, bArr, vqr.c + j2, j3); } } /* loaded from: classes.dex */ static final class LWm extends RVV { @Override // o.vqr.RVV public final boolean c() { return false; } LWm(Unsafe unsafe) { super(unsafe); } @Override // o.vqr.RVV public final byte b(Object obj, long j) { if (vqr.a) { return vqr.b(obj, j); } return vqr.d(obj, j); } @Override // o.vqr.RVV public final void d(Object obj, long j, byte b) { if (vqr.a) { vqr.e(obj, j, b); } else { vqr.a(obj, j, b); } } @Override // o.vqr.RVV public final boolean c(Object obj, long j) { if (vqr.a) { return vqr.a(obj, j); } return vqr.e(obj, j); } @Override // o.vqr.RVV public final void d(Object obj, long j, boolean z) { if (vqr.a) { vqr.b(obj, j, z); } else { vqr.a(obj, j, z); } } @Override // o.vqr.RVV public final float d(Object obj, long j) { return Float.intBitsToFloat(this.c.getInt(obj, j)); } @Override // o.vqr.RVV public final void c(Object obj, long j, float f) { this.c.putInt(obj, j, Float.floatToIntBits(f)); } @Override // o.vqr.RVV public final double a(Object obj, long j) { return Double.longBitsToDouble(this.c.getLong(obj, j)); } @Override // o.vqr.RVV public final void b(Object obj, long j, double d) { this.c.putLong(obj, j, Double.doubleToLongBits(d)); } @Override // o.vqr.RVV public final byte a(long j) { throw new UnsupportedOperationException(); } @Override // o.vqr.RVV public final void a(long j, byte[] bArr, long j2, long j3) { throw new UnsupportedOperationException(); } } /* loaded from: classes.dex */ static final class HBt extends RVV { @Override // o.vqr.RVV public final boolean c() { return false; } HBt(Unsafe unsafe) { super(unsafe); } @Override // o.vqr.RVV public final byte b(Object obj, long j) { if (vqr.a) { return vqr.b(obj, j); } return vqr.d(obj, j); } @Override // o.vqr.RVV public final void d(Object obj, long j, byte b) { if (vqr.a) { vqr.e(obj, j, b); } else { vqr.a(obj, j, b); } } @Override // o.vqr.RVV public final boolean c(Object obj, long j) { if (vqr.a) { return vqr.a(obj, j); } return vqr.e(obj, j); } @Override // o.vqr.RVV public final void d(Object obj, long j, boolean z) { if (vqr.a) { vqr.b(obj, j, z); } else { vqr.a(obj, j, z); } } @Override // o.vqr.RVV public final float d(Object obj, long j) { return Float.intBitsToFloat(this.c.getInt(obj, j)); } @Override // o.vqr.RVV public final void c(Object obj, long j, float f) { this.c.putInt(obj, j, Float.floatToIntBits(f)); } @Override // o.vqr.RVV public final double a(Object obj, long j) { return Double.longBitsToDouble(this.c.getLong(obj, j)); } @Override // o.vqr.RVV public final void b(Object obj, long j, double d) { this.c.putLong(obj, j, Double.doubleToLongBits(d)); } @Override // o.vqr.RVV public final byte a(long j) { throw new UnsupportedOperationException(); } @Override // o.vqr.RVV public final void a(long j, byte[] bArr, long j2, long j3) { throw new UnsupportedOperationException(); } } /* JADX INFO: Access modifiers changed from: private */ public static void e(Object obj, long j2, byte b2) { long j3 = (-4) & j2; RVV rvv = i; int i2 = rvv.c.getInt(obj, j3); int i3 = ((~((int) j2)) & 3) << 3; rvv.c.putInt(obj, j3, ((~(255 << i3)) & i2) | ((b2 & UnsignedBytes.MAX_VALUE) << i3)); } /* JADX INFO: Access modifiers changed from: private */ public static void a(Object obj, long j2, byte b2) { long j3 = (-4) & j2; RVV rvv = i; int i2 = rvv.c.getInt(obj, j3); int i3 = (((int) j2) & 3) << 3; rvv.c.putInt(obj, j3, ((~(255 << i3)) & i2) | ((b2 & UnsignedBytes.MAX_VALUE) << i3)); } static /* synthetic */ void a(Throwable th) { Logger.getLogger(vqr.class.getName()).log(Level.WARNING, "platform method missing - proto runtime falling back to safer methods: ".concat(String.valueOf(th))); } static /* synthetic */ byte b(Object obj, long j2) { return (byte) (i.c.getInt(obj, (-4) & j2) >>> ((int) (((~j2) & 3) << 3))); } static /* synthetic */ byte d(Object obj, long j2) { return (byte) (i.c.getInt(obj, (-4) & j2) >>> ((int) ((j2 & 3) << 3))); } static /* synthetic */ boolean a(Object obj, long j2) { return ((byte) (i.c.getInt(obj, (-4) & j2) >>> ((int) (((~j2) & 3) << 3)))) != 0; } static /* synthetic */ boolean e(Object obj, long j2) { return ((byte) (i.c.getInt(obj, (-4) & j2) >>> ((int) ((j2 & 3) << 3)))) != 0; } static /* synthetic */ void b(Object obj, long j2, boolean z) { e(obj, j2, z ? (byte) 1 : (byte) 0); } static /* synthetic */ void a(Object obj, long j2, boolean z) { a(obj, j2, z ? (byte) 1 : (byte) 0); } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean e() { return e; } public static boolean b() { return d; } }