@@ -101,7 +101,7 @@ struct caml_thread_struct {
101101 int backtrace_pos ; /* Saved Caml_state->backtrace_pos */
102102 backtrace_slot * backtrace_buffer ; /* Saved Caml_state->backtrace_buffer */
103103 value backtrace_last_exn ; /* Saved Caml_state->backtrace_last_exn (root) */
104- struct caml_memprof_th_ctx memprof_ctx ;
104+ struct caml_memprof_th_ctx * memprof_ctx ;
105105};
106106
107107typedef struct caml_thread_struct * caml_thread_t ;
@@ -178,7 +178,7 @@ static void memprof_ctx_iter(th_ctx_action f, void* data)
178178
179179 /* The current thread's entry array is handled directly in memprof.c */
180180 for (th = curr_thread -> next ; th != curr_thread ; th = th -> next )
181- f (& th -> memprof_ctx , data );
181+ f (th -> memprof_ctx , data );
182182}
183183
184184/* Saving and restoring runtime state in curr_thread */
@@ -209,7 +209,7 @@ Caml_inline void caml_thread_save_runtime_state(void)
209209 curr_thread -> backtrace_pos = Caml_state -> backtrace_pos ;
210210 curr_thread -> backtrace_buffer = Caml_state -> backtrace_buffer ;
211211 curr_thread -> backtrace_last_exn = Caml_state -> backtrace_last_exn ;
212- caml_memprof_save_th_ctx (& curr_thread -> memprof_ctx );
212+ caml_memprof_save_th_ctx (curr_thread -> memprof_ctx );
213213}
214214
215215Caml_inline void caml_thread_restore_runtime_state (void )
@@ -238,7 +238,7 @@ Caml_inline void caml_thread_restore_runtime_state(void)
238238 Caml_state -> backtrace_pos = curr_thread -> backtrace_pos ;
239239 Caml_state -> backtrace_buffer = curr_thread -> backtrace_buffer ;
240240 Caml_state -> backtrace_last_exn = curr_thread -> backtrace_last_exn ;
241- caml_memprof_restore_th_ctx (& curr_thread -> memprof_ctx );
241+ caml_memprof_restore_th_ctx (curr_thread -> memprof_ctx );
242242}
243243
244244/* Hooks for caml_enter_blocking_section and caml_leave_blocking_section */
@@ -391,7 +391,7 @@ static caml_thread_t caml_thread_new_info(void)
391391 th -> backtrace_pos = 0 ;
392392 th -> backtrace_buffer = NULL ;
393393 th -> backtrace_last_exn = Val_unit ;
394- caml_memprof_init_th_ctx ( & th -> memprof_ctx );
394+ th -> memprof_ctx = caml_memprof_new_th_ctx ( );
395395 return th ;
396396}
397397
@@ -447,7 +447,7 @@ static void caml_thread_reinitialize(void)
447447 /* Remove all other threads (now nonexistent)
448448 from the doubly-linked list of threads */
449449 while (curr_thread -> next != curr_thread ) {
450- caml_memprof_stop_th_ctx ( & curr_thread -> next -> memprof_ctx );
450+ caml_memprof_delete_th_ctx ( curr_thread -> next -> memprof_ctx );
451451 caml_thread_remove_info (curr_thread -> next );
452452 }
453453
@@ -493,6 +493,7 @@ CAMLprim value caml_thread_initialize(value unit) /* ML */
493493#ifdef NATIVE_CODE
494494 curr_thread -> exit_buf = & caml_termination_jmpbuf ;
495495#endif
496+ curr_thread -> memprof_ctx = & caml_memprof_main_ctx ;
496497 /* The stack-related fields will be filled in at the next
497498 caml_enter_blocking_section */
498499 /* Associate the thread descriptor with the thread */
@@ -544,7 +545,7 @@ static void caml_thread_stop(void)
544545 below uses accurate information. */
545546 caml_thread_save_runtime_state ();
546547 /* Tell memprof that this thread is terminating. */
547- caml_memprof_stop_th_ctx ( & curr_thread -> memprof_ctx );
548+ caml_memprof_delete_th_ctx ( curr_thread -> memprof_ctx );
548549 /* Signal that the thread has terminated */
549550 caml_threadstatus_terminate (Terminated (curr_thread -> descr ));
550551 /* Remove th from the doubly-linked list of threads and free its info block */
0 commit comments