NativeMemoryChunk.smali
.class public Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;
.super Ljava/lang/Object;
.source "NativeMemoryChunk.java"
# interfaces
.implements Lcom/facebook/imagepipeline/memory/MemoryChunk;
.implements Ljava/io/Closeable;
# annotations
.annotation build Lcom/facebook/common/internal/DoNotStrip;
.end annotation
# static fields
.field public static final TAG:Ljava/lang/String; = "NativeMemoryChunk"
# instance fields
.field public mIsClosed:Z
.field public final mNativePtr:J
.field public final mSize:I
# direct methods
.method public static constructor <clinit>()V
.registers 1
const-string v0, "imagepipeline"
invoke-static {v0}, Lcom/facebook/soloader/nativeloader/NativeLoader;->loadLibrary(Ljava/lang/String;)Z
return-void
.end method
.method public constructor <init>()V
.registers 3
.annotation build Lcom/facebook/common/internal/VisibleForTesting;
.end annotation
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
const/4 v0, 0x0
iput v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mSize:I
const-wide/16 v0, 0x0
iput-wide v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mNativePtr:J
const/4 v0, 0x1
iput-boolean v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mIsClosed:Z
return-void
.end method
.method public constructor <init>(I)V
.registers 5
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
const/4 v0, 0x0
if-lez p1, :cond_8
const/4 v1, 0x1
goto :goto_9
:cond_8
const/4 v1, 0x0
:goto_9
invoke-static {v1}, Lcom/facebook/common/internal/Preconditions;->checkArgument(Z)V
iput p1, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mSize:I
invoke-static {p1}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->nativeAllocate(I)J
move-result-wide v1
iput-wide v1, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mNativePtr:J
iput-boolean v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mIsClosed:Z
return-void
.end method
.method private doCopy(ILcom/facebook/imagepipeline/memory/MemoryChunk;II)V
.registers 9
instance-of v0, p2, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;
if-eqz v0, :cond_2d
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->isClosed()Z
move-result v0
xor-int/lit8 v0, v0, 0x1
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkState(Z)V
invoke-interface {p2}, Lcom/facebook/imagepipeline/memory/MemoryChunk;->isClosed()Z
move-result v0
xor-int/lit8 v0, v0, 0x1
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkState(Z)V
invoke-interface {p2}, Lcom/facebook/imagepipeline/memory/MemoryChunk;->getSize()I
move-result v0
iget v1, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mSize:I
invoke-static {p1, v0, p3, p4, v1}, Lcom/facebook/imagepipeline/memory/MemoryChunkUtil;->checkBounds(IIIII)V
invoke-interface {p2}, Lcom/facebook/imagepipeline/memory/MemoryChunk;->getNativePtr()J
move-result-wide v0
int-to-long p2, p3
add-long/2addr v0, p2
iget-wide p2, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mNativePtr:J
int-to-long v2, p1
add-long/2addr p2, v2
invoke-static {v0, v1, p2, p3, p4}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->nativeMemcpy(JJI)V
return-void
:cond_2d
new-instance p1, Ljava/lang/IllegalArgumentException;
const-string p2, "Cannot copy two incompatible MemoryChunks"
invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw p1
.end method
.method public static native nativeAllocate(I)J
.annotation build Lcom/facebook/common/internal/DoNotStrip;
.end annotation
.end method
.method public static native nativeCopyFromByteArray(J[BII)V
.annotation build Lcom/facebook/common/internal/DoNotStrip;
.end annotation
.end method
.method public static native nativeCopyToByteArray(J[BII)V
.annotation build Lcom/facebook/common/internal/DoNotStrip;
.end annotation
.end method
.method public static native nativeFree(J)V
.annotation build Lcom/facebook/common/internal/DoNotStrip;
.end annotation
.end method
.method public static native nativeMemcpy(JJI)V
.annotation build Lcom/facebook/common/internal/DoNotStrip;
.end annotation
.end method
.method public static native nativeReadByte(J)B
.annotation build Lcom/facebook/common/internal/DoNotStrip;
.end annotation
.end method
# virtual methods
.method public declared-synchronized close()V
.registers 3
monitor-enter p0
:try_start_1
iget-boolean v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mIsClosed:Z
if-nez v0, :cond_d
const/4 v0, 0x1
iput-boolean v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mIsClosed:Z
iget-wide v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mNativePtr:J
invoke-static {v0, v1}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->nativeFree(J)V
:try_end_d
.catchall {:try_start_1 .. :try_end_d} :catchall_f
:cond_d
monitor-exit p0
return-void
:catchall_f
move-exception v0
monitor-exit p0
throw v0
.end method
.method public copy(ILcom/facebook/imagepipeline/memory/MemoryChunk;II)V
.registers 10
invoke-static {p2}, Lcom/facebook/common/internal/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
invoke-interface {p2}, Lcom/facebook/imagepipeline/memory/MemoryChunk;->getUniqueId()J
move-result-wide v0
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->getUniqueId()J
move-result-wide v2
cmp-long v4, v0, v2
if-nez v4, :cond_4f
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
const-string v1, "Copying from NativeMemoryChunk "
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-static {p0}, Ljava/lang/System;->identityHashCode(Ljava/lang/Object;)I
move-result v1
invoke-static {v1}, Ljava/lang/Integer;->toHexString(I)Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v1, " to NativeMemoryChunk "
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-static {p2}, Ljava/lang/System;->identityHashCode(Ljava/lang/Object;)I
move-result v1
invoke-static {v1}, Ljava/lang/Integer;->toHexString(I)Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v1, " which share the same address "
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
iget-wide v1, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mNativePtr:J
invoke-static {v1, v2}, Ljava/lang/Long;->toHexString(J)Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
const-string v1, "NativeMemoryChunk"
invoke-static {v1, v0}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
const/4 v0, 0x0
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkArgument(Z)V
:cond_4f
invoke-interface {p2}, Lcom/facebook/imagepipeline/memory/MemoryChunk;->getUniqueId()J
move-result-wide v0
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->getUniqueId()J
move-result-wide v2
cmp-long v4, v0, v2
if-gez v4, :cond_69
monitor-enter p2
:try_start_5c
monitor-enter p0
:try_end_5d
.catchall {:try_start_5c .. :try_end_5d} :catchall_66
:try_start_5d
invoke-direct {p0, p1, p2, p3, p4}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->doCopy(ILcom/facebook/imagepipeline/memory/MemoryChunk;II)V
monitor-exit p0
:try_end_61
.catchall {:try_start_5d .. :try_end_61} :catchall_63
:try_start_61
monitor-exit p2
:try_end_62
.catchall {:try_start_61 .. :try_end_62} :catchall_66
return-void
:catchall_63
move-exception p1
:try_start_64
monitor-exit p0
:try_end_65
.catchall {:try_start_64 .. :try_end_65} :catchall_63
:try_start_65
throw p1
:catchall_66
move-exception p1
monitor-exit p2
:try_end_68
.catchall {:try_start_65 .. :try_end_68} :catchall_66
throw p1
:cond_69
monitor-enter p0
:try_start_6a
monitor-enter p2
:try_end_6b
.catchall {:try_start_6a .. :try_end_6b} :catchall_74
:try_start_6b
invoke-direct {p0, p1, p2, p3, p4}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->doCopy(ILcom/facebook/imagepipeline/memory/MemoryChunk;II)V
monitor-exit p2
:try_end_6f
.catchall {:try_start_6b .. :try_end_6f} :catchall_71
:try_start_6f
monitor-exit p0
:try_end_70
.catchall {:try_start_6f .. :try_end_70} :catchall_74
return-void
:catchall_71
move-exception p1
:try_start_72
monitor-exit p2
:try_end_73
.catchall {:try_start_72 .. :try_end_73} :catchall_71
:try_start_73
throw p1
:catchall_74
move-exception p1
monitor-exit p0
:try_end_76
.catchall {:try_start_73 .. :try_end_76} :catchall_74
throw p1
.end method
.method public finalize()V
.registers 3
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/lang/Throwable;
}
.end annotation
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->isClosed()Z
move-result v0
if-eqz v0, :cond_7
return-void
:cond_7
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
const-string v1, "finalize: Chunk "
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-static {p0}, Ljava/lang/System;->identityHashCode(Ljava/lang/Object;)I
move-result v1
invoke-static {v1}, Ljava/lang/Integer;->toHexString(I)Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v1, " still active. "
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
const-string v1, "NativeMemoryChunk"
invoke-static {v1, v0}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
:try_start_2a
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->close()V
:try_end_2d
.catchall {:try_start_2a .. :try_end_2d} :catchall_31
invoke-super {p0}, Ljava/lang/Object;->finalize()V
return-void
:catchall_31
move-exception v0
invoke-super {p0}, Ljava/lang/Object;->finalize()V
throw v0
.end method
.method public getByteBuffer()Ljava/nio/ByteBuffer;
.registers 2
.annotation runtime Ljavax/annotation/Nullable;
.end annotation
const/4 v0, 0x0
return-object v0
.end method
.method public getNativePtr()J
.registers 3
iget-wide v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mNativePtr:J
return-wide v0
.end method
.method public getSize()I
.registers 2
iget v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mSize:I
return v0
.end method
.method public getUniqueId()J
.registers 3
iget-wide v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mNativePtr:J
return-wide v0
.end method
.method public declared-synchronized isClosed()Z
.registers 2
monitor-enter p0
:try_start_1
iget-boolean v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mIsClosed:Z
:try_end_3
.catchall {:try_start_1 .. :try_end_3} :catchall_5
monitor-exit p0
return v0
:catchall_5
move-exception v0
monitor-exit p0
throw v0
.end method
.method public declared-synchronized read(I)B
.registers 6
monitor-enter p0
:try_start_1
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->isClosed()Z
move-result v0
const/4 v1, 0x1
const/4 v2, 0x0
if-nez v0, :cond_b
const/4 v0, 0x1
goto :goto_c
:cond_b
const/4 v0, 0x0
:goto_c
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkState(Z)V
if-ltz p1, :cond_13
const/4 v0, 0x1
goto :goto_14
:cond_13
const/4 v0, 0x0
:goto_14
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkArgument(Z)V
iget v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mSize:I
if-ge p1, v0, :cond_1c
goto :goto_1d
:cond_1c
const/4 v1, 0x0
:goto_1d
invoke-static {v1}, Lcom/facebook/common/internal/Preconditions;->checkArgument(Z)V
iget-wide v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mNativePtr:J
int-to-long v2, p1
add-long/2addr v0, v2
invoke-static {v0, v1}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->nativeReadByte(J)B
move-result p1
:try_end_28
.catchall {:try_start_1 .. :try_end_28} :catchall_2a
monitor-exit p0
return p1
:catchall_2a
move-exception p1
monitor-exit p0
throw p1
.end method
.method public declared-synchronized read(I[BII)I
.registers 9
monitor-enter p0
:try_start_1
invoke-static {p2}, Lcom/facebook/common/internal/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->isClosed()Z
move-result v0
if-nez v0, :cond_c
const/4 v0, 0x1
goto :goto_d
:cond_c
const/4 v0, 0x0
:goto_d
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkState(Z)V
iget v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mSize:I
invoke-static {p1, p4, v0}, Lcom/facebook/imagepipeline/memory/MemoryChunkUtil;->adjustByteCount(III)I
move-result p4
array-length v0, p2
iget v1, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mSize:I
invoke-static {p1, v0, p3, p4, v1}, Lcom/facebook/imagepipeline/memory/MemoryChunkUtil;->checkBounds(IIIII)V
iget-wide v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mNativePtr:J
int-to-long v2, p1
add-long/2addr v0, v2
invoke-static {v0, v1, p2, p3, p4}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->nativeCopyToByteArray(J[BII)V
:try_end_23
.catchall {:try_start_1 .. :try_end_23} :catchall_25
monitor-exit p0
return p4
:catchall_25
move-exception p1
monitor-exit p0
throw p1
.end method
.method public declared-synchronized write(I[BII)I
.registers 9
monitor-enter p0
:try_start_1
invoke-static {p2}, Lcom/facebook/common/internal/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->isClosed()Z
move-result v0
if-nez v0, :cond_c
const/4 v0, 0x1
goto :goto_d
:cond_c
const/4 v0, 0x0
:goto_d
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkState(Z)V
iget v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mSize:I
invoke-static {p1, p4, v0}, Lcom/facebook/imagepipeline/memory/MemoryChunkUtil;->adjustByteCount(III)I
move-result p4
array-length v0, p2
iget v1, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mSize:I
invoke-static {p1, v0, p3, p4, v1}, Lcom/facebook/imagepipeline/memory/MemoryChunkUtil;->checkBounds(IIIII)V
iget-wide v0, p0, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->mNativePtr:J
int-to-long v2, p1
add-long/2addr v0, v2
invoke-static {v0, v1, p2, p3, p4}, Lcom/facebook/imagepipeline/memory/NativeMemoryChunk;->nativeCopyFromByteArray(J[BII)V
:try_end_23
.catchall {:try_start_1 .. :try_end_23} :catchall_25
monitor-exit p0
return p4
:catchall_25
move-exception p1
monitor-exit p0
throw p1
.end method