@@ -72,21 +72,20 @@ typedef struct _jl_tls_states_t *jl_ptls_t;
7272#endif
7373#include "gc-interface.h"
7474#include "julia_atomics.h"
75- #include "julia_threads.h"
7675#include "julia_assert.h"
7776
77+ // the common fields are hidden before the pointer, but the following macro is
78+ // used to indicate which types below are subtypes of jl_value_t
79+ #define JL_DATA_TYPE
80+ typedef struct _jl_value_t jl_value_t ;
81+ #include "julia_threads.h"
82+
7883#ifdef __cplusplus
7984extern "C" {
8085#endif
8186
8287// core data types ------------------------------------------------------------
8388
84- // the common fields are hidden before the pointer, but the following macro is
85- // used to indicate which types below are subtypes of jl_value_t
86- #define JL_DATA_TYPE
87-
88- typedef struct _jl_value_t jl_value_t ;
89-
9089struct _jl_taggedvalue_bits {
9190 uintptr_t gc :2 ;
9291 uintptr_t in_image :1 ;
@@ -484,9 +483,6 @@ typedef struct _jl_abi_override_t {
484483 jl_method_instance_t * def ;
485484} jl_abi_override_t ;
486485
487- // all values are callable as Functions
488- typedef jl_value_t jl_function_t ;
489-
490486typedef struct {
491487 JL_DATA_TYPE
492488 jl_sym_t * name ;
@@ -2262,12 +2258,8 @@ JL_DLLEXPORT void jl_sigatomic_end(void);
22622258
22632259// tasks and exceptions -------------------------------------------------------
22642260
2265- typedef struct _jl_timing_block_t jl_timing_block_t ;
2266- typedef struct _jl_timing_event_t jl_timing_event_t ;
2267- typedef struct _jl_excstack_t jl_excstack_t ;
2268-
22692261// info describing an exception handler
2270- typedef struct _jl_handler_t {
2262+ struct _jl_handler_t {
22712263 jl_jmp_buf eh_ctx ;
22722264 jl_gcframe_t * gcstack ;
22732265 jl_value_t * scope ;
@@ -2277,68 +2269,7 @@ typedef struct _jl_handler_t {
22772269 sig_atomic_t defer_signal ;
22782270 jl_timing_block_t * timing_stack ;
22792271 size_t world_age ;
2280- } jl_handler_t ;
2281-
2282- #define JL_RNG_SIZE 5 // xoshiro 4 + splitmix 1
2283-
2284- typedef struct _jl_task_t {
2285- JL_DATA_TYPE
2286- jl_value_t * next ; // invasive linked list for scheduler
2287- jl_value_t * queue ; // invasive linked list for scheduler
2288- jl_value_t * tls ;
2289- jl_value_t * donenotify ;
2290- jl_value_t * result ;
2291- jl_value_t * scope ;
2292- jl_function_t * start ;
2293- _Atomic (uint8_t ) _state ;
2294- uint8_t sticky ; // record whether this Task can be migrated to a new thread
2295- uint16_t priority ;
2296- _Atomic (uint8_t ) _isexception ; // set if `result` is an exception to throw or that we exited with
2297- uint8_t pad0 [3 ];
2298- // === 64 bytes (cache line)
2299- uint64_t rngState [JL_RNG_SIZE ];
2300- // flag indicating whether or not to record timing metrics for this task
2301- uint8_t metrics_enabled ;
2302- uint8_t pad1 [3 ];
2303- // timestamp this task first entered the run queue
2304- _Atomic (uint64_t ) first_enqueued_at ;
2305- // timestamp this task was most recently scheduled to run
2306- _Atomic (uint64_t ) last_started_running_at ;
2307- // time this task has spent running; updated when it yields or finishes.
2308- _Atomic (uint64_t ) running_time_ns ;
2309- // === 64 bytes (cache line)
2310- // timestamp this task finished (i.e. entered state DONE or FAILED).
2311- _Atomic (uint64_t ) finished_at ;
2312-
2313- // hidden state:
2314-
2315- // id of owning thread - does not need to be defined until the task runs
2316- _Atomic (int16_t ) tid ;
2317- // threadpool id
2318- int8_t threadpoolid ;
2319- // Reentrancy bits
2320- // Bit 0: 1 if we are currently running inference/codegen
2321- // Bit 1-2: 0-3 counter of how many times we've reentered inference
2322- // Bit 3: 1 if we are writing the image and inference is illegal
2323- uint8_t reentrant_timing ;
2324- // 2 bytes of padding on 32-bit, 6 bytes on 64-bit
2325- // uint16_t padding2_32;
2326- // uint48_t padding2_64;
2327- // saved gc stack top for context switches
2328- jl_gcframe_t * gcstack ;
2329- size_t world_age ;
2330- // quick lookup for current ptls
2331- jl_ptls_t ptls ; // == jl_all_tls_states[tid]
2332- #ifdef USE_TRACY
2333- const char * name ;
2334- #endif
2335- // saved exception stack
2336- jl_excstack_t * excstack ;
2337- // current exception handler
2338- jl_handler_t * eh ;
2339- // saved thread state
2340- jl_ucontext_t ctx ; // pointer into stkbuf, if suspended
2341- } jl_task_t ;
2272+ };
23422273
23432274#define JL_TASK_STATE_RUNNABLE 0
23442275#define JL_TASK_STATE_DONE 1
0 commit comments