Skip to content

Commit 697a40b

Browse files
pchintalapudiPrem Chintalapudi
andauthored
Remove STORE_ARRAY_LEN option and associated dead code (#43476)
Co-authored-by: Prem Chintalapudi <premc@csail.mit.edu>
1 parent 4b83a64 commit 697a40b

File tree

5 files changed

+0
-85
lines changed

5 files changed

+0
-85
lines changed

src/array.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims,
153153
a->data = data;
154154
if (JL_ARRAY_IMPL_NUL && elsz == 1)
155155
((char*)data)[tot - 1] = '\0';
156-
#ifdef STORE_ARRAY_LEN
157156
a->length = nel;
158-
#endif
159157
a->flags.ndims = ndims;
160158
a->flags.ptrarray = !isunboxed;
161159
a->flags.hasptr = hasptr;
@@ -257,9 +255,7 @@ JL_DLLEXPORT jl_array_t *jl_reshape_array(jl_value_t *atype, jl_array_t *data,
257255

258256
if (ndims == 1) {
259257
size_t l = dims[0];
260-
#ifdef STORE_ARRAY_LEN
261258
a->length = l;
262-
#endif
263259
a->nrows = l;
264260
a->maxsize = l;
265261
}
@@ -277,9 +273,7 @@ JL_DLLEXPORT jl_array_t *jl_reshape_array(jl_value_t *atype, jl_array_t *data,
277273
jl_exceptionf(jl_argumenterror_type, "invalid Array dimensions");
278274
l = prod;
279275
}
280-
#ifdef STORE_ARRAY_LEN
281276
a->length = l;
282-
#endif
283277
}
284278

285279
return a;
@@ -305,9 +299,7 @@ JL_DLLEXPORT jl_array_t *jl_string_to_array(jl_value_t *str)
305299
a->flags.how = 3;
306300
a->flags.isshared = 1;
307301
size_t l = jl_string_len(str);
308-
#ifdef STORE_ARRAY_LEN
309302
a->length = l;
310-
#endif
311303
a->nrows = a->maxsize = l;
312304
return a;
313305
}
@@ -343,9 +335,7 @@ JL_DLLEXPORT jl_array_t *jl_ptr_to_array_1d(jl_value_t *atype, void *data,
343335
// No allocation or safepoint allowed after this
344336
a->flags.pooled = tsz <= GC_MAX_SZCLASS;
345337
a->data = data;
346-
#ifdef STORE_ARRAY_LEN
347338
a->length = nel;
348-
#endif
349339
a->elsize = LLT_ALIGN(elsz, align);
350340
a->flags.ptrarray = !isunboxed;
351341
a->flags.hasptr = isunboxed && (jl_is_datatype(eltype) && ((jl_datatype_t*)eltype)->layout->npointers > 0);
@@ -410,9 +400,7 @@ JL_DLLEXPORT jl_array_t *jl_ptr_to_array(jl_value_t *atype, void *data,
410400
// No allocation or safepoint allowed after this
411401
a->flags.pooled = tsz <= GC_MAX_SZCLASS;
412402
a->data = data;
413-
#ifdef STORE_ARRAY_LEN
414403
a->length = nel;
415-
#endif
416404
a->elsize = LLT_ALIGN(elsz, align);
417405
a->flags.ptrarray = !isunboxed;
418406
a->flags.hasptr = isunboxed && (jl_is_datatype(eltype) && ((jl_datatype_t*)eltype)->layout->npointers > 0);
@@ -486,17 +474,13 @@ JL_DLLEXPORT jl_value_t *jl_array_to_string(jl_array_t *a)
486474
a->flags.isshared = 1;
487475
*(size_t*)o = len;
488476
a->nrows = 0;
489-
#ifdef STORE_ARRAY_LEN
490477
a->length = 0;
491-
#endif
492478
a->maxsize = 0;
493479
return o;
494480
}
495481
}
496482
a->nrows = 0;
497-
#ifdef STORE_ARRAY_LEN
498483
a->length = 0;
499-
#endif
500484
a->maxsize = 0;
501485
return jl_pchar_to_string((const char*)jl_array_data(a), len);
502486
}
@@ -558,16 +542,6 @@ JL_DLLEXPORT jl_value_t *jl_apply_array_type(jl_value_t *type, size_t dim)
558542

559543
// array primitives -----------------------------------------------------------
560544

561-
#ifndef STORE_ARRAY_LEN
562-
JL_DLLEXPORT size_t jl_array_len_(jl_array_t *a)
563-
{
564-
size_t l = 1;
565-
for(size_t i=0; i < jl_array_ndims(a); i++)
566-
l *= jl_array_dim(a, i);
567-
return l;
568-
}
569-
#endif
570-
571545
JL_DLLEXPORT jl_value_t *jl_ptrarrayref(jl_array_t *a JL_PROPAGATES_ROOT, size_t i) JL_NOTSAFEPOINT
572546
{
573547
assert(i < jl_array_len(a));
@@ -871,9 +845,7 @@ STATIC_INLINE void jl_array_grow_at_beg(jl_array_t *a, size_t idx, size_t inc,
871845
}
872846
}
873847
}
874-
#ifdef STORE_ARRAY_LEN
875848
a->length = newnrows;
876-
#endif
877849
a->nrows = newnrows;
878850
a->data = newdata;
879851
if (jl_is_array_zeroinit(a)) {
@@ -952,9 +924,7 @@ STATIC_INLINE void jl_array_grow_at_end(jl_array_t *a, size_t idx,
952924
memset(typetagdata + idx, 0, inc);
953925
}
954926
size_t newnrows = n + inc;
955-
#ifdef STORE_ARRAY_LEN
956927
a->length = newnrows;
957-
#endif
958928
a->nrows = newnrows;
959929
if (jl_is_array_zeroinit(a)) {
960930
memset(data + idx * elsz, 0, inc * elsz);
@@ -1074,9 +1044,7 @@ STATIC_INLINE void jl_array_del_at_beg(jl_array_t *a, size_t idx, size_t dec,
10741044
size_t offset = a->offset;
10751045
int isbitsunion = jl_array_isbitsunion(a);
10761046
offset += dec;
1077-
#ifdef STORE_ARRAY_LEN
10781047
a->length = n - dec;
1079-
#endif
10801048
a->nrows = n - dec;
10811049
size_t newoffs = jl_array_limit_offset(a, offset);
10821050
assert(newoffs <= offset);
@@ -1134,9 +1102,7 @@ STATIC_INLINE void jl_array_del_at_end(jl_array_t *a, size_t idx, size_t dec,
11341102
if (elsz == 1 && !isbitsunion)
11351103
data[n] = 0;
11361104
a->nrows = n;
1137-
#ifdef STORE_ARRAY_LEN
11381105
a->length = n;
1139-
#endif
11401106
}
11411107

11421108
JL_DLLEXPORT void jl_array_del_at(jl_array_t *a, ssize_t idx, size_t dec)
@@ -1200,9 +1166,7 @@ JL_DLLEXPORT void jl_array_sizehint(jl_array_t *a, size_t sz)
12001166
jl_array_grow_end(a, inc);
12011167

12021168
a->nrows = n;
1203-
#ifdef STORE_ARRAY_LEN
12041169
a->length = n;
1205-
#endif
12061170
}
12071171
}
12081172

src/cgutils.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,7 +2464,6 @@ static Value *emit_arraylen_prim(jl_codectx_t &ctx, const jl_cgval_t &tinfo)
24642464
}
24652465
}
24662466
Value *t = boxed(ctx, tinfo);
2467-
#ifdef STORE_ARRAY_LEN
24682467
Value *addr = ctx.builder.CreateStructGEP(jl_array_llvmt,
24692468
emit_bitcast(ctx, decay_derived(ctx, t), jl_parray_llvmt),
24702469
1); //index (not offset) of length field in jl_parray_llvmt
@@ -2474,25 +2473,6 @@ static Value *emit_arraylen_prim(jl_codectx_t &ctx, const jl_cgval_t &tinfo)
24742473
auto rng = MDB.createRange(V_size0, ConstantInt::get(T_size, arraytype_maxsize(tinfo.typ)));
24752474
len->setMetadata(LLVMContext::MD_range, rng);
24762475
return tbaa_decorate(tbaa, len);
2477-
#else
2478-
(void)tbaa;
2479-
jl_value_t *p1 = jl_tparam1(ty); // FIXME: check that ty is an array type
2480-
if (jl_is_long(p1)) {
2481-
size_t nd = jl_unbox_long(p1);
2482-
Value *l = ConstantInt::get(T_size, 1);
2483-
for(size_t i=0; i < nd; i++) {
2484-
l = ctx.builder.CreateMul(l, emit_arraysize(ctx, t, (int)(i + 1)));
2485-
}
2486-
return l;
2487-
}
2488-
else {
2489-
std::vector<Type *> fargt(0);
2490-
fargt.push_back(T_pjlvalue);
2491-
FunctionType *ft = FunctionType::get(T_size, fargt, false);
2492-
Value *alen = jl_Module->getOrInsertFunction("jl_array_len_", ft); // TODO: move to codegen init block
2493-
return ctx.builder.CreateCall(prepare_call(alen), t);
2494-
}
2495-
#endif
24962476
}
24972477

24982478
static Value *emit_arraylen(jl_codectx_t &ctx, const jl_cgval_t &tinfo)
@@ -2555,11 +2535,7 @@ static Value *emit_arraysize(jl_codectx_t &ctx, const jl_cgval_t &tinfo, jl_valu
25552535
static Value *emit_arrayflags(jl_codectx_t &ctx, const jl_cgval_t &tinfo)
25562536
{
25572537
Value *t = boxed(ctx, tinfo);
2558-
#ifdef STORE_ARRAY_LEN
25592538
int arrayflag_field = 2;
2560-
#else
2561-
int arrayflag_field = 1;
2562-
#endif
25632539
Value *addr = ctx.builder.CreateStructGEP(
25642540
jl_array_llvmt,
25652541
emit_bitcast(ctx, decay_derived(ctx, t), jl_parray_llvmt),
@@ -2579,11 +2555,7 @@ static Value *emit_arrayndims(jl_codectx_t &ctx, const jl_cgval_t &ary)
25792555
static Value *emit_arrayelsize(jl_codectx_t &ctx, const jl_cgval_t &tinfo)
25802556
{
25812557
Value *t = boxed(ctx, tinfo);
2582-
#ifdef STORE_ARRAY_LEN
25832558
int elsize_field = 3;
2584-
#else
2585-
int elsize_field = 2;
2586-
#endif
25872559
Value *addr = ctx.builder.CreateStructGEP(jl_array_llvmt,
25882560
emit_bitcast(ctx, decay_derived(ctx, t), jl_parray_llvmt),
25892561
elsize_field);
@@ -2595,11 +2567,7 @@ static Value *emit_arrayoffset(jl_codectx_t &ctx, const jl_cgval_t &tinfo, int n
25952567
if (nd != -1 && nd != 1) // only Vector can have an offset
25962568
return ConstantInt::get(T_int32, 0);
25972569
Value *t = boxed(ctx, tinfo);
2598-
#ifdef STORE_ARRAY_LEN
25992570
int offset_field = 4;
2600-
#else
2601-
int offset_field = 3;
2602-
#endif
26032571

26042572
Value *addr = ctx.builder.CreateStructGEP(
26052573
jl_array_llvmt,

src/codegen.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7853,9 +7853,7 @@ static void init_julia_llvm_env(Module *m)
78537853
assert(jl_func_sig_sparams != NULL);
78547854

78557855
Type *vaelts[] = {PointerType::get(T_int8, AddressSpace::Loaded)
7856-
#ifdef STORE_ARRAY_LEN
78577856
, T_size
7858-
#endif
78597857
, T_int16
78607858
, T_int16
78617859
, T_int32

src/julia.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
#undef jl_longjmp
1010
#endif
1111

12-
//** Configuration options that affect the Julia ABI **//
13-
// if this is not defined, only individual dimension sizes are
14-
// stored and not total length, to save space.
15-
#define STORE_ARRAY_LEN
16-
//** End Configuration options **//
17-
1812
#include "julia_fasttls.h"
1913
#include "libsupport.h"
2014
#include <stdint.h>
@@ -174,9 +168,7 @@ typedef struct {
174168
JL_EXTENSION typedef struct {
175169
JL_DATA_TYPE
176170
void *data;
177-
#ifdef STORE_ARRAY_LEN
178171
size_t length;
179-
#endif
180172
jl_array_flags_t flags;
181173
uint16_t elsize; // element size including alignment (dim 1 memory stride)
182174
uint32_t offset; // for 1-d only. does not need to get big.
@@ -920,12 +912,7 @@ STATIC_INLINE jl_value_t *jl_svecset(
920912
}
921913
#endif
922914

923-
#ifdef STORE_ARRAY_LEN
924915
#define jl_array_len(a) (((jl_array_t*)(a))->length)
925-
#else
926-
JL_DLLEXPORT size_t jl_array_len_(jl_array_t *a);
927-
#define jl_array_len(a) jl_array_len_((jl_array_t*)(a))
928-
#endif
929916
#define jl_array_data(a) ((void*)((jl_array_t*)(a))->data)
930917
#define jl_array_dim(a,i) ((&((jl_array_t*)(a))->nrows)[i])
931918
#define jl_array_dim0(a) (((jl_array_t*)(a))->nrows)

src/sys.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,7 @@ JL_DLLEXPORT jl_value_t *jl_readuntil(ios_t *s, uint8_t delim, uint8_t str, uint
530530
a = jl_take_buffer(&dest);
531531
}
532532
else {
533-
#ifdef STORE_ARRAY_LEN
534533
a->length = n;
535-
#endif
536534
a->nrows = n;
537535
((char*)a->data)[n] = '\0';
538536
}

0 commit comments

Comments
 (0)