ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
with Garbage_Collected;
|
|
|
|
with Types.Mal;
|
2019-02-28 00:27:12 +03:00
|
|
|
|
|
|
|
package Types.Atoms is
|
|
|
|
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
type Instance (<>) is new Garbage_Collected.Instance with private;
|
2019-02-28 00:27:12 +03:00
|
|
|
|
|
|
|
-- Built-in functions.
|
|
|
|
function Atom (Args : in Mal.T_Array) return Mal.T;
|
|
|
|
function Deref (Args : in Mal.T_Array) return Mal.T;
|
|
|
|
function Reset (Args : in Mal.T_Array) return Mal.T;
|
2019-03-06 21:48:51 +03:00
|
|
|
function Swap (Args : in Mal.T_Array) return Mal.T;
|
|
|
|
|
|
|
|
-- Helper for print.
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
function Deref (Item : in Instance) return Mal.T with Inline;
|
2019-03-17 13:24:03 +03:00
|
|
|
|
2019-02-28 00:27:12 +03:00
|
|
|
private
|
|
|
|
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
type Instance is new Garbage_Collected.Instance with record
|
|
|
|
Data : Mal.T;
|
|
|
|
end record;
|
|
|
|
overriding procedure Keep_References (Object : in out Instance) with Inline;
|
2019-02-28 00:27:12 +03:00
|
|
|
|
|
|
|
end Types.Atoms;
|