Commit 6aba0723 authored by John van Groningen's avatar John van Groningen

make copying of (pointers to) nodes outside the heap thread safe

parent 63329256
......@@ -5,14 +5,14 @@ copy_graph_to_string.obj: copy_graph_to_string.c
cl /nologo /c /O2 /Gy copy_graph_to_string.c
copy copy_graph_to_string.obj "Clean System Files"\copy_graph_to_string.obj
copy_graph_to_string_interface.obj: copy_graph_to_string_interface.s
ml64 /nologo /c copy_graph_to_string_interface.asm
copy_graph_to_string_interface.obj: copy_graph_to_string_interface.asm
ml64 /nologo /c /DTHREAD=0 copy_graph_to_string_interface.asm
copy copy_graph_to_string_interface.obj "Clean System Files"\copy_graph_to_string_interface.obj
copy_string_to_graph.obj: copy_string_to_graph.c
cl /nologo /c /O2 /Gy copy_string_to_graph.c
copy copy_string_to_graph.obj "Clean System Files"\copy_string_to_graph.obj
copy_string_to_graph_interface.obj: copy_string_to_graph_interface.s
copy_string_to_graph_interface.obj: copy_string_to_graph_interface.asm
ml64 /nologo /c copy_string_to_graph_interface.asm
copy copy_string_to_graph_interface.obj "Clean System Files"\copy_string_to_graph_interface.obj
all: copy_graph_to_string_thread.obj copy_graph_to_string_interface_thread.obj copy_string_to_graph_thread.obj copy_string_to_graph_interface.obj
copy_graph_to_string_thread.obj: copy_graph_to_string.c
cl /nologo /c /O2 /Gy /DTHREAD /Focopy_graph_to_string_thread.obj copy_graph_to_string.c
copy copy_graph_to_string_thread.obj "Clean System Files"\copy_graph_to_string.obj
copy_graph_to_string_interface_thread.obj: copy_graph_to_string_interface.asm copy_graph_to_string_interface.asm
ml64 /nologo /c /DTHREAD=1 /Focopy_graph_to_string_interface_thread.obj copy_graph_to_string_interface.asm
copy copy_graph_to_string_interface_thread.obj "Clean System Files"\copy_graph_to_string_interface.obj
copy_string_to_graph_thread.obj: copy_string_to_graph.c
cl /nologo /c /O2 /Gy /DTHREAD /Focopy_string_to_graph_thread.obj copy_string_to_graph.c
copy copy_string_to_graph_thread.obj "Clean System Files"\copy_string_to_graph.obj
copy_string_to_graph_interface.obj: copy_string_to_graph_interface.asm
ml64 /nologo /c copy_string_to_graph_interface.asm
copy copy_string_to_graph_interface.obj "Clean System Files"\copy_string_to_graph_interface.obj
......@@ -22,7 +22,11 @@ static void copy (Int *dest_p,Int *source_p,Int n_words)
dest_p[i]=source_p[i];
}
Int *copy_graph_to_string (Int *node_p,void *begin_free_heap,void *end_free_heap)
Int *copy_graph_to_string (Int *node_p,void *begin_free_heap,void *end_free_heap
#ifdef THREAD
,void *begin_heap,unsigned Int heap_size
#endif
)
{
Int **stack_p,**stack_begin,**stack_end,*heap_p;
......@@ -43,8 +47,18 @@ Int *copy_graph_to_string (Int *node_p,void *begin_free_heap,void *end_free_heap
for (;;){
Int desc;
#ifdef THREAD
if (((unsigned Int)node_p-(unsigned Int)begin_heap)>=heap_size){
if (heap_p>=(Int*)stack_begin)
return NULL;
heap_p[0]=3+(Int)node_p;
++heap_p;
break;
}
#endif
desc=*node_p;
if (heap_p>=(Int*)stack_begin)
return NULL;
......
......@@ -8,6 +8,11 @@ extrn copy_graph_to_string:near
extrn remove_forwarding_pointers_from_graph:near
extrn collect_1:near
if THREAD
heap_p_offset = 192
heap_size_offset = 280
endif
_TEXT segment
public __copy__graph__to__string
......@@ -15,28 +20,42 @@ public __copy__graph__to__string
__copy__graph__to__string:
push rcx
if THREAD
mov rax,qword ptr heap_p_offset[r9]
mov rbx,qword ptr heap_size_offset[r9]
endif
mov rdx,rdi
lea r8,[rdi+r15*8]
mov rbp,rsp
or rsp,8
if THREAD
mov r12,r9
sub rsp,48
mov qword ptr 32[rsp],rbx
mov r9,rax
else
sub rsp,40
endif
call copy_graph_to_string
mov rsp,rbp
if THREAD
mov r9,r12
endif
mov rcx,qword ptr [rsp]
push rax
lea rdx,[rdi+r15*8]
mov rbp,rsp
or rsp,8
if THREAD
mov r12,r9
endif
sub rsp,40
call remove_forwarding_pointers_from_graph
mov rsp,rbp
if THREAD
mov r9,r12
endif
pop rcx
test rcx,rcx
......
......@@ -634,6 +634,15 @@ Int *copy_string_to_graph (Int *string_p,void *begin_free_heap,void *end_free_he
}
} else {
Int *node_p;
#ifdef THREAD
if (desc & 2){
node_p=(Int*)(desc-3);
*arg_a=node_p;
++string_p;
break;
}
#endif
node_p=*(Int**)((Int)string_p+(desc-1));
*arg_a=node_p;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment