Subversion Repositories Kolibri OS

Rev

Rev 1376 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1376 Rev 2382
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 1376 $
8
$Revision: 2382 $
9
 
9
 
10
 
10
 
Line 18... Line 18...
18
 
18
 
19
; temp
19
; temp
20
;  esi= nb
20
;  esi= nb
21
;  ebx= idx
21
;  ebx= idx
22
;
22
;
23
align 16 
23
align 4
24
malloc:
24
malloc:
Line 25... Line 25...
25
           push esi
25
        push    esi
Line 26... Line 26...
26
 
26
 
27
; nb = ((size+7)&~7)+8;
27
; nb = ((size+7)&~7)+8;
28
 
28
 
29
           mov esi, eax    ;size
29
        mov     esi, eax   ;size
Line 30... Line 30...
30
           add esi, 7
30
        add     esi, 7
31
           and esi, -8
31
        and     esi, -8
Line 32... Line 32...
32
           add esi, 8
32
        add     esi, 8
33
 
33
 
Line 34... Line 34...
34
           mov ebx, mst.mutex
34
        mov     ecx, mst.mutex
Line 90... Line 90...
90
           mov [edx+4], ebp
90
        mov     [edx+4], ebp
Line 91... Line 91...
91
 
91
 
92
           pop edi
92
        pop     edi
93
           pop ebp
93
        pop     ebp
-
 
94
.done:
-
 
95
        mov     esi, eax
-
 
96
        mov     ecx, mst.mutex
-
 
97
        call    mutex_unlock
94
.done:
98
        mov     eax, esi
95
           pop esi
-
 
96
           mov [mst.mutex], 0
99
        pop     esi
-
 
100
        ret
97
           ret
101
 
98
.split:
102
.split:
Line 99... Line 103...
99
           lea ebx, [edx+8]               ;ebx=mem
103
        lea     ebx, [edx+8]              ;ebx=mem
100
 
104
 
Line 131... Line 135...
131
           mov edx, [ecx+8]               ; F = B->fd;
135
        mov     edx, [ecx+8]              ; F = B->fd;
132
           mov [ecx+8], eax               ; B->fd = r;
136
        mov     [ecx+8], eax              ; B->fd = r;
133
           mov [edx+12], eax              ; F->bk = r;
137
        mov     [edx+12], eax             ; F->bk = r;
134
           mov [eax+8], edx               ; r->fd = F;
138
        mov     [eax+8], edx              ; r->fd = F;
135
           mov [eax+12], ecx              ; r->bk = B;
139
        mov     [eax+12], ecx             ; r->bk = B;
-
 
140
 
136
           mov eax, ebx
141
        mov     eax, ebx
137
           pop esi
142
        jmp     .done
138
           mov [mst.mutex], 0
-
 
139
           ret
143
 
140
.small:
144
.small:
Line 141... Line 145...
141
 
145
 
142
; if (ms.treemap != 0 && (mem = malloc_small(nb)) != 0)
146
; if (ms.treemap != 0 && (mem = malloc_small(nb)) != 0)
143
;;;;;;;;;;; start a change 
147
;;;;;;;;;;; start a change 
Line 148... Line 152...
148
           jz .from_top
152
        jz      .from_top
149
           mov eax, esi
153
        mov     eax, esi
150
           call malloc_small
154
        call    malloc_small
151
           test eax, eax
155
        test    eax, eax
152
           jz .from_top
156
        jz      .from_top
153
           pop esi
157
        jmp     .done
154
           and [mst.mutex], 0
-
 
155
           ret
158
 
156
.large:
159
.large:
Line 157... Line 160...
157
 
160
 
Line 158... Line 161...
158
; if (ms.treemap != 0 && (mem = malloc_large(nb)) != 0)
161
; if (ms.treemap != 0 && (mem = malloc_large(nb)) != 0)
Line 187... Line 190...
187
           mov [mst.top], edx
190
        mov     [mst.top], edx
188
           or esi, 3
191
        or      esi, 3
189
           mov [edx+4], eax
192
        mov     [edx+4], eax
190
           mov [ecx+4], esi
193
        mov     [ecx+4], esi
191
           lea eax, [ecx+8]
194
        lea     eax, [ecx+8]
192
           pop esi
195
        jmp     .done
193
           and [mst.mutex], 0
-
 
194
           ret
196
 
195
.fail:
197
.fail:
196
           xor eax, eax
198
        xor     eax, eax
197
           pop esi
199
        jmp     .done
198
           and [mst.mutex], 0
-
 
199
           ret
-
 
Line 200... Line 200...
200
 
200
 
201
; param
201
; param
202
;  eax= mem
202
;  eax= mem
203
 
203
align 4
-
 
204
free:
-
 
205
        test    eax, eax
-
 
206
        jz      .exit
204
free:
207
 
205
           push edi
208
        push    edi
206
           mov edi, eax
209
        mov     edi, eax
Line 207... Line 210...
207
           add edi, -8
210
        add     edi, -8
Line 208... Line 211...
208
 
211
 
209
; if(p->head & CINUSE_BIT)
212
; if(p->head & CINUSE_BIT)
Line 210... Line 213...
210
 
213
 
211
           test byte [edi+4], 2
214
        test    byte [edi+4], 2
Line 212... Line 215...
212
           je .fail
215
        je      .fail
Line 213... Line 216...
213
 
216
 
214
           mov ebx, mst.mutex
217
        mov     ecx, mst.mutex
Line 287... Line 290...
287
 
290
 
288
           or eax, 1
291
        or      eax, 1
289
           mov [mst.top], edi
292
        mov     [mst.top], edi
290
           mov [edi+4], eax
293
        mov     [edi+4], eax
-
 
294
.fail2:
291
.fail2:
295
        mov     esi, eax
-
 
296
        mov     ecx, mst.mutex
-
 
297
        call    mutex_unlock
292
           and [mst.mutex], 0
298
        mov     eax, esi
293
           pop esi
299
        pop     esi
294
.fail:
300
.fail:
-
 
301
        pop     edi
295
           pop edi
302
.exit:
-
 
303
        ret
296
           ret
304
 
Line 297... Line 305...
297
@@:
305
@@:
Line 298... Line 306...
298
 
306
 
Line 408... Line 416...
408
           mov [eax+8], esi            ;B->fd = P
416
        mov     [eax+8], esi           ;B->fd = P
409
           mov [edx+12], esi           ;F->bk = P
417
        mov     [edx+12], esi          ;F->bk = P
410
           mov [esi+8], edx            ;P->fd = F
418
        mov     [esi+8], edx           ;P->fd = F
411
           mov [esi+12], eax           ;P->bk = B
419
        mov     [esi+12], eax          ;P->bk = B
412
           pop esi
420
        pop     esi
413
           and [mst.mutex], 0
421
        mov     ecx, mst.mutex
-
 
422
        call    mutex_unlock
414
           ret
423
        ret
415
.large:
424
.large:
416
           mov ebx, eax
425
        mov     ebx, eax
417
           call insert_large_chunk
426
        call    insert_large_chunk
418
           pop esi
427
        pop     esi
419
           and [mst.mutex], 0
428
        mov     ecx, mst.mutex
-
 
429
        call    mutex_unlock
420
           ret
430
        ret
Line 421... Line 431...
421
 
431
 
422
 
432
 
Line 1023... Line 1033...
1023
           mov [eax+12], eax
1033
        mov     [eax+12], eax
1024
           add eax, 16
1034
        add     eax, 16
1025
           cmp eax, mst.smallbins+512
1035
        cmp     eax, mst.smallbins+512
1026
           jb @B
1036
        jb      @B
Line -... Line 1037...
-
 
1037
 
-
 
1038
        mov     ecx, mst.mutex
-
 
1039
        call    mutex_init
1027
 
1040