@@ -77,7 +77,7 @@ size_t jl_arr_xtralloc_limit = 0;
77
77
static jl_array_t * _new_array_ (jl_value_t * atype , uint32_t ndims , size_t * dims ,
78
78
int8_t isunboxed , int8_t hasptr , int8_t isunion , int8_t zeroinit , int elsz )
79
79
{
80
- jl_ptls_t ptls = jl_get_ptls_states () ;
80
+ jl_task_t * ct = jl_current_task ;
81
81
size_t i , tot , nel = 1 ;
82
82
void * data ;
83
83
jl_array_t * a ;
@@ -119,7 +119,7 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims,
119
119
size_t doffs = tsz ;
120
120
tsz += tot ;
121
121
tsz = JL_ARRAY_ALIGN (tsz , JL_SMALL_BYTE_ALIGNMENT ); // align whole object
122
- a = (jl_array_t * )jl_gc_alloc (ptls , tsz , atype );
122
+ a = (jl_array_t * )jl_gc_alloc (ct -> ptls , tsz , atype );
123
123
// No allocation or safepoint allowed after this
124
124
a -> flags .how = 0 ;
125
125
data = (char * )a + doffs ;
@@ -129,10 +129,10 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims,
129
129
data = jl_gc_managed_malloc (tot );
130
130
// Allocate the Array **after** allocating the data
131
131
// to make sure the array is still young
132
- a = (jl_array_t * )jl_gc_alloc (ptls , tsz , atype );
132
+ a = (jl_array_t * )jl_gc_alloc (ct -> ptls , tsz , atype );
133
133
// No allocation or safepoint allowed after this
134
134
a -> flags .how = 2 ;
135
- jl_gc_track_malloced_array (ptls , a );
135
+ jl_gc_track_malloced_array (ct -> ptls , a );
136
136
}
137
137
a -> flags .pooled = tsz <= GC_MAX_SZCLASS ;
138
138
@@ -213,7 +213,7 @@ static inline int is_ntuple_long(jl_value_t *v)
213
213
JL_DLLEXPORT jl_array_t * jl_reshape_array (jl_value_t * atype , jl_array_t * data ,
214
214
jl_value_t * _dims )
215
215
{
216
- jl_ptls_t ptls = jl_get_ptls_states () ;
216
+ jl_task_t * ct = jl_current_task ;
217
217
jl_array_t * a ;
218
218
size_t ndims = jl_nfields (_dims );
219
219
assert (is_ntuple_long (_dims ));
@@ -222,7 +222,7 @@ JL_DLLEXPORT jl_array_t *jl_reshape_array(jl_value_t *atype, jl_array_t *data,
222
222
223
223
int ndimwords = jl_array_ndimwords (ndims );
224
224
int tsz = JL_ARRAY_ALIGN (sizeof (jl_array_t ) + ndimwords * sizeof (size_t ) + sizeof (void * ), JL_SMALL_BYTE_ALIGNMENT );
225
- a = (jl_array_t * )jl_gc_alloc (ptls , tsz , atype );
225
+ a = (jl_array_t * )jl_gc_alloc (ct -> ptls , tsz , atype );
226
226
// No allocation or safepoint allowed after this
227
227
a -> flags .pooled = tsz <= GC_MAX_SZCLASS ;
228
228
a -> flags .ndims = ndims ;
@@ -298,12 +298,12 @@ JL_DLLEXPORT jl_array_t *jl_reshape_array(jl_value_t *atype, jl_array_t *data,
298
298
299
299
JL_DLLEXPORT jl_array_t * jl_string_to_array (jl_value_t * str )
300
300
{
301
- jl_ptls_t ptls = jl_get_ptls_states () ;
301
+ jl_task_t * ct = jl_current_task ;
302
302
jl_array_t * a ;
303
303
304
304
int ndimwords = jl_array_ndimwords (1 );
305
305
int tsz = JL_ARRAY_ALIGN (sizeof (jl_array_t ) + ndimwords * sizeof (size_t ) + sizeof (void * ), JL_SMALL_BYTE_ALIGNMENT );
306
- a = (jl_array_t * )jl_gc_alloc (ptls , tsz , jl_array_uint8_type );
306
+ a = (jl_array_t * )jl_gc_alloc (ct -> ptls , tsz , jl_array_uint8_type );
307
307
a -> flags .pooled = tsz <= GC_MAX_SZCLASS ;
308
308
a -> flags .ndims = 1 ;
309
309
a -> offset = 0 ;
@@ -327,7 +327,7 @@ JL_DLLEXPORT jl_array_t *jl_string_to_array(jl_value_t *str)
327
327
JL_DLLEXPORT jl_array_t * jl_ptr_to_array_1d (jl_value_t * atype , void * data ,
328
328
size_t nel , int own_buffer )
329
329
{
330
- jl_ptls_t ptls = jl_get_ptls_states () ;
330
+ jl_task_t * ct = jl_current_task ;
331
331
jl_array_t * a ;
332
332
jl_value_t * eltype = jl_tparam0 (atype );
333
333
@@ -350,7 +350,7 @@ JL_DLLEXPORT jl_array_t *jl_ptr_to_array_1d(jl_value_t *atype, void *data,
350
350
351
351
int ndimwords = jl_array_ndimwords (1 );
352
352
int tsz = JL_ARRAY_ALIGN (sizeof (jl_array_t ) + ndimwords * sizeof (size_t ), JL_CACHE_BYTE_ALIGNMENT );
353
- a = (jl_array_t * )jl_gc_alloc (ptls , tsz , atype );
353
+ a = (jl_array_t * )jl_gc_alloc (ct -> ptls , tsz , atype );
354
354
// No allocation or safepoint allowed after this
355
355
a -> flags .pooled = tsz <= GC_MAX_SZCLASS ;
356
356
a -> data = data ;
@@ -365,7 +365,7 @@ JL_DLLEXPORT jl_array_t *jl_ptr_to_array_1d(jl_value_t *atype, void *data,
365
365
a -> flags .isaligned = 0 ; // TODO: allow passing memalign'd buffers
366
366
if (own_buffer ) {
367
367
a -> flags .how = 2 ;
368
- jl_gc_track_malloced_array (ptls , a );
368
+ jl_gc_track_malloced_array (ct -> ptls , a );
369
369
jl_gc_count_allocd (nel * elsz + (elsz == 1 ? 1 : 0 ));
370
370
}
371
371
else {
@@ -381,7 +381,7 @@ JL_DLLEXPORT jl_array_t *jl_ptr_to_array_1d(jl_value_t *atype, void *data,
381
381
JL_DLLEXPORT jl_array_t * jl_ptr_to_array (jl_value_t * atype , void * data ,
382
382
jl_value_t * _dims , int own_buffer )
383
383
{
384
- jl_ptls_t ptls = jl_get_ptls_states () ;
384
+ jl_task_t * ct = jl_current_task ;
385
385
size_t nel = 1 ;
386
386
jl_array_t * a ;
387
387
size_t ndims = jl_nfields (_dims );
@@ -417,7 +417,7 @@ JL_DLLEXPORT jl_array_t *jl_ptr_to_array(jl_value_t *atype, void *data,
417
417
418
418
int ndimwords = jl_array_ndimwords (ndims );
419
419
int tsz = JL_ARRAY_ALIGN (sizeof (jl_array_t ) + ndimwords * sizeof (size_t ), JL_CACHE_BYTE_ALIGNMENT );
420
- a = (jl_array_t * )jl_gc_alloc (ptls , tsz , atype );
420
+ a = (jl_array_t * )jl_gc_alloc (ct -> ptls , tsz , atype );
421
421
// No allocation or safepoint allowed after this
422
422
a -> flags .pooled = tsz <= GC_MAX_SZCLASS ;
423
423
a -> data = data ;
@@ -433,7 +433,7 @@ JL_DLLEXPORT jl_array_t *jl_ptr_to_array(jl_value_t *atype, void *data,
433
433
a -> flags .isaligned = 0 ;
434
434
if (own_buffer ) {
435
435
a -> flags .how = 2 ;
436
- jl_gc_track_malloced_array (ptls , a );
436
+ jl_gc_track_malloced_array (ct -> ptls , a );
437
437
jl_gc_count_allocd (nel * elsz + (elsz == 1 ? 1 : 0 ));
438
438
}
439
439
else {
@@ -519,7 +519,8 @@ JL_DLLEXPORT jl_value_t *jl_pchar_to_string(const char *str, size_t len)
519
519
jl_throw (jl_memory_exception );
520
520
if (len == 0 )
521
521
return jl_an_empty_string ;
522
- jl_value_t * s = jl_gc_alloc_ (jl_get_ptls_states (), sz , jl_string_type ); // force inlining
522
+ jl_task_t * ct = jl_current_task ;
523
+ jl_value_t * s = jl_gc_alloc_ (ct -> ptls , sz , jl_string_type ); // force inlining
523
524
* (size_t * )s = len ;
524
525
memcpy ((char * )s + sizeof (size_t ), str , len );
525
526
((char * )s + sizeof (size_t ))[len ] = 0 ;
@@ -533,7 +534,8 @@ JL_DLLEXPORT jl_value_t *jl_alloc_string(size_t len)
533
534
jl_throw (jl_memory_exception );
534
535
if (len == 0 )
535
536
return jl_an_empty_string ;
536
- jl_value_t * s = jl_gc_alloc_ (jl_get_ptls_states (), sz , jl_string_type ); // force inlining
537
+ jl_task_t * ct = jl_current_task ;
538
+ jl_value_t * s = jl_gc_alloc_ (ct -> ptls , sz , jl_string_type ); // force inlining
537
539
* (size_t * )s = len ;
538
540
((char * )s + sizeof (size_t ))[len ] = 0 ;
539
541
return s ;
@@ -672,7 +674,7 @@ JL_DLLEXPORT void jl_arrayunset(jl_array_t *a, size_t i)
672
674
// the **beginning** of the new buffer.
673
675
static int NOINLINE array_resize_buffer (jl_array_t * a , size_t newlen )
674
676
{
675
- jl_ptls_t ptls = jl_get_ptls_states () ;
677
+ jl_task_t * ct = jl_current_task ;
676
678
assert (!a -> flags .isshared || a -> flags .how == 3 );
677
679
size_t elsz = a -> elsize ;
678
680
size_t nbytes = newlen * elsz ;
@@ -714,12 +716,12 @@ static int NOINLINE array_resize_buffer(jl_array_t *a, size_t newlen)
714
716
newbuf = 1 ;
715
717
if (nbytes >= MALLOC_THRESH ) {
716
718
a -> data = jl_gc_managed_malloc (nbytes );
717
- jl_gc_track_malloced_array (ptls , a );
719
+ jl_gc_track_malloced_array (ct -> ptls , a );
718
720
a -> flags .how = 2 ;
719
721
a -> flags .isaligned = 1 ;
720
722
}
721
723
else {
722
- a -> data = jl_gc_alloc_buf (ptls , nbytes );
724
+ a -> data = jl_gc_alloc_buf (ct -> ptls , nbytes );
723
725
a -> flags .how = 1 ;
724
726
jl_gc_wb_buf (a , a -> data , nbytes );
725
727
}
@@ -1008,8 +1010,9 @@ STATIC_INLINE void jl_array_shrink(jl_array_t *a, size_t dec)
1008
1010
typetagdata = (char * )malloc_s (a -> nrows );
1009
1011
memcpy (typetagdata , jl_array_typetagdata (a ), a -> nrows );
1010
1012
}
1013
+ jl_task_t * ct = jl_current_task ;
1011
1014
char * originaldata = (char * ) a -> data - a -> offset * a -> elsize ;
1012
- char * newdata = (char * )jl_gc_alloc_buf (jl_get_ptls_states () , newbytes );
1015
+ char * newdata = (char * )jl_gc_alloc_buf (ct -> ptls , newbytes );
1013
1016
jl_gc_wb_buf (a , newdata , newbytes );
1014
1017
a -> maxsize -= dec ;
1015
1018
if (isbitsunion ) {
0 commit comments