Subversion Repositories Kolibri OS

Rev

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

Rev 1635 Rev 2130
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: 1333 $
8
$Revision: 2130 $
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:
204
free:
205
           push edi
205
           push edi
206
           mov edi, eax
206
           mov edi, eax
Line 207... Line 207...
207
           add edi, -8
207
           add edi, -8
Line 208... Line 208...
208
 
208
 
209
; if(p->head & CINUSE_BIT)
209
; if(p->head & CINUSE_BIT)
Line 210... Line 210...
210
 
210
 
211
           test byte [edi+4], 2
211
           test byte [edi+4], 2
Line 212... Line 212...
212
           je .fail
212
           je .fail
Line 213... Line 213...
213
 
213
 
214
           mov ebx, mst.mutex
214
           mov ecx, mst.mutex
Line 287... Line 287...
287
 
287
 
288
           or eax, 1
288
           or eax, 1
289
           mov [mst.top], edi
289
           mov [mst.top], edi
290
           mov [edi+4], eax
290
           mov [edi+4], eax
-
 
291
.fail2:
291
.fail2:
292
           mov esi, eax
-
 
293
           mov ecx, mst.mutex
-
 
294
           call mutex_unlock
292
           and [mst.mutex], 0
295
           mov eax, esi
293
           pop esi
296
           pop esi
294
.fail:
297
.fail:
295
           pop edi
298
           pop edi
296
           ret
299
           ret
Line 408... Line 411...
408
           mov [eax+8], esi            ;B->fd = P
411
           mov [eax+8], esi            ;B->fd = P
409
           mov [edx+12], esi           ;F->bk = P
412
           mov [edx+12], esi           ;F->bk = P
410
           mov [esi+8], edx            ;P->fd = F
413
           mov [esi+8], edx            ;P->fd = F
411
           mov [esi+12], eax           ;P->bk = B
414
           mov [esi+12], eax           ;P->bk = B
412
           pop esi
415
           pop esi
413
           and [mst.mutex], 0
416
           mov ecx, mst.mutex
-
 
417
           call mutex_unlock
414
           ret
418
           ret
415
.large:
419
.large:
416
           mov ebx, eax
420
           mov ebx, eax
417
           call insert_large_chunk
421
           call insert_large_chunk
418
           pop esi
422
           pop esi
419
           and [mst.mutex], 0
423
           mov ecx, mst.mutex
-
 
424
           call mutex_unlock
420
           ret
425
           ret
Line 421... Line 426...
421
 
426
 
422
 
427
 
Line 1023... Line 1028...
1023
           mov [eax+12], eax
1028
           mov [eax+12], eax
1024
           add eax, 16
1029
           add eax, 16
1025
           cmp eax, mst.smallbins+512
1030
           cmp eax, mst.smallbins+512
1026
           jb @B
1031
           jb @B
Line -... Line 1032...
-
 
1032
 
-
 
1033
           mov ecx, mst.mutex
-
 
1034
           call mutex_init
1027
 
1035