Skip to content

Commit 4ef1980

Browse files
committed
CHANGE: enhanced number of possible series flags from 8 to 32 (could be lowered in the future and use some of these bits for something else)
1 parent 6fb6e0f commit 4ef1980

File tree

6 files changed

+27
-23
lines changed

6 files changed

+27
-23
lines changed

src/core/c-do.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ x*/ static REBINT Do_Args_Light(REBVAL *func, REBVAL *path, REBSER *block, REBCN
10551055

10561056
CHECK_MEMORY(4); // Be sure we don't go far with a problem.
10571057

1058-
ASSERT1(block->info, RP_GC_OF_BLOCK);
1058+
ASSERT1(SERIES_SIZES(block), RP_GC_OF_BLOCK);
10591059

10601060
while (index < BLK_LEN(block)) {
10611061
index = Do_Next(block, index, 0);

src/core/c-word.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@
119119

120120
oser = *ser;
121121
*ser = *nser;
122-
ser->info = oser.info;
122+
ser->sizes = oser.sizes;
123+
ser->flags = oser.flags;
123124
*nser = oser;
124125

125126
Clear_Series(ser);

src/core/m-pools.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,8 @@ const REBPOOLSPEC Mem_Pool_Spec[MAX_POOLS] =
447447
series->tail = series->size = 0;
448448
SERIES_REST(series) = length / wide; //FIXME: This is based on the assumption that length is multiple of wide
449449
series->data = (REBYTE *)node;
450-
series->info = wide; // also clears flags
450+
series->sizes = wide; // also clears bias
451+
SERIES_FLAGS(series) = 0;
451452
LABEL_SERIES(series, "make");
452453

453454
if ((GC_Ballast -= length) <= 0) SET_SIGNAL(SIG_RECYCLE);
@@ -533,7 +534,8 @@ const REBPOOLSPEC Mem_Pool_Spec[MAX_POOLS] =
533534
clear_header:
534535
if (protect) {
535536
series->data = BAD_MEM_PTR; // force bad references to trap
536-
series->info = 0; // indicates series deallocated (wide = 0)
537+
series->sizes = 0; // indicates series deallocated (wide = 0)
538+
series->flags = 0;
537539
}
538540
}
539541

@@ -563,7 +565,8 @@ const REBPOOLSPEC Mem_Pool_Spec[MAX_POOLS] =
563565
if (!IS_EXT_SERIES(series)) {
564566
Free_Series_Data(series, TRUE);
565567
}
566-
series->info = 0; // includes width
568+
series->sizes = 0; // includes bias and width
569+
series->flags = 0;
567570
//series->data = BAD_MEM_PTR;
568571
//series->tail = 0xBAD2BAD2;
569572
//series->size = 0xBAD3BAD3;
@@ -633,7 +636,8 @@ const REBPOOLSPEC Mem_Pool_Spec[MAX_POOLS] =
633636
**
634637
***********************************************************************/
635638
{
636-
newser->info = oldser->info;
639+
newser->sizes = oldser->sizes;
640+
newser->flags = oldser->flags;
637641
newser->all = oldser->all;
638642
#ifdef SERIES_LABELS
639643
newser->label = oldser->label;

src/core/t-vector.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void Set_Vector_Row(REBSER *ser, REBVAL *blk)
160160
set_vect(bits, ser->data, n++, (REBI64)(data[idx]), f);
161161
}
162162
#else
163-
REBCNT bytes = ser->tail * ser->info;
163+
REBCNT bytes = ser->tail * SERIES_WIDE(ser); //TODO: review! Wide is max 256 bytes!!!
164164
if (len > bytes) len = bytes;
165165
COPY_MEM(ser->data, VAL_BIN_DATA(blk), len);
166166
#endif

src/include/sys-value.h

+14-15
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,8 @@ static REBCNT byte_sizes[4] = { 1, 2, 4, 8 };
389389
REBYTE *data; // series data head
390390
REBLEN tail; // one past end of useful data
391391
REBLEN rest; // total number of units from bias to end
392-
REBINT info; // holds width and flags
393-
#if defined(__LP64__) || defined(__LLP64__)
394-
REBCNT padding; // ensure next pointer is naturally aligned
395-
#endif
392+
REBINT sizes; // 16 bits bias, 8 bits reserved, 8 bits wide!
393+
REBCNT flags;
396394
union {
397395
REBCNT size; // used for vectors and bitsets
398396
REBSER *series; // MAP datatype uses this
@@ -410,8 +408,9 @@ static REBCNT byte_sizes[4] = { 1, 2, 4, 8 };
410408
#define SERIES_TAIL(s) ((s)->tail)
411409
#define SERIES_REST(s) ((s)->rest)
412410
#define SERIES_LEN(s) ((s)->tail + 1) // Includes terminator
413-
#define SERIES_FLAGS(s) ((s)->info)
414-
#define SERIES_WIDE(s) (((s)->info) & 0xff)
411+
#define SERIES_SIZES(s) ((s)->sizes)
412+
#define SERIES_FLAGS(s) ((s)->flags)
413+
#define SERIES_WIDE(s) (((s)->sizes) & 0xff)
415414
#define SERIES_DATA(s) ((s)->data)
416415
#define SERIES_SKIP(s,i) (SERIES_DATA(s) + (SERIES_WIDE(s) * (i)))
417416

@@ -429,11 +428,11 @@ static REBCNT byte_sizes[4] = { 1, 2, 4, 8 };
429428
#define SERIES_FREED(s) (!SERIES_WIDE(s))
430429

431430
// Bias is empty space in front of head:
432-
#define SERIES_BIAS(s) (REBCNT)((SERIES_FLAGS(s) >> 16) & 0xffff)
431+
#define SERIES_BIAS(s) (REBCNT)((SERIES_SIZES(s) >> 16) & 0xffff)
433432
#define MAX_SERIES_BIAS 0x1000
434-
#define SERIES_SET_BIAS(s,b) (SERIES_FLAGS(s) = (SERIES_FLAGS(s) & 0xffff) | (b << 16))
435-
#define SERIES_ADD_BIAS(s,b) (SERIES_FLAGS(s) += (b << 16))
436-
#define SERIES_SUB_BIAS(s,b) (SERIES_FLAGS(s) -= (b << 16))
433+
#define SERIES_SET_BIAS(s,b) (SERIES_SIZES(s) = (SERIES_SIZES(s) & 0xffff) | (b << 16))
434+
#define SERIES_ADD_BIAS(s,b) (SERIES_SIZES(s) += (b << 16))
435+
#define SERIES_SUB_BIAS(s,b) (SERIES_SIZES(s) -= (b << 16))
437436

438437
// Size in bytes of memory allocated (including bias area):
439438
#define SERIES_TOTAL(s) ((SERIES_REST(s) + SERIES_BIAS(s)) * (REBCNT)SERIES_WIDE(s))
@@ -462,11 +461,11 @@ static REBCNT byte_sizes[4] = { 1, 2, 4, 8 };
462461
#define AT_TAIL ((REBCNT)(~0)) // Extend series at tail
463462

464463
// Is it a byte-sized series? (this works because no other odd size allowed)
465-
#define BYTE_SIZE(s) (((s)->info) & 1)
464+
#define BYTE_SIZE(s) (SERIES_SIZES(s) & 1)
466465
#define VAL_BYTE_SIZE(v) (BYTE_SIZE(VAL_SERIES(v)))
467466
#define VAL_STR_IS_ASCII(v) (VAL_BYTE_SIZE(v) && !Is_Not_ASCII(VAL_BIN_DATA(v), VAL_LEN(v)))
468467

469-
// Series Flags:
468+
// Series Flags (max32):
470469
enum {
471470
SER_MARK = 1, // Series was found during GC mark scan.
472471
SER_KEEP = 1<<1, // Series is permanent, do not GC it.
@@ -479,9 +478,9 @@ enum {
479478
SER_INT = 1<<8, // Series data is internal (loop frames) and should not be accessed by users
480479
};
481480

482-
#define SERIES_SET_FLAG(s, f) (SERIES_FLAGS(s) |= ((f) << 8))
483-
#define SERIES_CLR_FLAG(s, f) (SERIES_FLAGS(s) &= ~((f) << 8))
484-
#define SERIES_GET_FLAG(s, f) (SERIES_FLAGS(s) & ((f) << 8))
481+
#define SERIES_SET_FLAG(s, f) (SERIES_FLAGS(s) |= (f))
482+
#define SERIES_CLR_FLAG(s, f) (SERIES_FLAGS(s) &= ~(f))
483+
#define SERIES_GET_FLAG(s, f) (SERIES_FLAGS(s) & (f))
485484

486485
#define IS_FREEABLE(s) !SERIES_GET_FLAG(s, SER_MARK|SER_KEEP|SER_FREE)
487486
#define MARK_SERIES(s) SERIES_SET_FLAG(s, SER_MARK)

src/os/host-ext-test.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) {
285285
{
286286
REBSER *vec = RXA_SERIES(frm, 1);
287287
RXA_TYPE(frm, 1) = RXT_INTEGER;
288-
RXA_INT64(frm, 1) = vec->info * vec->tail;
288+
RXA_INT64(frm, 1) = (vec->sizes & 0xFF) * vec->tail; //TODO: review!
289289
}
290290
break;
291291
case 14: //command [{return vector size in values (from object)} o [object!]]

0 commit comments

Comments
 (0)