LCOV - code coverage report
Current view: top level - src - julia.h (source / functions) Hit Total Coverage
Test: [test only] commit 0f242327d2cc9bd130497f44b6350c924185606a Lines: 173 179 96.6 %
Date: 2022-07-16 23:42:53 Functions: 48 49 98.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 156 190 82.1 %

           Branch data     Line data    Source code
       1                 :            : // This file is a part of Julia. License is MIT: https://julialang.org/license
       2                 :            : 
       3                 :            : #ifndef JULIA_H
       4                 :            : #define JULIA_H
       5                 :            : 
       6                 :            : #ifdef LIBRARY_EXPORTS
       7                 :            : #include "jl_internal_funcs.inc"
       8                 :            : #undef jl_setjmp
       9                 :            : #undef jl_longjmp
      10                 :            : #undef jl_egal
      11                 :            : #endif
      12                 :            : 
      13                 :            : #include "julia_fasttls.h"
      14                 :            : #include "libsupport.h"
      15                 :            : #include <stdint.h>
      16                 :            : #include <string.h>
      17                 :            : 
      18                 :            : #include "htable.h"
      19                 :            : #include "arraylist.h"
      20                 :            : #include "analyzer_annotations.h"
      21                 :            : 
      22                 :            : #include <setjmp.h>
      23                 :            : #ifndef _OS_WINDOWS_
      24                 :            : #  define jl_jmp_buf sigjmp_buf
      25                 :            : #  if defined(_CPU_ARM_) || defined(_CPU_PPC_) || defined(_CPU_WASM_)
      26                 :            : #    define MAX_ALIGN 8
      27                 :            : #  elif defined(_CPU_AARCH64_)
      28                 :            : // int128 is 16 bytes aligned on aarch64
      29                 :            : #    define MAX_ALIGN 16
      30                 :            : #  elif defined(_P64)
      31                 :            : // Generically we assume MAX_ALIGN is sizeof(void*)
      32                 :            : #    define MAX_ALIGN 8
      33                 :            : #  else
      34                 :            : #    define MAX_ALIGN 4
      35                 :            : #  endif
      36                 :            : #else
      37                 :            : #  include "win32_ucontext.h"
      38                 :            : #  define jl_jmp_buf jmp_buf
      39                 :            : #  define MAX_ALIGN 8
      40                 :            : #endif
      41                 :            : 
      42                 :            : // Define the largest size (bytes) of a properly aligned object that the
      43                 :            : // processor family and compiler typically supports without a lock
      44                 :            : // (assumed to be at least a pointer size). Since C is bad at handling 16-byte
      45                 :            : // types, we currently use 8 here as the default.
      46                 :            : #define MAX_ATOMIC_SIZE 8
      47                 :            : #define MAX_POINTERATOMIC_SIZE 8
      48                 :            : 
      49                 :            : #ifdef _P64
      50                 :            : #define NWORDS(sz) (((sz)+7)>>3)
      51                 :            : #else
      52                 :            : #define NWORDS(sz) (((sz)+3)>>2)
      53                 :            : #endif
      54                 :            : 
      55                 :            : #if defined(__GNUC__)
      56                 :            : #  define JL_NORETURN __attribute__ ((noreturn))
      57                 :            : #  define JL_CONST_FUNC __attribute__((const))
      58                 :            : #  define JL_USED_FUNC __attribute__((used))
      59                 :            : #else
      60                 :            : #  define JL_NORETURN
      61                 :            : #  define JL_CONST_FUNC
      62                 :            : #  define JL_USED_FUNC
      63                 :            : #endif
      64                 :            : 
      65                 :            : #define container_of(ptr, type, member) \
      66                 :            :     ((type *) ((char *)(ptr) - offsetof(type, member)))
      67                 :            : 
      68                 :            : typedef struct _jl_taggedvalue_t jl_taggedvalue_t;
      69                 :            : typedef struct _jl_tls_states_t *jl_ptls_t;
      70                 :            : 
      71                 :            : #ifdef LIBRARY_EXPORTS
      72                 :            : #include "uv.h"
      73                 :            : #endif
      74                 :            : #include "julia_atomics.h"
      75                 :            : #include "julia_threads.h"
      76                 :            : #include "julia_assert.h"
      77                 :            : 
      78                 :            : #ifdef __cplusplus
      79                 :            : extern "C" {
      80                 :            : #endif
      81                 :            : 
      82                 :            : // core data types ------------------------------------------------------------
      83                 :            : 
      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                 :            : 
      90                 :            : struct _jl_taggedvalue_bits {
      91                 :            :     uintptr_t gc:2;
      92                 :            : };
      93                 :            : 
      94                 :            : JL_EXTENSION struct _jl_taggedvalue_t {
      95                 :            :     union {
      96                 :            :         uintptr_t header;
      97                 :            :         jl_taggedvalue_t *next;
      98                 :            :         jl_value_t *type; // 16-byte aligned
      99                 :            :         struct _jl_taggedvalue_bits bits;
     100                 :            :     };
     101                 :            :     // jl_value_t value;
     102                 :            : };
     103                 :            : 
     104                 :            : #ifdef __clang_gcanalyzer__
     105                 :            : JL_DLLEXPORT jl_taggedvalue_t *_jl_astaggedvalue(jl_value_t *v JL_PROPAGATES_ROOT) JL_NOTSAFEPOINT;
     106                 :            : #define jl_astaggedvalue(v) _jl_astaggedvalue((jl_value_t*)(v))
     107                 :            : jl_value_t *_jl_valueof(jl_taggedvalue_t *tv JL_PROPAGATES_ROOT) JL_NOTSAFEPOINT;
     108                 :            : #define jl_valueof(v) _jl_valueof((jl_taggedvalue_t*)(v))
     109                 :            : JL_DLLEXPORT jl_value_t *_jl_typeof(jl_value_t *v JL_PROPAGATES_ROOT) JL_NOTSAFEPOINT;
     110                 :            : #define jl_typeof(v) _jl_typeof((jl_value_t*)(v))
     111                 :            : #else
     112                 :            : #define jl_astaggedvalue(v)                                             \
     113                 :            :     ((jl_taggedvalue_t*)((char*)(v) - sizeof(jl_taggedvalue_t)))
     114                 :            : #define jl_valueof(v)                                           \
     115                 :            :     ((jl_value_t*)((char*)(v) + sizeof(jl_taggedvalue_t)))
     116                 :            : #define jl_typeof(v)                                                    \
     117                 :            :     ((jl_value_t*)(jl_astaggedvalue(v)->header & ~(uintptr_t)15))
     118                 :            : #endif
     119                 : 9281142806 : static inline void jl_set_typeof(void *v, void *t) JL_NOTSAFEPOINT
     120                 :            : {
     121                 :            :     // Do not call this on a value that is already initialized.
     122                 : 9281142806 :     jl_taggedvalue_t *tag = jl_astaggedvalue(v);
     123                 : 9281142806 :     jl_atomic_store_relaxed((_Atomic(jl_value_t*)*)&tag->type, (jl_value_t*)t);
     124                 : 9281142806 : }
     125                 :            : #define jl_typeis(v,t) (jl_typeof(v)==(jl_value_t*)(t))
     126                 :            : 
     127                 :            : // Symbols are interned strings (hash-consed) stored as an invasive binary tree.
     128                 :            : // The string data is nul-terminated and hangs off the end of the struct.
     129                 :            : typedef struct _jl_sym_t {
     130                 :            :     JL_DATA_TYPE
     131                 :            :     _Atomic(struct _jl_sym_t*) left;
     132                 :            :     _Atomic(struct _jl_sym_t*) right;
     133                 :            :     uintptr_t hash;    // precomputed hash value
     134                 :            :     // JL_ATTRIBUTE_ALIGN_PTRSIZE(char name[]);
     135                 :            : } jl_sym_t;
     136                 :            : 
     137                 :            : // A numbered SSA value, for optimized code analysis and generation
     138                 :            : // the `id` is a unique, small number
     139                 :            : typedef struct _jl_ssavalue_t {
     140                 :            :     JL_DATA_TYPE
     141                 :            :     ssize_t id;
     142                 :            : } jl_ssavalue_t;
     143                 :            : 
     144                 :            : // A SimpleVector is an immutable pointer array
     145                 :            : // Data is stored at the end of this variable-length struct.
     146                 :            : typedef struct {
     147                 :            :     JL_DATA_TYPE
     148                 :            :     size_t length;
     149                 :            :     // pointer size aligned
     150                 :            :     // jl_value_t *data[];
     151                 :            : } jl_svec_t;
     152                 :            : 
     153                 :            : typedef struct {
     154                 :            :     /*
     155                 :            :       how - allocation style
     156                 :            :       0 = data is inlined, or a foreign pointer we don't manage
     157                 :            :       1 = julia-allocated buffer that needs to be marked
     158                 :            :       2 = malloc-allocated pointer this array object manages
     159                 :            :       3 = has a pointer to the object that owns the data
     160                 :            :     */
     161                 :            :     uint16_t how:2;
     162                 :            :     uint16_t ndims:9;
     163                 :            :     uint16_t pooled:1;
     164                 :            :     uint16_t ptrarray:1; // representation is pointer array
     165                 :            :     uint16_t hasptr:1; // representation has embedded pointers
     166                 :            :     uint16_t isshared:1; // data is shared by multiple Arrays
     167                 :            :     uint16_t isaligned:1; // data allocated with memalign
     168                 :            : } jl_array_flags_t;
     169                 :            : 
     170                 :            : JL_EXTENSION typedef struct {
     171                 :            :     JL_DATA_TYPE
     172                 :            :     void *data;
     173                 :            :     size_t length;
     174                 :            :     jl_array_flags_t flags;
     175                 :            :     uint16_t elsize;  // element size including alignment (dim 1 memory stride)
     176                 :            :     uint32_t offset;  // for 1-d only. does not need to get big.
     177                 :            :     size_t nrows;
     178                 :            :     union {
     179                 :            :         // 1d
     180                 :            :         size_t maxsize;
     181                 :            :         // Nd
     182                 :            :         size_t ncols;
     183                 :            :     };
     184                 :            :     // other dim sizes go here for ndims > 2
     185                 :            : 
     186                 :            :     // followed by alignment padding and inline data, or owner pointer
     187                 :            : } jl_array_t;
     188                 :            : 
     189                 :            : // compute # of extra words needed to store dimensions
     190                 : 3795044112 : STATIC_INLINE int jl_array_ndimwords(uint32_t ndims) JL_NOTSAFEPOINT
     191                 :            : {
     192                 : 3795044112 :     return (ndims < 3 ? 0 : ndims-2);
     193                 :            : }
     194                 :            : 
     195                 :            : typedef struct _jl_datatype_t jl_tupletype_t;
     196                 :            : struct _jl_code_instance_t;
     197                 :            : 
     198                 :            : // TypeMap is an implicitly defined type
     199                 :            : // that can consist of any of the following nodes:
     200                 :            : //   typedef TypeMap Union{TypeMapLevel, TypeMapEntry, Nothing}
     201                 :            : // it forms a roughly tree-shaped structure, consisting of nodes of TypeMapLevels
     202                 :            : // which split the tree when possible, for example based on the key into the tuple type at `offs`
     203                 :            : // when key is a leaftype, (but only when the tree has enough entries for this to be
     204                 :            : // more efficient than storing them sorted linearly)
     205                 :            : // otherwise the leaf entries are stored sorted, linearly
     206                 :            : typedef jl_value_t jl_typemap_t;
     207                 :            : 
     208                 :            : typedef jl_value_t *(jl_call_t)(jl_value_t*, jl_value_t**, uint32_t, struct _jl_code_instance_t*);
     209                 :            : typedef jl_call_t *jl_callptr_t;
     210                 :            : 
     211                 :            : // "speccall" calling convention signatures.
     212                 :            : // This describes some of the special ABI used by compiled julia functions.
     213                 :            : extern jl_call_t jl_fptr_args;
     214                 :            : JL_DLLEXPORT extern jl_callptr_t jl_fptr_args_addr;
     215                 :            : typedef jl_value_t *(*jl_fptr_args_t)(jl_value_t*, jl_value_t**, uint32_t);
     216                 :            : 
     217                 :            : extern jl_call_t jl_fptr_const_return;
     218                 :            : JL_DLLEXPORT extern jl_callptr_t jl_fptr_const_return_addr;
     219                 :            : 
     220                 :            : extern jl_call_t jl_fptr_sparam;
     221                 :            : JL_DLLEXPORT extern jl_callptr_t jl_fptr_sparam_addr;
     222                 :            : typedef jl_value_t *(*jl_fptr_sparam_t)(jl_value_t*, jl_value_t**, uint32_t, jl_svec_t*);
     223                 :            : 
     224                 :            : extern jl_call_t jl_fptr_interpret_call;
     225                 :            : JL_DLLEXPORT extern jl_callptr_t jl_fptr_interpret_call_addr;
     226                 :            : 
     227                 :            : typedef struct _jl_method_instance_t jl_method_instance_t;
     228                 :            : 
     229                 :            : typedef struct _jl_line_info_node_t {
     230                 :            :     struct _jl_module_t *module;
     231                 :            :     jl_value_t *method;
     232                 :            :     jl_sym_t *file;
     233                 :            :     intptr_t line;
     234                 :            :     intptr_t inlined_at;
     235                 :            : } jl_line_info_node_t;
     236                 :            : 
     237                 :            : // the following mirrors `struct EffectsOverride` in `base/compiler/types.jl`
     238                 :            : typedef union __jl_purity_overrides_t {
     239                 :            :     struct {
     240                 :            :         uint8_t ipo_consistent  : 1;
     241                 :            :         uint8_t ipo_effect_free : 1;
     242                 :            :         uint8_t ipo_nothrow     : 1;
     243                 :            :         uint8_t ipo_terminates  : 1;
     244                 :            :         // Weaker form of `terminates` that asserts
     245                 :            :         // that any control flow syntactically in the method
     246                 :            :         // is guaranteed to terminate, but does not make
     247                 :            :         // assertions about any called functions.
     248                 :            :         uint8_t ipo_terminates_locally : 1;
     249                 :            :         uint8_t ipo_notaskstate : 1;
     250                 :            :     } overrides;
     251                 :            :     uint8_t bits;
     252                 :            : } _jl_purity_overrides_t;
     253                 :            : 
     254                 :            : // This type describes a single function body
     255                 :            : typedef struct _jl_code_info_t {
     256                 :            :     // ssavalue-indexed arrays of properties:
     257                 :            :     jl_array_t *code;  // Any array of statements
     258                 :            :     jl_value_t *codelocs; // Int32 array of indices into the line table
     259                 :            :     jl_value_t *ssavaluetypes; // types of ssa values (or count of them)
     260                 :            :     jl_array_t *ssaflags; // flags associated with each statement:
     261                 :            :         // 0 = inbounds
     262                 :            :         // 1 = inline
     263                 :            :         // 2 = noinline
     264                 :            :         // 3 = <reserved> strict-ieee (strictfp)
     265                 :            :         // 4 = effect-free (may be deleted if unused)
     266                 :            :         // 5-6 = <unused>
     267                 :            :         // 7 = has out-of-band info
     268                 :            :     // miscellaneous data:
     269                 :            :     jl_value_t *method_for_inference_limit_heuristics; // optional method used during inference
     270                 :            :     jl_value_t *linetable; // Table of locations [TODO: make this volatile like slotnames]
     271                 :            :     jl_array_t *slotnames; // names of local variables
     272                 :            :     jl_array_t *slotflags;  // local var bit flags
     273                 :            :     // the following are optional transient properties (not preserved by compression--as they typically get stored elsewhere):
     274                 :            :     jl_value_t *slottypes; // inferred types of slots
     275                 :            :     jl_value_t *rettype;
     276                 :            :     jl_method_instance_t *parent; // context (optionally, if available, otherwise nothing)
     277                 :            :     jl_value_t *edges; // forward edges to method instances that must be invalidated
     278                 :            :     size_t min_world;
     279                 :            :     size_t max_world;
     280                 :            :     // various boolean properties:
     281                 :            :     uint8_t inferred;
     282                 :            :     uint8_t inlineable;
     283                 :            :     uint8_t propagate_inbounds;
     284                 :            :     uint8_t pure;
     285                 :            :     // uint8 settings
     286                 :            :     uint8_t constprop; // 0 = use heuristic; 1 = aggressive; 2 = none
     287                 :            :     _jl_purity_overrides_t purity;
     288                 :            : } jl_code_info_t;
     289                 :            : 
     290                 :            : // This type describes a single method definition, and stores data
     291                 :            : // shared by the specializations of a function.
     292                 :            : typedef struct _jl_method_t {
     293                 :            :     JL_DATA_TYPE
     294                 :            :     jl_sym_t *name;  // for error reporting
     295                 :            :     struct _jl_module_t *module;
     296                 :            :     jl_sym_t *file;
     297                 :            :     int32_t line;
     298                 :            :     size_t primary_world;
     299                 :            :     size_t deleted_world;
     300                 :            : 
     301                 :            :     // method's type signature. redundant with TypeMapEntry->specTypes
     302                 :            :     jl_value_t *sig;
     303                 :            : 
     304                 :            :     // table of all jl_method_instance_t specializations we have
     305                 :            :     _Atomic(jl_svec_t*) specializations; // allocated as [hashable, ..., NULL, linear, ....]
     306                 :            :     _Atomic(jl_array_t*) speckeyset; // index lookup by hash into specializations
     307                 :            : 
     308                 :            :     jl_value_t *slot_syms; // compacted list of slot names (String)
     309                 :            :     jl_value_t *external_mt; // reference to the method table this method is part of, null if part of the internal table
     310                 :            :     jl_value_t *source;  // original code template (jl_code_info_t, but may be compressed), null for builtins
     311                 :            :     _Atomic(struct _jl_method_instance_t*) unspecialized;  // unspecialized executable method instance, or null
     312                 :            :     jl_value_t *generator;  // executable code-generating function if available
     313                 :            :     jl_array_t *roots;  // pointers in generated code (shared to reduce memory), or null
     314                 :            :     // Identify roots by module-of-origin. We only track the module for roots added during incremental compilation.
     315                 :            :     // May be NULL if no external roots have been added, otherwise it's a Vector{UInt64}
     316                 :            :     jl_array_t *root_blocks;   // RLE (build_id, offset) pairs (even/odd indexing)
     317                 :            :     int32_t nroots_sysimg;     // # of roots stored in the system image
     318                 :            :     jl_svec_t *ccallable; // svec(rettype, sig) if a ccallable entry point is requested for this
     319                 :            : 
     320                 :            :     // cache of specializations of this method for invoke(), i.e.
     321                 :            :     // cases where this method was called even though it was not necessarily
     322                 :            :     // the most specific for the argument types.
     323                 :            :     _Atomic(jl_typemap_t*) invokes;
     324                 :            : 
     325                 :            :     // A function that compares two specializations of this method, returning
     326                 :            :     // `true` if the first signature is to be considered "smaller" than the
     327                 :            :     // second for purposes of recursion analysis. Set to NULL to use
     328                 :            :     // the default recusion relation.
     329                 :            :     jl_value_t *recursion_relation;
     330                 :            : 
     331                 :            :     uint32_t nargs;
     332                 :            :     uint32_t called;        // bit flags: whether each of the first 8 arguments is called
     333                 :            :     uint32_t nospecialize;  // bit flags: which arguments should not be specialized
     334                 :            :     uint32_t nkw;           // # of leading arguments that are actually keyword arguments
     335                 :            :                             // of another method.
     336                 :            :     uint8_t isva;
     337                 :            :     uint8_t pure;
     338                 :            :     uint8_t is_for_opaque_closure;
     339                 :            :     // uint8 settings
     340                 :            :     uint8_t constprop;     // 0x00 = use heuristic; 0x01 = aggressive; 0x02 = none
     341                 :            : 
     342                 :            :     // Override the conclusions of inter-procedural effect analysis,
     343                 :            :     // forcing the conclusion to always true.
     344                 :            :     _jl_purity_overrides_t purity;
     345                 :            : 
     346                 :            : // hidden fields:
     347                 :            :     // lock for modifications to the method
     348                 :            :     jl_mutex_t writelock;
     349                 :            : } jl_method_t;
     350                 :            : 
     351                 :            : // This type is a placeholder to cache data for a specType signature specialization of a Method
     352                 :            : // can can be used as a unique dictionary key representation of a call to a particular Method
     353                 :            : // with a particular set of argument types
     354                 :            : struct _jl_method_instance_t {
     355                 :            :     JL_DATA_TYPE
     356                 :            :     union {
     357                 :            :         jl_value_t *value; // generic accessor
     358                 :            :         struct _jl_module_t *module; // this is a toplevel thunk
     359                 :            :         jl_method_t *method; // method this is specialized from
     360                 :            :     } def; // pointer back to the context for this code
     361                 :            :     jl_value_t *specTypes;  // argument types this was specialized for
     362                 :            :     jl_svec_t *sparam_vals; // static parameter values, indexed by def.method->sparam_syms
     363                 :            :     jl_value_t *uninferred; // cached uncompressed code, for generated functions, top-level thunks, or the interpreter
     364                 :            :     jl_array_t *backedges; // list of method-instances which contain a call into this method-instance
     365                 :            :     jl_array_t *callbacks; // list of callback functions to inform external caches about invalidations
     366                 :            :     _Atomic(struct _jl_code_instance_t*) cache;
     367                 :            :     uint8_t inInference; // flags to tell if inference is running on this object
     368                 :            :     uint8_t precompiled; // true if this instance was generated by an explicit `precompile(...)` call
     369                 :            : };
     370                 :            : 
     371                 :            : // OpaqueClosure
     372                 :            : typedef struct jl_opaque_closure_t {
     373                 :            :     JL_DATA_TYPE
     374                 :            :     jl_value_t *captures;
     375                 :            :     size_t world;
     376                 :            :     jl_method_t *source;
     377                 :            :     jl_fptr_args_t invoke;
     378                 :            :     void *specptr;
     379                 :            : } jl_opaque_closure_t;
     380                 :            : 
     381                 :            : // This type represents an executable operation
     382                 :            : typedef struct _jl_code_instance_t {
     383                 :            :     JL_DATA_TYPE
     384                 :            :     jl_method_instance_t *def; // method this is specialized from
     385                 :            :     _Atomic(struct _jl_code_instance_t*) next; // pointer to the next cache entry
     386                 :            : 
     387                 :            :     // world range for which this object is valid to use
     388                 :            :     size_t min_world;
     389                 :            :     size_t max_world;
     390                 :            : 
     391                 :            :     // inference state cache
     392                 :            :     jl_value_t *rettype; // return type for fptr
     393                 :            :     jl_value_t *rettype_const; // inferred constant return value, or null
     394                 :            :     jl_value_t *inferred; // inferred jl_code_info_t, or jl_nothing, or null
     395                 :            :     //TODO: jl_array_t *edges; // stored information about edges from this object
     396                 :            :     //TODO: uint8_t absolute_max; // whether true max world is unknown
     397                 :            : 
     398                 :            :     // purity results
     399                 :            : #ifdef JL_USE_ANON_UNIONS_FOR_PURITY_FLAGS
     400                 :            :     // see also encode_effects() and decode_effects() in `base/compiler/types.jl`,
     401                 :            :     union {
     402                 :            :         uint32_t ipo_purity_bits;
     403                 :            :         struct {
     404                 :            :             uint8_t ipo_consistent:2;
     405                 :            :             uint8_t ipo_effect_free:2;
     406                 :            :             uint8_t ipo_nothrow:2;
     407                 :            :             uint8_t ipo_terminates:2;
     408                 :            :             uint8_t ipo_nonoverlayed:1;
     409                 :            :         } ipo_purity_flags;
     410                 :            :     };
     411                 :            :     union {
     412                 :            :         uint32_t purity_bits;
     413                 :            :         struct {
     414                 :            :             uint8_t consistent:2;
     415                 :            :             uint8_t effect_free:2;
     416                 :            :             uint8_t nothrow:2;
     417                 :            :             uint8_t terminates:2;
     418                 :            :             uint8_t nonoverlayed:1;
     419                 :            :         } purity_flags;
     420                 :            :     };
     421                 :            : #else
     422                 :            :     uint32_t ipo_purity_bits;
     423                 :            :     uint32_t purity_bits;
     424                 :            : #endif
     425                 :            :     jl_value_t *argescapes; // escape information of call arguments
     426                 :            : 
     427                 :            :     // compilation state cache
     428                 :            :     uint8_t isspecsig; // if specptr is a specialized function signature for specTypes->rettype
     429                 :            :     _Atomic(uint8_t) precompile;  // if set, this will be added to the output system image
     430                 :            :     _Atomic(jl_callptr_t) invoke; // jlcall entry point
     431                 :            :     union _jl_generic_specptr_t {
     432                 :            :         _Atomic(void*) fptr;
     433                 :            :         _Atomic(jl_fptr_args_t) fptr1;
     434                 :            :         // 2 constant
     435                 :            :         _Atomic(jl_fptr_sparam_t) fptr3;
     436                 :            :         // 4 interpreter
     437                 :            :     } specptr; // private data for `jlcall entry point
     438                 :            :     uint8_t relocatability;  // nonzero if all roots are built into sysimg or tagged by module key
     439                 :            : } jl_code_instance_t;
     440                 :            : 
     441                 :            : // all values are callable as Functions
     442                 :            : typedef jl_value_t jl_function_t;
     443                 :            : 
     444                 :            : typedef struct {
     445                 :            :     JL_DATA_TYPE
     446                 :            :     jl_sym_t *name;
     447                 :            :     jl_value_t *lb;   // lower bound
     448                 :            :     jl_value_t *ub;   // upper bound
     449                 :            : } jl_tvar_t;
     450                 :            : 
     451                 :            : // UnionAll type (iterated union over all values of a variable in certain bounds)
     452                 :            : // written `body where lb<:var<:ub`
     453                 :            : typedef struct {
     454                 :            :     JL_DATA_TYPE
     455                 :            :     jl_tvar_t *var;
     456                 :            :     jl_value_t *body;
     457                 :            : } jl_unionall_t;
     458                 :            : 
     459                 :            : // represents the "name" part of a DataType, describing the syntactic structure
     460                 :            : // of a type and storing all data common to different instantiations of the type,
     461                 :            : // including a cache for hash-consed allocation of DataType objects.
     462                 :            : typedef struct {
     463                 :            :     JL_DATA_TYPE
     464                 :            :     jl_sym_t *name;
     465                 :            :     struct _jl_module_t *module;
     466                 :            :     jl_svec_t *names;  // field names
     467                 :            :     const uint32_t *atomicfields; // if any fields are atomic, we record them here
     468                 :            :     const uint32_t *constfields; // if any fields are const, we record them here
     469                 :            :     // `wrapper` is either the only instantiation of the type (if no parameters)
     470                 :            :     // or a UnionAll accepting parameters to make an instantiation.
     471                 :            :     jl_value_t *wrapper;
     472                 :            :     _Atomic(jl_value_t*) Typeofwrapper;  // cache for Type{wrapper}
     473                 :            :     _Atomic(jl_svec_t*) cache;        // sorted array
     474                 :            :     _Atomic(jl_svec_t*) linearcache;  // unsorted array
     475                 :            :     struct _jl_methtable_t *mt;
     476                 :            :     jl_array_t *partial;     // incomplete instantiations of this type
     477                 :            :     intptr_t hash;
     478                 :            :     int32_t n_uninitialized;
     479                 :            :     // type properties
     480                 :            :     uint8_t abstract:1;
     481                 :            :     uint8_t mutabl:1;
     482                 :            :     uint8_t mayinlinealloc:1;
     483                 :            :     uint8_t max_methods; // override for inference's max_methods setting (0 = no additional limit or relaxation)
     484                 :            : } jl_typename_t;
     485                 :            : 
     486                 :            : typedef struct {
     487                 :            :     JL_DATA_TYPE
     488                 :            :     jl_value_t *a;
     489                 :            :     jl_value_t *b;
     490                 :            : } jl_uniontype_t;
     491                 :            : 
     492                 :            : // in little-endian, isptr is always the first bit, avoiding the need for a branch in computing isptr
     493                 :            : typedef struct {
     494                 :            :     uint8_t isptr:1;
     495                 :            :     uint8_t size:7;
     496                 :            :     uint8_t offset;   // offset relative to data start, excluding type tag
     497                 :            : } jl_fielddesc8_t;
     498                 :            : 
     499                 :            : typedef struct {
     500                 :            :     uint16_t isptr:1;
     501                 :            :     uint16_t size:15;
     502                 :            :     uint16_t offset;   // offset relative to data start, excluding type tag
     503                 :            : } jl_fielddesc16_t;
     504                 :            : 
     505                 :            : typedef struct {
     506                 :            :     uint32_t isptr:1;
     507                 :            :     uint32_t size:31;
     508                 :            :     uint32_t offset;   // offset relative to data start, excluding type tag
     509                 :            : } jl_fielddesc32_t;
     510                 :            : 
     511                 :            : typedef struct {
     512                 :            :     uint32_t nfields;
     513                 :            :     uint32_t npointers; // number of pointers embedded inside
     514                 :            :     int32_t first_ptr; // index of the first pointer (or -1)
     515                 :            :     uint16_t alignment; // strictest alignment over all fields
     516                 :            :     uint16_t haspadding : 1; // has internal undefined bytes
     517                 :            :     uint16_t fielddesc_type : 2; // 0 -> 8, 1 -> 16, 2 -> 32, 3 -> foreign type
     518                 :            :     // union {
     519                 :            :     //     jl_fielddesc8_t field8[nfields];
     520                 :            :     //     jl_fielddesc16_t field16[nfields];
     521                 :            :     //     jl_fielddesc32_t field32[nfields];
     522                 :            :     // };
     523                 :            :     // union { // offsets relative to data start in words
     524                 :            :     //     uint8_t ptr8[npointers];
     525                 :            :     //     uint16_t ptr16[npointers];
     526                 :            :     //     uint32_t ptr32[npointers];
     527                 :            :     // };
     528                 :            : } jl_datatype_layout_t;
     529                 :            : 
     530                 :            : typedef struct _jl_datatype_t {
     531                 :            :     JL_DATA_TYPE
     532                 :            :     jl_typename_t *name;
     533                 :            :     struct _jl_datatype_t *super;
     534                 :            :     jl_svec_t *parameters;
     535                 :            :     jl_svec_t *types;
     536                 :            :     jl_value_t *instance;  // for singletons
     537                 :            :     const jl_datatype_layout_t *layout;
     538                 :            :     int32_t size; // TODO: move to _jl_datatype_layout_t
     539                 :            :     // memoized properties
     540                 :            :     uint32_t hash;
     541                 :            :     uint8_t hasfreetypevars:1; // majority part of isconcrete computation
     542                 :            :     uint8_t isconcretetype:1; // whether this type can have instances
     543                 :            :     uint8_t isdispatchtuple:1; // aka isleaftupletype
     544                 :            :     uint8_t isbitstype:1; // relevant query for C-api and type-parameters
     545                 :            :     uint8_t zeroinit:1; // if one or more fields requires zero-initialization
     546                 :            :     uint8_t has_concrete_subtype:1; // If clear, no value will have this datatype
     547                 :            :     uint8_t cached_by_hash:1; // stored in hash-based set cache (instead of linear cache)
     548                 :            : } jl_datatype_t;
     549                 :            : 
     550                 :            : typedef struct _jl_vararg_t {
     551                 :            :     JL_DATA_TYPE
     552                 :            :     jl_value_t *T;
     553                 :            :     jl_value_t *N;
     554                 :            : } jl_vararg_t;
     555                 :            : 
     556                 :            : typedef struct {
     557                 :            :     JL_DATA_TYPE
     558                 :            :     jl_value_t *value;
     559                 :            : } jl_weakref_t;
     560                 :            : 
     561                 :            : typedef struct {
     562                 :            :     // not first-class
     563                 :            :     jl_sym_t *name;
     564                 :            :     _Atomic(jl_value_t*) value;
     565                 :            :     _Atomic(jl_value_t*) globalref;  // cached GlobalRef for this binding
     566                 :            :     struct _jl_module_t* owner;  // for individual imported bindings -- TODO: make _Atomic
     567                 :            :     _Atomic(jl_value_t*) ty;  // binding type
     568                 :            :     uint8_t constp:1;
     569                 :            :     uint8_t exportp:1;
     570                 :            :     uint8_t imported:1;
     571                 :            :     uint8_t deprecated:2; // 0=not deprecated, 1=renamed, 2=moved to another package
     572                 :            : } jl_binding_t;
     573                 :            : 
     574                 :            : typedef struct {
     575                 :            :     uint64_t hi;
     576                 :            :     uint64_t lo;
     577                 :            : } jl_uuid_t;
     578                 :            : 
     579                 :            : typedef struct _jl_module_t {
     580                 :            :     JL_DATA_TYPE
     581                 :            :     jl_sym_t *name;
     582                 :            :     struct _jl_module_t *parent;
     583                 :            :     // hidden fields:
     584                 :            :     htable_t bindings;
     585                 :            :     arraylist_t usings;  // modules with all bindings potentially imported
     586                 :            :     uint64_t build_id;
     587                 :            :     jl_uuid_t uuid;
     588                 :            :     size_t primary_world;
     589                 :            :     _Atomic(uint32_t) counter;
     590                 :            :     int32_t nospecialize;  // global bit flags: initialization for new methods
     591                 :            :     int8_t optlevel;
     592                 :            :     int8_t compile;
     593                 :            :     int8_t infer;
     594                 :            :     uint8_t istopmod;
     595                 :            :     int8_t max_methods;
     596                 :            :     jl_mutex_t lock;
     597                 :            : } jl_module_t;
     598                 :            : 
     599                 :            : // one Type-to-Value entry
     600                 :            : typedef struct _jl_typemap_entry_t {
     601                 :            :     JL_DATA_TYPE
     602                 :            :     _Atomic(struct _jl_typemap_entry_t*) next; // invasive linked list
     603                 :            :     jl_tupletype_t *sig; // the type signature for this entry
     604                 :            :     jl_tupletype_t *simplesig; // a simple signature for fast rejection
     605                 :            :     jl_svec_t *guardsigs;
     606                 :            :     size_t min_world;
     607                 :            :     size_t max_world;
     608                 :            :     union {
     609                 :            :         jl_value_t *value; // generic accessor
     610                 :            :         jl_method_instance_t *linfo; // [nullable] for guard entries
     611                 :            :         jl_method_t *method;
     612                 :            :     } func;
     613                 :            :     // memoized properties of sig:
     614                 :            :     int8_t isleafsig; // isleaftype(sig) & !any(isType, sig) : unsorted and very fast
     615                 :            :     int8_t issimplesig; // all(isleaftype | isAny | isType | isVararg, sig) : sorted and fast
     616                 :            :     int8_t va; // isVararg(sig)
     617                 :            : } jl_typemap_entry_t;
     618                 :            : 
     619                 :            : // one level in a TypeMap tree (each level splits on a type at a given offset)
     620                 :            : typedef struct _jl_typemap_level_t {
     621                 :            :     JL_DATA_TYPE
     622                 :            :     // these vectors contains vectors of more levels in their intended visit order
     623                 :            :     // with an index that gives the functionality of a sorted dict.
     624                 :            :     // next split may be on Type{T} as LeafTypes then TypeName's parents up to Any
     625                 :            :     // next split may be on LeafType
     626                 :            :     // next split may be on TypeName
     627                 :            :     _Atomic(jl_array_t*) arg1; // contains LeafType
     628                 :            :     _Atomic(jl_array_t*) targ; // contains Type{LeafType}
     629                 :            :     _Atomic(jl_array_t*) name1; // contains non-abstract TypeName, for parents up to (excluding) Any
     630                 :            :     _Atomic(jl_array_t*) tname; // contains a dict of Type{TypeName}, for parents up to Any
     631                 :            :     // next a linear list of things too complicated at this level for analysis (no more levels)
     632                 :            :     _Atomic(jl_typemap_entry_t*) linear;
     633                 :            :     // finally, start a new level if the type at offs is Any
     634                 :            :     _Atomic(jl_typemap_t*) any;
     635                 :            : } jl_typemap_level_t;
     636                 :            : 
     637                 :            : // contains the TypeMap for one Type
     638                 :            : typedef struct _jl_methtable_t {
     639                 :            :     JL_DATA_TYPE
     640                 :            :     jl_sym_t *name; // sometimes a hack used by serialization to handle kwsorter
     641                 :            :     _Atomic(jl_typemap_t*) defs;
     642                 :            :     _Atomic(jl_array_t*) leafcache;
     643                 :            :     _Atomic(jl_typemap_t*) cache;
     644                 :            :     intptr_t max_args;  // max # of non-vararg arguments in a signature
     645                 :            :     jl_value_t *kwsorter;  // keyword argument sorter function
     646                 :            :     jl_module_t *module; // used for incremental serialization to locate original binding
     647                 :            :     jl_array_t *backedges;
     648                 :            :     jl_mutex_t writelock;
     649                 :            :     uint8_t offs;  // 0, or 1 to skip splitting typemap on first (function) argument
     650                 :            :     uint8_t frozen; // whether this accepts adding new methods
     651                 :            : } jl_methtable_t;
     652                 :            : 
     653                 :            : typedef struct {
     654                 :            :     JL_DATA_TYPE
     655                 :            :     jl_sym_t *head;
     656                 :            :     jl_array_t *args;
     657                 :            : } jl_expr_t;
     658                 :            : 
     659                 :            : typedef struct {
     660                 :            :     JL_DATA_TYPE
     661                 :            :     jl_tupletype_t *spec_types;
     662                 :            :     jl_svec_t *sparams;
     663                 :            :     jl_method_t *method;
     664                 :            :     // A bool on the julia side, but can be temporarily 0x2 as a sentinel
     665                 :            :     // during construction.
     666                 :            :     uint8_t fully_covers;
     667                 :            : } jl_method_match_t;
     668                 :            : 
     669                 :            : // constants and type objects -------------------------------------------------
     670                 :            : 
     671                 :            : // kinds
     672                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_typeofbottom_type JL_GLOBALLY_ROOTED;
     673                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_datatype_type JL_GLOBALLY_ROOTED;
     674                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_uniontype_type JL_GLOBALLY_ROOTED;
     675                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_unionall_type JL_GLOBALLY_ROOTED;
     676                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_tvar_type JL_GLOBALLY_ROOTED;
     677                 :            : 
     678                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_any_type JL_GLOBALLY_ROOTED;
     679                 :            : extern JL_DLLIMPORT jl_unionall_t *jl_type_type JL_GLOBALLY_ROOTED;
     680                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_typename_type JL_GLOBALLY_ROOTED;
     681                 :            : extern JL_DLLIMPORT jl_typename_t *jl_type_typename JL_GLOBALLY_ROOTED;
     682                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_symbol_type JL_GLOBALLY_ROOTED;
     683                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_ssavalue_type JL_GLOBALLY_ROOTED;
     684                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_abstractslot_type JL_GLOBALLY_ROOTED;
     685                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_slotnumber_type JL_GLOBALLY_ROOTED;
     686                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_typedslot_type JL_GLOBALLY_ROOTED;
     687                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_argument_type JL_GLOBALLY_ROOTED;
     688                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_const_type JL_GLOBALLY_ROOTED;
     689                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_partial_struct_type JL_GLOBALLY_ROOTED;
     690                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_partial_opaque_type JL_GLOBALLY_ROOTED;
     691                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_interconditional_type JL_GLOBALLY_ROOTED;
     692                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_method_match_type JL_GLOBALLY_ROOTED;
     693                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_simplevector_type JL_GLOBALLY_ROOTED;
     694                 :            : extern JL_DLLIMPORT jl_typename_t *jl_tuple_typename JL_GLOBALLY_ROOTED;
     695                 :            : extern JL_DLLIMPORT jl_typename_t *jl_vecelement_typename JL_GLOBALLY_ROOTED;
     696                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_anytuple_type JL_GLOBALLY_ROOTED;
     697                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_emptytuple_type JL_GLOBALLY_ROOTED;
     698                 :            : #define jl_tuple_type jl_anytuple_type
     699                 :            : extern JL_DLLIMPORT jl_unionall_t *jl_anytuple_type_type JL_GLOBALLY_ROOTED;
     700                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_vararg_type JL_GLOBALLY_ROOTED;
     701                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_function_type JL_GLOBALLY_ROOTED;
     702                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_builtin_type JL_GLOBALLY_ROOTED;
     703                 :            : extern JL_DLLIMPORT jl_unionall_t *jl_opaque_closure_type JL_GLOBALLY_ROOTED;
     704                 :            : extern JL_DLLIMPORT jl_typename_t *jl_opaque_closure_typename JL_GLOBALLY_ROOTED;
     705                 :            : 
     706                 :            : extern JL_DLLIMPORT jl_value_t *jl_bottom_type JL_GLOBALLY_ROOTED;
     707                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_method_instance_type JL_GLOBALLY_ROOTED;
     708                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_code_instance_type JL_GLOBALLY_ROOTED;
     709                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_code_info_type JL_GLOBALLY_ROOTED;
     710                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_method_type JL_GLOBALLY_ROOTED;
     711                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_module_type JL_GLOBALLY_ROOTED;
     712                 :            : extern JL_DLLIMPORT jl_unionall_t *jl_abstractarray_type JL_GLOBALLY_ROOTED;
     713                 :            : extern JL_DLLIMPORT jl_unionall_t *jl_densearray_type JL_GLOBALLY_ROOTED;
     714                 :            : extern JL_DLLIMPORT jl_unionall_t *jl_array_type JL_GLOBALLY_ROOTED;
     715                 :            : extern JL_DLLIMPORT jl_typename_t *jl_array_typename JL_GLOBALLY_ROOTED;
     716                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_weakref_type JL_GLOBALLY_ROOTED;
     717                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_abstractstring_type JL_GLOBALLY_ROOTED;
     718                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_string_type JL_GLOBALLY_ROOTED;
     719                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_errorexception_type JL_GLOBALLY_ROOTED;
     720                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_argumenterror_type JL_GLOBALLY_ROOTED;
     721                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_loaderror_type JL_GLOBALLY_ROOTED;
     722                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_initerror_type JL_GLOBALLY_ROOTED;
     723                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_typeerror_type JL_GLOBALLY_ROOTED;
     724                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_methoderror_type JL_GLOBALLY_ROOTED;
     725                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_undefvarerror_type JL_GLOBALLY_ROOTED;
     726                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_atomicerror_type JL_GLOBALLY_ROOTED;
     727                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_lineinfonode_type JL_GLOBALLY_ROOTED;
     728                 :            : extern JL_DLLIMPORT jl_value_t *jl_stackovf_exception JL_GLOBALLY_ROOTED;
     729                 :            : extern JL_DLLIMPORT jl_value_t *jl_memory_exception JL_GLOBALLY_ROOTED;
     730                 :            : extern JL_DLLIMPORT jl_value_t *jl_readonlymemory_exception JL_GLOBALLY_ROOTED;
     731                 :            : extern JL_DLLIMPORT jl_value_t *jl_diverror_exception JL_GLOBALLY_ROOTED;
     732                 :            : extern JL_DLLIMPORT jl_value_t *jl_undefref_exception JL_GLOBALLY_ROOTED;
     733                 :            : extern JL_DLLIMPORT jl_value_t *jl_interrupt_exception JL_GLOBALLY_ROOTED;
     734                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_boundserror_type JL_GLOBALLY_ROOTED;
     735                 :            : extern JL_DLLIMPORT jl_value_t *jl_an_empty_vec_any JL_GLOBALLY_ROOTED;
     736                 :            : extern JL_DLLIMPORT jl_value_t *jl_an_empty_string JL_GLOBALLY_ROOTED;
     737                 :            : 
     738                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_bool_type JL_GLOBALLY_ROOTED;
     739                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_char_type JL_GLOBALLY_ROOTED;
     740                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_int8_type JL_GLOBALLY_ROOTED;
     741                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_uint8_type JL_GLOBALLY_ROOTED;
     742                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_int16_type JL_GLOBALLY_ROOTED;
     743                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_uint16_type JL_GLOBALLY_ROOTED;
     744                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_int32_type JL_GLOBALLY_ROOTED;
     745                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_uint32_type JL_GLOBALLY_ROOTED;
     746                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_int64_type JL_GLOBALLY_ROOTED;
     747                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_uint64_type JL_GLOBALLY_ROOTED;
     748                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_float16_type JL_GLOBALLY_ROOTED;
     749                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_float32_type JL_GLOBALLY_ROOTED;
     750                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_float64_type JL_GLOBALLY_ROOTED;
     751                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_floatingpoint_type JL_GLOBALLY_ROOTED;
     752                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_number_type JL_GLOBALLY_ROOTED;
     753                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_void_type JL_GLOBALLY_ROOTED;  // deprecated
     754                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_nothing_type JL_GLOBALLY_ROOTED;
     755                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_signed_type JL_GLOBALLY_ROOTED;
     756                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_voidpointer_type JL_GLOBALLY_ROOTED;
     757                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_uint8pointer_type JL_GLOBALLY_ROOTED;
     758                 :            : extern JL_DLLIMPORT jl_unionall_t *jl_pointer_type JL_GLOBALLY_ROOTED;
     759                 :            : extern JL_DLLIMPORT jl_unionall_t *jl_llvmpointer_type JL_GLOBALLY_ROOTED;
     760                 :            : extern JL_DLLIMPORT jl_unionall_t *jl_ref_type JL_GLOBALLY_ROOTED;
     761                 :            : extern JL_DLLIMPORT jl_typename_t *jl_pointer_typename JL_GLOBALLY_ROOTED;
     762                 :            : extern JL_DLLIMPORT jl_typename_t *jl_llvmpointer_typename JL_GLOBALLY_ROOTED;
     763                 :            : extern JL_DLLIMPORT jl_typename_t *jl_namedtuple_typename JL_GLOBALLY_ROOTED;
     764                 :            : extern JL_DLLIMPORT jl_unionall_t *jl_namedtuple_type JL_GLOBALLY_ROOTED;
     765                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_task_type JL_GLOBALLY_ROOTED;
     766                 :            : extern JL_DLLIMPORT jl_value_t *jl_pair_type JL_GLOBALLY_ROOTED;
     767                 :            : 
     768                 :            : extern JL_DLLIMPORT jl_value_t *jl_array_uint8_type JL_GLOBALLY_ROOTED;
     769                 :            : extern JL_DLLIMPORT jl_value_t *jl_array_any_type JL_GLOBALLY_ROOTED;
     770                 :            : extern JL_DLLIMPORT jl_value_t *jl_array_symbol_type JL_GLOBALLY_ROOTED;
     771                 :            : extern JL_DLLIMPORT jl_value_t *jl_array_int32_type JL_GLOBALLY_ROOTED;
     772                 :            : extern JL_DLLIMPORT jl_value_t *jl_array_uint64_type JL_GLOBALLY_ROOTED;
     773                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_expr_type JL_GLOBALLY_ROOTED;
     774                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_globalref_type JL_GLOBALLY_ROOTED;
     775                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_linenumbernode_type JL_GLOBALLY_ROOTED;
     776                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_gotonode_type JL_GLOBALLY_ROOTED;
     777                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_gotoifnot_type JL_GLOBALLY_ROOTED;
     778                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_returnnode_type JL_GLOBALLY_ROOTED;
     779                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_phinode_type JL_GLOBALLY_ROOTED;
     780                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_pinode_type JL_GLOBALLY_ROOTED;
     781                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_phicnode_type JL_GLOBALLY_ROOTED;
     782                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_upsilonnode_type JL_GLOBALLY_ROOTED;
     783                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_quotenode_type JL_GLOBALLY_ROOTED;
     784                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_newvarnode_type JL_GLOBALLY_ROOTED;
     785                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_intrinsic_type JL_GLOBALLY_ROOTED;
     786                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_methtable_type JL_GLOBALLY_ROOTED;
     787                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_typemap_level_type JL_GLOBALLY_ROOTED;
     788                 :            : extern JL_DLLIMPORT jl_datatype_t *jl_typemap_entry_type JL_GLOBALLY_ROOTED;
     789                 :            : 
     790                 :            : extern JL_DLLIMPORT jl_svec_t *jl_emptysvec JL_GLOBALLY_ROOTED;
     791                 :            : extern JL_DLLIMPORT jl_value_t *jl_emptytuple JL_GLOBALLY_ROOTED;
     792                 :            : extern JL_DLLIMPORT jl_value_t *jl_true JL_GLOBALLY_ROOTED;
     793                 :            : extern JL_DLLIMPORT jl_value_t *jl_false JL_GLOBALLY_ROOTED;
     794                 :            : extern JL_DLLIMPORT jl_value_t *jl_nothing JL_GLOBALLY_ROOTED;
     795                 :            : 
     796                 :            : // gc -------------------------------------------------------------------------
     797                 :            : 
     798                 :            : struct _jl_gcframe_t {
     799                 :            :     size_t nroots;
     800                 :            :     struct _jl_gcframe_t *prev;
     801                 :            :     // actual roots go here
     802                 :            : };
     803                 :            : 
     804                 :            : // NOTE: it is the caller's responsibility to make sure arguments are
     805                 :            : // rooted such that the gc can see them on the stack.
     806                 :            : // `foo(f(), g())` is not safe,
     807                 :            : // since the result of `f()` is not rooted during the call to `g()`,
     808                 :            : // and the arguments to foo are not gc-protected during the call to foo.
     809                 :            : // foo can't do anything about it, so the caller must do:
     810                 :            : // jl_value_t *x=NULL, *y=NULL; JL_GC_PUSH2(&x, &y);
     811                 :            : // x = f(); y = g(); foo(x, y)
     812                 :            : 
     813                 :            : #define jl_pgcstack (jl_current_task->gcstack)
     814                 :            : 
     815                 :            : #define JL_GC_ENCODE_PUSHARGS(n)   (((size_t)(n))<<2)
     816                 :            : #define JL_GC_ENCODE_PUSH(n)       ((((size_t)(n))<<2)|1)
     817                 :            : 
     818                 :            : #ifdef __clang_gcanalyzer__
     819                 :            : 
     820                 :            : // When running with the analyzer make these real function calls, that are
     821                 :            : // easier to detect in the analyzer
     822                 :            : extern void JL_GC_PUSH1(void *) JL_NOTSAFEPOINT;
     823                 :            : extern void JL_GC_PUSH2(void *, void *) JL_NOTSAFEPOINT;
     824                 :            : extern void JL_GC_PUSH3(void *, void *, void *)  JL_NOTSAFEPOINT;
     825                 :            : extern void JL_GC_PUSH4(void *, void *, void *, void *)  JL_NOTSAFEPOINT;
     826                 :            : extern void JL_GC_PUSH5(void *, void *, void *, void *, void *)  JL_NOTSAFEPOINT;
     827                 :            : extern void JL_GC_PUSH7(void *, void *, void *, void *, void *, void *, void *)  JL_NOTSAFEPOINT;
     828                 :            : extern void _JL_GC_PUSHARGS(jl_value_t **, size_t) JL_NOTSAFEPOINT;
     829                 :            : // This is necessary, because otherwise the analyzer considers this undefined
     830                 :            : // behavior and terminates the exploration
     831                 :            : #define JL_GC_PUSHARGS(rts_var, n)     \
     832                 :            :   rts_var = (jl_value_t **)alloca(sizeof(void*) * (n)); \
     833                 :            :   memset(rts_var, 0, sizeof(void*) * (n)); \
     834                 :            :   _JL_GC_PUSHARGS(rts_var, (n));
     835                 :            : 
     836                 :            : extern void JL_GC_POP() JL_NOTSAFEPOINT;
     837                 :            : 
     838                 :            : #else
     839                 :            : 
     840                 :            : #define JL_GC_PUSH1(arg1)                                                                               \
     841                 :            :   void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH(1), jl_pgcstack, arg1};                                 \
     842                 :            :   jl_pgcstack = (jl_gcframe_t*)__gc_stkf;
     843                 :            : 
     844                 :            : #define JL_GC_PUSH2(arg1, arg2)                                                                         \
     845                 :            :   void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH(2), jl_pgcstack, arg1, arg2};                           \
     846                 :            :   jl_pgcstack = (jl_gcframe_t*)__gc_stkf;
     847                 :            : 
     848                 :            : #define JL_GC_PUSH3(arg1, arg2, arg3)                                                                   \
     849                 :            :   void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH(3), jl_pgcstack, arg1, arg2, arg3};                     \
     850                 :            :   jl_pgcstack = (jl_gcframe_t*)__gc_stkf;
     851                 :            : 
     852                 :            : #define JL_GC_PUSH4(arg1, arg2, arg3, arg4)                                                             \
     853                 :            :   void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH(4), jl_pgcstack, arg1, arg2, arg3, arg4};               \
     854                 :            :   jl_pgcstack = (jl_gcframe_t*)__gc_stkf;
     855                 :            : 
     856                 :            : #define JL_GC_PUSH5(arg1, arg2, arg3, arg4, arg5)                                                       \
     857                 :            :   void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH(5), jl_pgcstack, arg1, arg2, arg3, arg4, arg5};         \
     858                 :            :   jl_pgcstack = (jl_gcframe_t*)__gc_stkf;
     859                 :            : 
     860                 :            : #define JL_GC_PUSH6(arg1, arg2, arg3, arg4, arg5, arg6)                                                 \
     861                 :            :   void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH(6), jl_pgcstack, arg1, arg2, arg3, arg4, arg5, arg6};   \
     862                 :            :   jl_pgcstack = (jl_gcframe_t*)__gc_stkf;
     863                 :            : 
     864                 :            : #define JL_GC_PUSH7(arg1, arg2, arg3, arg4, arg5, arg6, arg7)                                           \
     865                 :            :   void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH(7), jl_pgcstack, arg1, arg2, arg3, arg4, arg5, arg6, arg7}; \
     866                 :            :   jl_pgcstack = (jl_gcframe_t*)__gc_stkf;
     867                 :            : 
     868                 :            : 
     869                 :            : #define JL_GC_PUSHARGS(rts_var,n)                                                                       \
     870                 :            :   rts_var = ((jl_value_t**)alloca(((n)+2)*sizeof(jl_value_t*)))+2;                                      \
     871                 :            :   ((void**)rts_var)[-2] = (void*)JL_GC_ENCODE_PUSHARGS(n);                                              \
     872                 :            :   ((void**)rts_var)[-1] = jl_pgcstack;                                                                  \
     873                 :            :   memset((void*)rts_var, 0, (n)*sizeof(jl_value_t*));                                                   \
     874                 :            :   jl_pgcstack = (jl_gcframe_t*)&(((void**)rts_var)[-2])
     875                 :            : 
     876                 :            : #define JL_GC_POP() (jl_pgcstack = jl_pgcstack->prev)
     877                 :            : 
     878                 :            : #endif
     879                 :            : 
     880                 :            : JL_DLLEXPORT int jl_gc_enable(int on);
     881                 :            : JL_DLLEXPORT int jl_gc_is_enabled(void);
     882                 :            : 
     883                 :            : typedef enum {
     884                 :            :     JL_GC_AUTO = 0,         // use heuristics to determine the collection type
     885                 :            :     JL_GC_FULL = 1,         // force a full collection
     886                 :            :     JL_GC_INCREMENTAL = 2,  // force an incremental collection
     887                 :            : } jl_gc_collection_t;
     888                 :            : 
     889                 :            : JL_DLLEXPORT void jl_gc_collect(jl_gc_collection_t);
     890                 :            : 
     891                 :            : JL_DLLEXPORT void jl_gc_add_finalizer(jl_value_t *v, jl_function_t *f) JL_NOTSAFEPOINT;
     892                 :            : JL_DLLEXPORT void jl_gc_add_ptr_finalizer(jl_ptls_t ptls, jl_value_t *v, void *f) JL_NOTSAFEPOINT;
     893                 :            : JL_DLLEXPORT void jl_finalize(jl_value_t *o);
     894                 :            : JL_DLLEXPORT jl_weakref_t *jl_gc_new_weakref(jl_value_t *value);
     895                 :            : JL_DLLEXPORT jl_value_t *jl_gc_alloc_0w(void);
     896                 :            : JL_DLLEXPORT jl_value_t *jl_gc_alloc_1w(void);
     897                 :            : JL_DLLEXPORT jl_value_t *jl_gc_alloc_2w(void);
     898                 :            : JL_DLLEXPORT jl_value_t *jl_gc_alloc_3w(void);
     899                 :            : JL_DLLEXPORT jl_value_t *jl_gc_allocobj(size_t sz);
     900                 :            : JL_DLLEXPORT void *jl_malloc_stack(size_t *bufsz, struct _jl_task_t *owner) JL_NOTSAFEPOINT;
     901                 :            : JL_DLLEXPORT void jl_free_stack(void *stkbuf, size_t bufsz);
     902                 :            : JL_DLLEXPORT void jl_gc_use(jl_value_t *a);
     903                 :            : 
     904                 :            : JL_DLLEXPORT void jl_clear_malloc_data(void);
     905                 :            : 
     906                 :            : // GC write barriers
     907                 :            : JL_DLLEXPORT void jl_gc_queue_root(const jl_value_t *root) JL_NOTSAFEPOINT;
     908                 :            : JL_DLLEXPORT void jl_gc_queue_multiroot(const jl_value_t *root, const jl_value_t *stored) JL_NOTSAFEPOINT;
     909                 :            : 
     910                 : 8926515344 : STATIC_INLINE void jl_gc_wb(const void *parent, const void *ptr) JL_NOTSAFEPOINT
     911                 :            : {
     912                 :            :     // parent and ptr isa jl_value_t*
     913   [ +  +  +  +  : 8926515344 :     if (__unlikely(jl_astaggedvalue(parent)->bits.gc == 3 && // parent is old and not in remset
                   +  + ]
     914                 :            :                    (jl_astaggedvalue(ptr)->bits.gc & 1) == 0)) // ptr is young
     915                 :    4010047 :         jl_gc_queue_root((jl_value_t*)parent);
     916                 : 8926515344 : }
     917                 :            : 
     918                 :     160150 : STATIC_INLINE void jl_gc_wb_back(const void *ptr) JL_NOTSAFEPOINT // ptr isa jl_value_t*
     919                 :            : {
     920                 :            :     // if ptr is old
     921         [ +  + ]:     160150 :     if (__unlikely(jl_astaggedvalue(ptr)->bits.gc == 3)) {
     922                 :        172 :         jl_gc_queue_root((jl_value_t*)ptr);
     923                 :            :     }
     924                 :     160150 : }
     925                 :            : 
     926                 :    3870440 : STATIC_INLINE void jl_gc_multi_wb(const void *parent, const jl_value_t *ptr) JL_NOTSAFEPOINT
     927                 :            : {
     928                 :            :     // ptr is an immutable object
     929         [ +  + ]:    3870440 :     if (__likely(jl_astaggedvalue(parent)->bits.gc != 3))
     930                 :    3864000 :         return; // parent is young or in remset
     931         [ -  + ]:       6441 :     if (__likely(jl_astaggedvalue(ptr)->bits.gc == 3))
     932                 :          0 :         return; // ptr is old and not in remset (thus it does not point to young)
     933                 :       6441 :     jl_datatype_t *dt = (jl_datatype_t*)jl_typeof(ptr);
     934                 :       6441 :     const jl_datatype_layout_t *ly = dt->layout;
     935         [ +  - ]:       6441 :     if (ly->npointers)
     936                 :       6441 :         jl_gc_queue_multiroot((jl_value_t*)parent, ptr);
     937                 :            : }
     938                 :            : 
     939                 :            : JL_DLLEXPORT void *jl_gc_managed_malloc(size_t sz);
     940                 :            : JL_DLLEXPORT void *jl_gc_managed_realloc(void *d, size_t sz, size_t oldsz,
     941                 :            :                                          int isaligned, jl_value_t *owner);
     942                 :            : JL_DLLEXPORT void jl_gc_safepoint(void);
     943                 :            : 
     944                 :            : // object accessors -----------------------------------------------------------
     945                 :            : 
     946                 :            : #define jl_svec_len(t)              (((jl_svec_t*)(t))->length)
     947                 :            : #define jl_svec_set_len_unsafe(t,n) (((jl_svec_t*)(t))->length=(n))
     948                 :            : #define jl_svec_data(t) ((jl_value_t**)((char*)(t) + sizeof(jl_svec_t)))
     949                 :            : 
     950                 :            : #ifdef __clang_gcanalyzer__
     951                 :            : STATIC_INLINE jl_value_t *jl_svecref(void *t JL_PROPAGATES_ROOT, size_t i) JL_NOTSAFEPOINT;
     952                 :            : STATIC_INLINE jl_value_t *jl_svecset(
     953                 :            :     void *t JL_ROOTING_ARGUMENT JL_PROPAGATES_ROOT,
     954                 :            :     size_t i, void *x JL_ROOTED_ARGUMENT) JL_NOTSAFEPOINT;
     955                 :            : #else
     956                 :80670090386 : STATIC_INLINE jl_value_t *jl_svecref(void *t JL_PROPAGATES_ROOT, size_t i) JL_NOTSAFEPOINT
     957                 :            : {
     958         [ -  + ]:80670090386 :     assert(jl_typeis(t,jl_simplevector_type));
     959         [ -  + ]:80670090386 :     assert(i < jl_svec_len(t));
     960                 :            :     // while svec is supposedly immutable, in practice we sometimes publish it first
     961                 :            :     // and set the values lazily
     962                 :80670090386 :     return jl_atomic_load_relaxed((_Atomic(jl_value_t*)*)jl_svec_data(t) + i);
     963                 :            : }
     964                 : 6480745606 : STATIC_INLINE jl_value_t *jl_svecset(
     965                 :            :     void *t JL_ROOTING_ARGUMENT JL_PROPAGATES_ROOT,
     966                 :            :     size_t i, void *x JL_ROOTED_ARGUMENT) JL_NOTSAFEPOINT
     967                 :            : {
     968         [ -  + ]: 6480745606 :     assert(jl_typeis(t,jl_simplevector_type));
     969         [ -  + ]: 6480745606 :     assert(i < jl_svec_len(t));
     970                 :            :     // TODO: while svec is supposedly immutable, in practice we sometimes publish it first
     971                 :            :     // and set the values lazily. Those users should be using jl_atomic_store_release here.
     972                 : 6480745606 :     jl_svec_data(t)[i] = (jl_value_t*)x;
     973                 : 6480745606 :     jl_gc_wb(t, x);
     974                 : 6480745606 :     return (jl_value_t*)x;
     975                 :            : }
     976                 :            : #endif
     977                 :            : 
     978                 :            : #define jl_array_len(a)   (((jl_array_t*)(a))->length)
     979                 :            : #define jl_array_data(a)  ((void*)((jl_array_t*)(a))->data)
     980                 :            : #define jl_array_dim(a,i) ((&((jl_array_t*)(a))->nrows)[i])
     981                 :            : #define jl_array_dim0(a)  (((jl_array_t*)(a))->nrows)
     982                 :            : #define jl_array_nrows(a) (((jl_array_t*)(a))->nrows)
     983                 :            : #define jl_array_ndims(a) ((int32_t)(((jl_array_t*)a)->flags.ndims))
     984                 :            : #define jl_array_data_owner_offset(ndims) (offsetof(jl_array_t,ncols) + sizeof(size_t)*(1+jl_array_ndimwords(ndims))) // in bytes
     985                 :            : #define jl_array_data_owner(a) (*((jl_value_t**)((char*)a + jl_array_data_owner_offset(jl_array_ndims(a)))))
     986                 :            : 
     987                 :            : JL_DLLEXPORT char *jl_array_typetagdata(jl_array_t *a) JL_NOTSAFEPOINT;
     988                 :            : 
     989                 :            : #ifdef __clang_gcanalyzer__
     990                 :            : jl_value_t **jl_array_ptr_data(jl_array_t *a JL_PROPAGATES_ROOT) JL_NOTSAFEPOINT;
     991                 :            : STATIC_INLINE jl_value_t *jl_array_ptr_ref(void *a JL_PROPAGATES_ROOT, size_t i) JL_NOTSAFEPOINT;
     992                 :            : STATIC_INLINE jl_value_t *jl_array_ptr_set(
     993                 :            :     void *a JL_ROOTING_ARGUMENT, size_t i,
     994                 :            :     void *x JL_ROOTED_ARGUMENT) JL_NOTSAFEPOINT;
     995                 :            : #else
     996                 :            : #define jl_array_ptr_data(a)  ((jl_value_t**)((jl_array_t*)(a))->data)
     997                 :50577549287 : STATIC_INLINE jl_value_t *jl_array_ptr_ref(void *a JL_PROPAGATES_ROOT, size_t i) JL_NOTSAFEPOINT
     998                 :            : {
     999         [ -  + ]:50577549287 :     assert(((jl_array_t*)a)->flags.ptrarray);
    1000         [ -  + ]:50577549287 :     assert(i < jl_array_len(a));
    1001                 :50577549287 :     return jl_atomic_load_relaxed(((_Atomic(jl_value_t*)*)(jl_array_data(a))) + i);
    1002                 :            : }
    1003                 :  466359664 : STATIC_INLINE jl_value_t *jl_array_ptr_set(
    1004                 :            :     void *a JL_ROOTING_ARGUMENT, size_t i,
    1005                 :            :     void *x JL_ROOTED_ARGUMENT) JL_NOTSAFEPOINT
    1006                 :            : {
    1007         [ -  + ]:  466359664 :     assert(((jl_array_t*)a)->flags.ptrarray);
    1008         [ -  + ]:  466359664 :     assert(i < jl_array_len(a));
    1009                 :  466359664 :     jl_atomic_store_release(((_Atomic(jl_value_t*)*)(jl_array_data(a))) + i, (jl_value_t*)x);
    1010         [ +  + ]:  466359664 :     if (x) {
    1011         [ -  + ]:  466359664 :         if (((jl_array_t*)a)->flags.how == 3) {
    1012                 :          0 :             a = jl_array_data_owner(a);
    1013                 :            :         }
    1014                 :  466359664 :         jl_gc_wb(a, x);
    1015                 :            :     }
    1016                 :  466359764 :     return (jl_value_t*)x;
    1017                 :            : }
    1018                 :            : #endif
    1019                 :            : 
    1020                 :    1373977 : STATIC_INLINE uint8_t jl_array_uint8_ref(void *a, size_t i) JL_NOTSAFEPOINT
    1021                 :            : {
    1022         [ -  + ]:    1373977 :     assert(i < jl_array_len(a));
    1023         [ -  + ]:    1373977 :     assert(jl_typeis(a, jl_array_uint8_type));
    1024                 :    1373977 :     return ((uint8_t*)(jl_array_data(a)))[i];
    1025                 :            : }
    1026                 :    4658451 : STATIC_INLINE void jl_array_uint8_set(void *a, size_t i, uint8_t x) JL_NOTSAFEPOINT
    1027                 :            : {
    1028         [ -  + ]:    4658451 :     assert(i < jl_array_len(a));
    1029         [ -  + ]:    4658451 :     assert(jl_typeis(a, jl_array_uint8_type));
    1030                 :    4658451 :     ((uint8_t*)(jl_array_data(a)))[i] = x;
    1031                 :    4658451 : }
    1032                 :            : 
    1033                 :            : #define jl_exprarg(e,n) jl_array_ptr_ref(((jl_expr_t*)(e))->args, n)
    1034                 :            : #define jl_exprargset(e, n, v) jl_array_ptr_set(((jl_expr_t*)(e))->args, n, v)
    1035                 :            : #define jl_expr_nargs(e) jl_array_len(((jl_expr_t*)(e))->args)
    1036                 :            : 
    1037                 :            : #define jl_fieldref(s,i) jl_get_nth_field(((jl_value_t*)(s)),i)
    1038                 :            : #define jl_fieldref_noalloc(s,i) jl_get_nth_field_noalloc(((jl_value_t*)(s)),i)
    1039                 :            : #define jl_nfields(v)    jl_datatype_nfields(jl_typeof(v))
    1040                 :            : 
    1041                 :            : // Not using jl_fieldref to avoid allocations
    1042                 :            : #define jl_linenode_line(x) (((intptr_t*)(x))[0])
    1043                 :            : #define jl_linenode_file(x) (((jl_value_t**)(x))[1])
    1044                 :            : #define jl_slot_number(x) (((intptr_t*)(x))[0])
    1045                 :            : #define jl_typedslot_get_type(x) (((jl_value_t**)(x))[1])
    1046                 :            : #define jl_gotonode_label(x) (((intptr_t*)(x))[0])
    1047                 :            : #define jl_gotoifnot_cond(x) (((jl_value_t**)(x))[0])
    1048                 :            : #define jl_gotoifnot_label(x) (((intptr_t*)(x))[1])
    1049                 :            : #define jl_globalref_mod(s) (*(jl_module_t**)(s))
    1050                 :            : #define jl_globalref_name(s) (((jl_sym_t**)(s))[1])
    1051                 :            : #define jl_quotenode_value(x) (((jl_value_t**)x)[0])
    1052                 :            : #define jl_returnnode_value(x) (((jl_value_t**)x)[0])
    1053                 :            : 
    1054                 :            : #define jl_nparams(t)  jl_svec_len(((jl_datatype_t*)(t))->parameters)
    1055                 :            : #define jl_tparam0(t)  jl_svecref(((jl_datatype_t*)(t))->parameters, 0)
    1056                 :            : #define jl_tparam1(t)  jl_svecref(((jl_datatype_t*)(t))->parameters, 1)
    1057                 :            : #define jl_tparam(t,i) jl_svecref(((jl_datatype_t*)(t))->parameters, i)
    1058                 :            : 
    1059                 :            : // get a pointer to the data in a datatype
    1060                 :            : #define jl_data_ptr(v)  ((jl_value_t**)v)
    1061                 :            : 
    1062                 :            : #define jl_string_data(s) ((char*)s + sizeof(void*))
    1063                 :            : #define jl_string_len(s)  (*(size_t*)s)
    1064                 :            : 
    1065                 :            : #define jl_gf_mtable(f) (((jl_datatype_t*)jl_typeof(f))->name->mt)
    1066                 :            : #define jl_gf_name(f)   (jl_gf_mtable(f)->name)
    1067                 :            : 
    1068                 :            : // struct type info
    1069                 :            : JL_DLLEXPORT jl_svec_t *jl_compute_fieldtypes(jl_datatype_t *st JL_PROPAGATES_ROOT, void *stack);
    1070                 :            : #define jl_get_fieldtypes(st) ((st)->types ? (st)->types : jl_compute_fieldtypes((st), NULL))
    1071                 :  312258272 : STATIC_INLINE jl_svec_t *jl_field_names(jl_datatype_t *st) JL_NOTSAFEPOINT
    1072                 :            : {
    1073                 :  312258272 :     return st->name->names;
    1074                 :            : }
    1075                 :  195258012 : STATIC_INLINE jl_value_t *jl_field_type(jl_datatype_t *st JL_PROPAGATES_ROOT, size_t i)
    1076                 :            : {
    1077         [ +  + ]:  195258012 :     return jl_svecref(jl_get_fieldtypes(st), i);
    1078                 :            : }
    1079                 : 1650060481 : STATIC_INLINE jl_value_t *jl_field_type_concrete(jl_datatype_t *st JL_PROPAGATES_ROOT, size_t i) JL_NOTSAFEPOINT
    1080                 :            : {
    1081         [ -  + ]: 1650060481 :     assert(st->types);
    1082                 : 1650060481 :     return jl_svecref(st->types, i);
    1083                 :            : }
    1084                 :            : 
    1085                 :            : #define jl_datatype_size(t)    (((jl_datatype_t*)t)->size)
    1086                 :            : #define jl_datatype_align(t)   (((jl_datatype_t*)t)->layout->alignment)
    1087                 :            : #define jl_datatype_nbits(t)   ((((jl_datatype_t*)t)->size)*8)
    1088                 :            : #define jl_datatype_nfields(t) (((jl_datatype_t*)(t))->layout->nfields)
    1089                 :            : 
    1090                 :            : JL_DLLEXPORT void *jl_symbol_name(jl_sym_t *s);
    1091                 :            : // inline version with strong type check to detect typos in a `->name` chain
    1092                 :  547152766 : STATIC_INLINE char *jl_symbol_name_(jl_sym_t *s) JL_NOTSAFEPOINT
    1093                 :            : {
    1094                 :  547152766 :     return (char*)s + LLT_ALIGN(sizeof(jl_sym_t), sizeof(void*));
    1095                 :            : }
    1096                 :            : #define jl_symbol_name(s) jl_symbol_name_(s)
    1097                 :            : 
    1098                 : 6121860200 : static inline uint32_t jl_fielddesc_size(int8_t fielddesc_type) JL_NOTSAFEPOINT
    1099                 :            : {
    1100   [ +  -  +  - ]: 6121860200 :     assert(fielddesc_type >= 0 && fielddesc_type <= 2);
    1101                 : 6121860200 :     return 2 << fielddesc_type;
    1102                 :            :     //if (fielddesc_type == 0) {
    1103                 :            :     //    return sizeof(jl_fielddesc8_t);
    1104                 :            :     //}
    1105                 :            :     //else if (fielddesc_type == 1) {
    1106                 :            :     //    return sizeof(jl_fielddesc16_t);
    1107                 :            :     //}
    1108                 :            :     //else {
    1109                 :            :     //    return sizeof(jl_fielddesc32_t);
    1110                 :            :     //}
    1111                 :            : }
    1112                 :            : 
    1113                 :            : #define jl_dt_layout_fields(d) ((const char*)(d) + sizeof(jl_datatype_layout_t))
    1114                 : 1455183343 : static inline const char *jl_dt_layout_ptrs(const jl_datatype_layout_t *l) JL_NOTSAFEPOINT
    1115                 :            : {
    1116                 : 1455183343 :     return jl_dt_layout_fields(l) + jl_fielddesc_size(l->fielddesc_type) * l->nfields;
    1117                 :            : }
    1118                 :            : 
    1119                 :            : #define DEFINE_FIELD_ACCESSORS(f)                                             \
    1120                 :            :     static inline uint32_t jl_field_##f(jl_datatype_t *st,                    \
    1121                 :            :                                         int i) JL_NOTSAFEPOINT                \
    1122                 :            :     {                                                                         \
    1123                 :            :         const jl_datatype_layout_t *ly = st->layout;                          \
    1124                 :            :         assert(i >= 0 && (size_t)i < ly->nfields);                            \
    1125                 :            :         if (ly->fielddesc_type == 0) {                                        \
    1126                 :            :             return ((const jl_fielddesc8_t*)jl_dt_layout_fields(ly))[i].f;    \
    1127                 :            :         }                                                                     \
    1128                 :            :         else if (ly->fielddesc_type == 1) {                                   \
    1129                 :            :             return ((const jl_fielddesc16_t*)jl_dt_layout_fields(ly))[i].f;   \
    1130                 :            :         }                                                                     \
    1131                 :            :         else {                                                                \
    1132                 :            :             assert(ly->fielddesc_type == 2);                                  \
    1133                 :            :             return ((const jl_fielddesc32_t*)jl_dt_layout_fields(ly))[i].f;   \
    1134                 :            :         }                                                                     \
    1135                 :            :     }                                                                         \
    1136                 :            : 
    1137   [ +  +  +  +  : 9795431488 : DEFINE_FIELD_ACCESSORS(offset)
          +  +  +  +  -  
                      + ]
    1138   [ +  -  +  -  :   20734968 : DEFINE_FIELD_ACCESSORS(size)
          +  +  +  -  -  
                      - ]
    1139                 :            : #undef DEFINE_FIELD_ACCESSORS
    1140                 :            : 
    1141                 : 4664682704 : static inline int jl_field_isptr(jl_datatype_t *st, int i) JL_NOTSAFEPOINT
    1142                 :            : {
    1143                 : 4664682704 :     const jl_datatype_layout_t *ly = st->layout;
    1144   [ +  -  +  - ]: 4664682704 :     assert(i >= 0 && (size_t)i < ly->nfields);
    1145                 : 4664682704 :     return ((const jl_fielddesc8_t*)(jl_dt_layout_fields(ly) + jl_fielddesc_size(ly->fielddesc_type) * i))->isptr;
    1146                 :            : }
    1147                 :            : 
    1148                 :  293144013 : static inline uint32_t jl_ptr_offset(jl_datatype_t *st, int i) JL_NOTSAFEPOINT
    1149                 :            : {
    1150                 :  293144013 :     const jl_datatype_layout_t *ly = st->layout;
    1151   [ +  -  +  - ]:  293144013 :     assert(i >= 0 && (size_t)i < ly->npointers);
    1152                 :  293144013 :     const void *ptrs = jl_dt_layout_ptrs(ly);
    1153         [ +  + ]:  293144013 :     if (ly->fielddesc_type == 0) {
    1154                 :  293033931 :         return ((const uint8_t*)ptrs)[i];
    1155                 :            :     }
    1156         [ +  - ]:     110179 :     else if (ly->fielddesc_type == 1) {
    1157                 :     110179 :         return ((const uint16_t*)ptrs)[i];
    1158                 :            :     }
    1159                 :            :     else {
    1160         [ #  # ]:          0 :         assert(ly->fielddesc_type == 2);
    1161                 :          0 :         return ((const uint32_t*)ptrs)[i];
    1162                 :            :     }
    1163                 :            : }
    1164                 :            : 
    1165                 : 1454649500 : static inline int jl_field_isatomic(jl_datatype_t *st, int i) JL_NOTSAFEPOINT
    1166                 :            : {
    1167                 : 1454649500 :     const uint32_t *atomicfields = st->name->atomicfields;
    1168         [ +  + ]: 1454649500 :     if (atomicfields != NULL) {
    1169         [ +  + ]:      93637 :         if (atomicfields[i / 32] & (1 << (i % 32)))
    1170                 :      35270 :             return 1;
    1171                 :            :     }
    1172                 : 1454614600 :     return 0;
    1173                 :            : }
    1174                 :            : 
    1175                 :    3206293 : static inline int jl_field_isconst(jl_datatype_t *st, int i) JL_NOTSAFEPOINT
    1176                 :            : {
    1177                 :    3206293 :     jl_typename_t *tn = st->name;
    1178         [ +  + ]:    3206293 :     if (!tn->mutabl)
    1179                 :    2345360 :         return 1;
    1180                 :     860932 :     const uint32_t *constfields = tn->constfields;
    1181         [ +  + ]:     860932 :     if (constfields != NULL) {
    1182         [ +  + ]:      63053 :         if (constfields[i / 32] & (1 << (i % 32)))
    1183                 :       1365 :             return 1;
    1184                 :            :     }
    1185                 :     859567 :     return 0;
    1186                 :            : }
    1187                 :            : 
    1188                 :            : 
    1189                 :   16881110 : static inline int jl_is_layout_opaque(const jl_datatype_layout_t *l) JL_NOTSAFEPOINT
    1190                 :            : {
    1191   [ +  +  +  + ]:   16881110 :     return l->nfields == 0 && l->npointers > 0;
    1192                 :            : }
    1193                 :            : 
    1194                 :            : // basic predicates -----------------------------------------------------------
    1195                 :            : #define jl_is_nothing(v)     (((jl_value_t*)(v)) == ((jl_value_t*)jl_nothing))
    1196                 :            : #define jl_is_tuple(v)       (((jl_datatype_t*)jl_typeof(v))->name == jl_tuple_typename)
    1197                 :            : #define jl_is_namedtuple(v)  (((jl_datatype_t*)jl_typeof(v))->name == jl_namedtuple_typename)
    1198                 :            : #define jl_is_svec(v)        jl_typeis(v,jl_simplevector_type)
    1199                 :            : #define jl_is_simplevector(v) jl_is_svec(v)
    1200                 :            : #define jl_is_datatype(v)    jl_typeis(v,jl_datatype_type)
    1201                 :            : #define jl_is_mutable(t)     (((jl_datatype_t*)t)->name->mutabl)
    1202                 :            : #define jl_is_mutable_datatype(t) (jl_is_datatype(t) && (((jl_datatype_t*)t)->name->mutabl))
    1203                 :            : #define jl_is_immutable(t)   (!((jl_datatype_t*)t)->name->mutabl)
    1204                 :            : #define jl_is_immutable_datatype(t) (jl_is_datatype(t) && (!((jl_datatype_t*)t)->name->mutabl))
    1205                 :            : #define jl_is_uniontype(v)   jl_typeis(v,jl_uniontype_type)
    1206                 :            : #define jl_is_typevar(v)     jl_typeis(v,jl_tvar_type)
    1207                 :            : #define jl_is_unionall(v)    jl_typeis(v,jl_unionall_type)
    1208                 :            : #define jl_is_typename(v)    jl_typeis(v,jl_typename_type)
    1209                 :            : #define jl_is_int8(v)        jl_typeis(v,jl_int8_type)
    1210                 :            : #define jl_is_int16(v)       jl_typeis(v,jl_int16_type)
    1211                 :            : #define jl_is_int32(v)       jl_typeis(v,jl_int32_type)
    1212                 :            : #define jl_is_int64(v)       jl_typeis(v,jl_int64_type)
    1213                 :            : #define jl_is_uint8(v)       jl_typeis(v,jl_uint8_type)
    1214                 :            : #define jl_is_uint16(v)      jl_typeis(v,jl_uint16_type)
    1215                 :            : #define jl_is_uint32(v)      jl_typeis(v,jl_uint32_type)
    1216                 :            : #define jl_is_uint64(v)      jl_typeis(v,jl_uint64_type)
    1217                 :            : #define jl_is_bool(v)        jl_typeis(v,jl_bool_type)
    1218                 :            : #define jl_is_symbol(v)      jl_typeis(v,jl_symbol_type)
    1219                 :            : #define jl_is_ssavalue(v)    jl_typeis(v,jl_ssavalue_type)
    1220                 :            : #define jl_is_slot(v)        (jl_typeis(v,jl_slotnumber_type) || jl_typeis(v,jl_typedslot_type))
    1221                 :            : #define jl_is_expr(v)        jl_typeis(v,jl_expr_type)
    1222                 :            : #define jl_is_globalref(v)   jl_typeis(v,jl_globalref_type)
    1223                 :            : #define jl_is_gotonode(v)    jl_typeis(v,jl_gotonode_type)
    1224                 :            : #define jl_is_gotoifnot(v)   jl_typeis(v,jl_gotoifnot_type)
    1225                 :            : #define jl_is_returnnode(v)  jl_typeis(v,jl_returnnode_type)
    1226                 :            : #define jl_is_argument(v)    jl_typeis(v,jl_argument_type)
    1227                 :            : #define jl_is_pinode(v)      jl_typeis(v,jl_pinode_type)
    1228                 :            : #define jl_is_phinode(v)     jl_typeis(v,jl_phinode_type)
    1229                 :            : #define jl_is_phicnode(v)    jl_typeis(v,jl_phicnode_type)
    1230                 :            : #define jl_is_upsilonnode(v) jl_typeis(v,jl_upsilonnode_type)
    1231                 :            : #define jl_is_quotenode(v)   jl_typeis(v,jl_quotenode_type)
    1232                 :            : #define jl_is_newvarnode(v)  jl_typeis(v,jl_newvarnode_type)
    1233                 :            : #define jl_is_linenode(v)    jl_typeis(v,jl_linenumbernode_type)
    1234                 :            : #define jl_is_method_instance(v) jl_typeis(v,jl_method_instance_type)
    1235                 :            : #define jl_is_code_instance(v) jl_typeis(v,jl_code_instance_type)
    1236                 :            : #define jl_is_code_info(v)   jl_typeis(v,jl_code_info_type)
    1237                 :            : #define jl_is_method(v)      jl_typeis(v,jl_method_type)
    1238                 :            : #define jl_is_module(v)      jl_typeis(v,jl_module_type)
    1239                 :            : #define jl_is_mtable(v)      jl_typeis(v,jl_methtable_type)
    1240                 :            : #define jl_is_task(v)        jl_typeis(v,jl_task_type)
    1241                 :            : #define jl_is_string(v)      jl_typeis(v,jl_string_type)
    1242                 :            : #define jl_is_cpointer(v)    jl_is_cpointer_type(jl_typeof(v))
    1243                 :            : #define jl_is_pointer(v)     jl_is_cpointer_type(jl_typeof(v))
    1244                 :            : #define jl_is_uint8pointer(v)jl_typeis(v,jl_uint8pointer_type)
    1245                 :            : #define jl_is_llvmpointer(v) (((jl_datatype_t*)jl_typeof(v))->name == jl_llvmpointer_typename)
    1246                 :            : #define jl_is_intrinsic(v)   jl_typeis(v,jl_intrinsic_type)
    1247                 :            : #define jl_array_isbitsunion(a) (!(((jl_array_t*)(a))->flags.ptrarray) && jl_is_uniontype(jl_tparam0(jl_typeof(a))))
    1248                 :            : 
    1249                 :            : JL_DLLEXPORT int jl_subtype(jl_value_t *a, jl_value_t *b);
    1250                 :            : 
    1251                 :18543799217 : STATIC_INLINE int jl_is_kind(jl_value_t *v) JL_NOTSAFEPOINT
    1252                 :            : {
    1253         [ +  + ]:17357368020 :     return (v==(jl_value_t*)jl_uniontype_type || v==(jl_value_t*)jl_datatype_type ||
    1254   [ +  +  +  +  :35901165047 :             v==(jl_value_t*)jl_unionall_type || v==(jl_value_t*)jl_typeofbottom_type);
                   +  + ]
    1255                 :            : }
    1256                 :            : 
    1257                 :13613879418 : STATIC_INLINE int jl_is_type(jl_value_t *v) JL_NOTSAFEPOINT
    1258                 :            : {
    1259                 :13613879418 :     return jl_is_kind(jl_typeof(v));
    1260                 :            : }
    1261                 :            : 
    1262                 : 2905879173 : STATIC_INLINE int jl_is_primitivetype(void *v) JL_NOTSAFEPOINT
    1263                 :            : {
    1264         [ +  + ]: 2905847168 :     return (jl_is_datatype(v) && jl_is_immutable(v) &&
    1265         [ +  + ]: 2903961561 :             ((jl_datatype_t*)(v))->layout &&
    1266   [ +  +  +  + ]: 8195845247 :             jl_datatype_nfields(v) == 0 &&
    1267         [ +  + ]: 2540632606 :             jl_datatype_size(v) > 0);
    1268                 :            : }
    1269                 :            : 
    1270                 :   14653233 : STATIC_INLINE int jl_is_structtype(void *v) JL_NOTSAFEPOINT
    1271                 :            : {
    1272                 :   29229361 :     return (jl_is_datatype(v) &&
    1273   [ +  +  +  +  :   28653648 :             !((jl_datatype_t*)(v))->name->abstract &&
                   +  + ]
    1274                 :   28612015 :             !jl_is_primitivetype(v));
    1275                 :            : }
    1276                 :            : 
    1277                 :   52276286 : STATIC_INLINE int jl_isbits(void *t) JL_NOTSAFEPOINT // corresponding to isbits() in julia
    1278                 :            : {
    1279   [ +  +  +  + ]:   52276286 :     return (jl_is_datatype(t) && ((jl_datatype_t*)t)->isbitstype);
    1280                 :            : }
    1281                 :            : 
    1282                 :  103059395 : STATIC_INLINE int jl_is_datatype_singleton(jl_datatype_t *d) JL_NOTSAFEPOINT
    1283                 :            : {
    1284                 :  103059395 :     return (d->instance != NULL);
    1285                 :            : }
    1286                 :            : 
    1287                 :   36048510 : STATIC_INLINE int jl_is_abstracttype(void *v) JL_NOTSAFEPOINT
    1288                 :            : {
    1289   [ +  -  +  + ]:   36048510 :     return (jl_is_datatype(v) && ((jl_datatype_t*)(v))->name->abstract);
    1290                 :            : }
    1291                 :            : 
    1292                 :  214649519 : STATIC_INLINE int jl_is_array_type(void *t) JL_NOTSAFEPOINT
    1293                 :            : {
    1294         [ +  + ]:  429241418 :     return (jl_is_datatype(t) &&
    1295         [ +  + ]:  242786119 :             ((jl_datatype_t*)(t))->name == jl_array_typename);
    1296                 :            : }
    1297                 :            : 
    1298                 :  194339747 : STATIC_INLINE int jl_is_array(void *v) JL_NOTSAFEPOINT
    1299                 :            : {
    1300                 :  194339747 :     jl_value_t *t = jl_typeof(v);
    1301                 :  194339747 :     return jl_is_array_type(t);
    1302                 :            : }
    1303                 :            : 
    1304                 :            : 
    1305                 :            : STATIC_INLINE int jl_is_opaque_closure_type(void *t) JL_NOTSAFEPOINT
    1306                 :            : {
    1307                 :            :     return (jl_is_datatype(t) &&
    1308                 :            :             ((jl_datatype_t*)(t))->name == jl_opaque_closure_typename);
    1309                 :            : }
    1310                 :            : 
    1311                 :            : STATIC_INLINE int jl_is_opaque_closure(void *v) JL_NOTSAFEPOINT
    1312                 :            : {
    1313                 :            :     jl_value_t *t = jl_typeof(v);
    1314                 :            :     return jl_is_opaque_closure_type(t);
    1315                 :            : }
    1316                 :            : 
    1317                 :   15313009 : STATIC_INLINE int jl_is_cpointer_type(jl_value_t *t) JL_NOTSAFEPOINT
    1318                 :            : {
    1319         [ +  + ]:   30183627 :     return (jl_is_datatype(t) &&
    1320         [ +  + ]:   17874168 :             ((jl_datatype_t*)(t))->name == ((jl_datatype_t*)jl_pointer_type->body)->name);
    1321                 :            : }
    1322                 :            : 
    1323                 :   18295900 : STATIC_INLINE int jl_is_llvmpointer_type(jl_value_t *t) JL_NOTSAFEPOINT
    1324                 :            : {
    1325         [ +  - ]:   36591700 :     return (jl_is_datatype(t) &&
    1326         [ +  + ]:   36591700 :             ((jl_datatype_t*)(t))->name == jl_llvmpointer_typename);
    1327                 :            : }
    1328                 :            : 
    1329                 :    3435562 : STATIC_INLINE int jl_is_abstract_ref_type(jl_value_t *t) JL_NOTSAFEPOINT
    1330                 :            : {
    1331         [ +  + ]:    6871064 :     return (jl_is_datatype(t) &&
    1332         [ +  + ]:    6867412 :             ((jl_datatype_t*)(t))->name == ((jl_datatype_t*)jl_ref_type->body)->name);
    1333                 :            : }
    1334                 :            : 
    1335                 : 8759189838 : STATIC_INLINE int jl_is_tuple_type(void *t) JL_NOTSAFEPOINT
    1336                 :            : {
    1337         [ +  + ]:16970979085 :     return (jl_is_datatype(t) &&
    1338         [ +  + ]: 8223693141 :             ((jl_datatype_t*)(t))->name == jl_tuple_typename);
    1339                 :            : }
    1340                 :            : 
    1341                 :  258862474 : STATIC_INLINE int jl_is_namedtuple_type(void *t) JL_NOTSAFEPOINT
    1342                 :            : {
    1343         [ +  - ]:  517724948 :     return (jl_is_datatype(t) &&
    1344         [ +  + ]:  258862474 :             ((jl_datatype_t*)(t))->name == jl_namedtuple_typename);
    1345                 :            : }
    1346                 :            : 
    1347                 :   13961863 : STATIC_INLINE int jl_is_vecelement_type(jl_value_t* t) JL_NOTSAFEPOINT
    1348                 :            : {
    1349         [ +  + ]:   27923621 :     return (jl_is_datatype(t) &&
    1350         [ +  + ]:   27730158 :             ((jl_datatype_t*)(t))->name == jl_vecelement_typename);
    1351                 :            : }
    1352                 :            : 
    1353                 :13582996696 : STATIC_INLINE int jl_is_type_type(jl_value_t *v) JL_NOTSAFEPOINT
    1354                 :            : {
    1355         [ +  + ]:26666978430 :     return (jl_is_datatype(v) &&
    1356         [ +  + ]:13179079134 :             ((jl_datatype_t*)(v))->name == ((jl_datatype_t*)jl_type_type->body)->name);
    1357                 :            : }
    1358                 :            : 
    1359                 : 1944030000 : STATIC_INLINE int jl_is_array_zeroinit(jl_array_t *a) JL_NOTSAFEPOINT
    1360                 :            : {
    1361   [ +  +  +  + ]: 1944030000 :     if (a->flags.ptrarray || a->flags.hasptr)
    1362                 :  673147000 :         return 1;
    1363                 : 1270890000 :     jl_value_t *elty = jl_tparam0(jl_typeof(a));
    1364   [ +  +  +  + ]: 1270890000 :     return jl_is_datatype(elty) && ((jl_datatype_t*)elty)->zeroinit;
    1365                 :            : }
    1366                 :            : 
    1367                 :            : // object identity
    1368                 :            : JL_DLLEXPORT int jl_egal(const jl_value_t *a JL_MAYBE_UNROOTED, const jl_value_t *b JL_MAYBE_UNROOTED) JL_NOTSAFEPOINT;
    1369                 :            : JL_DLLEXPORT int jl_egal__bits(const jl_value_t *a JL_MAYBE_UNROOTED, const jl_value_t *b JL_MAYBE_UNROOTED, jl_datatype_t *dt) JL_NOTSAFEPOINT;
    1370                 :            : JL_DLLEXPORT int jl_egal__special(const jl_value_t *a JL_MAYBE_UNROOTED, const jl_value_t *b JL_MAYBE_UNROOTED, jl_datatype_t *dt) JL_NOTSAFEPOINT;
    1371                 :            : JL_DLLEXPORT int jl_egal__unboxed(const jl_value_t *a JL_MAYBE_UNROOTED, const jl_value_t *b JL_MAYBE_UNROOTED, jl_datatype_t *dt) JL_NOTSAFEPOINT;
    1372                 :            : JL_DLLEXPORT uintptr_t jl_object_id(jl_value_t *v) JL_NOTSAFEPOINT;
    1373                 :            : 
    1374                 : 3400295913 : STATIC_INLINE int jl_egal__unboxed_(const jl_value_t *a JL_MAYBE_UNROOTED, const jl_value_t *b JL_MAYBE_UNROOTED, jl_datatype_t *dt) JL_NOTSAFEPOINT
    1375                 :            : {
    1376         [ +  + ]: 3400295913 :     if (dt->name->mutabl) {
    1377   [ +  +  +  +  : 1331655969 :         if (dt == jl_simplevector_type || dt == jl_string_type || dt == jl_datatype_type)
                   +  + ]
    1378                 :  857913687 :             return jl_egal__special(a, b, dt);
    1379                 :  473742530 :         return 0;
    1380                 :            :     }
    1381                 : 2068635864 :     return jl_egal__bits(a, b, dt);
    1382                 :            : }
    1383                 :            : 
    1384                 : 7662277264 : STATIC_INLINE int jl_egal_(const jl_value_t *a JL_MAYBE_UNROOTED, const jl_value_t *b JL_MAYBE_UNROOTED) JL_NOTSAFEPOINT
    1385                 :            : {
    1386         [ +  + ]: 7662277264 :     if (a == b)
    1387                 :  734371916 :         return 1;
    1388                 : 6927903122 :     jl_datatype_t *dt = (jl_datatype_t*)jl_typeof(a);
    1389         [ +  + ]: 6927903122 :     if (dt != (jl_datatype_t*)jl_typeof(b))
    1390                 : 4830859269 :         return 0;
    1391                 : 2097043913 :     return jl_egal__unboxed_(a, b, dt);
    1392                 :            : }
    1393                 :            : #define jl_egal(a, b) jl_egal_((a), (b))
    1394                 :            : 
    1395                 :            : // type predicates and basic operations
    1396                 :            : JL_DLLEXPORT int jl_type_equality_is_identity(jl_value_t *t1, jl_value_t *t2) JL_NOTSAFEPOINT;
    1397                 :            : JL_DLLEXPORT int jl_has_free_typevars(jl_value_t *v) JL_NOTSAFEPOINT;
    1398                 :            : JL_DLLEXPORT int jl_has_typevar(jl_value_t *t, jl_tvar_t *v) JL_NOTSAFEPOINT;
    1399                 :            : JL_DLLEXPORT int jl_has_typevar_from_unionall(jl_value_t *t, jl_unionall_t *ua);
    1400                 :            : JL_DLLEXPORT int jl_subtype_env_size(jl_value_t *t);
    1401                 :            : JL_DLLEXPORT int jl_subtype_env(jl_value_t *x, jl_value_t *y, jl_value_t **env, int envsz);
    1402                 :            : JL_DLLEXPORT int jl_isa(jl_value_t *a, jl_value_t *t);
    1403                 :            : JL_DLLEXPORT int jl_types_equal(jl_value_t *a, jl_value_t *b);
    1404                 :            : JL_DLLEXPORT int jl_is_not_broken_subtype(jl_value_t *a, jl_value_t *b);
    1405                 :            : JL_DLLEXPORT jl_value_t *jl_type_union(jl_value_t **ts, size_t n);
    1406                 :            : JL_DLLEXPORT jl_value_t *jl_type_intersection(jl_value_t *a, jl_value_t *b);
    1407                 :            : JL_DLLEXPORT int jl_has_empty_intersection(jl_value_t *x, jl_value_t *y);
    1408                 :            : JL_DLLEXPORT jl_value_t *jl_type_unionall(jl_tvar_t *v, jl_value_t *body);
    1409                 :            : JL_DLLEXPORT const char *jl_typename_str(jl_value_t *v) JL_NOTSAFEPOINT;
    1410                 :            : JL_DLLEXPORT const char *jl_typeof_str(jl_value_t *v) JL_NOTSAFEPOINT;
    1411                 :            : JL_DLLEXPORT int jl_type_morespecific(jl_value_t *a, jl_value_t *b);
    1412                 :            : 
    1413                 :   31248398 : STATIC_INLINE int jl_is_dispatch_tupletype(jl_value_t *v) JL_NOTSAFEPOINT
    1414                 :            : {
    1415   [ +  +  +  + ]:   31248398 :     return jl_is_datatype(v) && ((jl_datatype_t*)v)->isdispatchtuple;
    1416                 :            : }
    1417                 :            : 
    1418                 : 9834889793 : STATIC_INLINE int jl_is_concrete_type(jl_value_t *v) JL_NOTSAFEPOINT
    1419                 :            : {
    1420   [ +  +  +  + ]: 9834889793 :     return jl_is_datatype(v) && ((jl_datatype_t*)v)->isconcretetype;
    1421                 :            : }
    1422                 :            : 
    1423                 :            : JL_DLLEXPORT int jl_isa_compileable_sig(jl_tupletype_t *type, jl_method_t *definition);
    1424                 :            : 
    1425                 :            : // type constructors
    1426                 :            : JL_DLLEXPORT jl_typename_t *jl_new_typename_in(jl_sym_t *name, jl_module_t *inmodule, int abstract, int mutabl);
    1427                 :            : JL_DLLEXPORT jl_tvar_t *jl_new_typevar(jl_sym_t *name, jl_value_t *lb, jl_value_t *ub);
    1428                 :            : JL_DLLEXPORT jl_value_t *jl_instantiate_unionall(jl_unionall_t *u, jl_value_t *p);
    1429                 :            : JL_DLLEXPORT jl_value_t *jl_apply_type(jl_value_t *tc, jl_value_t **params, size_t n);
    1430                 :            : JL_DLLEXPORT jl_value_t *jl_apply_type1(jl_value_t *tc, jl_value_t *p1);
    1431                 :            : JL_DLLEXPORT jl_value_t *jl_apply_type2(jl_value_t *tc, jl_value_t *p1, jl_value_t *p2);
    1432                 :            : JL_DLLEXPORT jl_datatype_t *jl_apply_modify_type(jl_value_t *dt);
    1433                 :            : JL_DLLEXPORT jl_datatype_t *jl_apply_cmpswap_type(jl_value_t *dt);
    1434                 :            : JL_DLLEXPORT jl_tupletype_t *jl_apply_tuple_type(jl_svec_t *params);
    1435                 :            : JL_DLLEXPORT jl_tupletype_t *jl_apply_tuple_type_v(jl_value_t **p, size_t np);
    1436                 :            : JL_DLLEXPORT jl_datatype_t *jl_new_datatype(jl_sym_t *name,
    1437                 :            :                                             jl_module_t *module,
    1438                 :            :                                             jl_datatype_t *super,
    1439                 :            :                                             jl_svec_t *parameters,
    1440                 :            :                                             jl_svec_t *fnames,
    1441                 :            :                                             jl_svec_t *ftypes,
    1442                 :            :                                             jl_svec_t *fattrs,
    1443                 :            :                                             int abstract, int mutabl,
    1444                 :            :                                             int ninitialized);
    1445                 :            : JL_DLLEXPORT jl_datatype_t *jl_new_primitivetype(jl_value_t *name,
    1446                 :            :                                                  jl_module_t *module,
    1447                 :            :                                                  jl_datatype_t *super,
    1448                 :            :                                                  jl_svec_t *parameters, size_t nbits);
    1449                 :            : 
    1450                 :            : // constructors
    1451                 :            : JL_DLLEXPORT jl_value_t *jl_new_bits(jl_value_t *bt, const void *src);
    1452                 :            : JL_DLLEXPORT jl_value_t *jl_atomic_new_bits(jl_value_t *dt, const char *src);
    1453                 :            : JL_DLLEXPORT void jl_atomic_store_bits(char *dst, const jl_value_t *src, int nb);
    1454                 :            : JL_DLLEXPORT jl_value_t *jl_atomic_swap_bits(jl_value_t *dt, char *dst, const jl_value_t *src, int nb);
    1455                 :            : JL_DLLEXPORT int jl_atomic_bool_cmpswap_bits(char *dst, const jl_value_t *expected, const jl_value_t *src, int nb);
    1456                 :            : JL_DLLEXPORT jl_value_t *jl_atomic_cmpswap_bits(jl_datatype_t *dt, jl_datatype_t *rettype, char *dst, const jl_value_t *expected, const jl_value_t *src, int nb);
    1457                 :            : JL_DLLEXPORT jl_value_t *jl_new_struct(jl_datatype_t *type, ...);
    1458                 :            : JL_DLLEXPORT jl_value_t *jl_new_structv(jl_datatype_t *type, jl_value_t **args, uint32_t na);
    1459                 :            : JL_DLLEXPORT jl_value_t *jl_new_structt(jl_datatype_t *type, jl_value_t *tup);
    1460                 :            : JL_DLLEXPORT jl_value_t *jl_new_struct_uninit(jl_datatype_t *type);
    1461                 :            : JL_DLLEXPORT jl_method_instance_t *jl_new_method_instance_uninit(void);
    1462                 :            : JL_DLLEXPORT jl_svec_t *jl_svec(size_t n, ...) JL_MAYBE_UNROOTED;
    1463                 :            : JL_DLLEXPORT jl_svec_t *jl_svec1(void *a);
    1464                 :            : JL_DLLEXPORT jl_svec_t *jl_svec2(void *a, void *b);
    1465                 :            : JL_DLLEXPORT jl_svec_t *jl_alloc_svec(size_t n);
    1466                 :            : JL_DLLEXPORT jl_svec_t *jl_alloc_svec_uninit(size_t n);
    1467                 :            : JL_DLLEXPORT jl_svec_t *jl_svec_copy(jl_svec_t *a);
    1468                 :            : JL_DLLEXPORT jl_svec_t *jl_svec_fill(size_t n, jl_value_t *x);
    1469                 :            : JL_DLLEXPORT jl_value_t *jl_tupletype_fill(size_t n, jl_value_t *v);
    1470                 :            : JL_DLLEXPORT jl_sym_t *jl_symbol(const char *str) JL_NOTSAFEPOINT;
    1471                 :            : JL_DLLEXPORT jl_sym_t *jl_symbol_lookup(const char *str) JL_NOTSAFEPOINT;
    1472                 :            : JL_DLLEXPORT jl_sym_t *jl_symbol_n(const char *str, size_t len) JL_NOTSAFEPOINT;
    1473                 :            : JL_DLLEXPORT jl_sym_t *jl_gensym(void);
    1474                 :            : JL_DLLEXPORT jl_sym_t *jl_tagged_gensym(const char *str, size_t len);
    1475                 :            : JL_DLLEXPORT jl_sym_t *jl_get_root_symbol(void);
    1476                 :            : JL_DLLEXPORT jl_value_t *jl_generic_function_def(jl_sym_t *name,
    1477                 :            :                                                  jl_module_t *module,
    1478                 :            :                                                  _Atomic(jl_value_t*) *bp, jl_value_t *bp_owner,
    1479                 :            :                                                  jl_binding_t *bnd);
    1480                 :            : JL_DLLEXPORT jl_method_t *jl_method_def(jl_svec_t *argdata, jl_methtable_t *mt, jl_code_info_t *f, jl_module_t *module);
    1481                 :            : JL_DLLEXPORT jl_code_info_t *jl_code_for_staged(jl_method_instance_t *linfo);
    1482                 :            : JL_DLLEXPORT jl_code_info_t *jl_copy_code_info(jl_code_info_t *src);
    1483                 :            : JL_DLLEXPORT size_t jl_get_world_counter(void) JL_NOTSAFEPOINT;
    1484                 :            : JL_DLLEXPORT jl_function_t *jl_get_kwsorter(jl_value_t *ty);
    1485                 :            : JL_DLLEXPORT jl_value_t *jl_box_bool(int8_t x) JL_NOTSAFEPOINT;
    1486                 :            : JL_DLLEXPORT jl_value_t *jl_box_int8(int8_t x) JL_NOTSAFEPOINT;
    1487                 :            : JL_DLLEXPORT jl_value_t *jl_box_uint8(uint8_t x) JL_NOTSAFEPOINT;
    1488                 :            : JL_DLLEXPORT jl_value_t *jl_box_int16(int16_t x);
    1489                 :            : JL_DLLEXPORT jl_value_t *jl_box_uint16(uint16_t x);
    1490                 :            : JL_DLLEXPORT jl_value_t *jl_box_int32(int32_t x);
    1491                 :            : JL_DLLEXPORT jl_value_t *jl_box_uint32(uint32_t x);
    1492                 :            : JL_DLLEXPORT jl_value_t *jl_box_char(uint32_t x);
    1493                 :            : JL_DLLEXPORT jl_value_t *jl_box_int64(int64_t x);
    1494                 :            : JL_DLLEXPORT jl_value_t *jl_box_uint64(uint64_t x);
    1495                 :            : JL_DLLEXPORT jl_value_t *jl_box_float32(float x);
    1496                 :            : JL_DLLEXPORT jl_value_t *jl_box_float64(double x);
    1497                 :            : JL_DLLEXPORT jl_value_t *jl_box_voidpointer(void *x);
    1498                 :            : JL_DLLEXPORT jl_value_t *jl_box_uint8pointer(uint8_t *x);
    1499                 :            : JL_DLLEXPORT jl_value_t *jl_box_ssavalue(size_t x);
    1500                 :            : JL_DLLEXPORT jl_value_t *jl_box_slotnumber(size_t x);
    1501                 :            : JL_DLLEXPORT int8_t jl_unbox_bool(jl_value_t *v) JL_NOTSAFEPOINT;
    1502                 :            : JL_DLLEXPORT int8_t jl_unbox_int8(jl_value_t *v) JL_NOTSAFEPOINT;
    1503                 :            : JL_DLLEXPORT uint8_t jl_unbox_uint8(jl_value_t *v) JL_NOTSAFEPOINT;
    1504                 :            : JL_DLLEXPORT int16_t jl_unbox_int16(jl_value_t *v) JL_NOTSAFEPOINT;
    1505                 :            : JL_DLLEXPORT uint16_t jl_unbox_uint16(jl_value_t *v) JL_NOTSAFEPOINT;
    1506                 :            : JL_DLLEXPORT int32_t jl_unbox_int32(jl_value_t *v) JL_NOTSAFEPOINT;
    1507                 :            : JL_DLLEXPORT uint32_t jl_unbox_uint32(jl_value_t *v) JL_NOTSAFEPOINT;
    1508                 :            : JL_DLLEXPORT int64_t jl_unbox_int64(jl_value_t *v) JL_NOTSAFEPOINT;
    1509                 :            : JL_DLLEXPORT uint64_t jl_unbox_uint64(jl_value_t *v) JL_NOTSAFEPOINT;
    1510                 :            : JL_DLLEXPORT float jl_unbox_float32(jl_value_t *v) JL_NOTSAFEPOINT;
    1511                 :            : JL_DLLEXPORT double jl_unbox_float64(jl_value_t *v) JL_NOTSAFEPOINT;
    1512                 :            : JL_DLLEXPORT void *jl_unbox_voidpointer(jl_value_t *v) JL_NOTSAFEPOINT;
    1513                 :            : JL_DLLEXPORT uint8_t *jl_unbox_uint8pointer(jl_value_t *v) JL_NOTSAFEPOINT;
    1514                 :            : 
    1515                 :            : JL_DLLEXPORT int jl_get_size(jl_value_t *val, size_t *pnt);
    1516                 :            : 
    1517                 :            : #ifdef _P64
    1518                 :            : #define jl_box_long(x)   jl_box_int64(x)
    1519                 :            : #define jl_box_ulong(x)  jl_box_uint64(x)
    1520                 :            : #define jl_unbox_long(x) jl_unbox_int64(x)
    1521                 :            : #define jl_unbox_ulong(x) jl_unbox_uint64(x)
    1522                 :            : #define jl_is_long(x)    jl_is_int64(x)
    1523                 :            : #define jl_is_ulong(x)   jl_is_uint64(x)
    1524                 :            : #define jl_long_type     jl_int64_type
    1525                 :            : #define jl_ulong_type    jl_uint64_type
    1526                 :            : #else
    1527                 :            : #define jl_box_long(x)   jl_box_int32(x)
    1528                 :            : #define jl_box_ulong(x)  jl_box_uint32(x)
    1529                 :            : #define jl_unbox_long(x) jl_unbox_int32(x)
    1530                 :            : #define jl_unbox_ulong(x) jl_unbox_uint32(x)
    1531                 :            : #define jl_is_long(x)    jl_is_int32(x)
    1532                 :            : #define jl_is_ulong(x)   jl_is_uint32(x)
    1533                 :            : #define jl_long_type     jl_int32_type
    1534                 :            : #define jl_ulong_type    jl_uint32_type
    1535                 :            : #endif
    1536                 :            : 
    1537                 :            : // structs
    1538                 :            : JL_DLLEXPORT int         jl_field_index(jl_datatype_t *t, jl_sym_t *fld, int err);
    1539                 :            : JL_DLLEXPORT jl_value_t *jl_get_nth_field(jl_value_t *v, size_t i);
    1540                 :            : // Like jl_get_nth_field above, but asserts if it needs to allocate
    1541                 :            : JL_DLLEXPORT jl_value_t *jl_get_nth_field_noalloc(jl_value_t *v JL_PROPAGATES_ROOT, size_t i) JL_NOTSAFEPOINT;
    1542                 :            : JL_DLLEXPORT jl_value_t *jl_get_nth_field_checked(jl_value_t *v, size_t i);
    1543                 :            : JL_DLLEXPORT void        jl_set_nth_field(jl_value_t *v, size_t i, jl_value_t *rhs) JL_NOTSAFEPOINT;
    1544                 :            : JL_DLLEXPORT int         jl_field_isdefined(jl_value_t *v, size_t i) JL_NOTSAFEPOINT;
    1545                 :            : JL_DLLEXPORT jl_value_t *jl_get_field(jl_value_t *o, const char *fld);
    1546                 :            : JL_DLLEXPORT jl_value_t *jl_value_ptr(jl_value_t *a);
    1547                 :            : int jl_uniontype_size(jl_value_t *ty, size_t *sz);
    1548                 :            : JL_DLLEXPORT int jl_islayout_inline(jl_value_t *eltype, size_t *fsz, size_t *al);
    1549                 :            : 
    1550                 :            : // arrays
    1551                 :            : JL_DLLEXPORT jl_array_t *jl_new_array(jl_value_t *atype, jl_value_t *dims);
    1552                 :            : JL_DLLEXPORT jl_array_t *jl_reshape_array(jl_value_t *atype, jl_array_t *data,
    1553                 :            :                                           jl_value_t *dims);
    1554                 :            : JL_DLLEXPORT jl_array_t *jl_ptr_to_array_1d(jl_value_t *atype, void *data,
    1555                 :            :                                             size_t nel, int own_buffer);
    1556                 :            : JL_DLLEXPORT jl_array_t *jl_ptr_to_array(jl_value_t *atype, void *data,
    1557                 :            :                                          jl_value_t *dims, int own_buffer);
    1558                 :            : 
    1559                 :            : JL_DLLEXPORT jl_array_t *jl_alloc_array_1d(jl_value_t *atype, size_t nr);
    1560                 :            : JL_DLLEXPORT jl_array_t *jl_alloc_array_2d(jl_value_t *atype, size_t nr,
    1561                 :            :                                            size_t nc);
    1562                 :            : JL_DLLEXPORT jl_array_t *jl_alloc_array_3d(jl_value_t *atype, size_t nr,
    1563                 :            :                                            size_t nc, size_t z);
    1564                 :            : JL_DLLEXPORT jl_array_t *jl_pchar_to_array(const char *str, size_t len);
    1565                 :            : JL_DLLEXPORT jl_value_t *jl_pchar_to_string(const char *str, size_t len);
    1566                 :            : JL_DLLEXPORT jl_value_t *jl_cstr_to_string(const char *str);
    1567                 :            : JL_DLLEXPORT jl_value_t *jl_alloc_string(size_t len);
    1568                 :            : JL_DLLEXPORT jl_value_t *jl_array_to_string(jl_array_t *a);
    1569                 :            : JL_DLLEXPORT jl_array_t *jl_alloc_vec_any(size_t n);
    1570                 :            : JL_DLLEXPORT jl_value_t *jl_arrayref(jl_array_t *a, size_t i);  // 0-indexed
    1571                 :            : JL_DLLEXPORT jl_value_t *jl_ptrarrayref(jl_array_t *a JL_PROPAGATES_ROOT, size_t i) JL_NOTSAFEPOINT;  // 0-indexed
    1572                 :            : JL_DLLEXPORT void jl_arrayset(jl_array_t *a JL_ROOTING_ARGUMENT, jl_value_t *v JL_ROOTED_ARGUMENT JL_MAYBE_UNROOTED, size_t i);  // 0-indexed
    1573                 :            : JL_DLLEXPORT void jl_arrayunset(jl_array_t *a, size_t i);  // 0-indexed
    1574                 :            : JL_DLLEXPORT int jl_array_isassigned(jl_array_t *a, size_t i);  // 0-indexed
    1575                 :            : JL_DLLEXPORT void jl_array_grow_end(jl_array_t *a, size_t inc);
    1576                 :            : JL_DLLEXPORT void jl_array_del_end(jl_array_t *a, size_t dec);
    1577                 :            : JL_DLLEXPORT void jl_array_grow_beg(jl_array_t *a, size_t inc);
    1578                 :            : JL_DLLEXPORT void jl_array_del_beg(jl_array_t *a, size_t dec);
    1579                 :            : JL_DLLEXPORT void jl_array_sizehint(jl_array_t *a, size_t sz);
    1580                 :            : JL_DLLEXPORT void jl_array_ptr_1d_push(jl_array_t *a, jl_value_t *item);
    1581                 :            : JL_DLLEXPORT void jl_array_ptr_1d_append(jl_array_t *a, jl_array_t *a2);
    1582                 :            : JL_DLLEXPORT jl_value_t *jl_apply_array_type(jl_value_t *type, size_t dim);
    1583                 :            : JL_DLLEXPORT int jl_array_validate_dims(size_t *nel, size_t *tot, uint32_t ndims, size_t *dims, size_t elsz);
    1584                 :            : // property access
    1585                 :            : JL_DLLEXPORT void *jl_array_ptr(jl_array_t *a);
    1586                 :            : JL_DLLEXPORT void *jl_array_eltype(jl_value_t *a);
    1587                 :            : JL_DLLEXPORT int jl_array_rank(jl_value_t *a);
    1588                 :            : JL_DLLEXPORT size_t jl_array_size(jl_value_t *a, int d);
    1589                 :            : 
    1590                 :            : // strings
    1591                 :            : JL_DLLEXPORT const char *jl_string_ptr(jl_value_t *s);
    1592                 :            : 
    1593                 :            : // modules and global variables
    1594                 :            : extern JL_DLLEXPORT jl_module_t *jl_main_module JL_GLOBALLY_ROOTED;
    1595                 :            : extern JL_DLLEXPORT jl_module_t *jl_core_module JL_GLOBALLY_ROOTED;
    1596                 :            : extern JL_DLLEXPORT jl_module_t *jl_base_module JL_GLOBALLY_ROOTED;
    1597                 :            : extern JL_DLLEXPORT jl_module_t *jl_top_module JL_GLOBALLY_ROOTED;
    1598                 :            : JL_DLLEXPORT jl_module_t *jl_new_module(jl_sym_t *name);
    1599                 :            : JL_DLLEXPORT void jl_set_module_nospecialize(jl_module_t *self, int on);
    1600                 :            : JL_DLLEXPORT void jl_set_module_optlevel(jl_module_t *self, int lvl);
    1601                 :            : JL_DLLEXPORT int jl_get_module_optlevel(jl_module_t *m);
    1602                 :            : JL_DLLEXPORT void jl_set_module_compile(jl_module_t *self, int value);
    1603                 :            : JL_DLLEXPORT int jl_get_module_compile(jl_module_t *m);
    1604                 :            : JL_DLLEXPORT void jl_set_module_infer(jl_module_t *self, int value);
    1605                 :            : JL_DLLEXPORT int jl_get_module_infer(jl_module_t *m);
    1606                 :            : JL_DLLEXPORT void jl_set_module_max_methods(jl_module_t *self, int value);
    1607                 :            : JL_DLLEXPORT int jl_get_module_max_methods(jl_module_t *m);
    1608                 :            : // get binding for reading
    1609                 :            : JL_DLLEXPORT jl_binding_t *jl_get_binding(jl_module_t *m JL_PROPAGATES_ROOT, jl_sym_t *var);
    1610                 :            : JL_DLLEXPORT jl_binding_t *jl_get_binding_or_error(jl_module_t *m, jl_sym_t *var);
    1611                 :            : JL_DLLEXPORT jl_value_t *jl_module_globalref(jl_module_t *m, jl_sym_t *var);
    1612                 :            : JL_DLLEXPORT jl_value_t *jl_binding_type(jl_module_t *m, jl_sym_t *var);
    1613                 :            : // get binding for assignment
    1614                 :            : JL_DLLEXPORT jl_binding_t *jl_get_binding_wr(jl_module_t *m JL_PROPAGATES_ROOT, jl_sym_t *var, int alloc);
    1615                 :            : JL_DLLEXPORT jl_binding_t *jl_get_binding_wr_or_error(jl_module_t *m JL_PROPAGATES_ROOT, jl_sym_t *var);
    1616                 :            : JL_DLLEXPORT jl_binding_t *jl_get_binding_for_method_def(jl_module_t *m JL_PROPAGATES_ROOT, jl_sym_t *var);
    1617                 :            : JL_DLLEXPORT int jl_boundp(jl_module_t *m, jl_sym_t *var);
    1618                 :            : JL_DLLEXPORT int jl_defines_or_exports_p(jl_module_t *m, jl_sym_t *var);
    1619                 :            : JL_DLLEXPORT int jl_binding_resolved_p(jl_module_t *m, jl_sym_t *var);
    1620                 :            : JL_DLLEXPORT int jl_is_const(jl_module_t *m, jl_sym_t *var);
    1621                 :            : JL_DLLEXPORT jl_value_t *jl_get_global(jl_module_t *m JL_PROPAGATES_ROOT, jl_sym_t *var);
    1622                 :            : JL_DLLEXPORT void jl_set_const(jl_module_t *m JL_ROOTING_ARGUMENT, jl_sym_t *var, jl_value_t *val JL_ROOTED_ARGUMENT);
    1623                 :            : JL_DLLEXPORT void jl_checked_assignment(jl_binding_t *b, jl_value_t *rhs JL_MAYBE_UNROOTED);
    1624                 :            : JL_DLLEXPORT void jl_declare_constant(jl_binding_t *b);
    1625                 :            : JL_DLLEXPORT void jl_module_using(jl_module_t *to, jl_module_t *from);
    1626                 :            : JL_DLLEXPORT void jl_module_use(jl_module_t *to, jl_module_t *from, jl_sym_t *s);
    1627                 :            : JL_DLLEXPORT void jl_module_use_as(jl_module_t *to, jl_module_t *from, jl_sym_t *s, jl_sym_t *asname);
    1628                 :            : JL_DLLEXPORT void jl_module_import(jl_module_t *to, jl_module_t *from, jl_sym_t *s);
    1629                 :            : JL_DLLEXPORT void jl_module_import_as(jl_module_t *to, jl_module_t *from, jl_sym_t *s, jl_sym_t *asname);
    1630                 :            : JL_DLLEXPORT void jl_module_export(jl_module_t *from, jl_sym_t *s);
    1631                 :            : JL_DLLEXPORT int jl_is_imported(jl_module_t *m, jl_sym_t *s);
    1632                 :            : JL_DLLEXPORT int jl_module_exports_p(jl_module_t *m, jl_sym_t *var);
    1633                 :            : JL_DLLEXPORT void jl_add_standard_imports(jl_module_t *m);
    1634                 :          0 : STATIC_INLINE jl_function_t *jl_get_function(jl_module_t *m, const char *name)
    1635                 :            : {
    1636                 :          0 :     return (jl_function_t*)jl_get_global(m, jl_symbol(name));
    1637                 :            : }
    1638                 :            : 
    1639                 :            : // eq hash tables
    1640                 :            : JL_DLLEXPORT jl_array_t *jl_eqtable_put(jl_array_t *h, jl_value_t *key, jl_value_t *val, int *inserted);
    1641                 :            : JL_DLLEXPORT jl_value_t *jl_eqtable_get(jl_array_t *h, jl_value_t *key, jl_value_t *deflt) JL_NOTSAFEPOINT;
    1642                 :            : 
    1643                 :            : // system information
    1644                 :            : JL_DLLEXPORT int jl_errno(void) JL_NOTSAFEPOINT;
    1645                 :            : JL_DLLEXPORT void jl_set_errno(int e) JL_NOTSAFEPOINT;
    1646                 :            : JL_DLLEXPORT int32_t jl_stat(const char *path, char *statbuf) JL_NOTSAFEPOINT;
    1647                 :            : JL_DLLEXPORT int jl_cpu_threads(void) JL_NOTSAFEPOINT;
    1648                 :            : JL_DLLEXPORT int jl_effective_threads(void) JL_NOTSAFEPOINT;
    1649                 :            : JL_DLLEXPORT long jl_getpagesize(void) JL_NOTSAFEPOINT;
    1650                 :            : JL_DLLEXPORT long jl_getallocationgranularity(void) JL_NOTSAFEPOINT;
    1651                 :            : JL_DLLEXPORT int jl_is_debugbuild(void) JL_NOTSAFEPOINT;
    1652                 :            : JL_DLLEXPORT jl_sym_t *jl_get_UNAME(void) JL_NOTSAFEPOINT;
    1653                 :            : JL_DLLEXPORT jl_sym_t *jl_get_ARCH(void) JL_NOTSAFEPOINT;
    1654                 :            : JL_DLLEXPORT jl_value_t *jl_get_libllvm(void) JL_NOTSAFEPOINT;
    1655                 :            : extern JL_DLLIMPORT int jl_n_threadpools;
    1656                 :            : extern JL_DLLIMPORT int jl_n_threads;
    1657                 :            : extern JL_DLLIMPORT int *jl_n_threads_per_pool;
    1658                 :            : 
    1659                 :            : // environment entries
    1660                 :            : JL_DLLEXPORT jl_value_t *jl_environ(int i);
    1661                 :            : 
    1662                 :            : // throwing common exceptions
    1663                 :            : JL_DLLEXPORT jl_value_t *jl_vexceptionf(jl_datatype_t *exception_type,
    1664                 :            :                                         const char *fmt, va_list args);
    1665                 :            : JL_DLLEXPORT void JL_NORETURN jl_error(const char *str);
    1666                 :            : JL_DLLEXPORT void JL_NORETURN jl_errorf(const char *fmt, ...);
    1667                 :            : JL_DLLEXPORT void JL_NORETURN jl_exceptionf(jl_datatype_t *ty,
    1668                 :            :                                             const char *fmt, ...);
    1669                 :            : JL_DLLEXPORT void JL_NORETURN jl_too_few_args(const char *fname, int min);
    1670                 :            : JL_DLLEXPORT void JL_NORETURN jl_too_many_args(const char *fname, int max);
    1671                 :            : JL_DLLEXPORT void JL_NORETURN jl_type_error(const char *fname,
    1672                 :            :                                             jl_value_t *expected JL_MAYBE_UNROOTED,
    1673                 :            :                                             jl_value_t *got JL_MAYBE_UNROOTED);
    1674                 :            : JL_DLLEXPORT void JL_NORETURN jl_type_error_rt(const char *fname,
    1675                 :            :                                                const char *context,
    1676                 :            :                                                jl_value_t *ty JL_MAYBE_UNROOTED,
    1677                 :            :                                                jl_value_t *got JL_MAYBE_UNROOTED);
    1678                 :            : JL_DLLEXPORT void JL_NORETURN jl_undefined_var_error(jl_sym_t *var);
    1679                 :            : JL_DLLEXPORT void JL_NORETURN jl_atomic_error(char *str);
    1680                 :            : JL_DLLEXPORT void JL_NORETURN jl_bounds_error(jl_value_t *v JL_MAYBE_UNROOTED,
    1681                 :            :                                               jl_value_t *t JL_MAYBE_UNROOTED);
    1682                 :            : JL_DLLEXPORT void JL_NORETURN jl_bounds_error_v(jl_value_t *v JL_MAYBE_UNROOTED,
    1683                 :            :                                                 jl_value_t **idxs, size_t nidxs);
    1684                 :            : JL_DLLEXPORT void JL_NORETURN jl_bounds_error_int(jl_value_t *v JL_MAYBE_UNROOTED,
    1685                 :            :                                                   size_t i);
    1686                 :            : JL_DLLEXPORT void JL_NORETURN jl_bounds_error_tuple_int(jl_value_t **v,
    1687                 :            :                                                         size_t nv, size_t i);
    1688                 :            : JL_DLLEXPORT void JL_NORETURN jl_bounds_error_unboxed_int(void *v, jl_value_t *vt, size_t i);
    1689                 :            : JL_DLLEXPORT void JL_NORETURN jl_bounds_error_ints(jl_value_t *v JL_MAYBE_UNROOTED,
    1690                 :            :                                                    size_t *idxs, size_t nidxs);
    1691                 :            : JL_DLLEXPORT void JL_NORETURN jl_eof_error(void);
    1692                 :            : 
    1693                 :            : // Return the exception currently being handled, or `jl_nothing`.
    1694                 :            : //
    1695                 :            : // The catch scope is determined dynamically so this works in functions called
    1696                 :            : // from a catch block.  The returned value is gc rooted until we exit the
    1697                 :            : // enclosing JL_CATCH.
    1698                 :            : // FIXME: Teach the static analyzer about this rather than using
    1699                 :            : // JL_GLOBALLY_ROOTED which is far too optimistic.
    1700                 :            : JL_DLLEXPORT jl_value_t *jl_current_exception(void) JL_GLOBALLY_ROOTED JL_NOTSAFEPOINT;
    1701                 :            : JL_DLLEXPORT jl_value_t *jl_exception_occurred(void);
    1702                 :            : JL_DLLEXPORT void jl_exception_clear(void) JL_NOTSAFEPOINT;
    1703                 :            : 
    1704                 :            : #define JL_NARGS(fname, min, max)                               \
    1705                 :            :     if (nargs < min) jl_too_few_args(#fname, min);              \
    1706                 :            :     else if (nargs > max) jl_too_many_args(#fname, max);
    1707                 :            : 
    1708                 :            : #define JL_NARGSV(fname, min)                           \
    1709                 :            :     if (nargs < min) jl_too_few_args(#fname, min);
    1710                 :            : 
    1711                 :            : #define JL_TYPECHK(fname, type, v)                                 \
    1712                 :            :     if (!jl_is_##type(v)) {                                        \
    1713                 :            :         jl_type_error(#fname, (jl_value_t*)jl_##type##_type, (v)); \
    1714                 :            :     }
    1715                 :            : #define JL_TYPECHKS(fname, type, v)                                     \
    1716                 :            :     if (!jl_is_##type(v)) {                                             \
    1717                 :            :         jl_type_error(fname, (jl_value_t*)jl_##type##_type, (v));       \
    1718                 :            :     }
    1719                 :            : 
    1720                 :            : // initialization functions
    1721                 :            : typedef enum {
    1722                 :            :     JL_IMAGE_CWD = 0,
    1723                 :            :     JL_IMAGE_JULIA_HOME = 1,
    1724                 :            :     //JL_IMAGE_LIBJULIA = 2,
    1725                 :            : } JL_IMAGE_SEARCH;
    1726                 :            : 
    1727                 :            : JL_DLLEXPORT const char *jl_get_libdir(void);
    1728                 :            : JL_DLLEXPORT void julia_init(JL_IMAGE_SEARCH rel);
    1729                 :            : JL_DLLEXPORT void jl_init(void);
    1730                 :            : JL_DLLEXPORT void jl_init_with_image(const char *julia_bindir,
    1731                 :            :                                      const char *image_path);
    1732                 :            : JL_DLLEXPORT const char *jl_get_default_sysimg_path(void);
    1733                 :            : JL_DLLEXPORT int jl_is_initialized(void);
    1734                 :            : JL_DLLEXPORT void jl_atexit_hook(int status);
    1735                 :            : JL_DLLEXPORT void jl_postoutput_hook(void);
    1736                 :            : JL_DLLEXPORT void JL_NORETURN jl_exit(int status);
    1737                 :            : JL_DLLEXPORT const char *jl_pathname_for_handle(void *handle);
    1738                 :            : 
    1739                 :            : JL_DLLEXPORT int jl_deserialize_verify_header(ios_t *s);
    1740                 :            : JL_DLLEXPORT void jl_preload_sysimg_so(const char *fname);
    1741                 :            : JL_DLLEXPORT void jl_set_sysimg_so(void *handle);
    1742                 :            : JL_DLLEXPORT ios_t *jl_create_system_image(void *);
    1743                 :            : JL_DLLEXPORT void jl_save_system_image(const char *fname);
    1744                 :            : JL_DLLEXPORT void jl_restore_system_image(const char *fname);
    1745                 :            : JL_DLLEXPORT void jl_restore_system_image_data(const char *buf, size_t len);
    1746                 :            : JL_DLLEXPORT void jl_set_newly_inferred(jl_value_t *newly_inferred);
    1747                 :            : JL_DLLEXPORT int jl_save_incremental(const char *fname, jl_array_t *worklist);
    1748                 :            : JL_DLLEXPORT jl_value_t *jl_restore_incremental(const char *fname, jl_array_t *depmods);
    1749                 :            : JL_DLLEXPORT jl_value_t *jl_restore_incremental_from_buf(const char *buf, size_t sz, jl_array_t *depmods);
    1750                 :            : 
    1751                 :            : // parsing
    1752                 :            : JL_DLLEXPORT jl_value_t *jl_parse_all(const char *text, size_t text_len,
    1753                 :            :                                       const char *filename, size_t filename_len, size_t lineno);
    1754                 :            : JL_DLLEXPORT jl_value_t *jl_parse_string(const char *text, size_t text_len,
    1755                 :            :                                          int offset, int greedy);
    1756                 :            : // lowering
    1757                 :            : JL_DLLEXPORT jl_value_t *jl_expand(jl_value_t *expr, jl_module_t *inmodule);
    1758                 :            : JL_DLLEXPORT jl_value_t *jl_expand_with_loc(jl_value_t *expr, jl_module_t *inmodule,
    1759                 :            :                                             const char *file, int line);
    1760                 :            : JL_DLLEXPORT jl_value_t *jl_expand_with_loc_warn(jl_value_t *expr, jl_module_t *inmodule,
    1761                 :            :                                                  const char *file, int line);
    1762                 :            : JL_DLLEXPORT jl_value_t *jl_expand_in_world(jl_value_t *expr, jl_module_t *inmodule,
    1763                 :            :                                             const char *file, int line, size_t world);
    1764                 :            : JL_DLLEXPORT jl_value_t *jl_expand_stmt(jl_value_t *expr, jl_module_t *inmodule);
    1765                 :            : JL_DLLEXPORT jl_value_t *jl_expand_stmt_with_loc(jl_value_t *expr, jl_module_t *inmodule,
    1766                 :            :                                                  const char *file, int line);
    1767                 :            : // deprecated; use jl_parse_all
    1768                 :            : JL_DLLEXPORT jl_value_t *jl_parse_input_line(const char *text, size_t text_len,
    1769                 :            :                                              const char *filename, size_t filename_len);
    1770                 :            : 
    1771                 :            : // external libraries
    1772                 :            : enum JL_RTLD_CONSTANT {
    1773                 :            :      JL_RTLD_LOCAL=1U,
    1774                 :            :      JL_RTLD_GLOBAL=2U,
    1775                 :            :      JL_RTLD_LAZY=4U,
    1776                 :            :      JL_RTLD_NOW=8U,
    1777                 :            :      /* Linux/glibc and MacOS X: */
    1778                 :            :      JL_RTLD_NODELETE=16U,
    1779                 :            :      JL_RTLD_NOLOAD=32U,
    1780                 :            :      /* Linux/glibc: */
    1781                 :            :      JL_RTLD_DEEPBIND=64U,
    1782                 :            :      /* MacOS X 10.5+: */
    1783                 :            :      JL_RTLD_FIRST=128U
    1784                 :            : };
    1785                 :            : #define JL_RTLD_DEFAULT (JL_RTLD_LAZY | JL_RTLD_DEEPBIND)
    1786                 :            : 
    1787                 :            : typedef void *jl_libhandle; // compatible with dlopen (void*) / LoadLibrary (HMODULE)
    1788                 :            : JL_DLLEXPORT jl_libhandle jl_load_dynamic_library(const char *fname, unsigned flags, int throw_err);
    1789                 :            : JL_DLLEXPORT jl_libhandle jl_dlopen(const char *filename, unsigned flags) JL_NOTSAFEPOINT;
    1790                 :            : JL_DLLEXPORT int jl_dlclose(jl_libhandle handle) JL_NOTSAFEPOINT;
    1791                 :            : JL_DLLEXPORT int jl_dlsym(jl_libhandle handle, const char *symbol, void ** value, int throw_err) JL_NOTSAFEPOINT;
    1792                 :            : 
    1793                 :            : // evaluation
    1794                 :            : JL_DLLEXPORT jl_value_t *jl_toplevel_eval(jl_module_t *m, jl_value_t *v);
    1795                 :            : JL_DLLEXPORT jl_value_t *jl_toplevel_eval_in(jl_module_t *m, jl_value_t *ex);
    1796                 :            : // code loading (parsing + evaluation)
    1797                 :            : JL_DLLEXPORT jl_value_t *jl_eval_string(const char *str); // embedding interface
    1798                 :            : JL_DLLEXPORT jl_value_t *jl_load_file_string(const char *text, size_t len,
    1799                 :            :                                              char *filename, jl_module_t *module);
    1800                 :            : JL_DLLEXPORT jl_value_t *jl_load(jl_module_t *module, const char *fname);
    1801                 :            : 
    1802                 :            : JL_DLLEXPORT jl_module_t *jl_base_relative_to(jl_module_t *m JL_PROPAGATES_ROOT);
    1803                 :            : 
    1804                 :            : // tracing
    1805                 :            : JL_DLLEXPORT void jl_register_newmeth_tracer(void (*callback)(jl_method_t *tracee));
    1806                 :            : 
    1807                 :            : // AST access
    1808                 :            : JL_DLLEXPORT jl_value_t *jl_copy_ast(jl_value_t *expr JL_MAYBE_UNROOTED);
    1809                 :            : 
    1810                 :            : // IR representation
    1811                 :            : JL_DLLEXPORT jl_array_t *jl_compress_ir(jl_method_t *m, jl_code_info_t *code);
    1812                 :            : JL_DLLEXPORT jl_code_info_t *jl_uncompress_ir(jl_method_t *m, jl_code_instance_t *metadata, jl_array_t *data);
    1813                 :            : JL_DLLEXPORT uint8_t jl_ir_flag_inferred(jl_array_t *data) JL_NOTSAFEPOINT;
    1814                 :            : JL_DLLEXPORT uint8_t jl_ir_flag_inlineable(jl_array_t *data) JL_NOTSAFEPOINT;
    1815                 :            : JL_DLLEXPORT uint8_t jl_ir_flag_pure(jl_array_t *data) JL_NOTSAFEPOINT;
    1816                 :            : JL_DLLEXPORT ssize_t jl_ir_nslots(jl_array_t *data) JL_NOTSAFEPOINT;
    1817                 :            : JL_DLLEXPORT uint8_t jl_ir_slotflag(jl_array_t *data, size_t i) JL_NOTSAFEPOINT;
    1818                 :            : JL_DLLEXPORT jl_value_t *jl_compress_argnames(jl_array_t *syms);
    1819                 :            : JL_DLLEXPORT jl_array_t *jl_uncompress_argnames(jl_value_t *syms);
    1820                 :            : JL_DLLEXPORT jl_value_t *jl_uncompress_argname_n(jl_value_t *syms, size_t i);
    1821                 :            : 
    1822                 :            : JL_DLLEXPORT int jl_is_operator(char *sym);
    1823                 :            : JL_DLLEXPORT int jl_is_unary_operator(char *sym);
    1824                 :            : JL_DLLEXPORT int jl_is_unary_and_binary_operator(char *sym);
    1825                 :            : JL_DLLEXPORT int jl_is_syntactic_operator(char *sym);
    1826                 :            : JL_DLLEXPORT int jl_operator_precedence(char *sym);
    1827                 :            : 
    1828                 :    1246550 : STATIC_INLINE int jl_vinfo_sa(uint8_t vi)
    1829                 :            : {
    1830                 :    1246550 :     return (vi&16)!=0;
    1831                 :            : }
    1832                 :            : 
    1833                 :    1246550 : STATIC_INLINE int jl_vinfo_usedundef(uint8_t vi)
    1834                 :            : {
    1835                 :    1246550 :     return (vi&32)!=0;
    1836                 :            : }
    1837                 :            : 
    1838                 :            : // calling into julia ---------------------------------------------------------
    1839                 :            : 
    1840                 :            : JL_DLLEXPORT jl_value_t *jl_apply_generic(jl_value_t *F, jl_value_t **args, uint32_t nargs);
    1841                 :            : JL_DLLEXPORT jl_value_t *jl_invoke(jl_value_t *F, jl_value_t **args, uint32_t nargs, jl_method_instance_t *meth);
    1842                 :            : JL_DLLEXPORT int32_t jl_invoke_api(jl_code_instance_t *linfo);
    1843                 :            : 
    1844                 :  132173190 : STATIC_INLINE jl_value_t *jl_apply(jl_value_t **args, uint32_t nargs)
    1845                 :            : {
    1846                 :  132173190 :     return jl_apply_generic(args[0], &args[1], nargs - 1);
    1847                 :            : }
    1848                 :            : 
    1849                 :            : JL_DLLEXPORT jl_value_t *jl_call(jl_function_t *f JL_MAYBE_UNROOTED, jl_value_t **args, uint32_t nargs);
    1850                 :            : JL_DLLEXPORT jl_value_t *jl_call0(jl_function_t *f JL_MAYBE_UNROOTED);
    1851                 :            : JL_DLLEXPORT jl_value_t *jl_call1(jl_function_t *f JL_MAYBE_UNROOTED, jl_value_t *a JL_MAYBE_UNROOTED);
    1852                 :            : JL_DLLEXPORT jl_value_t *jl_call2(jl_function_t *f JL_MAYBE_UNROOTED, jl_value_t *a JL_MAYBE_UNROOTED, jl_value_t *b JL_MAYBE_UNROOTED);
    1853                 :            : JL_DLLEXPORT jl_value_t *jl_call3(jl_function_t *f JL_MAYBE_UNROOTED, jl_value_t *a JL_MAYBE_UNROOTED,
    1854                 :            :                                   jl_value_t *b JL_MAYBE_UNROOTED, jl_value_t *c JL_MAYBE_UNROOTED);
    1855                 :            : 
    1856                 :            : // interfacing with Task runtime
    1857                 :            : JL_DLLEXPORT void jl_yield(void);
    1858                 :            : 
    1859                 :            : // async signal handling ------------------------------------------------------
    1860                 :            : 
    1861                 :            : JL_DLLEXPORT void jl_install_sigint_handler(void);
    1862                 :            : JL_DLLEXPORT void jl_sigatomic_begin(void);
    1863                 :            : JL_DLLEXPORT void jl_sigatomic_end(void);
    1864                 :            : 
    1865                 :            : // tasks and exceptions -------------------------------------------------------
    1866                 :            : 
    1867                 :            : typedef struct _jl_timing_block_t jl_timing_block_t;
    1868                 :            : typedef struct _jl_excstack_t jl_excstack_t;
    1869                 :            : 
    1870                 :            : // info describing an exception handler
    1871                 :            : typedef struct _jl_handler_t {
    1872                 :            :     jl_jmp_buf eh_ctx;
    1873                 :            :     jl_gcframe_t *gcstack;
    1874                 :            :     struct _jl_handler_t *prev;
    1875                 :            :     int8_t gc_state;
    1876                 :            :     size_t locks_len;
    1877                 :            :     sig_atomic_t defer_signal;
    1878                 :            :     jl_timing_block_t *timing_stack;
    1879                 :            :     size_t world_age;
    1880                 :            : } jl_handler_t;
    1881                 :            : 
    1882                 :            : typedef struct _jl_task_t {
    1883                 :            :     JL_DATA_TYPE
    1884                 :            :     jl_value_t *next; // invasive linked list for scheduler
    1885                 :            :     jl_value_t *queue; // invasive linked list for scheduler
    1886                 :            :     jl_value_t *tls;
    1887                 :            :     jl_value_t *donenotify;
    1888                 :            :     jl_value_t *result;
    1889                 :            :     jl_value_t *logstate;
    1890                 :            :     jl_function_t *start;
    1891                 :            :     uint64_t rngState[4];
    1892                 :            :     _Atomic(uint8_t) _state;
    1893                 :            :     uint8_t sticky; // record whether this Task can be migrated to a new thread
    1894                 :            :     _Atomic(uint8_t) _isexception; // set if `result` is an exception to throw or that we exited with
    1895                 :            :     // multiqueue priority
    1896                 :            :     uint16_t priority;
    1897                 :            : 
    1898                 :            : // hidden state:
    1899                 :            :     // id of owning thread - does not need to be defined until the task runs
    1900                 :            :     _Atomic(int16_t) tid;
    1901                 :            :     // threadpool id
    1902                 :            :     int8_t threadpoolid;
    1903                 :            :     // saved gc stack top for context switches
    1904                 :            :     jl_gcframe_t *gcstack;
    1905                 :            :     size_t world_age;
    1906                 :            :     // quick lookup for current ptls
    1907                 :            :     jl_ptls_t ptls; // == jl_all_tls_states[tid]
    1908                 :            :     // saved exception stack
    1909                 :            :     jl_excstack_t *excstack;
    1910                 :            :     // current exception handler
    1911                 :            :     jl_handler_t *eh;
    1912                 :            :     // saved thread state
    1913                 :            :     jl_ucontext_t ctx;
    1914                 :            :     void *stkbuf; // malloc'd memory (either copybuf or stack)
    1915                 :            :     size_t bufsz; // actual sizeof stkbuf
    1916                 :            :     unsigned int copy_stack:31; // sizeof stack for copybuf
    1917                 :            :     unsigned int started:1;
    1918                 :            : } jl_task_t;
    1919                 :            : 
    1920                 :            : #define JL_TASK_STATE_RUNNABLE 0
    1921                 :            : #define JL_TASK_STATE_DONE     1
    1922                 :            : #define JL_TASK_STATE_FAILED   2
    1923                 :            : 
    1924                 :            : JL_DLLEXPORT jl_task_t *jl_new_task(jl_function_t*, jl_value_t*, size_t);
    1925                 :            : JL_DLLEXPORT void jl_switchto(jl_task_t **pt);
    1926                 :            : JL_DLLEXPORT int jl_set_task_tid(jl_task_t *task, int16_t tid) JL_NOTSAFEPOINT;
    1927                 :            : JL_DLLEXPORT int jl_set_task_threadpoolid(jl_task_t *task, int8_t tpid) JL_NOTSAFEPOINT;
    1928                 :            : JL_DLLEXPORT void JL_NORETURN jl_throw(jl_value_t *e JL_MAYBE_UNROOTED);
    1929                 :            : JL_DLLEXPORT void JL_NORETURN jl_rethrow(void);
    1930                 :            : JL_DLLEXPORT void JL_NORETURN jl_sig_throw(void);
    1931                 :            : JL_DLLEXPORT void JL_NORETURN jl_rethrow_other(jl_value_t *e JL_MAYBE_UNROOTED);
    1932                 :            : JL_DLLEXPORT void JL_NORETURN jl_no_exc_handler(jl_value_t *e);
    1933                 :            : JL_DLLEXPORT JL_CONST_FUNC jl_gcframe_t **(jl_get_pgcstack)(void) JL_GLOBALLY_ROOTED JL_NOTSAFEPOINT;
    1934                 :            : #define jl_current_task (container_of(jl_get_pgcstack(), jl_task_t, gcstack))
    1935                 :            : 
    1936                 :            : #include "julia_locks.h"   // requires jl_task_t definition
    1937                 :            : 
    1938                 :            : JL_DLLEXPORT void jl_enter_handler(jl_handler_t *eh);
    1939                 :            : JL_DLLEXPORT void jl_eh_restore_state(jl_handler_t *eh);
    1940                 :            : JL_DLLEXPORT void jl_pop_handler(int n);
    1941                 :            : JL_DLLEXPORT size_t jl_excstack_state(void) JL_NOTSAFEPOINT;
    1942                 :            : JL_DLLEXPORT void jl_restore_excstack(size_t state) JL_NOTSAFEPOINT;
    1943                 :            : 
    1944                 :            : #if defined(_OS_WINDOWS_)
    1945                 :            : #if defined(_COMPILER_GCC_)
    1946                 :            : JL_DLLEXPORT int __attribute__ ((__nothrow__,__returns_twice__)) (jl_setjmp)(jmp_buf _Buf);
    1947                 :            : __declspec(noreturn) __attribute__ ((__nothrow__)) void (jl_longjmp)(jmp_buf _Buf, int _Value);
    1948                 :            : JL_DLLEXPORT int __attribute__ ((__nothrow__,__returns_twice__)) (ijl_setjmp)(jmp_buf _Buf);
    1949                 :            : __declspec(noreturn) __attribute__ ((__nothrow__)) void (ijl_longjmp)(jmp_buf _Buf, int _Value);
    1950                 :            : #else
    1951                 :            : JL_DLLEXPORT int (jl_setjmp)(jmp_buf _Buf);
    1952                 :            : void (jl_longjmp)(jmp_buf _Buf, int _Value);
    1953                 :            : JL_DLLEXPORT int (ijl_setjmp)(jmp_buf _Buf);
    1954                 :            : void (ijl_longjmp)(jmp_buf _Buf, int _Value);
    1955                 :            : #endif
    1956                 :            : #ifdef LIBRARY_EXPORTS
    1957                 :            : #define jl_setjmp_f ijl_setjmp
    1958                 :            : #define jl_setjmp_name "ijl_setjmp"
    1959                 :            : #define jl_setjmp(a,b) ijl_setjmp(a)
    1960                 :            : #define jl_longjmp(a,b) ijl_longjmp(a,b)
    1961                 :            : #else
    1962                 :            : #define jl_setjmp_f jl_setjmp
    1963                 :            : #define jl_setjmp_name "jl_setjmp"
    1964                 :            : #define jl_setjmp(a,b) jl_setjmp(a)
    1965                 :            : #define jl_longjmp(a,b) jl_longjmp(a,b)
    1966                 :            : #endif
    1967                 :            : #elif defined(_OS_EMSCRIPTEN_)
    1968                 :            : #define jl_setjmp(a,b) setjmp(a)
    1969                 :            : #define jl_longjmp(a,b) longjmp(a,b)
    1970                 :            : #define jl_setjmp_f    setjmp
    1971                 :            : #define jl_setjmp_name "setjmp"
    1972                 :            : #else
    1973                 :            : // determine actual entry point name
    1974                 :            : #if defined(sigsetjmp)
    1975                 :            : #define jl_setjmp_f    __sigsetjmp
    1976                 :            : #define jl_setjmp_name "__sigsetjmp"
    1977                 :            : #else
    1978                 :            : #define jl_setjmp_f    sigsetjmp
    1979                 :            : #define jl_setjmp_name "sigsetjmp"
    1980                 :            : #endif
    1981                 :            : #define jl_setjmp(a,b) sigsetjmp(a,b)
    1982                 :            : #define jl_longjmp(a,b) siglongjmp(a,b)
    1983                 :            : #endif
    1984                 :            : 
    1985                 :            : 
    1986                 :            : #ifdef __clang_gcanalyzer__
    1987                 :            : 
    1988                 :            : // This is hard. Ideally we'd teach the static analyzer about the extra control
    1989                 :            : // flow edges. But for now, just hide this as best we can
    1990                 :            : extern int had_exception;
    1991                 :            : #define JL_TRY if (1)
    1992                 :            : #define JL_CATCH if (had_exception)
    1993                 :            : 
    1994                 :            : #else
    1995                 :            : 
    1996                 :            : #define JL_TRY                                                    \
    1997                 :            :     int i__tr, i__ca; jl_handler_t __eh;                          \
    1998                 :            :     size_t __excstack_state = jl_excstack_state();                \
    1999                 :            :     jl_enter_handler(&__eh);                                      \
    2000                 :            :     if (!jl_setjmp(__eh.eh_ctx,0))                                \
    2001                 :            :         for (i__tr=1; i__tr; i__tr=0, jl_eh_restore_state(&__eh))
    2002                 :            : 
    2003                 :            : #define JL_CATCH                                                \
    2004                 :            :     else                                                        \
    2005                 :            :         for (i__ca=1, jl_eh_restore_state(&__eh); i__ca; i__ca=0, jl_restore_excstack(__excstack_state))
    2006                 :            : 
    2007                 :            : #endif
    2008                 :            : 
    2009                 :            : // I/O system -----------------------------------------------------------------
    2010                 :            : 
    2011                 :            : struct uv_loop_s;
    2012                 :            : struct uv_handle_s;
    2013                 :            : struct uv_stream_s;
    2014                 :            : #ifdef _OS_WINDOWS_
    2015                 :            : typedef HANDLE jl_uv_os_fd_t;
    2016                 :            : #else
    2017                 :            : typedef int jl_uv_os_fd_t;
    2018                 :            : #endif
    2019                 :            : #define JL_STREAM struct uv_stream_s
    2020                 :            : #define JL_STDOUT jl_uv_stdout
    2021                 :            : #define JL_STDERR jl_uv_stderr
    2022                 :            : #define JL_STDIN  jl_uv_stdin
    2023                 :            : 
    2024                 :            : JL_DLLEXPORT int jl_process_events(void);
    2025                 :            : 
    2026                 :            : JL_DLLEXPORT struct uv_loop_s *jl_global_event_loop(void);
    2027                 :            : 
    2028                 :            : JL_DLLEXPORT void jl_close_uv(struct uv_handle_s *handle);
    2029                 :            : 
    2030                 :            : JL_DLLEXPORT jl_array_t *jl_take_buffer(ios_t *s);
    2031                 :            : 
    2032                 :            : typedef struct {
    2033                 :            :     void *data;
    2034                 :            :     struct uv_loop_s *loop;
    2035                 :            :     int type; // enum uv_handle_type
    2036                 :            :     jl_uv_os_fd_t file;
    2037                 :            : } jl_uv_file_t;
    2038                 :            : 
    2039                 :            : #ifdef __GNUC__
    2040                 :            : #define _JL_FORMAT_ATTR(type, str, arg) \
    2041                 :            :     __attribute__((format(type, str, arg)))
    2042                 :            : #else
    2043                 :            : #define _JL_FORMAT_ATTR(type, str, arg)
    2044                 :            : #endif
    2045                 :            : 
    2046                 :            : JL_DLLEXPORT void jl_uv_puts(struct uv_stream_s *stream, const char *str, size_t n);
    2047                 :            : JL_DLLEXPORT int jl_printf(struct uv_stream_s *s, const char *format, ...)
    2048                 :            :     _JL_FORMAT_ATTR(printf, 2, 3);
    2049                 :            : JL_DLLEXPORT int jl_vprintf(struct uv_stream_s *s, const char *format, va_list args)
    2050                 :            :     _JL_FORMAT_ATTR(printf, 2, 0);
    2051                 :            : JL_DLLEXPORT void jl_safe_printf(const char *str, ...) JL_NOTSAFEPOINT
    2052                 :            :     _JL_FORMAT_ATTR(printf, 1, 2);
    2053                 :            : 
    2054                 :            : extern JL_DLLEXPORT JL_STREAM *JL_STDIN;
    2055                 :            : extern JL_DLLEXPORT JL_STREAM *JL_STDOUT;
    2056                 :            : extern JL_DLLEXPORT JL_STREAM *JL_STDERR;
    2057                 :            : 
    2058                 :            : JL_DLLEXPORT JL_STREAM *jl_stdout_stream(void);
    2059                 :            : JL_DLLEXPORT JL_STREAM *jl_stdin_stream(void);
    2060                 :            : JL_DLLEXPORT JL_STREAM *jl_stderr_stream(void);
    2061                 :            : JL_DLLEXPORT int jl_termios_size(void);
    2062                 :            : 
    2063                 :            : // showing and std streams
    2064                 :            : JL_DLLEXPORT void jl_flush_cstdio(void) JL_NOTSAFEPOINT;
    2065                 :            : JL_DLLEXPORT jl_value_t *jl_stdout_obj(void) JL_NOTSAFEPOINT;
    2066                 :            : JL_DLLEXPORT jl_value_t *jl_stderr_obj(void) JL_NOTSAFEPOINT;
    2067                 :            : JL_DLLEXPORT size_t jl_static_show(JL_STREAM *out, jl_value_t *v) JL_NOTSAFEPOINT;
    2068                 :            : JL_DLLEXPORT size_t jl_static_show_func_sig(JL_STREAM *s, jl_value_t *type) JL_NOTSAFEPOINT;
    2069                 :            : JL_DLLEXPORT void jl_print_backtrace(void) JL_NOTSAFEPOINT;
    2070                 :            : JL_DLLEXPORT void jlbacktrace(void) JL_NOTSAFEPOINT; // deprecated
    2071                 :            : // Mainly for debugging, use `void*` so that no type cast is needed in C++.
    2072                 :            : JL_DLLEXPORT void jl_(void *jl_value) JL_NOTSAFEPOINT;
    2073                 :            : 
    2074                 :            : // julia options -----------------------------------------------------------
    2075                 :            : 
    2076                 :            : #include "jloptions.h"
    2077                 :            : 
    2078                 :            : extern JL_DLLIMPORT jl_options_t jl_options;
    2079                 :            : 
    2080                 :            : JL_DLLEXPORT ssize_t jl_sizeof_jl_options(void);
    2081                 :            : 
    2082                 :            : // Parse an argc/argv pair to extract general julia options, passing back out
    2083                 :            : // any arguments that should be passed on to the script.
    2084                 :            : JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp);
    2085                 :            : JL_DLLEXPORT char *jl_format_filename(const char *output_pattern);
    2086                 :            : 
    2087                 :            : // Set julia-level ARGS array according to the arguments provided in
    2088                 :            : // argc/argv
    2089                 :            : JL_DLLEXPORT void jl_set_ARGS(int argc, char **argv);
    2090                 :            : 
    2091                 :            : JL_DLLEXPORT int jl_generating_output(void) JL_NOTSAFEPOINT;
    2092                 :            : 
    2093                 :            : // Settings for code_coverage and malloc_log
    2094                 :            : // NOTE: if these numbers change, test/cmdlineargs.jl will have to be updated
    2095                 :            : #define JL_LOG_NONE 0
    2096                 :            : #define JL_LOG_USER 1
    2097                 :            : #define JL_LOG_ALL  2
    2098                 :            : #define JL_LOG_PATH 3
    2099                 :            : 
    2100                 :            : #define JL_OPTIONS_CHECK_BOUNDS_DEFAULT 0
    2101                 :            : #define JL_OPTIONS_CHECK_BOUNDS_ON 1
    2102                 :            : #define JL_OPTIONS_CHECK_BOUNDS_OFF 2
    2103                 :            : 
    2104                 :            : #define JL_OPTIONS_COMPILE_DEFAULT 1
    2105                 :            : #define JL_OPTIONS_COMPILE_OFF 0
    2106                 :            : #define JL_OPTIONS_COMPILE_ON  1
    2107                 :            : #define JL_OPTIONS_COMPILE_ALL 2
    2108                 :            : #define JL_OPTIONS_COMPILE_MIN 3
    2109                 :            : 
    2110                 :            : #define JL_OPTIONS_COLOR_AUTO 0
    2111                 :            : #define JL_OPTIONS_COLOR_ON 1
    2112                 :            : #define JL_OPTIONS_COLOR_OFF 2
    2113                 :            : 
    2114                 :            : #define JL_OPTIONS_HISTORYFILE_ON 1
    2115                 :            : #define JL_OPTIONS_HISTORYFILE_OFF 0
    2116                 :            : 
    2117                 :            : #define JL_OPTIONS_STARTUPFILE_ON 1
    2118                 :            : #define JL_OPTIONS_STARTUPFILE_OFF 2
    2119                 :            : 
    2120                 :            : #define JL_LOGLEVEL_BELOWMIN -1000001
    2121                 :            : #define JL_LOGLEVEL_DEBUG    -1000
    2122                 :            : #define JL_LOGLEVEL_INFO      0
    2123                 :            : #define JL_LOGLEVEL_WARN      1000
    2124                 :            : #define JL_LOGLEVEL_ERROR     2000
    2125                 :            : #define JL_LOGLEVEL_ABOVEMAX  1000001
    2126                 :            : 
    2127                 :            : #define JL_OPTIONS_DEPWARN_OFF 0
    2128                 :            : #define JL_OPTIONS_DEPWARN_ON 1
    2129                 :            : #define JL_OPTIONS_DEPWARN_ERROR 2
    2130                 :            : 
    2131                 :            : #define JL_OPTIONS_WARN_OVERWRITE_OFF 0
    2132                 :            : #define JL_OPTIONS_WARN_OVERWRITE_ON 1
    2133                 :            : 
    2134                 :            : #define JL_OPTIONS_WARN_SCOPE_OFF 0
    2135                 :            : #define JL_OPTIONS_WARN_SCOPE_ON 1
    2136                 :            : 
    2137                 :            : #define JL_OPTIONS_POLLY_ON 1
    2138                 :            : #define JL_OPTIONS_POLLY_OFF 0
    2139                 :            : 
    2140                 :            : #define JL_OPTIONS_FAST_MATH_ON 1
    2141                 :            : #define JL_OPTIONS_FAST_MATH_OFF 2
    2142                 :            : #define JL_OPTIONS_FAST_MATH_DEFAULT 0
    2143                 :            : 
    2144                 :            : #define JL_OPTIONS_HANDLE_SIGNALS_ON 1
    2145                 :            : #define JL_OPTIONS_HANDLE_SIGNALS_OFF 0
    2146                 :            : 
    2147                 :            : #define JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES 1
    2148                 :            : #define JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_NO 0
    2149                 :            : 
    2150                 :            : #define JL_OPTIONS_USE_COMPILED_MODULES_YES 1
    2151                 :            : #define JL_OPTIONS_USE_COMPILED_MODULES_NO 0
    2152                 :            : 
    2153                 :            : // Version information
    2154                 :            : #include "julia_version.h"
    2155                 :            : 
    2156                 :            : JL_DLLEXPORT extern int jl_ver_major(void);
    2157                 :            : JL_DLLEXPORT extern int jl_ver_minor(void);
    2158                 :            : JL_DLLEXPORT extern int jl_ver_patch(void);
    2159                 :            : JL_DLLEXPORT extern int jl_ver_is_release(void);
    2160                 :            : JL_DLLEXPORT extern const char *jl_ver_string(void);
    2161                 :            : JL_DLLEXPORT const char *jl_git_branch(void);
    2162                 :            : JL_DLLEXPORT const char *jl_git_commit(void);
    2163                 :            : 
    2164                 :            : // nullable struct representations
    2165                 :            : typedef struct {
    2166                 :            :     uint8_t hasvalue;
    2167                 :            :     double value;
    2168                 :            : } jl_nullable_float64_t;
    2169                 :            : 
    2170                 :            : typedef struct {
    2171                 :            :     uint8_t hasvalue;
    2172                 :            :     float value;
    2173                 :            : } jl_nullable_float32_t;
    2174                 :            : 
    2175                 :            : #define jl_root_task (jl_current_task->ptls->root_task)
    2176                 :            : 
    2177                 :            : JL_DLLEXPORT jl_task_t *jl_get_current_task(void) JL_GLOBALLY_ROOTED JL_NOTSAFEPOINT;
    2178                 :            : 
    2179                 :            : // TODO: we need to pin the task while using this (set pure bit)
    2180                 :            : JL_DLLEXPORT jl_jmp_buf *jl_get_safe_restore(void) JL_NOTSAFEPOINT;
    2181                 :            : JL_DLLEXPORT void jl_set_safe_restore(jl_jmp_buf *) JL_NOTSAFEPOINT;
    2182                 :            : 
    2183                 :            : // codegen interface ----------------------------------------------------------
    2184                 :            : // The root propagation here doesn't have to be literal, but callers should
    2185                 :            : // ensure that the return value outlives the MethodInstance
    2186                 :            : typedef jl_value_t *(*jl_codeinstance_lookup_t)(jl_method_instance_t *mi JL_PROPAGATES_ROOT,
    2187                 :            :     size_t min_world, size_t max_world);
    2188                 :            : typedef struct {
    2189                 :            :     int track_allocations;  // can we track allocations?
    2190                 :            :     int code_coverage;      // can we measure coverage?
    2191                 :            :     int prefer_specsig;     // are specialized function signatures preferred?
    2192                 :            : 
    2193                 :            :     // controls the emission of debug-info. mirrors the clang options
    2194                 :            :     int gnu_pubnames;       // can we emit the gnu pubnames debuginfo
    2195                 :            :     int debug_info_kind; // Enum for line-table-only, line-directives-only,
    2196                 :            :                             // limited, standalone
    2197                 :            : 
    2198                 :            :     // Cache access. Default: jl_rettype_inferred.
    2199                 :            :     jl_codeinstance_lookup_t lookup;
    2200                 :            : 
    2201                 :            :     // If not `nothing`, rewrite all generic calls to call
    2202                 :            :     // generic_context(f, args...) instead of f(args...).
    2203                 :            :     jl_value_t *generic_context;
    2204                 :            : } jl_cgparams_t;
    2205                 :            : extern JL_DLLEXPORT int jl_default_debug_info_kind;
    2206                 :            : 
    2207                 :            : #ifdef __cplusplus
    2208                 :            : }
    2209                 :            : #endif
    2210                 :            : 
    2211                 :            : #endif

Generated by: LCOV version 1.14