mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-26 21:20:30 +02:00
Use Whippet API to boot threads
* libguile/scm.h (scm_tc7_thread): Give threads their own tc7. * libguile/threads.h (struct scm_thread): Add a tag, so that struct thread can be a SCM directly. Add a struct gc_mutator* member. (scm_thread_handle): New inline function. (SCM_I_IS_THREAD, SCM_I_THREAD_DATA, SCM_VALIDATE_THREAD): Update to use tc7 instead of SMOB tags. * libguile/continuations.c (scm_i_with_continuation_barrier) * libguile/finalizers.c (queue_finalizer_async) * libguile/jit.c (compile_current_thread) * libguile/threads.c (block_self, guilify_self_2) (lock_mutex, unlock_mutex, timed_wait scm_current_thread) (scm_all_threads) * libguile/vm-engine.c (current-thread): Use scm_thread_handle instead of thread->handle. * libguile/evalext.c (scm_self_evaluating_p): * libguile/goops.c (class_thread, scm_class_of, scm_sys_goops_early_init) * libguile/print.c (iprin1) * module/language/cps/compile-bytecode.scm (compile-function) * module/oop/goops.scm (<thread>) * module/system/base/types.scm (cell->object) * module/system/base/types/internal.scm (heap-tags) * module/system/vm/assembler.scm: (emit-thread?): Adapt to scm_tc7_thread. * libguile/gc-internal.h: Move init functions that take "struct gc_stack_addr" here, so that internal Whippet uses don't cause Whippet to be added to public headers. * libguile/gc.c (scm_storage_prehistory): Take struct gc_stack_addr as arg, and pass to gc_init. Return a mutator pointer. * libguile/init.c (scm_i_init_guile): Pass mutator and stack base to GC and thread init routines. * libguile/threads.c (scm_trace_dynstack, scm_trace_thread) (scm_trace_thread_mutator_roots): New infra for marking threads in terms of Whippet API. * libguile/threads.c (guilify_self_1): Since we don't use a separate GC kind for threads any more, and thread marking is keyed off gc_mutator_set_roots, we can avoid some of the gnarly synchronization. (on_thread_exit): Arrange to gc_finish_for_thread. (scm_i_init_thread_for_guile): Use gc_init_for_thread. (init_main_thread, with_guile, scm_i_with_guile): Use Whippet API. (scm_threads_prehistory): Take main-thread mutator and the stack base as arguments. * libguile/vm.c (scm_trace_vm): Rework in terms of Whippet API. * libguile/whippet-embedder.h (gc_trace_mutator_roots): Arrange to trace the current mutator's SCM thread object. * libguile/trace.h: New file, to declare implementations of trace routines. * libguile/Makefile.am (noinst_HEADERS): Add trace.h.
This commit is contained in:
parent
55e9d0672b
commit
27f0490801
25 changed files with 299 additions and 217 deletions
|
@ -1,6 +1,6 @@
|
|||
;;; Continuation-passing style (CPS) intermediate language (IL)
|
||||
|
||||
;; Copyright (C) 2013-2021, 2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2013-2021, 2023, 2025 Free Software Foundation, Inc.
|
||||
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -504,6 +504,7 @@
|
|||
(#('program? #f (a)) (unary emit-program? a))
|
||||
(#('vm-continuation? #f (a)) (unary emit-vm-continuation? a))
|
||||
(#('bytevector? #f (a)) (unary emit-bytevector? a))
|
||||
(#('thread? #f (a)) (unary emit-thread? a))
|
||||
(#('weak-set? #f (a)) (unary emit-weak-set? a))
|
||||
(#('weak-table? #f (a)) (unary emit-weak-table? a))
|
||||
(#('array? #f (a)) (unary emit-array? a))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;;; goops.scm -- The Guile Object-Oriented Programming System
|
||||
;;;;
|
||||
;;;; Copyright (C) 1998-2003,2006,2009-2011,2013-2015,2017-2018,2021
|
||||
;;;; Copyright (C) 1998-2003,2006,2009-2011,2013-2015,2017-2018,2021,2025
|
||||
;;;; Free Software Foundation, Inc.
|
||||
;;;; Copyright (C) 1993-1998 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
|
||||
;;;;
|
||||
|
@ -69,7 +69,7 @@
|
|||
<boolean> <char> <list> <pair> <null> <string> <symbol>
|
||||
<vector> <bytevector> <uvec> <foreign> <hashtable>
|
||||
<fluid> <dynamic-state> <frame> <vm> <vm-continuation>
|
||||
<keyword> <syntax> <atomic-box>
|
||||
<keyword> <syntax> <atomic-box> <thread>
|
||||
|
||||
;; Numbers.
|
||||
<number> <complex> <real> <integer> <fraction>
|
||||
|
@ -81,7 +81,7 @@
|
|||
;; corresponding classes, which may be obtained via class-of,
|
||||
;; once you have an instance. Perhaps FIXME to provide a
|
||||
;; smob-type-name->class procedure.
|
||||
<promise> <thread> <mutex> <condition-variable>
|
||||
<promise> <mutex> <condition-variable>
|
||||
<regexp> <hook> <bitvector> <random-state>
|
||||
<directory> <array> <character-set>
|
||||
<dynamic-object> <guardian> <macro>
|
||||
|
@ -1078,6 +1078,7 @@ slots as we go."
|
|||
(define-standard-class <uvec> (<bytevector>))
|
||||
(define-standard-class <array> (<top>))
|
||||
(define-standard-class <bitvector> (<top>))
|
||||
(define-standard-class <thread> (<top>))
|
||||
(define-standard-class <number> (<top>))
|
||||
(define-standard-class <complex> (<number>))
|
||||
(define-standard-class <real> (<complex>))
|
||||
|
@ -3525,7 +3526,6 @@ var{initargs}."
|
|||
;;;
|
||||
|
||||
(define <promise> (find-subclass <top> '<promise>))
|
||||
(define <thread> (find-subclass <top> '<thread>))
|
||||
(define <mutex> (find-subclass <top> '<mutex>))
|
||||
(define <condition-variable> (find-subclass <top> '<condition-variable>))
|
||||
(define <regexp> (find-subclass <top> '<regexp>))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
;;; 'SCM' type tag decoding.
|
||||
;;; Copyright (C) 2014, 2015, 2017, 2018, 2022 Free Software Foundation, Inc.
|
||||
;;; Copyright (C) 2014, 2015, 2017, 2018, 2022, 2025 Free Software Foundation, Inc.
|
||||
;;;
|
||||
;;; This library is free software; you can redistribute it and/or modify it
|
||||
;;; under the terms of the GNU Lesser General Public License as published by
|
||||
|
@ -417,6 +417,8 @@ using BACKEND."
|
|||
(((_ & #x7f = %tc7-bytevector) len address)
|
||||
(let ((bv-port (memory-port backend address len)))
|
||||
(get-bytevector-n bv-port len)))
|
||||
(((_ & #x7f = %tc7-thread))
|
||||
(inferior-object 'thread address))
|
||||
((((len << 8) || %tc7-vector))
|
||||
(let ((words (get-bytevector-n port (* len %word-size)))
|
||||
(vector (make-vector len)))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
;;; Details on internal value representation.
|
||||
;;; Copyright (C) 2014, 2015, 2017, 2018, 2020, 2021 Free Software Foundation, Inc.
|
||||
;;; Copyright (C) 2014, 2015, 2017, 2018, 2020, 2021, 2025 Free Software Foundation, Inc.
|
||||
;;;
|
||||
;;; This library is free software; you can redistribute it and/or modify it
|
||||
;;; under the terms of the GNU Lesser General Public License as published by
|
||||
|
@ -51,6 +51,7 @@
|
|||
%tc7-program
|
||||
%tc7-vm-continuation
|
||||
%tc7-bytevector
|
||||
%tc7-thread
|
||||
%tc7-weak-set
|
||||
%tc7-weak-table
|
||||
%tc7-array
|
||||
|
@ -147,7 +148,7 @@
|
|||
(program program? #b1111111 #b1000101)
|
||||
(vm-continuation vm-continuation? #b1111111 #b1000111)
|
||||
(bytevector bytevector? #b1111111 #b1001101)
|
||||
;;(unused unused #b1111111 #b1001111)
|
||||
(thread thread? #b1111111 #b1001111)
|
||||
(weak-set weak-set? #b1111111 #b1010101)
|
||||
(weak-table weak-table? #b1111111 #b1010111)
|
||||
(array array? #b1111111 #b1011101)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; Guile bytecode assembler
|
||||
|
||||
;;; Copyright (C) 2001, 2009-2023 Free Software Foundation, Inc.
|
||||
;;; Copyright (C) 2001, 2009-2023, 2025, 2025 Free Software Foundation, Inc.
|
||||
;;;
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -132,6 +132,7 @@
|
|||
emit-program?
|
||||
emit-vm-continuation?
|
||||
emit-bytevector?
|
||||
emit-thread?
|
||||
emit-weak-set?
|
||||
emit-weak-table?
|
||||
emit-array?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue