Change data heap alignment to 16 bytes
parent
50f9bf67a7
commit
d85d84697a
|
@ -218,8 +218,12 @@ USERENV: undefined-quot 60
|
||||||
|
|
||||||
: here-as ( tag -- pointer ) here bitor ;
|
: here-as ( tag -- pointer ) here bitor ;
|
||||||
|
|
||||||
|
: (align-here) ( alignment -- )
|
||||||
|
[ here neg ] dip rem
|
||||||
|
[ bootstrap-cell /i [ 0 emit ] times ] unless-zero ;
|
||||||
|
|
||||||
: align-here ( -- )
|
: align-here ( -- )
|
||||||
here 8 mod 4 = [ 0 emit ] when ;
|
data-alignment get (align-here) ;
|
||||||
|
|
||||||
: emit-fixnum ( n -- ) tag-fixnum emit ;
|
: emit-fixnum ( n -- ) tag-fixnum emit ;
|
||||||
|
|
||||||
|
@ -293,7 +297,7 @@ M: fake-bignum ' n>> tag-fixnum ;
|
||||||
M: float '
|
M: float '
|
||||||
[
|
[
|
||||||
float [
|
float [
|
||||||
align-here double>bits emit-64
|
8 (align-here) double>bits emit-64
|
||||||
] emit-object
|
] emit-object
|
||||||
] cache-eql-object ;
|
] cache-eql-object ;
|
||||||
|
|
||||||
|
@ -411,6 +415,7 @@ M: byte-array '
|
||||||
[
|
[
|
||||||
byte-array [
|
byte-array [
|
||||||
dup length emit-fixnum
|
dup length emit-fixnum
|
||||||
|
bootstrap-cell 4 = [ 0 emit 0 emit ] when
|
||||||
pad-bytes emit-bytes
|
pad-bytes emit-bytes
|
||||||
] emit-object
|
] emit-object
|
||||||
] cache-eq-object ;
|
] cache-eq-object ;
|
||||||
|
|
|
@ -17,7 +17,7 @@ CONSTANT: deck-bits 18
|
||||||
: string-offset ( -- n ) 4 string tag-number slot-offset ; inline
|
: string-offset ( -- n ) 4 string tag-number slot-offset ; inline
|
||||||
: string-aux-offset ( -- n ) 2 string tag-number slot-offset ; inline
|
: string-aux-offset ( -- n ) 2 string tag-number slot-offset ; inline
|
||||||
: profile-count-offset ( -- n ) 8 \ word tag-number slot-offset ; inline
|
: profile-count-offset ( -- n ) 8 \ word tag-number slot-offset ; inline
|
||||||
: byte-array-offset ( -- n ) 2 byte-array tag-number slot-offset ; inline
|
: byte-array-offset ( -- n ) 16 byte-array tag-number - ; inline
|
||||||
: alien-offset ( -- n ) 3 alien tag-number slot-offset ; inline
|
: alien-offset ( -- n ) 3 alien tag-number slot-offset ; inline
|
||||||
: underlying-alien-offset ( -- n ) 1 alien tag-number slot-offset ; inline
|
: underlying-alien-offset ( -- n ) 1 alien tag-number slot-offset ; inline
|
||||||
: tuple-class-offset ( -- n ) 1 tuple tag-number slot-offset ; inline
|
: tuple-class-offset ( -- n ) 1 tuple tag-number slot-offset ; inline
|
||||||
|
|
|
@ -374,7 +374,7 @@ M: ppc %set-alien-double -rot STFD ;
|
||||||
[ drop load-zone-ptr ] [ swap 0 LWZ ] 2bi ;
|
[ drop load-zone-ptr ] [ swap 0 LWZ ] 2bi ;
|
||||||
|
|
||||||
:: inc-allot-ptr ( nursery-ptr allot-ptr n -- )
|
:: inc-allot-ptr ( nursery-ptr allot-ptr n -- )
|
||||||
scratch-reg allot-ptr n 8 align ADDI
|
scratch-reg allot-ptr n data-alignment get align ADDI
|
||||||
scratch-reg nursery-ptr 0 STW ;
|
scratch-reg nursery-ptr 0 STW ;
|
||||||
|
|
||||||
:: store-header ( dst class -- )
|
:: store-header ( dst class -- )
|
||||||
|
|
|
@ -388,7 +388,7 @@ M: x86 %vm-field-ptr ( dst field -- )
|
||||||
[ drop "nursery" %vm-field-ptr ] [ swap [] MOV ] 2bi ;
|
[ drop "nursery" %vm-field-ptr ] [ swap [] MOV ] 2bi ;
|
||||||
|
|
||||||
: inc-allot-ptr ( nursery-ptr n -- )
|
: inc-allot-ptr ( nursery-ptr n -- )
|
||||||
[ [] ] dip 8 align ADD ;
|
[ [] ] dip data-alignment get align ADD ;
|
||||||
|
|
||||||
: store-header ( temp class -- )
|
: store-header ( temp class -- )
|
||||||
[ [] ] [ type-number tag-fixnum ] bi* MOV ;
|
[ [] ] [ type-number tag-fixnum ] bi* MOV ;
|
||||||
|
|
|
@ -5,6 +5,8 @@ hashtables vectors strings sbufs arrays
|
||||||
quotations assocs layouts classes.tuple.private
|
quotations assocs layouts classes.tuple.private
|
||||||
kernel.private ;
|
kernel.private ;
|
||||||
|
|
||||||
|
16 data-alignment set
|
||||||
|
|
||||||
BIN: 111 tag-mask set
|
BIN: 111 tag-mask set
|
||||||
8 num-tags set
|
8 num-tags set
|
||||||
3 tag-bits set
|
3 tag-bits set
|
||||||
|
|
|
@ -4,6 +4,8 @@ USING: namespaces math words kernel assocs classes
|
||||||
math.order kernel.private ;
|
math.order kernel.private ;
|
||||||
IN: layouts
|
IN: layouts
|
||||||
|
|
||||||
|
SYMBOL: data-alignment
|
||||||
|
|
||||||
SYMBOL: tag-mask
|
SYMBOL: tag-mask
|
||||||
|
|
||||||
SYMBOL: num-tags
|
SYMBOL: num-tags
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace factor
|
||||||
array *factor_vm::allot_array(cell capacity, cell fill_)
|
array *factor_vm::allot_array(cell capacity, cell fill_)
|
||||||
{
|
{
|
||||||
gc_root<object> fill(fill_,this);
|
gc_root<object> fill(fill_,this);
|
||||||
gc_root<array> new_array(allot_array_internal<array>(capacity),this);
|
gc_root<array> new_array(allot_uninitialized_array<array>(capacity),this);
|
||||||
|
|
||||||
if(fill.value() == tag_fixnum(0))
|
if(fill.value() == tag_fixnum(0))
|
||||||
memset(new_array->data(),'\0',capacity * sizeof(cell));
|
memset(new_array->data(),'\0',capacity * sizeof(cell));
|
||||||
|
@ -33,7 +33,7 @@ void factor_vm::primitive_array()
|
||||||
cell factor_vm::allot_array_1(cell obj_)
|
cell factor_vm::allot_array_1(cell obj_)
|
||||||
{
|
{
|
||||||
gc_root<object> obj(obj_,this);
|
gc_root<object> obj(obj_,this);
|
||||||
gc_root<array> a(allot_array_internal<array>(1),this);
|
gc_root<array> a(allot_uninitialized_array<array>(1),this);
|
||||||
set_array_nth(a.untagged(),0,obj.value());
|
set_array_nth(a.untagged(),0,obj.value());
|
||||||
return a.value();
|
return a.value();
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ cell factor_vm::allot_array_2(cell v1_, cell v2_)
|
||||||
{
|
{
|
||||||
gc_root<object> v1(v1_,this);
|
gc_root<object> v1(v1_,this);
|
||||||
gc_root<object> v2(v2_,this);
|
gc_root<object> v2(v2_,this);
|
||||||
gc_root<array> a(allot_array_internal<array>(2),this);
|
gc_root<array> a(allot_uninitialized_array<array>(2),this);
|
||||||
set_array_nth(a.untagged(),0,v1.value());
|
set_array_nth(a.untagged(),0,v1.value());
|
||||||
set_array_nth(a.untagged(),1,v2.value());
|
set_array_nth(a.untagged(),1,v2.value());
|
||||||
return a.value();
|
return a.value();
|
||||||
|
@ -54,7 +54,7 @@ cell factor_vm::allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_)
|
||||||
gc_root<object> v2(v2_,this);
|
gc_root<object> v2(v2_,this);
|
||||||
gc_root<object> v3(v3_,this);
|
gc_root<object> v3(v3_,this);
|
||||||
gc_root<object> v4(v4_,this);
|
gc_root<object> v4(v4_,this);
|
||||||
gc_root<array> a(allot_array_internal<array>(4),this);
|
gc_root<array> a(allot_uninitialized_array<array>(4),this);
|
||||||
set_array_nth(a.untagged(),0,v1.value());
|
set_array_nth(a.untagged(),0,v1.value());
|
||||||
set_array_nth(a.untagged(),1,v2.value());
|
set_array_nth(a.untagged(),1,v2.value());
|
||||||
set_array_nth(a.untagged(),2,v3.value());
|
set_array_nth(a.untagged(),2,v3.value());
|
||||||
|
|
|
@ -1299,7 +1299,7 @@ bignum *factor_vm::bignum_digit_to_bignum(bignum_digit_type digit, int negative_
|
||||||
bignum *factor_vm::allot_bignum(bignum_length_type length, int negative_p)
|
bignum *factor_vm::allot_bignum(bignum_length_type length, int negative_p)
|
||||||
{
|
{
|
||||||
BIGNUM_ASSERT ((length >= 0) || (length < BIGNUM_RADIX));
|
BIGNUM_ASSERT ((length >= 0) || (length < BIGNUM_RADIX));
|
||||||
bignum * result = allot_array_internal<bignum>(length + 1);
|
bignum * result = allot_uninitialized_array<bignum>(length + 1);
|
||||||
BIGNUM_SET_NEGATIVE_P (result, negative_p);
|
BIGNUM_SET_NEGATIVE_P (result, negative_p);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace factor
|
||||||
|
|
||||||
byte_array *factor_vm::allot_byte_array(cell size)
|
byte_array *factor_vm::allot_byte_array(cell size)
|
||||||
{
|
{
|
||||||
byte_array *array = allot_array_internal<byte_array>(size);
|
byte_array *array = allot_uninitialized_array<byte_array>(size);
|
||||||
memset(array + 1,0,size);
|
memset(array + 1,0,size);
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ void factor_vm::primitive_byte_array()
|
||||||
void factor_vm::primitive_uninitialized_byte_array()
|
void factor_vm::primitive_uninitialized_byte_array()
|
||||||
{
|
{
|
||||||
cell size = unbox_array_size();
|
cell size = unbox_array_size();
|
||||||
dpush(tag<byte_array>(allot_array_internal<byte_array>(size)));
|
dpush(tag<byte_array>(allot_uninitialized_array<byte_array>(size)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void factor_vm::primitive_resize_byte_array()
|
void factor_vm::primitive_resize_byte_array()
|
||||||
|
|
|
@ -39,14 +39,14 @@ callback *callback_heap::add(code_block *compiled)
|
||||||
tagged<byte_array> insns(array_nth(code_template.untagged(),0));
|
tagged<byte_array> insns(array_nth(code_template.untagged(),0));
|
||||||
cell size = array_capacity(insns.untagged());
|
cell size = array_capacity(insns.untagged());
|
||||||
|
|
||||||
cell bump = align8(size) + sizeof(callback);
|
cell bump = align(size,sizeof(cell)) + sizeof(callback);
|
||||||
if(here + bump > seg->end) fatal_error("Out of callback space",0);
|
if(here + bump > seg->end) fatal_error("Out of callback space",0);
|
||||||
|
|
||||||
callback *stub = (callback *)here;
|
callback *stub = (callback *)here;
|
||||||
stub->compiled = compiled;
|
stub->compiled = compiled;
|
||||||
memcpy(stub + 1,insns->data<void>(),size);
|
memcpy(stub + 1,insns->data<void>(),size);
|
||||||
|
|
||||||
stub->size = align8(size);
|
stub->size = align(size,sizeof(cell));
|
||||||
here += bump;
|
here += bump;
|
||||||
|
|
||||||
update(stub);
|
update(stub);
|
||||||
|
|
|
@ -133,7 +133,7 @@ bool factor_vm::stack_to_array(cell bottom, cell top)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
array *a = allot_array_internal<array>(depth / sizeof(cell));
|
array *a = allot_uninitialized_array<array>(depth / sizeof(cell));
|
||||||
memcpy(a + 1,(void*)bottom,depth);
|
memcpy(a + 1,(void*)bottom,depth);
|
||||||
dpush(tag<array>(a));
|
dpush(tag<array>(a));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -119,7 +119,7 @@ cell factor_vm::object_size(cell tagged)
|
||||||
/* Size of the object pointed to by an untagged pointer */
|
/* Size of the object pointed to by an untagged pointer */
|
||||||
cell factor_vm::untagged_object_size(object *pointer)
|
cell factor_vm::untagged_object_size(object *pointer)
|
||||||
{
|
{
|
||||||
return align8(unaligned_object_size(pointer));
|
return align(unaligned_object_size(pointer),data_alignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Size of the data area of an object pointed to by an untagged pointer */
|
/* Size of the data area of an object pointed to by an untagged pointer */
|
||||||
|
|
|
@ -19,7 +19,7 @@ template<typename Array> cell array_size(Array *array)
|
||||||
return array_size<Array>(array_capacity(array));
|
return array_size<Array>(array_capacity(array));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Array> Array *factor_vm::allot_array_internal(cell capacity)
|
template<typename Array> Array *factor_vm::allot_uninitialized_array(cell capacity)
|
||||||
{
|
{
|
||||||
Array *array = allot<Array>(array_size<Array>(capacity));
|
Array *array = allot<Array>(array_size<Array>(capacity));
|
||||||
array->capacity = tag_fixnum(capacity);
|
array->capacity = tag_fixnum(capacity);
|
||||||
|
@ -46,7 +46,7 @@ template<typename Array> Array *factor_vm::reallot_array(Array *array_, cell cap
|
||||||
if(capacity < to_copy)
|
if(capacity < to_copy)
|
||||||
to_copy = capacity;
|
to_copy = capacity;
|
||||||
|
|
||||||
Array *new_array = allot_array_internal<Array>(capacity);
|
Array *new_array = allot_uninitialized_array<Array>(capacity);
|
||||||
|
|
||||||
memcpy(new_array + 1,array.untagged() + 1,to_copy * Array::element_size);
|
memcpy(new_array + 1,array.untagged() + 1,to_copy * Array::element_size);
|
||||||
memset((char *)(new_array + 1) + to_copy * Array::element_size,
|
memset((char *)(new_array + 1) + to_copy * Array::element_size,
|
||||||
|
|
|
@ -88,7 +88,7 @@ void factor_vm::primitive_fread()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gc_root<byte_array> buf(allot_array_internal<byte_array>(size),this);
|
gc_root<byte_array> buf(allot_uninitialized_array<byte_array>(size),this);
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,10 +23,7 @@ inline static cell align(cell a, cell b)
|
||||||
return (a + (b-1)) & ~(b-1);
|
return (a + (b-1)) & ~(b-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static cell align8(cell a)
|
static const cell data_alignment = 16;
|
||||||
{
|
|
||||||
return align(a,8);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define WORD_SIZE (signed)(sizeof(cell)*8)
|
#define WORD_SIZE (signed)(sizeof(cell)*8)
|
||||||
|
|
||||||
|
@ -186,6 +183,11 @@ struct byte_array : public object {
|
||||||
/* tagged */
|
/* tagged */
|
||||||
cell capacity;
|
cell capacity;
|
||||||
|
|
||||||
|
#ifndef FACTOR_64
|
||||||
|
cell padding0;
|
||||||
|
cell padding1;
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename Scalar> Scalar *data() { return (Scalar *)(this + 1); }
|
template<typename Scalar> Scalar *data() { return (Scalar *)(this + 1); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -249,9 +251,9 @@ struct code_block : public heap_block
|
||||||
return (void *)(this + 1);
|
return (void *)(this + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
cell type()
|
code_block_type type()
|
||||||
{
|
{
|
||||||
return (header >> 1) & 0x3;
|
return (code_block_type)((header >> 1) & 0x3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_type(code_block_type type)
|
void set_type(code_block_type type)
|
||||||
|
|
|
@ -45,7 +45,7 @@ void factor_vm::set_string_nth_slow(string *str_, cell index, cell ch)
|
||||||
if the most significant bit of a
|
if the most significant bit of a
|
||||||
character is set. Initially all of
|
character is set. Initially all of
|
||||||
the bits are clear. */
|
the bits are clear. */
|
||||||
aux = allot_array_internal<byte_array>(untag_fixnum(str->length) * sizeof(u16));
|
aux = allot_uninitialized_array<byte_array>(untag_fixnum(str->length) * sizeof(u16));
|
||||||
|
|
||||||
str->aux = tag<byte_array>(aux);
|
str->aux = tag<byte_array>(aux);
|
||||||
write_barrier(&str->aux);
|
write_barrier(&str->aux);
|
||||||
|
|
|
@ -298,7 +298,7 @@ struct factor_vm
|
||||||
}
|
}
|
||||||
|
|
||||||
// generic arrays
|
// generic arrays
|
||||||
template<typename Array> Array *allot_array_internal(cell capacity);
|
template<typename Array> Array *allot_uninitialized_array(cell capacity);
|
||||||
template<typename Array> bool reallot_array_in_place_p(Array *array, cell capacity);
|
template<typename Array> bool reallot_array_in_place_p(Array *array, cell capacity);
|
||||||
template<typename Array> Array *reallot_array(Array *array_, cell capacity);
|
template<typename Array> Array *reallot_array(Array *array_, cell capacity);
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ struct zone {
|
||||||
inline object *allot(cell size)
|
inline object *allot(cell size)
|
||||||
{
|
{
|
||||||
cell h = here;
|
cell h = here;
|
||||||
here = h + align8(size);
|
here = h + align(size,data_alignment);
|
||||||
return (object *)h;
|
return (object *)h;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue