-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
julia.h
1696 lines (1486 loc) · 65.7 KB
/
julia.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This file is a part of Julia. License is MIT: http://julialang.org/license
#ifndef JULIA_H
#define JULIA_H
#ifdef __cplusplus
extern "C" {
#endif
//** Configuration options that affect the Julia ABI **//
// if this is not defined, only individual dimension sizes are
// stored and not total length, to save space.
#define STORE_ARRAY_LEN
//** End Configuration options **//
#include "libsupport.h"
#include <stdint.h>
#include <string.h>
#include "htable.h"
#include "arraylist.h"
#include <setjmp.h>
#ifndef _OS_WINDOWS_
# define jl_jmp_buf sigjmp_buf
# if defined(_CPU_ARM_)
# define MAX_ALIGN 8
# else
# define MAX_ALIGN sizeof(void*)
# endif
#else
# define jl_jmp_buf jmp_buf
# include <malloc.h> //for _resetstkoflw
# define MAX_ALIGN 8
#endif
#ifdef _P64
#define NWORDS(sz) (((sz)+7)>>3)
#else
#define NWORDS(sz) (((sz)+3)>>2)
#endif
#if defined(__GNUC__)
# define JL_NORETURN __attribute__ ((noreturn))
# define JL_CONST_FUNC __attribute__((const))
# define JL_MARK_INITIALIZED(var) asm("" : "=rm" (var))
#elif defined(_COMPILER_MICROSOFT_)
# define JL_NORETURN __declspec(noreturn)
// This is the closest I can find for __attribute__((const))
# define JL_CONST_FUNC __declspec(noalias)
# define JL_MARK_INITIALIZED(var) do {} while (0)
#else
# define JL_NORETURN
# define JL_CONST_FUNC
# define JL_MARK_INITIALIZED(var) do {} while (0)
#endif
#define container_of(ptr, type, member) \
((type *) ((char *)(ptr) - offsetof(type, member)))
// threading ------------------------------------------------------------------
// WARNING: Threading support is incomplete and experimental
// Nonetheless, we define JL_THREAD and use it to give advanced notice to
// maintainers of what eventual threading support will change.
// JULIA_ENABLE_THREADING is switched on in Make.inc if JULIA_THREADS is
// set (in Make.user)
JL_DLLEXPORT int16_t jl_threadid(void);
JL_DLLEXPORT void *jl_threadgroup(void);
JL_DLLEXPORT void jl_cpu_pause(void);
JL_DLLEXPORT void jl_threading_profile(void);
#if defined(__GNUC__)
# define JL_ATOMIC_FETCH_AND_ADD(a,b) \
__sync_fetch_and_add(&(a), (b))
# define JL_ATOMIC_COMPARE_AND_SWAP(a,b,c) \
__sync_bool_compare_and_swap(&(a), (b), (c))
# define JL_ATOMIC_TEST_AND_SET(a) \
__sync_lock_test_and_set(&(a), 1)
# define JL_ATOMIC_RELEASE(a) \
__sync_lock_release(&(a))
#elif defined(_OS_WINDOWS_)
# define JL_ATOMIC_FETCH_AND_ADD(a,b) \
_InterlockedExchangeAdd((volatile LONG *)&(a), (b))
# define JL_ATOMIC_COMPARE_AND_SWAP(a,b,c) \
_InterlockedCompareExchange64((volatile LONG64 *)&(a), (c), (b))
# define JL_ATOMIC_TEST_AND_SET(a) \
_InterlockedExchange64(&(a), 1)
# define JL_ATOMIC_RELEASE(a) \
_InterlockedExchange64(&(a), 0)
#else
# error "No atomic operations supported."
#endif
#ifdef JULIA_ENABLE_THREADING
#define FORCE_ELF
#define JL_DEFINE_MUTEX(m) \
uint64_t volatile m ## _mutex = 0; \
int32_t m ## _lock_count = 0;
#define JL_DEFINE_MUTEX_EXT(m) \
extern uint64_t volatile m ## _mutex; \
extern int32_t m ## _lock_count;
#define JL_LOCK(m) do { \
if (m ## _mutex == uv_thread_self()) { \
++m ## _lock_count; \
} \
else { \
for (;;) { \
if (m ## _mutex == 0 && \
JL_ATOMIC_COMPARE_AND_SWAP(m ## _mutex, 0, \
uv_thread_self())) { \
m ## _lock_count = 1; \
break; \
} \
jl_cpu_pause(); \
} \
} \
} while (0)
#define JL_UNLOCK(m) do { \
if (m ## _mutex == uv_thread_self()) { \
--m ## _lock_count; \
if (m ## _lock_count == 0) { \
JL_ATOMIC_COMPARE_AND_SWAP(m ## _mutex, uv_thread_self(), 0); \
} \
} \
} while (0)
#else
#define JL_DEFINE_MUTEX(m)
#define JL_DEFINE_MUTEX_EXT(m)
#define JL_LOCK(m) do {} while (0)
#define JL_UNLOCK(m) do {} while (0)
#endif
// core data types ------------------------------------------------------------
#define JL_DATA_TYPE
typedef struct _jl_value_t jl_value_t;
// typedef struct _jl_value_t {
// JL_DATA_TYPE
// struct _jl_value_t *fieldptr[];
// } jl_value_t;
typedef struct {
union {
jl_value_t *type; // 16-bytes aligned
uintptr_t type_bits;
uintptr_t gc_bits:2;
};
// jl_value_t value;
} jl_taggedvalue_t;
#define jl_astaggedvalue(v) \
((jl_taggedvalue_t*)((char*)(v) - sizeof(jl_taggedvalue_t)))
#define jl_valueof(v) \
((jl_value_t*)((char*)(v) + sizeof(jl_taggedvalue_t)))
#define jl_typeof(v) \
((jl_value_t*)(jl_astaggedvalue(v)->type_bits & ~(uintptr_t)15))
static inline void jl_set_typeof(void *v, void *t)
{
jl_taggedvalue_t *tag = jl_astaggedvalue(v);
tag->type = (jl_value_t*)t;
}
#define jl_typeis(v,t) (jl_typeof(v)==(jl_value_t*)(t))
typedef struct _jl_sym_t {
JL_DATA_TYPE
struct _jl_sym_t *left;
struct _jl_sym_t *right;
uptrint_t hash; // precomputed hash value
// JL_ATTRIBUTE_ALIGN_PTRSIZE(char name[]);
} jl_sym_t;
typedef struct _jl_gensym_t {
JL_DATA_TYPE
ssize_t id;
} jl_gensym_t;
typedef struct {
JL_DATA_TYPE
size_t length;
// pointer size aligned
// jl_value_t *data[];
} jl_svec_t;
typedef struct {
JL_DATA_TYPE
void *data;
#ifdef STORE_ARRAY_LEN
size_t length;
#endif
union {
struct {
/*
how - allocation style
0 = data is inlined, or a foreign pointer we don't manage
1 = julia-allocated buffer that needs to be marked
2 = malloc-allocated pointer this array object manages
3 = has a pointer to the Array that owns the data
*/
unsigned short how:2;
unsigned short ndims:10;
unsigned short pooled:1;
unsigned short ptrarray:1; // representation is pointer array
unsigned short isshared:1; // data is shared by multiple Arrays
unsigned short isaligned:1; // data allocated with memalign
};
unsigned short flags;
};
uint16_t elsize;
uint32_t offset; // for 1-d only. does not need to get big.
size_t nrows;
union {
// 1d
size_t maxsize;
// Nd
size_t ncols;
};
// other dim sizes go here for ndims > 2
// followed by alignment padding and inline data, or owner pointer
} jl_array_t;
// compute # of extra words needed to store dimensions
STATIC_INLINE int jl_array_ndimwords(uint32_t ndims)
{
return (ndims < 3 ? 0 : ndims-2);
}
typedef jl_value_t *(*jl_fptr_t)(jl_value_t*, jl_value_t**, uint32_t);
typedef struct _jl_datatype_t jl_tupletype_t;
typedef struct _jl_llvm_functions_t {
void *functionObject; // jlcall llvm Function
void *cFunctionList; // c callable llvm Functions
// specialized llvm Function (common core for the other two)
void *specFunctionObject;
} jl_llvm_functions_t;
typedef struct _jl_lambda_info_t {
JL_DATA_TYPE
// this holds the static data for a function:
// a syntax tree, static parameters, and (if it has been compiled)
// a function pointer.
// this is the stuff that's shared among different instantiations
// (different environments) of a closure.
jl_value_t *ast;
// sparams is a vector (symbol, value, symbol, value, ...)
jl_svec_t *sparams;
jl_value_t *tfunc;
jl_sym_t *name; // for error reporting
jl_array_t *roots; // pointers in generated code
jl_tupletype_t *specTypes; // argument types this will be compiled for
// a slower-but-works version of this function as a fallback
struct _jl_function_t *unspecialized;
// array of all lambda infos with code generated from this one
jl_array_t *specializations;
struct _jl_module_t *module;
struct _jl_lambda_info_t *def; // original this is specialized from, for consolidating codegen roots
jl_value_t *capt; // captured var info
jl_sym_t *file;
int32_t line;
int8_t inferred;
int8_t pure;
// hidden fields:
// flag telling if inference is running on this function
// used to avoid infinite recursion
uint8_t inInference : 1;
uint8_t inCompile : 1;
jl_fptr_t fptr; // jlcall entry point
// On the old JIT, handles to all Functions generated for this linfo
// For the new JITs, handles to declarations in the shadow module
// with the same name as the generated functions for this linfo, suitable
// for referencing in LLVM IR
jl_llvm_functions_t functionObjects;
int32_t functionID; // index that this function will have in the codegen table
int32_t specFunctionID; // index that this specFunction will have in the codegen table
} jl_lambda_info_t;
typedef struct _jl_function_t {
JL_DATA_TYPE
jl_fptr_t fptr;
jl_value_t *env;
jl_lambda_info_t *linfo;
} jl_function_t;
typedef struct {
JL_DATA_TYPE
jl_svec_t *parameters;
jl_value_t *body;
} jl_typector_t;
typedef struct {
JL_DATA_TYPE
jl_sym_t *name;
struct _jl_module_t *module;
jl_svec_t *names; // field names
// if this is the name of a parametric type, this field points to the
// original type.
// a type alias, for example, might make a type constructor that is
// not the original.
jl_value_t *primary;
jl_svec_t *cache; // sorted array
jl_svec_t *linearcache; // unsorted array
ptrint_t uid;
} jl_typename_t;
typedef struct {
JL_DATA_TYPE
jl_svec_t *types;
} jl_uniontype_t;
typedef struct {
uint8_t offset; // offset relative to data start, excluding type tag
uint8_t size:7;
uint8_t isptr:1;
} jl_fielddesc8_t;
typedef struct {
uint16_t offset; // offset relative to data start, excluding type tag
uint16_t size:15;
uint16_t isptr:1;
} jl_fielddesc16_t;
typedef struct {
uint32_t offset; // offset relative to data start, excluding type tag
uint32_t size:31;
uint32_t isptr:1;
} jl_fielddesc32_t;
typedef struct _jl_datatype_t {
JL_DATA_TYPE
jl_typename_t *name;
struct _jl_datatype_t *super;
jl_svec_t *parameters;
jl_svec_t *types;
jl_value_t *instance; // for singletons
int32_t size;
uint8_t abstract;
uint8_t mutabl;
uint8_t pointerfree;
int32_t ninitialized;
// hidden fields:
uint32_t nfields;
uint32_t alignment : 29; // strictest alignment over all fields
uint32_t haspadding : 1; // has internal undefined bytes
uint32_t fielddesc_type : 2; // 0 -> 8, 1 -> 16, 2 -> 32
uint32_t uid;
void *struct_decl; //llvm::Value*
void *ditype; // llvm::MDNode* to be used as llvm::DIType(ditype)
// Last field needs to be pointer size aligned
// union {
// jl_fielddesc8_t field8[];
// jl_fielddesc16_t field16[];
// jl_fielddesc32_t field32[];
// };
} jl_datatype_t;
typedef struct {
JL_DATA_TYPE
jl_sym_t *name;
jl_value_t *lb; // lower bound
jl_value_t *ub; // upper bound
uint8_t bound; // part of a constraint environment
} jl_tvar_t;
typedef struct {
JL_DATA_TYPE
jl_value_t *value;
} jl_weakref_t;
typedef struct {
// not first-class
jl_sym_t *name;
jl_value_t *value;
jl_value_t *globalref; // cached GlobalRef for this binding
struct _jl_module_t *owner; // for individual imported bindings
unsigned constp:1;
unsigned exportp:1;
unsigned imported:1;
unsigned deprecated:1;
} jl_binding_t;
typedef struct _jl_module_t {
JL_DATA_TYPE
jl_sym_t *name;
struct _jl_module_t *parent;
htable_t bindings;
arraylist_t usings; // modules with all bindings potentially imported
jl_array_t *constant_table;
jl_function_t *call_func; // cached lookup of `call` within this module
uint8_t istopmod;
uint8_t std_imports; // only for temporarily deprecating `importall Base.Operators`
uint64_t uuid;
} jl_module_t;
typedef struct _jl_methlist_t {
JL_DATA_TYPE
jl_tupletype_t *sig;
int8_t va;
int8_t isstaged;
jl_svec_t *tvars;
jl_function_t *func;
// cache of specializations of this method for invoke(), i.e.
// cases where this method was called even though it was not necessarily
// the most specific for the argument types.
struct _jl_methtable_t *invokes;
// TODO: pointer from specialized to original method
//jl_function_t *orig_method;
struct _jl_methlist_t *next;
} jl_methlist_t;
typedef struct _jl_methtable_t {
JL_DATA_TYPE
jl_sym_t *name;
jl_methlist_t *defs;
jl_methlist_t *cache;
jl_array_t *cache_arg1;
jl_array_t *cache_targ;
ptrint_t max_args; // max # of non-vararg arguments in a signature
jl_function_t *kwsorter; // keyword argument sorter function
jl_module_t *module; // used for incremental serialization to locate original binding
#ifdef JL_GF_PROFILE
int ncalls;
#endif
} jl_methtable_t;
typedef struct {
JL_DATA_TYPE
jl_sym_t *head;
jl_array_t *args;
jl_value_t *etype;
} jl_expr_t;
// constants and type objects -------------------------------------------------
extern JL_DLLEXPORT jl_datatype_t *jl_any_type;
extern JL_DLLEXPORT jl_datatype_t *jl_type_type;
extern JL_DLLEXPORT jl_tvar_t *jl_typetype_tvar;
extern JL_DLLEXPORT jl_datatype_t *jl_typetype_type;
extern JL_DLLEXPORT jl_value_t *jl_ANY_flag;
extern JL_DLLEXPORT jl_datatype_t *jl_typename_type;
extern JL_DLLEXPORT jl_datatype_t *jl_typector_type;
extern JL_DLLEXPORT jl_datatype_t *jl_sym_type;
extern JL_DLLEXPORT jl_datatype_t *jl_symbol_type;
extern JL_DLLEXPORT jl_datatype_t *jl_gensym_type;
extern JL_DLLEXPORT jl_datatype_t *jl_simplevector_type;
extern JL_DLLEXPORT jl_typename_t *jl_tuple_typename;
extern JL_DLLEXPORT jl_datatype_t *jl_anytuple_type;
#define jl_tuple_type jl_anytuple_type
extern JL_DLLEXPORT jl_datatype_t *jl_ntuple_type;
extern JL_DLLEXPORT jl_typename_t *jl_ntuple_typename;
extern JL_DLLEXPORT jl_datatype_t *jl_vararg_type;
extern JL_DLLEXPORT jl_datatype_t *jl_tvar_type;
extern JL_DLLEXPORT jl_datatype_t *jl_task_type;
extern JL_DLLEXPORT jl_datatype_t *jl_uniontype_type;
extern JL_DLLEXPORT jl_datatype_t *jl_datatype_type;
extern JL_DLLEXPORT jl_value_t *jl_bottom_type;
extern JL_DLLEXPORT jl_datatype_t *jl_lambda_info_type;
extern JL_DLLEXPORT jl_datatype_t *jl_module_type;
extern JL_DLLEXPORT jl_datatype_t *jl_function_type;
extern JL_DLLEXPORT jl_datatype_t *jl_abstractarray_type;
extern JL_DLLEXPORT jl_datatype_t *jl_densearray_type;
extern JL_DLLEXPORT jl_datatype_t *jl_array_type;
extern JL_DLLEXPORT jl_typename_t *jl_array_typename;
extern JL_DLLEXPORT jl_datatype_t *jl_weakref_type;
extern JL_DLLEXPORT jl_datatype_t *jl_ascii_string_type;
extern JL_DLLEXPORT jl_datatype_t *jl_utf8_string_type;
extern JL_DLLEXPORT jl_datatype_t *jl_errorexception_type;
extern JL_DLLEXPORT jl_datatype_t *jl_argumenterror_type;
extern JL_DLLEXPORT jl_datatype_t *jl_loaderror_type;
extern JL_DLLEXPORT jl_datatype_t *jl_initerror_type;
extern JL_DLLEXPORT jl_datatype_t *jl_typeerror_type;
extern JL_DLLEXPORT jl_datatype_t *jl_methoderror_type;
extern JL_DLLEXPORT jl_datatype_t *jl_undefvarerror_type;
extern JL_DLLEXPORT jl_value_t *jl_stackovf_exception;
extern JL_DLLEXPORT jl_value_t *jl_memory_exception;
extern JL_DLLEXPORT jl_value_t *jl_readonlymemory_exception;
extern JL_DLLEXPORT jl_value_t *jl_diverror_exception;
extern JL_DLLEXPORT jl_value_t *jl_domain_exception;
extern JL_DLLEXPORT jl_value_t *jl_overflow_exception;
extern JL_DLLEXPORT jl_value_t *jl_inexact_exception;
extern JL_DLLEXPORT jl_value_t *jl_undefref_exception;
extern JL_DLLEXPORT jl_value_t *jl_interrupt_exception;
extern JL_DLLEXPORT jl_datatype_t *jl_boundserror_type;
extern JL_DLLEXPORT jl_value_t *jl_an_empty_cell;
extern JL_DLLEXPORT jl_datatype_t *jl_bool_type;
extern JL_DLLEXPORT jl_datatype_t *jl_char_type;
extern JL_DLLEXPORT jl_datatype_t *jl_int8_type;
extern JL_DLLEXPORT jl_datatype_t *jl_uint8_type;
extern JL_DLLEXPORT jl_datatype_t *jl_int16_type;
extern JL_DLLEXPORT jl_datatype_t *jl_uint16_type;
extern JL_DLLEXPORT jl_datatype_t *jl_int32_type;
extern JL_DLLEXPORT jl_datatype_t *jl_uint32_type;
extern JL_DLLEXPORT jl_datatype_t *jl_int64_type;
extern JL_DLLEXPORT jl_datatype_t *jl_uint64_type;
extern JL_DLLEXPORT jl_datatype_t *jl_float32_type;
extern JL_DLLEXPORT jl_datatype_t *jl_float64_type;
extern JL_DLLEXPORT jl_datatype_t *jl_floatingpoint_type;
extern JL_DLLEXPORT jl_datatype_t *jl_number_type;
extern JL_DLLEXPORT jl_datatype_t *jl_void_type;
extern JL_DLLEXPORT jl_datatype_t *jl_complex_type;
extern JL_DLLEXPORT jl_datatype_t *jl_signed_type;
extern JL_DLLEXPORT jl_datatype_t *jl_voidpointer_type;
extern JL_DLLEXPORT jl_datatype_t *jl_pointer_type;
extern JL_DLLEXPORT jl_datatype_t *jl_ref_type;
extern JL_DLLEXPORT jl_value_t *jl_array_uint8_type;
extern JL_DLLEXPORT jl_value_t *jl_array_any_type;
extern JL_DLLEXPORT jl_value_t *jl_array_symbol_type;
extern JL_DLLEXPORT jl_datatype_t *jl_expr_type;
extern JL_DLLEXPORT jl_datatype_t *jl_symbolnode_type;
extern JL_DLLEXPORT jl_datatype_t *jl_globalref_type;
extern JL_DLLEXPORT jl_datatype_t *jl_linenumbernode_type;
extern JL_DLLEXPORT jl_datatype_t *jl_labelnode_type;
extern JL_DLLEXPORT jl_datatype_t *jl_gotonode_type;
extern JL_DLLEXPORT jl_datatype_t *jl_quotenode_type;
extern JL_DLLEXPORT jl_datatype_t *jl_newvarnode_type;
extern JL_DLLEXPORT jl_datatype_t *jl_topnode_type;
extern JL_DLLEXPORT jl_datatype_t *jl_intrinsic_type;
extern JL_DLLEXPORT jl_datatype_t *jl_methtable_type;
extern JL_DLLEXPORT jl_datatype_t *jl_method_type;
extern JL_DLLEXPORT jl_svec_t *jl_emptysvec;
extern JL_DLLEXPORT jl_value_t *jl_emptytuple;
extern JL_DLLEXPORT jl_value_t *jl_true;
extern JL_DLLEXPORT jl_value_t *jl_false;
extern JL_DLLEXPORT jl_value_t *jl_nothing;
// some important symbols
extern jl_sym_t *call_sym;
extern jl_sym_t *dots_sym; extern jl_sym_t *vararg_sym;
extern jl_sym_t *quote_sym; extern jl_sym_t *newvar_sym;
extern jl_sym_t *top_sym; extern jl_sym_t *dot_sym;
extern jl_sym_t *line_sym; extern jl_sym_t *toplevel_sym;
extern JL_DLLEXPORT jl_sym_t *jl_incomplete_sym;
extern jl_sym_t *error_sym; extern jl_sym_t *amp_sym;
extern jl_sym_t *module_sym; extern jl_sym_t *colons_sym;
extern jl_sym_t *export_sym; extern jl_sym_t *import_sym;
extern jl_sym_t *importall_sym; extern jl_sym_t *using_sym;
extern jl_sym_t *goto_sym; extern jl_sym_t *goto_ifnot_sym;
extern jl_sym_t *label_sym; extern jl_sym_t *return_sym;
extern jl_sym_t *lambda_sym; extern jl_sym_t *assign_sym;
extern jl_sym_t *null_sym; extern jl_sym_t *body_sym;
extern jl_sym_t *macro_sym; extern jl_sym_t *method_sym;
extern jl_sym_t *enter_sym; extern jl_sym_t *leave_sym;
extern jl_sym_t *exc_sym; extern jl_sym_t *new_sym;
extern jl_sym_t *static_typeof_sym; extern jl_sym_t *kw_sym;
extern jl_sym_t *const_sym; extern jl_sym_t *thunk_sym;
extern jl_sym_t *anonymous_sym; extern jl_sym_t *underscore_sym;
extern jl_sym_t *abstracttype_sym; extern jl_sym_t *bitstype_sym;
extern jl_sym_t *compositetype_sym; extern jl_sym_t *type_goto_sym;
extern jl_sym_t *global_sym; extern jl_sym_t *tuple_sym;
extern jl_sym_t *boundscheck_sym; extern jl_sym_t *copyast_sym;
extern jl_sym_t *fastmath_sym; extern jl_sym_t *pure_sym;
extern jl_sym_t *simdloop_sym; extern jl_sym_t *meta_sym;
extern jl_sym_t *arrow_sym; extern jl_sym_t *inert_sym;
// gc -------------------------------------------------------------------------
typedef struct _jl_gcframe_t {
size_t nroots;
struct _jl_gcframe_t *prev;
// actual roots go here
} jl_gcframe_t;
// NOTE: it is the caller's responsibility to make sure arguments are
// rooted such that the gc can see them on the stack.
// `foo(f(), g())` is not safe,
// since the result of `f()` is not rooted during the call to `g()`,
// and the arguments to foo are not gc-protected during the call to foo.
// foo can't do anything about it, so the caller must do:
// jl_value_t *x=NULL, *y=NULL; JL_GC_PUSH2(&x, &y);
// x = f(); y = g(); foo(x, y)
#define jl_pgcstack (jl_get_ptls_states()->pgcstack)
#define JL_GC_PUSH1(arg1) \
void *__gc_stkf[] = {(void*)3, jl_pgcstack, arg1}; \
jl_pgcstack = (jl_gcframe_t*)__gc_stkf;
#define JL_GC_PUSH2(arg1, arg2) \
void *__gc_stkf[] = {(void*)5, jl_pgcstack, arg1, arg2}; \
jl_pgcstack = (jl_gcframe_t*)__gc_stkf;
#define JL_GC_PUSH3(arg1, arg2, arg3) \
void *__gc_stkf[] = {(void*)7, jl_pgcstack, arg1, arg2, arg3}; \
jl_pgcstack = (jl_gcframe_t*)__gc_stkf;
#define JL_GC_PUSH4(arg1, arg2, arg3, arg4) \
void *__gc_stkf[] = {(void*)9, jl_pgcstack, arg1, arg2, arg3, arg4}; \
jl_pgcstack = (jl_gcframe_t*)__gc_stkf;
#define JL_GC_PUSH5(arg1, arg2, arg3, arg4, arg5) \
void *__gc_stkf[] = {(void*)11, jl_pgcstack, arg1, arg2, arg3, arg4, arg5}; \
jl_pgcstack = (jl_gcframe_t*)__gc_stkf;
#define JL_GC_PUSHARGS(rts_var,n) \
rts_var = ((jl_value_t**)alloca(((n)+2)*sizeof(jl_value_t*)))+2; \
((void**)rts_var)[-2] = (void*)(((size_t)n)<<1); \
((void**)rts_var)[-1] = jl_pgcstack; \
memset((void*)rts_var, 0, (n)*sizeof(jl_value_t*)); \
jl_pgcstack = (jl_gcframe_t*)&(((void**)rts_var)[-2])
#define JL_GC_POP() (jl_pgcstack = jl_pgcstack->prev)
JL_DLLEXPORT int jl_gc_enable(int on);
JL_DLLEXPORT int jl_gc_is_enabled(void);
JL_DLLEXPORT int64_t jl_gc_total_bytes(void);
JL_DLLEXPORT uint64_t jl_gc_total_hrtime(void);
JL_DLLEXPORT int64_t jl_gc_diff_total_bytes(void);
JL_DLLEXPORT void jl_gc_collect(int);
JL_DLLEXPORT void jl_gc_preserve(jl_value_t *v);
JL_DLLEXPORT void jl_gc_unpreserve(void);
JL_DLLEXPORT int jl_gc_n_preserved_values(void);
JL_DLLEXPORT void jl_gc_add_finalizer(jl_value_t *v, jl_function_t *f);
JL_DLLEXPORT void jl_finalize(jl_value_t *o);
JL_DLLEXPORT jl_weakref_t *jl_gc_new_weakref(jl_value_t *value);
JL_DLLEXPORT jl_value_t *jl_gc_alloc_0w(void);
JL_DLLEXPORT jl_value_t *jl_gc_alloc_1w(void);
JL_DLLEXPORT jl_value_t *jl_gc_alloc_2w(void);
JL_DLLEXPORT jl_value_t *jl_gc_alloc_3w(void);
JL_DLLEXPORT jl_value_t *jl_gc_allocobj(size_t sz);
JL_DLLEXPORT void jl_clear_malloc_data(void);
// GC write barriers
JL_DLLEXPORT void jl_gc_queue_root(jl_value_t *root); // root isa jl_value_t*
STATIC_INLINE void jl_gc_wb(void *parent, void *ptr)
{
// parent and ptr isa jl_value_t*
if (__unlikely((jl_astaggedvalue(parent)->gc_bits & 1) == 1 &&
(jl_astaggedvalue(ptr)->gc_bits & 1) == 0))
jl_gc_queue_root((jl_value_t*)parent);
}
STATIC_INLINE void jl_gc_wb_back(void *ptr) // ptr isa jl_value_t*
{
// if ptr is marked
if (__unlikely((jl_astaggedvalue(ptr)->gc_bits & 1) == 1)) {
jl_gc_queue_root((jl_value_t*)ptr);
}
}
JL_DLLEXPORT void *jl_gc_managed_malloc(size_t sz);
JL_DLLEXPORT void *jl_gc_managed_realloc(void *d, size_t sz, size_t oldsz,
int isaligned, jl_value_t* owner);
// object accessors -----------------------------------------------------------
#define jl_typeis(v,t) (jl_typeof(v)==(jl_value_t*)(t))
#define jl_svec_len(t) (((jl_svec_t*)(t))->length)
#define jl_svec_set_len_unsafe(t,n) (((jl_svec_t*)(t))->length=(n))
#define jl_svec_data(t) ((jl_value_t**)((char*)(t) + sizeof(jl_svec_t)))
STATIC_INLINE jl_value_t *jl_svecref(void *t, size_t i)
{
assert(jl_typeis(t,jl_simplevector_type));
assert(i < jl_svec_len(t));
return jl_svec_data(t)[i];
}
STATIC_INLINE jl_value_t *jl_svecset(void *t, size_t i, void *x)
{
assert(jl_typeis(t,jl_simplevector_type));
assert(i < jl_svec_len(t));
jl_svec_data(t)[i] = (jl_value_t*)x;
if (x) jl_gc_wb(t, x);
return (jl_value_t*)x;
}
#ifdef STORE_ARRAY_LEN
#define jl_array_len(a) (((jl_array_t*)(a))->length)
#else
JL_DLLEXPORT size_t jl_array_len_(jl_array_t *a);
#define jl_array_len(a) jl_array_len_((jl_array_t*)(a))
#endif
#define jl_array_data(a) ((void*)((jl_array_t*)(a))->data)
#define jl_array_dim(a,i) ((&((jl_array_t*)(a))->nrows)[i])
#define jl_array_dim0(a) (((jl_array_t*)(a))->nrows)
#define jl_array_nrows(a) (((jl_array_t*)(a))->nrows)
#define jl_array_ndims(a) ((int32_t)(((jl_array_t*)a)->ndims))
#define jl_array_data_owner_offset(ndims) (offsetof(jl_array_t,ncols) + sizeof(size_t)*(1+jl_array_ndimwords(ndims))) // in bytes
#define jl_array_data_owner(a) (*((jl_value_t**)((char*)a + jl_array_data_owner_offset(jl_array_ndims(a)))))
STATIC_INLINE jl_value_t *jl_cellref(void *a, size_t i)
{
assert(i < jl_array_len(a));
return ((jl_value_t**)(jl_array_data(a)))[i];
}
STATIC_INLINE jl_value_t *jl_cellset(void *a, size_t i, void *x)
{
assert(i < jl_array_len(a));
((jl_value_t**)(jl_array_data(a)))[i] = (jl_value_t*)x;
if (x) {
if (((jl_array_t*)a)->how == 3) {
a = jl_array_data_owner(a);
}
jl_gc_wb(a, x);
}
return (jl_value_t*)x;
}
#define jl_exprarg(e,n) (((jl_value_t**)jl_array_data(((jl_expr_t*)(e))->args))[n])
#define jl_exprargset(e, n, v) jl_cellset(((jl_expr_t*)(e))->args, n, v)
#define jl_expr_nargs(e) jl_array_len(((jl_expr_t*)(e))->args)
#define jl_fieldref(s,i) jl_get_nth_field(((jl_value_t*)s),i)
#define jl_nfields(v) jl_datatype_nfields(jl_typeof(v))
// Not using jl_fieldref to avoid allocations
#define jl_symbolnode_sym(s) (*(jl_sym_t**)s)
#define jl_symbolnode_type(s) (((jl_value_t**)s)[1])
#define jl_linenode_file(x) (*(jl_sym_t**)x)
#define jl_linenode_line(x) (((ptrint_t*)x)[1])
#define jl_labelnode_label(x) (((ptrint_t*)x)[0])
#define jl_gotonode_label(x) (((ptrint_t*)x)[0])
#define jl_globalref_mod(s) (*(jl_module_t**)s)
#define jl_globalref_name(s) (((jl_sym_t**)s)[1])
#define jl_nparams(t) jl_svec_len(((jl_datatype_t*)(t))->parameters)
#define jl_tparam0(t) jl_svecref(((jl_datatype_t*)(t))->parameters, 0)
#define jl_tparam1(t) jl_svecref(((jl_datatype_t*)(t))->parameters, 1)
#define jl_tparam(t,i) jl_svecref(((jl_datatype_t*)(t))->parameters, i)
// get a pointer to the data in a datatype
#define jl_data_ptr(v) ((jl_value_t**)v)
#define jl_cell_data(a) ((jl_value_t**)((jl_array_t*)a)->data)
#define jl_string_data(s) ((char*)((jl_array_t*)jl_data_ptr(s)[0])->data)
#define jl_string_len(s) (jl_array_len((jl_array_t*)(jl_data_ptr(s)[0])))
#define jl_iostr_data(s) ((char*)((jl_array_t*)jl_data_ptr(s)[0])->data)
#define jl_gf_mtable(f) ((jl_methtable_t*)((jl_function_t*)(f))->env)
#define jl_gf_name(f) (jl_gf_mtable(f)->name)
// struct type info
#define jl_field_name(st,i) (jl_sym_t*)jl_svecref(((jl_datatype_t*)st)->name->names, (i))
#define jl_field_type(st,i) jl_svecref(((jl_datatype_t*)st)->types, (i))
#define jl_datatype_size(t) (((jl_datatype_t*)t)->size)
#define jl_datatype_nfields(t) (((jl_datatype_t*)(t))->nfields)
// inline version with strong type check to detect typos in a `->name` chain
STATIC_INLINE char *jl_symbol_name_(jl_sym_t *s)
{
return (char*)s + LLT_ALIGN(sizeof(jl_sym_t), sizeof(void*));
}
#define jl_symbol_name(s) jl_symbol_name_(s)
#define jl_datatype_fields(d) ((char*)(d) + sizeof(jl_datatype_t))
#define DEFINE_FIELD_ACCESSORS(f) \
static inline uint32_t jl_field_##f(jl_datatype_t *st, int i) \
{ \
if (st->fielddesc_type == 0) { \
return ((jl_fielddesc8_t*)jl_datatype_fields(st))[i].f; \
} \
else if (st->fielddesc_type == 1) { \
return ((jl_fielddesc16_t*)jl_datatype_fields(st))[i].f; \
} \
else { \
return ((jl_fielddesc32_t*)jl_datatype_fields(st))[i].f; \
} \
} \
static inline void jl_field_set##f(jl_datatype_t *st, int i, \
uint32_t val) \
{ \
if (st->fielddesc_type == 0) { \
((jl_fielddesc8_t*)jl_datatype_fields(st))[i].f = val; \
} \
else if (st->fielddesc_type == 1) { \
((jl_fielddesc16_t*)jl_datatype_fields(st))[i].f = val; \
} \
else { \
((jl_fielddesc32_t*)jl_datatype_fields(st))[i].f = val; \
} \
}
DEFINE_FIELD_ACCESSORS(offset)
DEFINE_FIELD_ACCESSORS(size)
DEFINE_FIELD_ACCESSORS(isptr)
static inline uint32_t jl_fielddesc_size(int8_t fielddesc_type)
{
if (fielddesc_type == 0) {
return sizeof(jl_fielddesc8_t);
}
else if (fielddesc_type == 1) {
return sizeof(jl_fielddesc16_t);
}
else {
return sizeof(jl_fielddesc32_t);
}
}
#undef DEFINE_FIELD_ACCESSORS
// basic predicates -----------------------------------------------------------
#define jl_is_nothing(v) (((jl_value_t*)(v)) == ((jl_value_t*)jl_nothing))
#define jl_is_tuple(v) (((jl_datatype_t*)jl_typeof(v))->name == jl_tuple_typename)
#define jl_is_svec(v) jl_typeis(v,jl_simplevector_type)
#define jl_is_simplevector(v) jl_is_svec(v)
#define jl_is_datatype(v) jl_typeis(v,jl_datatype_type)
#define jl_is_pointerfree(t) (((jl_datatype_t*)t)->pointerfree)
#define jl_is_mutable(t) (((jl_datatype_t*)t)->mutabl)
#define jl_is_mutable_datatype(t) (jl_is_datatype(t) && (((jl_datatype_t*)t)->mutabl))
#define jl_is_immutable(t) (!((jl_datatype_t*)t)->mutabl)
#define jl_is_immutable_datatype(t) (jl_is_datatype(t) && (!((jl_datatype_t*)t)->mutabl))
#define jl_is_uniontype(v) jl_typeis(v,jl_uniontype_type)
#define jl_is_typevar(v) jl_typeis(v,jl_tvar_type)
#define jl_is_typector(v) jl_typeis(v,jl_typector_type)
#define jl_is_TypeConstructor(v) jl_typeis(v,jl_typector_type)
#define jl_is_typename(v) jl_typeis(v,jl_typename_type)
#define jl_is_int8(v) jl_typeis(v,jl_int8_type)
#define jl_is_int16(v) jl_typeis(v,jl_int16_type)
#define jl_is_int32(v) jl_typeis(v,jl_int32_type)
#define jl_is_int64(v) jl_typeis(v,jl_int64_type)
#define jl_is_uint8(v) jl_typeis(v,jl_uint8_type)
#define jl_is_uint16(v) jl_typeis(v,jl_uint16_type)
#define jl_is_uint32(v) jl_typeis(v,jl_uint32_type)
#define jl_is_uint64(v) jl_typeis(v,jl_uint64_type)
#define jl_is_float(v) jl_subtype(v,(jl_value_t*)jl_floatingpoint_type,1)
#define jl_is_floattype(v) jl_subtype(v,(jl_value_t*)jl_floatingpoint_type,0)
#define jl_is_float32(v) jl_typeis(v,jl_float32_type)
#define jl_is_float64(v) jl_typeis(v,jl_float64_type)
#define jl_is_bool(v) jl_typeis(v,jl_bool_type)
#define jl_is_symbol(v) jl_typeis(v,jl_sym_type)
#define jl_is_gensym(v) jl_typeis(v,jl_gensym_type)
#define jl_is_expr(v) jl_typeis(v,jl_expr_type)
#define jl_is_symbolnode(v) jl_typeis(v,jl_symbolnode_type)
#define jl_is_globalref(v) jl_typeis(v,jl_globalref_type)
#define jl_is_labelnode(v) jl_typeis(v,jl_labelnode_type)
#define jl_is_gotonode(v) jl_typeis(v,jl_gotonode_type)
#define jl_is_quotenode(v) jl_typeis(v,jl_quotenode_type)
#define jl_is_newvarnode(v) jl_typeis(v,jl_newvarnode_type)
#define jl_is_topnode(v) jl_typeis(v,jl_topnode_type)
#define jl_is_linenode(v) jl_typeis(v,jl_linenumbernode_type)
#define jl_is_lambda_info(v) jl_typeis(v,jl_lambda_info_type)
#define jl_is_module(v) jl_typeis(v,jl_module_type)
#define jl_is_mtable(v) jl_typeis(v,jl_methtable_type)
#define jl_is_task(v) jl_typeis(v,jl_task_type)
#define jl_is_func(v) jl_typeis(v,jl_function_type)
#define jl_is_function(v) jl_is_func(v)
#define jl_is_ascii_string(v) jl_typeis(v,jl_ascii_string_type)
#define jl_is_utf8_string(v) jl_typeis(v,jl_utf8_string_type)
#define jl_is_byte_string(v) (jl_is_ascii_string(v) || jl_is_utf8_string(v))
#define jl_is_cpointer(v) jl_is_cpointer_type(jl_typeof(v))
#define jl_is_pointer(v) jl_is_cpointer_type(jl_typeof(v))
#define jl_is_gf(f) (((jl_function_t*)(f))->fptr==jl_apply_generic)
STATIC_INLINE int jl_is_bitstype(void *v)
{
return (jl_is_datatype(v) && jl_is_immutable(v) &&
jl_datatype_nfields(v) == 0 &&
!((jl_datatype_t*)(v))->abstract &&
((jl_datatype_t*)(v))->size > 0);
}
STATIC_INLINE int jl_is_structtype(void *v)
{
return (jl_is_datatype(v) &&
(jl_datatype_nfields(v) > 0 ||
((jl_datatype_t*)(v))->size == 0) &&
!((jl_datatype_t*)(v))->abstract);
}
STATIC_INLINE int jl_isbits(void *t) // corresponding to isbits() in julia
{
return (jl_is_datatype(t) && !((jl_datatype_t*)t)->mutabl &&
((jl_datatype_t*)t)->pointerfree && !((jl_datatype_t*)t)->abstract);
}
STATIC_INLINE int jl_is_datatype_singleton(jl_datatype_t *d)
{
return (d->instance != NULL ||
(!d->abstract && d->size == 0 && d != jl_sym_type && d->name != jl_array_typename &&
(d->name->names == jl_emptysvec || !d->mutabl)));
}
STATIC_INLINE int jl_is_abstracttype(void *v)
{
return (jl_is_datatype(v) && ((jl_datatype_t*)(v))->abstract);
}
STATIC_INLINE int jl_is_array_type(void *t)
{
return (jl_is_datatype(t) &&
((jl_datatype_t*)(t))->name == jl_array_typename);
}
STATIC_INLINE int jl_is_array(void *v)
{
jl_value_t *t = jl_typeof(v);
return jl_is_array_type(t);
}
STATIC_INLINE int jl_is_cpointer_type(jl_value_t *t)
{
return (jl_is_datatype(t) &&
((jl_datatype_t*)(t))->name == jl_pointer_type->name);
}
STATIC_INLINE int jl_is_abstract_ref_type(jl_value_t *t)
{
return (jl_is_datatype(t) &&
((jl_datatype_t*)(t))->name == jl_ref_type->name);
}
STATIC_INLINE jl_value_t *jl_is_ref_type(jl_value_t *t)
{
if (!jl_is_datatype(t)) return 0;
jl_datatype_t *dt = (jl_datatype_t*)t;
while (dt != jl_any_type && dt->name != dt->super->name) {
if (dt->name == jl_ref_type->name)
return (jl_value_t*)dt;
dt = dt->super;
}
return 0;
}
STATIC_INLINE int jl_is_tuple_type(void *t)
{
return (jl_is_datatype(t) &&
((jl_datatype_t*)(t))->name == jl_tuple_typename);
}
STATIC_INLINE int jl_is_vararg_type(jl_value_t *v)
{
return (jl_is_datatype(v) &&
((jl_datatype_t*)(v))->name == jl_vararg_type->name);
}
STATIC_INLINE int jl_is_va_tuple(jl_datatype_t *t)
{
size_t l = jl_svec_len(t->parameters);
return (l>0 && jl_is_vararg_type(jl_tparam(t,l-1)));
}
STATIC_INLINE int jl_is_ntuple_type(jl_value_t *v)
{
return (jl_is_datatype(v) &&
((jl_datatype_t*)v)->name == jl_ntuple_typename);
}
STATIC_INLINE int jl_is_type_type(jl_value_t *v)
{
return (jl_is_datatype(v) &&
((jl_datatype_t*)(v))->name == jl_type_type->name);
}
// object identity
JL_DLLEXPORT int jl_egal(jl_value_t *a, jl_value_t *b);
JL_DLLEXPORT uptrint_t jl_object_id(jl_value_t *v);
// type predicates and basic operations
JL_DLLEXPORT int jl_is_leaf_type(jl_value_t *v);
JL_DLLEXPORT int jl_has_typevars(jl_value_t *v);
JL_DLLEXPORT int jl_subtype(jl_value_t *a, jl_value_t *b, int ta);
JL_DLLEXPORT int jl_types_equal(jl_value_t *a, jl_value_t *b);
JL_DLLEXPORT jl_value_t *jl_type_union(jl_svec_t *types);
JL_DLLEXPORT jl_value_t *jl_type_intersection(jl_value_t *a, jl_value_t *b);
JL_DLLEXPORT int jl_args_morespecific(jl_value_t *a, jl_value_t *b);
JL_DLLEXPORT const char *jl_typename_str(jl_value_t *v);
JL_DLLEXPORT const char *jl_typeof_str(jl_value_t *v);
JL_DLLEXPORT int jl_type_morespecific(jl_value_t *a, jl_value_t *b);
// type constructors
JL_DLLEXPORT jl_typename_t *jl_new_typename(jl_sym_t *name);
JL_DLLEXPORT jl_tvar_t *jl_new_typevar(jl_sym_t *name,jl_value_t *lb,jl_value_t *ub);
JL_DLLEXPORT jl_value_t *jl_apply_type(jl_value_t *tc, jl_svec_t *params);
JL_DLLEXPORT jl_tupletype_t *jl_apply_tuple_type(jl_svec_t *params);
JL_DLLEXPORT jl_tupletype_t *jl_apply_tuple_type_v(jl_value_t **p, size_t np);
JL_DLLEXPORT jl_datatype_t *jl_new_uninitialized_datatype(size_t nfields,
int8_t fielddesc_type);
JL_DLLEXPORT jl_datatype_t *jl_new_datatype(jl_sym_t *name, jl_datatype_t *super,
jl_svec_t *parameters,
jl_svec_t *fnames, jl_svec_t *ftypes,
int abstract, int mutabl,
int ninitialized);
JL_DLLEXPORT jl_datatype_t *jl_new_bitstype(jl_value_t *name,
jl_datatype_t *super,
jl_svec_t *parameters, size_t nbits);