SegmentPool.smali 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. .class final Lokio/SegmentPool;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # static fields
  5. .field static final MAX_SIZE:J = 0x10000L
  6. .field static byteCount:J
  7. .field static next:Lokio/Segment;
  8. # direct methods
  9. .method private constructor <init>()V
  10. .locals 0
  11. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  12. return-void
  13. .end method
  14. .method static recycle(Lokio/Segment;)V
  15. .locals 8
  16. iget-object v0, p0, Lokio/Segment;->next:Lokio/Segment;
  17. if-nez v0, :cond_2
  18. iget-object v0, p0, Lokio/Segment;->prev:Lokio/Segment;
  19. if-nez v0, :cond_2
  20. iget-boolean v0, p0, Lokio/Segment;->shared:Z
  21. if-eqz v0, :cond_0
  22. return-void
  23. :cond_0
  24. const-class v0, Lokio/SegmentPool;
  25. monitor-enter v0
  26. :try_start_0
  27. sget-wide v1, Lokio/SegmentPool;->byteCount:J
  28. const-wide/16 v3, 0x2000
  29. add-long/2addr v1, v3
  30. const-wide/32 v5, 0x10000
  31. cmp-long v7, v1, v5
  32. if-lez v7, :cond_1
  33. monitor-exit v0
  34. return-void
  35. :cond_1
  36. sget-wide v1, Lokio/SegmentPool;->byteCount:J
  37. add-long/2addr v1, v3
  38. sput-wide v1, Lokio/SegmentPool;->byteCount:J
  39. sget-object v1, Lokio/SegmentPool;->next:Lokio/Segment;
  40. iput-object v1, p0, Lokio/Segment;->next:Lokio/Segment;
  41. const/4 v1, 0x0
  42. iput v1, p0, Lokio/Segment;->limit:I
  43. iput v1, p0, Lokio/Segment;->pos:I
  44. sput-object p0, Lokio/SegmentPool;->next:Lokio/Segment;
  45. monitor-exit v0
  46. return-void
  47. :catchall_0
  48. move-exception p0
  49. monitor-exit v0
  50. :try_end_0
  51. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  52. throw p0
  53. :cond_2
  54. new-instance p0, Ljava/lang/IllegalArgumentException;
  55. invoke-direct {p0}, Ljava/lang/IllegalArgumentException;-><init>()V
  56. throw p0
  57. .end method
  58. .method static take()Lokio/Segment;
  59. .locals 6
  60. const-class v0, Lokio/SegmentPool;
  61. monitor-enter v0
  62. :try_start_0
  63. sget-object v1, Lokio/SegmentPool;->next:Lokio/Segment;
  64. if-eqz v1, :cond_0
  65. sget-object v1, Lokio/SegmentPool;->next:Lokio/Segment;
  66. iget-object v2, v1, Lokio/Segment;->next:Lokio/Segment;
  67. sput-object v2, Lokio/SegmentPool;->next:Lokio/Segment;
  68. const/4 v2, 0x0
  69. iput-object v2, v1, Lokio/Segment;->next:Lokio/Segment;
  70. sget-wide v2, Lokio/SegmentPool;->byteCount:J
  71. const-wide/16 v4, 0x2000
  72. sub-long/2addr v2, v4
  73. sput-wide v2, Lokio/SegmentPool;->byteCount:J
  74. monitor-exit v0
  75. return-object v1
  76. :cond_0
  77. monitor-exit v0
  78. :try_end_0
  79. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  80. new-instance v0, Lokio/Segment;
  81. invoke-direct {v0}, Lokio/Segment;-><init>()V
  82. return-object v0
  83. :catchall_0
  84. move-exception v1
  85. :try_start_1
  86. monitor-exit v0
  87. :try_end_1
  88. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  89. throw v1
  90. .end method