2016-10-15 06:42:56 +03:00
|
|
|
Global Unique:
|
|
|
|
|
|
|
|
Z% : boxed memory values
|
2016-11-07 02:20:03 +03:00
|
|
|
Z1 : Z% size
|
|
|
|
Z2 : S$ size
|
|
|
|
Z3 : stack start address (cbm) or X% size (qbasic)
|
|
|
|
Z4 : release stack start address (cbm) or Y% size (qbasic)
|
2016-10-15 06:42:56 +03:00
|
|
|
ZI : start of unused memory (index into Z%)
|
|
|
|
ZK : start of free list (index into Z%)
|
2016-10-23 00:11:46 +03:00
|
|
|
ZT : top of memory after repl env allocations
|
2016-10-15 06:42:56 +03:00
|
|
|
|
|
|
|
S$ : string memory storage
|
2016-10-23 00:11:46 +03:00
|
|
|
S : next free index in S$
|
2016-10-15 06:42:56 +03:00
|
|
|
|
2016-10-23 00:11:46 +03:00
|
|
|
X% : logic/call stack (Z% indexes)
|
|
|
|
X : top element of X% stack
|
2016-10-15 06:42:56 +03:00
|
|
|
|
2016-10-23 00:11:46 +03:00
|
|
|
Y% : pending release stack [index into Z%, eval level]
|
|
|
|
Y : top element of Y% stack
|
2016-10-15 06:42:56 +03:00
|
|
|
|
2016-10-23 00:11:46 +03:00
|
|
|
D : root repl environment
|
2016-10-15 06:42:56 +03:00
|
|
|
|
2016-11-07 02:20:03 +03:00
|
|
|
BT : begin time (TI)
|
2016-10-15 06:42:56 +03:00
|
|
|
ER : error type (-2: none, -1: string, >=0: object)
|
2016-11-04 08:07:09 +03:00
|
|
|
E$ : error string (ER=-1)
|
2016-11-10 10:51:02 +03:00
|
|
|
EZ : READLINE EOF return, READ_FILE EOF temp
|
2016-10-15 06:42:56 +03:00
|
|
|
|
|
|
|
LV : EVAL stack call level/depth
|
|
|
|
|
2016-10-24 06:18:08 +03:00
|
|
|
RI : reader current string position
|
|
|
|
RJ : READ_TOKEN current character index
|
2016-10-23 00:11:46 +03:00
|
|
|
|
|
|
|
|
2016-10-15 06:42:56 +03:00
|
|
|
Calling arguments/temporaries:
|
|
|
|
|
2016-11-04 08:07:09 +03:00
|
|
|
A : common call argument (especially EVAL, EVAL_AST)
|
|
|
|
A$ : common call argument (READLINE, reader, string temp, key value)
|
|
|
|
B : common call argument
|
2017-09-15 20:57:10 +03:00
|
|
|
B$ : STRING arg (HASHMAP_GET temp), PR_STR_SEQ separator
|
2016-11-10 10:51:02 +03:00
|
|
|
: INIT_CORE_SET_FUNCTION, ENV_SET_S, ASSOC1_S
|
2016-11-07 02:20:03 +03:00
|
|
|
C : common call argument, DO_TCO_FUNCTION temp in DO_APPLY
|
2016-10-15 06:42:56 +03:00
|
|
|
E : environment (EVAL, EVAL_AST)
|
|
|
|
F : function
|
|
|
|
H : hash map
|
|
|
|
K : hash map key (Z% index)
|
2016-10-15 07:48:03 +03:00
|
|
|
L : ALLOC* Z%(R,1) default
|
|
|
|
M : ALLOC* Z%(R+1,0) default
|
|
|
|
N : ALLOC* Z%(R+1,1) default
|
2016-10-15 06:42:56 +03:00
|
|
|
R : common return value
|
2016-11-04 08:07:09 +03:00
|
|
|
R$ : common string return value
|
|
|
|
T : type arg, common temp
|
2016-11-05 05:46:45 +03:00
|
|
|
Q : PUSH*, POP*, PEEK* return value (and PEEK_Q_Q call arg)
|
2016-10-15 06:42:56 +03:00
|
|
|
|
2016-11-07 02:20:03 +03:00
|
|
|
AR : APPLY, DO_*_FUNCTION arg list
|
2016-11-04 08:07:09 +03:00
|
|
|
AY : RELEASE/FREE arg
|
|
|
|
AZ : PR_STR arg
|
2016-12-10 17:53:10 +03:00
|
|
|
P1 : PR_MEMORY*, PR_OBJECT, CHECK_FREE_LIST start
|
|
|
|
P2 : PR_MEMORY*, PR_OBJECT, CHECK_FREE_LIST end
|
2016-11-18 09:54:04 +03:00
|
|
|
P3 : PR_OBJECT, PR_MEMORY_VALUE
|
2016-11-07 02:20:03 +03:00
|
|
|
R1 : REP, RE - MAL_READ result temp
|
|
|
|
R2 : REP, RE - EVAL result temp
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
R3 : HASHMAP_GET, DO_HASH_MAP, DO_KEYS_VALS temp and return value
|
2016-11-07 02:20:03 +03:00
|
|
|
R4 : ENV_FIND temp and return value
|
|
|
|
R6 : SLICE return value (last element)
|
2016-10-15 06:42:56 +03:00
|
|
|
SZ : size argument to ALLOC
|
2016-11-04 08:07:09 +03:00
|
|
|
S1$ : REPLACE needle
|
|
|
|
S2$ : REPLACE replacement
|
2016-10-15 06:42:56 +03:00
|
|
|
|
2016-11-07 02:20:03 +03:00
|
|
|
|
2016-11-04 08:07:09 +03:00
|
|
|
Other temporaries:
|
2016-11-07 02:20:03 +03:00
|
|
|
|
2016-10-24 06:18:08 +03:00
|
|
|
A0 : EVAL ast elements
|
2016-11-19 08:51:33 +03:00
|
|
|
A1 : EVAL ast elements, DO_FUNCTION temp
|
|
|
|
A2 : EVAL ast elements, DO_FUNCTION temp
|
2016-10-24 06:18:08 +03:00
|
|
|
A3 : EVAL ast elements
|
2016-11-19 08:51:33 +03:00
|
|
|
B1 : DO_FUNCTION temp
|
2016-10-25 07:29:27 +03:00
|
|
|
|
2016-11-04 08:07:09 +03:00
|
|
|
CZ : DO_CONCAT stack position
|
2016-10-25 07:29:27 +03:00
|
|
|
ED : EQUAL_Q recursion depth counter
|
|
|
|
RD : PR_OBJECT recursion depth
|
|
|
|
SD : READ_STR sequence read recursion depth
|
|
|
|
|
2016-11-03 07:36:44 +03:00
|
|
|
C$ : READ_TOKEN, SKIP_SPACES, SKIP_TO_EOL current character
|
2016-12-10 17:53:10 +03:00
|
|
|
D$ : READ_TOKEN/READ_FILE_CHAR temp
|
2016-11-18 09:54:04 +03:00
|
|
|
G : function value ON GOTO switch flag, EVAL_AST changed flag
|
|
|
|
I : STRING, REPLACE, SLICE, PR_MEMORY, PR_OBJECT, PR_MEMORY_VALUE
|
|
|
|
J : REPLACE, PR_MEMORY_VALUE
|
2016-11-07 02:20:03 +03:00
|
|
|
U : ALLOC, RELEASE, PR_STR temp
|
2016-11-10 10:51:02 +03:00
|
|
|
V : RELEASE, PR_STR_SEQ temp
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
W : SLICE, LAST, QUASIQUOTE, DO_HASH_MAP, DO_KEYS_VALS, step2-3 EVAL temp
|
2016-12-10 17:53:10 +03:00
|
|
|
P : PR_MEMORY_SUMMARY_SMALL
|
2016-11-07 02:20:03 +03:00
|
|
|
RC : RELEASE remaining number of elements to release
|
|
|
|
RF : reader reading from file flag
|
2016-10-24 06:18:08 +03:00
|
|
|
S1 : READ_TOKEN in a string?
|
|
|
|
S2 : READ_TOKEN escaped?
|
|
|
|
T$ : READ_* current token string
|
2016-11-10 10:51:02 +03:00
|
|
|
T1 : EQUAL_Q, PR_STR, DO_KEYS_VALS temp
|
2016-11-04 08:07:09 +03:00
|
|
|
T2 : EQUAL_Q, DO_KEY_VALS, HASH_MAP_GET
|
|
|
|
T3$ : REPLACE temp
|
2016-11-07 02:20:03 +03:00
|
|
|
|
2016-10-15 06:42:56 +03:00
|
|
|
|
|
|
|
Unused:
|
|
|
|
|
2016-11-07 02:20:03 +03:00
|
|
|
O
|
|
|
|
|
|
|
|
|
|
|
|
Counting number of times each variable is assigned:
|
|
|
|
sed 's/:/\n /g' readline.in.bas types.in.bas reader.in.bas printer.in.bas env.in.bas core.in.bas stepA_mal.in.bas | grep "[A-Z][A-Z0-9]*[%$]*=" | sed 's/.*[^A-Z]\([A-Z][A-Z0-9]*[%$]*\)=.*/\1/g' | sort | uniq -c | sort -n
|
|
|
|
|