insert a 'align 4'

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

View File

@ -20,6 +20,7 @@ $Revision$
; esi= nb ; esi= nb
; ebx= idx ; ebx= idx
; ;
align 4
malloc: malloc:
push esi push esi
@ -68,6 +69,7 @@ malloc:
jne @F jne @F
btr [mst.smallmap], ebx btr [mst.smallmap], ebx
align 4
@@: @@:
; B->fd = F; ; B->fd = F;
@ -90,10 +92,12 @@ malloc:
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
@ -135,12 +139,16 @@ malloc:
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)
;;;;;;;;;;; start a change <lrz>
cmp [mst.treemap], 0 mov eax,[mst.treemap]
je .from_top test eax,eax
;;;;;;;;;;; end the change <lrz>
; cmp [mst.treemap], 0
jz .from_top
mov eax, esi mov eax, esi
call malloc_small call malloc_small
test eax, eax test eax, eax
@ -148,6 +156,7 @@ malloc:
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)
@ -158,6 +167,7 @@ malloc:
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)
@ -187,6 +197,7 @@ malloc:
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
@ -247,13 +258,16 @@ 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)
@ -284,12 +298,15 @@ free:
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;
@ -312,6 +329,7 @@ free:
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
@ -333,6 +351,7 @@ free:
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);
@ -356,6 +375,7 @@ free:
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;
@ -409,6 +429,7 @@ 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
@ -457,6 +478,7 @@ 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;
@ -475,7 +497,7 @@ insert_large_chunk:
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]);
@ -492,6 +514,7 @@ insert_large_chunk:
; T = *C; ; T = *C;
mov edx, edi mov edx, edi
align 4
.loop: .loop:
; for (;;) ; for (;;)
@ -517,11 +540,12 @@ insert_large_chunk:
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;
@ -549,6 +573,7 @@ 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
@ -560,6 +585,7 @@ unlink_large_chunk:
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]
@ -568,14 +594,18 @@ unlink_large_chunk:
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
@ -593,17 +623,21 @@ unlink_large_chunk:
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]
@ -612,6 +646,7 @@ unlink_large_chunk:
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
@ -619,6 +654,7 @@ unlink_large_chunk:
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
@ -641,8 +677,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)
@ -652,8 +690,10 @@ malloc_small:
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
@ -704,6 +744,7 @@ malloc_small:
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;
@ -736,6 +777,7 @@ malloc_small:
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
@ -789,17 +831,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;
@ -819,6 +864,7 @@ malloc_large:
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];
@ -840,6 +886,7 @@ malloc_large:
; rst = rt; ; rst = rt;
mov [.rst], ecx mov [.rst], ecx
align 4
@@: @@:
; if (t == 0) ; if (t == 0)
@ -850,9 +897,11 @@ malloc_large:
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)
@ -861,6 +910,7 @@ malloc_large:
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;
@ -874,11 +924,13 @@ malloc_large:
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;
@ -896,6 +948,7 @@ malloc_large:
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);
@ -905,20 +958,24 @@ malloc_large:
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);
@ -949,6 +1006,7 @@ malloc_large:
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;
@ -973,6 +1031,7 @@ malloc_large:
pop edi pop edi
pop ebp pop ebp
ret ret
align 4
.done: .done:
add esp, 8 add esp, 8
pop edi pop edi
@ -989,6 +1048,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