aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-07-30 17:31:21 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-30 17:31:21 +0200
commit6e32982c22e108244c392f642f4aa3280d73fb4e (patch)
treeb0660ebe967d91837b4b0104df9faaa72bd7daf7
parentfbcee9484d51d7cdf2921fdbb2ff12639337335d (diff)
wip
-rw-r--r--GC.md25
-rw-r--r--README.md1
2 files changed, 26 insertions, 0 deletions
diff --git a/GC.md b/GC.md
new file mode 100644
index 0000000..c7aac96
--- /dev/null
+++ b/GC.md
@@ -0,0 +1,25 @@
+# Region-based garbage collection
+Memory that is allocated should have metadata to which block (scope) it belongs to.
+When data is moved, the metadata should be updated to which block it belongs to.
+When a function is called and the function accesses a member owned by the callee, then the owner region of the member should
+be temporary changed to that function and then at the end of the scope, it should be reverted to the callee so the member is not
+freed. This would be a runtime borrow mechanism. However if the variable is passed to the function and not used after that, then it should be freed in
+the called function, or at the end of the parent scope (which could be a if/for scope). This would be a runtime move mechanism.
+
+```
+create_linked_list = fn() {
+ # Circular linked list!
+ a = { next: null }
+ b = { next: a }
+ c = { next: b }
+ a.next = c
+ return c
+}
+
+main = fn() {
+ linked_list = create_linked_list()
+ while(true) {
+ # ...
+ }
+}
+``` \ No newline at end of file
diff --git a/README.md b/README.md
index cbb907c..8e35312 100644
--- a/README.md
+++ b/README.md
@@ -11,4 +11,5 @@ Run: `sudo make install`. The tsl binary will be installed in /usr/bin/local.
* Remove dependency on `gc`. Write our own gc instead.
* Implement big int, which numbers should automatically switch to when they are too large to fit into double.
* Use a list instead of a hash map for variable lookup in the parser, since the list will be small most of the time.
+* Use a list instead of a hash map for variable lookup in the vm (program.c). Variable load/store will then always be O(1).
* Implement sandboxes similar to lua, by disabling use of import, file io and other functions. \ No newline at end of file