Commit 2dd75d2d authored by John van Groningen's avatar John van Groningen
Browse files

in the compacting garbage collector for 32 bit Intel change marking and copying of arrays,

the arrays are not reordered anymore

to mark an array using pointer reversal:
  - temporarily replace the _ARRAY_ descriptor with the previous node information, except the
    2 least significant bits. these are cleared because the least significant bit must be zero
    to detect reversed pointers
  - these 2 least significant bits from the previous node information are stored by temporarily
    multiplying the size by 4 and using the least significant 2 bits
  - the address of the array + 3 is stored in the first element of the array, or for unboxed
    arrays of records with both pointers and non pointers, in the first pointer of the current
    record to be marked
    the first argument of an argument part may also contain and address + 3 if the pointer to the
    argument part has been reversed. this pointer always points to a higher address. for arrays the
    address + 3 points to a lower address. so we can use this to distinguish these pointers
    while marking with pointer reversal. after marking this is no longer possible because
    forward pointers to argument parts will also be reversed.
  - the overwritten first element of the array or record in an array is stored in the element that
    is currently being marked, and later restored.
  - elements are marked in reverse order, so starting with the last pointer element
  - while marking we can detect if we have reached the first element because it is an address + 3
    that points backward. because this is the address of the array we can test if this is not
    yet the first record element of an array of records, and using the record descriptor determine
    the beginning and end of the previous (next to be marked) record element
parent ad3a1ec8
......@@ -857,6 +857,7 @@ cp_s_arg_lp3:
addl $4,a0
movl d1,(a4)
addl $4,a4
st_cp_s_arg_lp3:
subl $1,d0
jnc cp_s_arg_lp3
......@@ -874,163 +875,60 @@ move_array:
cmpl $__ARRAY__+2,d0
jb move_normal_hnf_0
#endif
#ifdef NO_BIT_INSTRUCTIONS
test a3,a3
jne bsf_and_end_array_bit
#else
bsf a3,d1
jne end_array_bit
#endif
pushl a0
movl vector_counter,d0
movl vector_p,a0
skip_zeros_a:
subl $1,d0
movl (a0),a3
addl $4,a0
testl a3,a3
je skip_zeros_a
movl neg_heap_vector_plus_4,a2
addl a0,a2
movl d0,vector_counter
shl $5,a2
movl a0,vector_p
addl heap_p3,a2
popl a0
#ifdef NO_BIT_INSTRUCTIONS
bsf_and_end_array_bit:
movl a3,d0
movl a3,a1
andl $0xff,d0
jne a_found_bit1
andl $0xff00,a1
jne a_found_bit2
movl a3,d0
movl a3,a1
andl $0xff0000,d0
jne a_found_bit3
shrl $24,a1
movzbl first_one_bit_table(,a1,1),d1
addl $24,d1
jmp end_array_bit
a_found_bit3:
shrl $16,d0
movzbl first_one_bit_table(,d0,1),d1
addl $16,d1
jmp end_array_bit
a_found_bit2:
shrl $8,a1
movzbl first_one_bit_table(,a1,1),d1
addl $8,d1
jmp end_array_bit
a_found_bit1:
movzbl first_one_bit_table(,d0,1),d1
#else
bsf a3,d1
#endif
end_array_bit:
#ifdef NO_BIT_INSTRUCTIONS
andl bit_clear_table(,d1,4),a3
#else
btr d1,a3
#endif
leal (a2,d1,4),d1
movl (a0),d1
movl d1,(a4)
movl 4(a0),a1
movl a1,4(a4)
addl $8,a0
addl $8,a4
cmpl d1,a0
jne move_a_array
testl a1,a1
je st_move_array_lp
move_b_array:
movl (a0),a1
movl a1,(a4)
movl 4(a0),d1
addl $4,a0
movzwl -2(d1),d0
addl $4,a4
movzwl -2(a1),d0
test d0,d0
je move_strict_basic_array
movzwl -2+2(a1),a1
subl $256,d0
imull d0,a1
movl a1,d0
jmp cp_s_arg_lp3
test a1,a1
je move_b_record_array
subl a1,d0
je move_a_record_array
pushl a1
pushl d0
pushl d1
jmp st_move_array_lp_ab
move_strict_basic_array:
movl a1,d0
cmpl $INT+2,d1
je cp_s_arg_lp3
movl d1,d0
cmpl $INT+2,a1
je st_cp_s_arg_lp3
cmpl $BOOL+2,d1
cmpl $BOOL+2,a1
je move_bool_array
cmpl $REAL+2,d1
jne cp_s_arg_lp3
cmpl $REAL+2,a1
jne st_cp_s_arg_lp3
move_real_array:
addl d0,d0
jmp cp_s_arg_lp3
jmp st_cp_s_arg_lp3
move_bool_array:
addl $3,d0
shr $2,d0
jmp cp_s_arg_lp3
move_a_array:
movl d1,a1
subl a0,d1
shr $2,d1
pushl a3
subl $1,d1
jb end_array
movl (a0),a3
movl -4(a1),d0
movl a3,-4(a1)
movl d0,(a4)
movl (a1),d0
movl 4(a0),a3
addl $8,a0
movl a3,(a1)
movl d0,4(a4)
addl $8,a4
test d0,d0
je st_move_array_lp
jmp st_cp_s_arg_lp3
movzwl -2+2(d0),a3
movzwl -2(d0),d0
subl $256,d0
cmpl a3,d0
je st_move_array_lp
move_array_ab:
pushl a0
move_b_record_array:
imull d1,d0
jmp st_cp_s_arg_lp3
movl -8(a4),a1
movl a3,d1
imull d0,a1
shl $2,a1
subl d1,d0
addl a0,a1
call reorder
popl a0
subl $1,d1
subl $1,d0
pushl d1
pushl d0
pushl -8(a4)
jmp st_move_array_lp_ab
move_a_record_array:
imull a1,d1
jmp st_move_array_lp
move_array_ab_lp1:
movl 8(sp),d0
......@@ -1044,7 +942,7 @@ move_array_ab_a_elements:
jnc move_array_element_ab
#endif
movl d1,a1
movl (a1),d1
movl (d1),d1
inc a4
movl a4,(a1)
dec a4
......@@ -1052,7 +950,7 @@ move_array_element_ab:
movl d1,(a4)
addl $4,a4
subl $1,d0
jnc move_array_ab_a_elements
jne move_array_ab_a_elements
movl 4(sp),d0
move_array_ab_b_elements:
......@@ -1061,7 +959,7 @@ move_array_ab_b_elements:
movl d1,(a4)
addl $4,a4
subl $1,d0
jnc move_array_ab_b_elements
jne move_array_ab_b_elements
st_move_array_lp_ab:
subl $1,(sp)
......@@ -1080,12 +978,10 @@ move_array_lp1:
cmpl end_heap_p3,d0
jnc move_array_element
#endif
movl (d0),a3
movl d0,a1
movl a3,-4(a4)
leal -4+1(a4),d0
movl d0,(a1)
movl (d0),a1
movl a1,-4(a4)
leal -4+1(a4),a1
movl a1,(d0)
subl $1,d1
jnc move_array_lp1
......@@ -1098,8 +994,6 @@ st_move_array_lp:
jnc move_array_lp1
end_array:
popl a3
#ifdef NO_BIT_INSTRUCTIONS
test a3,a3
jne bsf_and_copy_nodes
......
......@@ -41,6 +41,12 @@ rmark_more_stack_nodes:
ret
rmark_stack_node:
#ifdef TEST_COMPACT_RMARKR
push $-1
push a3
mov $3,a3
jmp rmarkr_arguments_
#else
subl $8,sp
movl d0,(a3)
lea 1(a3),a2
......@@ -49,6 +55,7 @@ rmark_stack_node:
movl $0,(sp)
movl a2,(a0)
jmp rmark_no_reverse
#endif
rmark_node_d1:
movl neg_heap_p3,d0
......@@ -299,7 +306,6 @@ rmark_record_3_aab:
movl neg_heap_p3,d0
addl a1,d0
movl d0,a2
andl $31*4,d0
shrl $7,a2
......@@ -743,56 +749,91 @@ rmark_no_normal_hnf_0:
movzwl -2+2(d0),a1
test a1,a1
je rmark_b_array
je rmark_next_node
movzwl -2(d0),d0
test d0,d0
je rmark_b_array
je rmark_next_node
cmpl end_stack,sp
jb rmark_array_using_reversal
subl $256,d0
cmpl d0,a1
movl a1,d1
je rmark_a_record_array
rmark_ab_record_array:
movl 4(a0),a1
addl $8,a0
pushl a0
movl 4(a0),d1
imull d0,d1
imull d0,a1
shl $2,a1
shl $2,d0
subl d1,d0
addl $4,a0
addl a0,a1
call reorder
popl a0
movl d1,d0
imull -4(a0),d0
jmp rmark_lr_array
lea 12(a0),a3
lea 12(a0,d1,4),a0
pushl a0
pushl d0
subl a1,d0
addl a3,a1
pushl d0
pushl a1
jmp rmark_array_ab_nodes
rmark_array_ab_node_mark:
orl d0,a2
movl a2,(a4,d1,4)
movl (a0),d0
call rmark_array_node
rmark_next_array_ab_node:
addl $4,a3
cmpl (sp),a3
je rmark_array_ab_end_as
rmark_array_ab_next_record:
movl (a3),a0
rmark_b_array:
movl neg_heap_p3,d0
addl a0,d0
addl $4,d0
movl d0,a2
#ifdef SHARE_CHAR_INT
cmpl heap_size_32_33,d0
jnc rmark_next_array_ab_node
#endif
movl d0,d1
andl $31*4,d0
shrl $7,a2
shrl $7,d1
movl bit_set_table(d0),d0
orl d0,(a4,a2,4)
movl (a4,d1,4),a2
test d0,a2
je rmark_array_ab_node_mark
cmpl a3,a0
ja rmark_next_array_ab_node
movl (a0),d1
leal 1(a3),d0
movl d1,(a3)
movl d0,(a0)
jmp rmark_next_array_ab_node
rmark_array_ab_end_as:
movl a3,a0
addl 4(sp),a3
addl 8(sp),a0
movl a0,(sp)
rmark_array_ab_nodes:
cmpl 12(sp),a3
jne rmark_array_ab_next_record
addl $16,sp
jmp rmark_next_node
rmark_a_record_array:
movl 4(a0),d0
addl $8,a0
cmpl $2,d1
jb rmark_lr_array
imull d1,d0
imull a1,d0
jmp rmark_lr_array
rmark_lazy_array:
......@@ -800,55 +841,30 @@ rmark_lazy_array:
jb rmark_array_using_reversal
movl 4(a0),d0
addl $8,a0
rmark_lr_array:
movl neg_heap_p3,d1
addl a0,d1
shrl $2,d1
addl d0,d1
movl d1,a1
andl $31,d1
shrl $5,a1
movl bit_set_table(,d1,4),d1
orl d1,(a4,a1,4)
cmpl $1,d0
jbe rmark_array_length_0_1
movl a0,a1
lea (a0,d0,4),a0
testl d0,d0
je rmark_next_node
movl (a0),d0
movl (a1),d1
movl d0,(a1)
movl d1,(a0)
lea 12(a0),a3
lea 12(a0,d0,4),a0
movl -4(a0),d0
subl $4,a0
movl -4(a1),d1
subl $4,a1
movl d1,(a0)
movl d0,(a1)
pushl a0
movl a1,a3
jmp rmark_array_nodes
jmp rmark_st_array_nodes
rmark_array_nodes1:
cmpl a3,a0
ja rmark_next_array_node
rmark_array_node_mark:
orl d0,a2
movl a2,(a4,d1,4)
movl (a0),d1
leal 1(a3),d0
movl d1,(a3)
movl d0,(a0)
movl (a0),d0
call rmark_array_node
rmark_next_array_node:
addl $4,a3
rmark_st_array_nodes:
cmpl (sp),a3
je end_rmark_array_node
rmark_array_nodes:
movl (a3),a0
movl neg_heap_p3,d0
......@@ -863,21 +879,16 @@ rmark_array_nodes:
movl bit_set_table(d0),d0
movl (a4,d1,4),a2
test d0,a2
jne rmark_array_nodes1
orl d0,a2
movl a2,(a4,d1,4)
movl (a0),d0
call rmark_array_node
je rmark_array_node_mark
addl $4,a3
cmpl (sp),a3
jne rmark_array_nodes
cmpl a3,a0
ja rmark_next_array_node
end_rmark_array_node:
addl $4,sp
jmp rmark_next_node
movl (a0),d1
leal 1(a3),d0
movl d1,(a3)
movl d0,(a0)
jmp rmark_next_array_node
rmark_array_node:
subl $8,sp
......@@ -886,18 +897,9 @@ rmark_array_node:
movl $1,(sp)
jmp rmark_arguments
rmark_array_length_0_1:
lea -8(a0),a0
jb rmark_next_node
movl 12(a0),d1
movl 8(a0),a2
movl a2,12(a0)
movl 4(a0),a2
movl a2,8(a0)
movl d1,4(a0)
addl $4,a0
jmp rmark_hnf_1
end_rmark_array_node:
addl $4,sp
jmp rmark_next_node
.data
pointer_compare_address: .long 0
......
......@@ -2,7 +2,7 @@
rmark_using_reversal:
pushl a3
pushl a3
movl $1,a3
movl $3,a3
jmp rmarkr_node
rmark_using_reversal_:
......@@ -14,7 +14,7 @@ rmark_using_reversal_:
movl a0,(a3)
movl d0,(a0)
rmark_no_undo_reverse_1:
movl $1,a3
movl $3,a3
jmp rmarkr_arguments
rmark_array_using_reversal:
......@@ -25,7 +25,7 @@ rmark_array_using_reversal:
movl a0,(a3)
movl $__ARRAY__+2,(a0)
rmark_no_undo_reverse_2:
movl $1,a3
movl $3,a3
jmp rmarkr_arguments
rmarkr_hnf_2:
......@@ -55,6 +55,9 @@ rmarkr_node:
rmarkr_arguments:
movl (a0),d0
#ifdef TEST_COMPACT_RMARKR
rmarkr_arguments_:
#endif
testb $2,d0b
je rmarkr_lazy_node
......@@ -193,7 +196,6 @@ rmarkr_bit_in_same_word2:
movl neg_heap_p3,d0
addl a0,d0
addl $4,d0
movl d0,a2
andl $31*4,d0
......@@ -485,13 +487,14 @@ rmarkr_next_node:
movl $3,d1
andl a2,d1
movl (a3),d0
subl $4,a3
cmpl $3,d1
je rmarkr_argument_part_cycle1
movl 4(a3),a1
movl a1,(a3)
movl d0,(a3)
rmarkr_c_argument_part_cycle1:
cmpl a3,a0
......@@ -611,123 +614,112 @@ rmarkr_no_normal_hnf_0:
test d0,d0
je rmarkr_lazy_array
movzwl -2+2(d0),d1
movzwl -2(d0),d1
test d1,d1
je rmarkr_b_array
je rmarkr_next_node
movzwl -2(d0),d0
movzwl -2+2(d0),d0
test d0,d0
je rmarkr_b_array
je rmarkr_next_node
subl $256,d0
cmpl d0,d1
subl $256,d1
cmpl d1,d0
je rmarkr_a_record_array
rmarkr_ab_record_array:
movl 4(a0),a1
addl $8,a0
pushl a0
test a1,a1
je rmarkr_next_node
imull d0,a1
shl $2,a1
imull d1,a1
subl d1,a1
subl d1,d0
addl $4,a0
addl a0,a1
call reorder
popl a0
movl d1,d0
imull -4(a0),d0
jmp rmarkr_lr_array
movl 4(a0),a2
movl a3,d1
andl $-4,a3
movl a3,(a0)
and $3,d1
shl $2,a2
orl d1,a2
movl a2,4(a0)
rmarkr_b_array:
movl neg_heap_p3,d0
addl a0,d0
addl $4,d0
movl d0,a2
andl $31*4,d0
shrl $7,a2
movl bit_set_table(d0),d0
orl d0,(a4,a2,4)