History

sl_cv: make inline space not an array but just a single byte

Sigrid Solveig Haflínudóttir committed 10 months ago

Commit 8ba2cfd1 parent 76ac96f2 files · +6 −6Browse files

Unified · Split

2 files
  1. src/cvalues.c +4 −4
  2. src/sl.h +2 −2
src/cvalues.c+4−4
@@ -119,7 +119,7 @@ cvalue_(const sl_type *type, usize sz, bool nofinalize) · 118 unmodified lines
119 usize nw = CVALUE_NWORDS + NWORDS(sz);119 usize nw = CVALUE_NWORDS + NWORDS(sz);
120 pcv = alloc_words(nw);120 pcv = alloc_words(nw);
121 pcv->type = type;121 pcv->type = type;
122 pcv->data = pcv->_space;122 pcv->data = &pcv->_space;
123 if(!nofinalize && type->vtable != nil)123 if(!nofinalize && type->vtable != nil)
124 add_finalizer(pcv);124 add_finalizer(pcv);
125 }else{125 }else{
@@ -772,7 +772,7 @@ cvalue_relocate(sl_v v) · 646 unmodified lines
772 nv = alloc_words(nw);772 nv = alloc_words(nw);
773 memcpy(nv, cv, nw*sizeof(sl_v));773 memcpy(nv, cv, nw*sizeof(sl_v));
774 if(isinlined(cv))774 if(isinlined(cv))
775 nv->data = nv->_space;775 nv->data = &nv->_space;
776 ncv = tagptr(nv, TAG_CVALUE);776 ncv = tagptr(nv, TAG_CVALUE);
777 const sl_type *t = cv_class(cv);777 const sl_type *t = cv_class(cv);
778 if(t->vtable != nil && t->vtable->relocate != nil)778 if(t->vtable != nil && t->vtable->relocate != nil)
@@ -802,7 +802,7 @@ cvalue_copy(sl_v v) · 23 unmodified lines
802 memcpy(ncv->data, cv->data, len);802 memcpy(ncv->data, cv->data, len);
803 cv_autorelease(ncv);803 cv_autorelease(ncv);
804 }else{804 }else{
805 ncv->data = ncv->_space;805 ncv->data = &ncv->_space;
806 }806 }
807 807
808 return tagptr(ncv, TAG_CVALUE);808 return tagptr(ncv, TAG_CVALUE);
@@ -1590,5 +1590,5 @@ cvalues_init(void) · 781 unmodified lines
1590 sl_strtype = get_type(mk_list2(sl_arrsym, sl_utf8sym), 0);1590 sl_strtype = get_type(mk_list2(sl_arrsym, sl_utf8sym), 0);
1591 sl_emptystr = cvalue_from_ref(sl_strtype, (char*)"", 0);1591 sl_emptystr = cvalue_from_ref(sl_strtype, (char*)"", 0);
1592 sl_cv *cv = ptr(sl_cv, sl_emptystr);1592 sl_cv *cv = ptr(sl_cv, sl_emptystr);
1593 cv->data = cv->_space;1593 cv->data = &cv->_space;
1594}1594}
src/sl.h+2−2
@@ -115,7 +115,7 @@ struct sl_builtin { · 114 unmodified lines
115#define ubnumval(v) ((sl_fx)(v)>>TAG_EXT_BITS)115#define ubnumval(v) ((sl_fx)(v)>>TAG_EXT_BITS)
116#define builtin(v) tagptr(((sl_v)(v)<<TAG_BITS), TAG_FN)116#define builtin(v) tagptr(((sl_v)(v)<<TAG_BITS), TAG_FN)
117#define bothfixnums(x, y) (isfixnum(x) && isfixnum(y))117#define bothfixnums(x, y) (isfixnum(x) && isfixnum(y))
118#define isinlined(cv) ((cv)->data == (cv)->_space)118#define isinlined(cv) ((cv)->data == &(cv)->_space)
119 119
120#define mk_rune(r) (((sl_v)(r))<<TAG_EXT_BITS | 0xfc)120#define mk_rune(r) (((sl_v)(r))<<TAG_EXT_BITS | 0xfc)
121#define sl_isrune(v) (((v) & 0xff) == 0xfc)121#define sl_isrune(v) (((v) & 0xff) == 0xfc)
@@ -314,7 +314,7 @@ struct sl_cv { · 192 unmodified lines
314 u32int startbytes;314 u32int startbytes;
315 u32int startrune;315 u32int startrune;
316 };316 };
317 u8int _space[1]; // variable size317 u8int _space; // variable size
318 };318 };
319}sl_aligned(8);319}sl_aligned(8);
320 320

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t