a bugfix for previously commit.

git-svn-id: svn://kolibrios.org@1211 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Alexey Teplov ( 2009-10-13 07:47:13 +00:00
parent 41b9d8be8d
commit 08bc0b6e4a

View File

@ -20,7 +20,7 @@ $Revision$
; esi= nb ; esi= nb
; ebx= idx ; ebx= idx
; ;
align 4 align 16
malloc: malloc:
push esi push esi
@ -69,7 +69,6 @@ malloc:
jne @F jne @F
btr [mst.smallmap], ebx btr [mst.smallmap], ebx
align 4
@@: @@:
; B->fd = F; ; B->fd = F;
@ -92,12 +91,10 @@ align 4
pop edi pop edi
pop ebp pop ebp
align 4
.done: .done:
pop esi pop esi
mov [mst.mutex], 0 mov [mst.mutex], 0
ret ret
align 4
.split: .split:
lea ebx, [edx+8] ;ebx=mem lea ebx, [edx+8] ;ebx=mem
@ -139,7 +136,6 @@ align 4
mov eax, ebx mov eax, ebx
pop esi pop esi
ret ret
align 4
.small: .small:
; if (ms.treemap != 0 && (mem = malloc_small(nb)) != 0) ; if (ms.treemap != 0 && (mem = malloc_small(nb)) != 0)
@ -156,7 +152,6 @@ align 4
pop esi pop esi
and [mst.mutex], 0 and [mst.mutex], 0
ret ret
align 4
.large: .large:
; if (ms.treemap != 0 && (mem = malloc_large(nb)) != 0) ; if (ms.treemap != 0 && (mem = malloc_large(nb)) != 0)
@ -167,7 +162,6 @@ align 4
call malloc_large ;esi= nb call malloc_large ;esi= nb
test eax, eax test eax, eax
jne .done jne .done
align 4
.from_top: .from_top:
; if (nb < ms.topsize) ; if (nb < ms.topsize)
@ -197,7 +191,6 @@ align 4
pop esi pop esi
and [mst.mutex], 0 and [mst.mutex], 0
ret ret
align 4
.fail: .fail:
xor eax, eax xor eax, eax
pop esi pop esi
@ -207,7 +200,6 @@ align 4
; param ; param
; eax= mem ; eax= mem
align 4
free: free:
push edi push edi
mov edi, eax mov edi, eax
@ -258,16 +250,13 @@ free:
cmp eax, edx cmp eax, edx
jne @F jne @F
and [mst.smallmap], ecx and [mst.smallmap], ecx
align 4
@@: @@:
mov [eax+12], edx ;F->bk = B; mov [eax+12], edx ;F->bk = B;
mov [edx+8], eax ;B->fd = F mov [edx+8], eax ;B->fd = F
jmp .next jmp .next
align 4
.unlink_large: .unlink_large:
mov edx, edi mov edx, edi
call unlink_large_chunk call unlink_large_chunk
align 4
.next: .next:
; if(next->head & PINUSE_BIT) ; if(next->head & PINUSE_BIT)
@ -298,15 +287,12 @@ align 4
or eax, 1 or eax, 1
mov [mst.top], edi mov [mst.top], edi
mov [edi+4], eax mov [edi+4], eax
align 4
.fail2: .fail2:
and [mst.mutex], 0 and [mst.mutex], 0
pop esi pop esi
align 4
.fail: .fail:
pop edi pop edi
ret ret
align 4
@@: @@:
; nsize = next->head & ~INUSE_BITS; ; nsize = next->head & ~INUSE_BITS;
@ -329,7 +315,6 @@ align 4
mov ecx, eax mov ecx, eax
shr ecx, 3 shr ecx, 3
btr [mst.smallmap], ecx btr [mst.smallmap], ecx
align 4
@@: @@:
mov [edx+12], ebx ;F->bk = B mov [edx+12], ebx ;F->bk = B
@ -351,7 +336,6 @@ align 4
mov ecx, edi mov ecx, edi
pop edi pop edi
jmp insert_chunk jmp insert_chunk
align 4
.unl_large: .unl_large:
; unlink_large_chunk((tchunkptr)next); ; unlink_large_chunk((tchunkptr)next);
@ -375,7 +359,6 @@ align 4
mov ecx, edi mov ecx, edi
pop edi pop edi
jmp insert_chunk jmp insert_chunk
align 4
.fix_next: .fix_next:
; (p+psize)->prev_foot = psize; ; (p+psize)->prev_foot = psize;
@ -403,7 +386,6 @@ align 4
; ecx = chunk ; ecx = chunk
; eax = size ; eax = size
align 4
insert_chunk: insert_chunk:
cmp eax, 256 cmp eax, 256
@ -429,7 +411,6 @@ insert_chunk:
pop esi pop esi
and [mst.mutex], 0 and [mst.mutex], 0
ret ret
align 4
.large: .large:
mov ebx, eax mov ebx, eax
call insert_large_chunk call insert_large_chunk
@ -437,13 +418,11 @@ align 4
and [mst.mutex], 0 and [mst.mutex], 0
ret ret
align 4
; param ; param
; esi= chunk ; esi= chunk
; ebx= size ; ebx= size
align 4
insert_large_chunk: insert_large_chunk:
; I = compute_tree_index(S); ; I = compute_tree_index(S);
@ -478,7 +457,6 @@ insert_large_chunk:
; *H = X; ; *H = X;
mov dword [edx], esi mov dword [edx], esi
jmp .done jmp .done
align 4
.tree: .tree:
; T = *H; ; T = *H;
@ -497,7 +475,6 @@ align 4
shl eax, cl ;eax= K shl eax, cl ;eax= K
jmp .loop jmp .loop
align 4
.not_eq_size: .not_eq_size:
; C = &(T->child[(K >> 31) & 1]); ; C = &(T->child[(K >> 31) & 1]);
@ -514,7 +491,6 @@ align 4
; T = *C; ; T = *C;
mov edx, edi mov edx, edi
align 4
.loop: .loop:
; for (;;) ; for (;;)
@ -540,12 +516,10 @@ align 4
mov [esi+8], eax mov [esi+8], eax
mov [esi+12], edx mov [esi+12], edx
ret ret
align 4
.insert_child: .insert_child:
; *C = X; ; *C = X;
mov [ecx], esi mov [ecx], esi
align 4
.done: .done:
; X->parent = T; ; X->parent = T;
@ -560,7 +534,6 @@ align 4
; param ; param
; edx= chunk ; edx= chunk
align 4
unlink_large_chunk: unlink_large_chunk:
mov eax, [edx+12] mov eax, [edx+12]
@ -573,7 +546,6 @@ unlink_large_chunk:
mov [ecx+12], eax ;F->bk = R; mov [ecx+12], eax ;F->bk = R;
mov [eax+8], ecx ;R->fd = F mov [eax+8], ecx ;R->fd = F
jmp .parent jmp .parent
align 4
@@: @@:
mov eax, [edx+20] mov eax, [edx+20]
test eax, eax test eax, eax
@ -585,7 +557,6 @@ align 4
test eax, eax test eax, eax
lea esi, [edx+16] lea esi, [edx+16]
je .l2 je .l2
align 4
.loop: .loop:
cmp dword [eax+20], 0 cmp dword [eax+20], 0
lea ecx, [eax+20] lea ecx, [eax+20]
@ -594,18 +565,14 @@ align 4
cmp dword [eax+16], 0 cmp dword [eax+16], 0
lea ecx, [eax+16] lea ecx, [eax+16]
je .l1 je .l1
align 4
@@: @@:
mov eax, [ecx] mov eax, [ecx]
mov esi, ecx mov esi, ecx
jmp .loop jmp .loop
align 4
.l1: .l1:
mov dword [esi], 0 mov dword [esi], 0
align 4
.l2: .l2:
pop esi pop esi
align 4
.parent: .parent:
test edi, edi test edi, edi
je .done je .done
@ -623,21 +590,21 @@ align 4
btr [mst.treemap], ecx btr [mst.treemap], ecx
pop edi pop edi
ret ret
align 4
.l3: .l3:
cmp [edi+16], edx cmp [edi+16], edx
jne @F jne @F
mov [edi+16], eax mov [edi+16], eax
jmp .l4 jmp .l4
align 4
@@: @@:
mov [edi+20], eax mov [edi+20], eax
align 4
.l4: .l4:
test eax, eax test eax, eax
je .done je .done
align 4
.l5: .l5:
mov [eax+24], edi mov [eax+24], edi
mov ecx, [edx+16] mov ecx, [edx+16]
@ -646,7 +613,7 @@ align 4
mov [eax+16], ecx mov [eax+16], ecx
mov [ecx+24], eax mov [ecx+24], eax
align 4
.l6: .l6:
mov edx, [edx+20] mov edx, [edx+20]
test edx, edx test edx, edx
@ -654,7 +621,7 @@ align 4
mov [eax+20], edx mov [eax+20], edx
mov [edx+24], eax mov [edx+24], eax
align 4
.done: .done:
pop edi pop edi
ret ret
@ -662,7 +629,6 @@ align 4
; param ; param
; esi= nb ; esi= nb
align 4
malloc_small: malloc_small:
push ebp push ebp
mov ebp, esi mov ebp, esi
@ -677,10 +643,10 @@ malloc_small:
mov edi, [ecx+4] mov edi, [ecx+4]
and edi, -4 and edi, -4
sub edi, esi sub edi, esi
align 4
.loop: .loop:
mov ebx, ecx mov ebx, ecx
align 4
.loop_1: .loop_1:
; while ((t = leftmost_child(t)) != 0) ; while ((t = leftmost_child(t)) != 0)
@ -690,10 +656,10 @@ align 4
jz @F jz @F
mov ecx, eax mov ecx, eax
jmp .l1 jmp .l1
align 4
@@: @@:
mov ecx, [ecx+20] mov ecx, [ecx+20]
align 4
.l1: .l1:
test ecx, ecx test ecx, ecx
jz .unlink jz .unlink
@ -744,7 +710,7 @@ align 4
lea eax, [ebx+8] lea eax, [ebx+8]
ret ret
align 4
.split: .split:
; v->head = nb|PINUSE_BIT|CINUSE_BIT; ; v->head = nb|PINUSE_BIT|CINUSE_BIT;
@ -777,7 +743,7 @@ align 4
pop ebp pop ebp
lea eax, [ebx+8] lea eax, [ebx+8]
ret ret
align 4
.large: .large:
lea eax, [ebx+8] lea eax, [ebx+8]
push eax push eax
@ -792,7 +758,6 @@ align 4
; param ; param
; esi= nb ; esi= nb
align 4
malloc_large: malloc_large:
.idx equ esp+4 .idx equ esp+4
.rst equ esp .rst equ esp
@ -831,20 +796,20 @@ malloc_large:
jne @F jne @F
xor ecx, ecx xor ecx, ecx
jmp .l1 jmp .l1
align 4
@@: @@:
mov edx, ecx mov edx, ecx
shr edx, 1 shr edx, 1
mov ecx, 37 mov ecx, 37
sub ecx, edx sub ecx, edx
align 4
.l1: .l1:
mov edx, ebx mov edx, ebx
shl edx, cl shl edx, cl
; rst = 0; ; rst = 0;
mov [.rst], ebp mov [.rst], ebp
align 4
.loop: .loop:
; trem = (t->head & ~INUSE_BITS) - nb; ; trem = (t->head & ~INUSE_BITS) - nb;
@ -864,7 +829,7 @@ align 4
mov ebp, eax mov ebp, eax
mov edi, ecx mov edi, ecx
je .l2 je .l2
align 4
@@: @@:
; rt = t->child[1]; ; rt = t->child[1];
@ -886,7 +851,7 @@ align 4
; rst = rt; ; rst = rt;
mov [.rst], ecx mov [.rst], ecx
align 4
@@: @@:
; if (t == 0) ; if (t == 0)
@ -897,11 +862,11 @@ align 4
add edx, edx add edx, edx
jmp .loop jmp .loop
align 4
@@: @@:
; t = rst; ; t = rst;
mov eax, [.rst] mov eax, [.rst]
align 4
.l2: .l2:
; if (t == 0 && v == 0) ; if (t == 0 && v == 0)
@ -910,7 +875,7 @@ align 4
test ebp, ebp test ebp, ebp
jne .l7 jne .l7
mov ecx, [.idx] mov ecx, [.idx]
align 4
.l3: .l3:
; leftbits = (-1<<idx) & ms.treemap; ; leftbits = (-1<<idx) & ms.treemap;
@ -924,13 +889,13 @@ align 4
bsf eax, edx bsf eax, edx
; t = ms.treebins[i]; ; t = ms.treebins[i];
mov eax, [mst.treebins+eax*4] mov eax, [mst.treebins+eax*4]
align 4
@@: @@:
; while (t != 0) ; while (t != 0)
test eax, eax test eax, eax
jz .l5 jz .l5
align 4
.l4: .l4:
; trem = (t->head & ~INUSE_BITS) - nb; ; trem = (t->head & ~INUSE_BITS) - nb;
@ -948,7 +913,7 @@ align 4
mov edi, ecx mov edi, ecx
; v = t; ; v = t;
mov ebp, eax mov ebp, eax
align 4
@@: @@:
; t = leftmost_child(t); ; t = leftmost_child(t);
@ -958,24 +923,24 @@ align 4
je @F je @F
mov eax, ecx mov eax, ecx
jmp .l6 jmp .l6
align 4
@@: @@:
mov eax, [eax+20] mov eax, [eax+20]
align 4
.l6: .l6:
; while (t != 0) ; while (t != 0)
test eax, eax test eax, eax
jne .l4 jne .l4
align 4
.l5: .l5:
; if (v != 0) ; if (v != 0)
test ebp, ebp test ebp, ebp
jz .done jz .done
align 4
.l7: .l7:
; r = chunk_plus_offset((mchunkptr)v, nb); ; r = chunk_plus_offset((mchunkptr)v, nb);
@ -1006,7 +971,7 @@ align 4
pop edi pop edi
pop ebp pop ebp
ret ret
align 4
.large: .large:
; v->head = nb|PINUSE_BIT|CINUSE_BIT; ; v->head = nb|PINUSE_BIT|CINUSE_BIT;
@ -1031,7 +996,7 @@ align 4
pop edi pop edi
pop ebp pop ebp
ret ret
align 4
.done: .done:
add esp, 8 add esp, 8
pop edi pop edi
@ -1039,7 +1004,6 @@ align 4
xor eax, eax xor eax, eax
ret ret
align 4
init_malloc: init_malloc:
stdcall kernel_alloc, 0x40000 stdcall kernel_alloc, 0x40000
@ -1048,7 +1012,7 @@ init_malloc:
mov [mst.topsize], 128*1024 mov [mst.topsize], 128*1024
mov dword [eax+4], (128*1024) or 1 mov dword [eax+4], (128*1024) or 1
mov eax, mst.smallbins mov eax, mst.smallbins
align 4
@@: @@:
mov [eax+8], eax mov [eax+8], eax
mov [eax+12], eax mov [eax+12], eax
@ -1058,6 +1022,3 @@ align 4
ret ret