Segment.smali 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. .class final Lokio/Segment;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # static fields
  5. .field static final SHARE_MINIMUM:I = 0x400
  6. .field static final SIZE:I = 0x2000
  7. # instance fields
  8. .field final data:[B
  9. .field limit:I
  10. .field next:Lokio/Segment;
  11. .field owner:Z
  12. .field pos:I
  13. .field prev:Lokio/Segment;
  14. .field shared:Z
  15. # direct methods
  16. .method constructor <init>()V
  17. .locals 1
  18. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  19. const/16 v0, 0x2000
  20. new-array v0, v0, [B
  21. iput-object v0, p0, Lokio/Segment;->data:[B
  22. const/4 v0, 0x1
  23. iput-boolean v0, p0, Lokio/Segment;->owner:Z
  24. const/4 v0, 0x0
  25. iput-boolean v0, p0, Lokio/Segment;->shared:Z
  26. return-void
  27. .end method
  28. .method constructor <init>(Lokio/Segment;)V
  29. .locals 3
  30. iget-object v0, p1, Lokio/Segment;->data:[B
  31. iget v1, p1, Lokio/Segment;->pos:I
  32. iget v2, p1, Lokio/Segment;->limit:I
  33. invoke-direct {p0, v0, v1, v2}, Lokio/Segment;-><init>([BII)V
  34. const/4 v0, 0x1
  35. iput-boolean v0, p1, Lokio/Segment;->shared:Z
  36. return-void
  37. .end method
  38. .method constructor <init>([BII)V
  39. .locals 0
  40. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  41. iput-object p1, p0, Lokio/Segment;->data:[B
  42. iput p2, p0, Lokio/Segment;->pos:I
  43. iput p3, p0, Lokio/Segment;->limit:I
  44. const/4 p1, 0x0
  45. iput-boolean p1, p0, Lokio/Segment;->owner:Z
  46. const/4 p1, 0x1
  47. iput-boolean p1, p0, Lokio/Segment;->shared:Z
  48. return-void
  49. .end method
  50. # virtual methods
  51. .method public compact()V
  52. .locals 4
  53. iget-object v0, p0, Lokio/Segment;->prev:Lokio/Segment;
  54. if-eq v0, p0, :cond_3
  55. iget-boolean v1, v0, Lokio/Segment;->owner:Z
  56. if-nez v1, :cond_0
  57. return-void
  58. :cond_0
  59. iget v1, p0, Lokio/Segment;->limit:I
  60. iget v2, p0, Lokio/Segment;->pos:I
  61. sub-int/2addr v1, v2
  62. iget v2, v0, Lokio/Segment;->limit:I
  63. rsub-int v2, v2, 0x2000
  64. iget-boolean v3, v0, Lokio/Segment;->shared:Z
  65. if-eqz v3, :cond_1
  66. const/4 v0, 0x0
  67. goto :goto_0
  68. :cond_1
  69. iget v0, v0, Lokio/Segment;->pos:I
  70. :goto_0
  71. add-int/2addr v2, v0
  72. if-le v1, v2, :cond_2
  73. return-void
  74. :cond_2
  75. iget-object v0, p0, Lokio/Segment;->prev:Lokio/Segment;
  76. invoke-virtual {p0, v0, v1}, Lokio/Segment;->writeTo(Lokio/Segment;I)V
  77. invoke-virtual {p0}, Lokio/Segment;->pop()Lokio/Segment;
  78. invoke-static {p0}, Lokio/SegmentPool;->recycle(Lokio/Segment;)V
  79. return-void
  80. :cond_3
  81. new-instance v0, Ljava/lang/IllegalStateException;
  82. invoke-direct {v0}, Ljava/lang/IllegalStateException;-><init>()V
  83. throw v0
  84. .end method
  85. .method public pop()Lokio/Segment;
  86. .locals 4
  87. iget-object v0, p0, Lokio/Segment;->next:Lokio/Segment;
  88. const/4 v1, 0x0
  89. if-eq v0, p0, :cond_0
  90. goto :goto_0
  91. :cond_0
  92. move-object v0, v1
  93. :goto_0
  94. iget-object v2, p0, Lokio/Segment;->prev:Lokio/Segment;
  95. iget-object v3, p0, Lokio/Segment;->next:Lokio/Segment;
  96. iput-object v3, v2, Lokio/Segment;->next:Lokio/Segment;
  97. iget-object v3, p0, Lokio/Segment;->next:Lokio/Segment;
  98. iput-object v2, v3, Lokio/Segment;->prev:Lokio/Segment;
  99. iput-object v1, p0, Lokio/Segment;->next:Lokio/Segment;
  100. iput-object v1, p0, Lokio/Segment;->prev:Lokio/Segment;
  101. return-object v0
  102. .end method
  103. .method public push(Lokio/Segment;)Lokio/Segment;
  104. .locals 1
  105. iput-object p0, p1, Lokio/Segment;->prev:Lokio/Segment;
  106. iget-object v0, p0, Lokio/Segment;->next:Lokio/Segment;
  107. iput-object v0, p1, Lokio/Segment;->next:Lokio/Segment;
  108. iget-object v0, p0, Lokio/Segment;->next:Lokio/Segment;
  109. iput-object p1, v0, Lokio/Segment;->prev:Lokio/Segment;
  110. iput-object p1, p0, Lokio/Segment;->next:Lokio/Segment;
  111. return-object p1
  112. .end method
  113. .method public split(I)Lokio/Segment;
  114. .locals 5
  115. if-lez p1, :cond_1
  116. iget v0, p0, Lokio/Segment;->limit:I
  117. iget v1, p0, Lokio/Segment;->pos:I
  118. sub-int/2addr v0, v1
  119. if-gt p1, v0, :cond_1
  120. const/16 v0, 0x400
  121. if-lt p1, v0, :cond_0
  122. new-instance v0, Lokio/Segment;
  123. invoke-direct {v0, p0}, Lokio/Segment;-><init>(Lokio/Segment;)V
  124. goto :goto_0
  125. :cond_0
  126. invoke-static {}, Lokio/SegmentPool;->take()Lokio/Segment;
  127. move-result-object v0
  128. iget-object v1, p0, Lokio/Segment;->data:[B
  129. iget v2, p0, Lokio/Segment;->pos:I
  130. iget-object v3, v0, Lokio/Segment;->data:[B
  131. const/4 v4, 0x0
  132. invoke-static {v1, v2, v3, v4, p1}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
  133. :goto_0
  134. iget v1, v0, Lokio/Segment;->pos:I
  135. add-int/2addr v1, p1
  136. iput v1, v0, Lokio/Segment;->limit:I
  137. iget v1, p0, Lokio/Segment;->pos:I
  138. add-int/2addr v1, p1
  139. iput v1, p0, Lokio/Segment;->pos:I
  140. iget-object p1, p0, Lokio/Segment;->prev:Lokio/Segment;
  141. invoke-virtual {p1, v0}, Lokio/Segment;->push(Lokio/Segment;)Lokio/Segment;
  142. return-object v0
  143. :cond_1
  144. new-instance p1, Ljava/lang/IllegalArgumentException;
  145. invoke-direct {p1}, Ljava/lang/IllegalArgumentException;-><init>()V
  146. throw p1
  147. .end method
  148. .method public writeTo(Lokio/Segment;I)V
  149. .locals 4
  150. iget-boolean v0, p1, Lokio/Segment;->owner:Z
  151. if-eqz v0, :cond_3
  152. iget v0, p1, Lokio/Segment;->limit:I
  153. add-int v1, v0, p2
  154. const/16 v2, 0x2000
  155. if-le v1, v2, :cond_2
  156. iget-boolean v1, p1, Lokio/Segment;->shared:Z
  157. if-nez v1, :cond_1
  158. add-int v1, v0, p2
  159. iget v3, p1, Lokio/Segment;->pos:I
  160. sub-int/2addr v1, v3
  161. if-gt v1, v2, :cond_0
  162. iget-object v1, p1, Lokio/Segment;->data:[B
  163. sub-int/2addr v0, v3
  164. const/4 v2, 0x0
  165. invoke-static {v1, v3, v1, v2, v0}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
  166. iget v0, p1, Lokio/Segment;->limit:I
  167. iget v1, p1, Lokio/Segment;->pos:I
  168. sub-int/2addr v0, v1
  169. iput v0, p1, Lokio/Segment;->limit:I
  170. iput v2, p1, Lokio/Segment;->pos:I
  171. goto :goto_0
  172. :cond_0
  173. new-instance p1, Ljava/lang/IllegalArgumentException;
  174. invoke-direct {p1}, Ljava/lang/IllegalArgumentException;-><init>()V
  175. throw p1
  176. :cond_1
  177. new-instance p1, Ljava/lang/IllegalArgumentException;
  178. invoke-direct {p1}, Ljava/lang/IllegalArgumentException;-><init>()V
  179. throw p1
  180. :cond_2
  181. :goto_0
  182. iget-object v0, p0, Lokio/Segment;->data:[B
  183. iget v1, p0, Lokio/Segment;->pos:I
  184. iget-object v2, p1, Lokio/Segment;->data:[B
  185. iget v3, p1, Lokio/Segment;->limit:I
  186. invoke-static {v0, v1, v2, v3, p2}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
  187. iget v0, p1, Lokio/Segment;->limit:I
  188. add-int/2addr v0, p2
  189. iput v0, p1, Lokio/Segment;->limit:I
  190. iget p1, p0, Lokio/Segment;->pos:I
  191. add-int/2addr p1, p2
  192. iput p1, p0, Lokio/Segment;->pos:I
  193. return-void
  194. :cond_3
  195. new-instance p1, Ljava/lang/IllegalArgumentException;
  196. invoke-direct {p1}, Ljava/lang/IllegalArgumentException;-><init>()V
  197. throw p1
  198. .end method