Finish up O(1) byte array allocation
parent
d9231f3bc5
commit
ec23584f48
|
@ -204,7 +204,7 @@ M: byte-array byte-length length ;
|
||||||
dup length [ nip malloc dup ] 2keep memcpy ;
|
dup length [ nip malloc dup ] 2keep memcpy ;
|
||||||
|
|
||||||
: memory>byte-array ( alien len -- byte-array )
|
: memory>byte-array ( alien len -- byte-array )
|
||||||
[ nip <byte-array> dup ] 2keep memcpy ;
|
[ nip (byte-array) dup ] 2keep memcpy ;
|
||||||
|
|
||||||
: byte-array>memory ( byte-array base -- )
|
: byte-array>memory ( byte-array base -- )
|
||||||
swap dup length memcpy ;
|
swap dup length memcpy ;
|
||||||
|
|
|
@ -100,4 +100,8 @@ SYMBOL: bootstrap-time
|
||||||
|
|
||||||
"output-image" get save-image-and-exit
|
"output-image" get save-image-and-exit
|
||||||
] if
|
] if
|
||||||
] [ drop "resource:basis/bootstrap/bootstrap-error.factor" run-file ] recover
|
] [
|
||||||
|
drop
|
||||||
|
load-help? off
|
||||||
|
"resource:basis/bootstrap/bootstrap-error.factor" run-file
|
||||||
|
] recover
|
||||||
|
|
|
@ -14,12 +14,13 @@ IN: compiler.tree.propagation.slots
|
||||||
UNION: fixed-length-sequence array byte-array string ;
|
UNION: fixed-length-sequence array byte-array string ;
|
||||||
|
|
||||||
: sequence-constructor? ( word -- ? )
|
: sequence-constructor? ( word -- ? )
|
||||||
{ <array> <byte-array> <string> } memq? ;
|
{ <array> <byte-array> (byte-array) <string> } memq? ;
|
||||||
|
|
||||||
: constructor-output-class ( word -- class )
|
: constructor-output-class ( word -- class )
|
||||||
{
|
{
|
||||||
{ <array> array }
|
{ <array> array }
|
||||||
{ <byte-array> byte-array }
|
{ <byte-array> byte-array }
|
||||||
|
{ (byte-array) byte-array }
|
||||||
{ <string> string }
|
{ <string> string }
|
||||||
} at ;
|
} at ;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
USING: arrays help.markup help.syntax math
|
USING: arrays help.markup help.syntax math
|
||||||
sequences.private vectors strings kernel math.order layouts
|
sequences.private vectors strings kernel math.order layouts
|
||||||
quotations ;
|
quotations generic.standard ;
|
||||||
IN: sequences
|
IN: sequences
|
||||||
|
|
||||||
HELP: sequence
|
HELP: sequence
|
||||||
|
@ -14,8 +14,8 @@ HELP: length
|
||||||
|
|
||||||
HELP: set-length
|
HELP: set-length
|
||||||
{ $values { "n" "a non-negative integer" } { "seq" "a resizable sequence" } }
|
{ $values { "n" "a non-negative integer" } { "seq" "a resizable sequence" } }
|
||||||
{ $contract "Resizes the sequence. Not all sequences are resizable." }
|
{ $contract "Resizes a sequence. The initial contents of the new area is undefined." }
|
||||||
{ $errors "Throws a " { $link bounds-error } " if the new length is negative." }
|
{ $errors "Throws a " { $link no-method } " error if the sequence is not resizable, and a " { $link bounds-error } " if the new length is negative." }
|
||||||
{ $side-effects "seq" } ;
|
{ $side-effects "seq" } ;
|
||||||
|
|
||||||
HELP: lengthen
|
HELP: lengthen
|
||||||
|
|
|
@ -126,7 +126,6 @@ void *primitives[] = {
|
||||||
primitive_wrapper,
|
primitive_wrapper,
|
||||||
primitive_clone,
|
primitive_clone,
|
||||||
primitive_string,
|
primitive_string,
|
||||||
primitive_uninitialized_string,
|
|
||||||
primitive_array_to_quotation,
|
primitive_array_to_quotation,
|
||||||
primitive_quotation_xt,
|
primitive_quotation_xt,
|
||||||
primitive_tuple,
|
primitive_tuple,
|
||||||
|
|
|
@ -256,7 +256,7 @@ F_BYTE_ARRAY *reallot_byte_array(F_BYTE_ARRAY *array, CELL capacity)
|
||||||
to_copy = capacity;
|
to_copy = capacity;
|
||||||
|
|
||||||
REGISTER_UNTAGGED(array);
|
REGISTER_UNTAGGED(array);
|
||||||
F_BYTE_ARRAY *new_array = allot_byte_array(capacity);
|
F_BYTE_ARRAY *new_array = allot_byte_array_internal(capacity);
|
||||||
UNREGISTER_UNTAGGED(array);
|
UNREGISTER_UNTAGGED(array);
|
||||||
|
|
||||||
memcpy(new_array + 1,array + 1,to_copy);
|
memcpy(new_array + 1,array + 1,to_copy);
|
||||||
|
|
Loading…
Reference in New Issue