aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/elymasGlobalSysAsm.ey16
-rw-r--r--compiler/standardClient.ey5
-rw-r--r--elymas/lib/sys/so.ey4
3 files changed, 19 insertions, 6 deletions
diff --git a/compiler/elymasGlobalSysAsm.ey b/compiler/elymasGlobalSysAsm.ey
index e131e3e..e31ab74 100644
--- a/compiler/elymasGlobalSysAsm.ey
+++ b/compiler/elymasGlobalSysAsm.ey
@@ -580,7 +580,9 @@
# correct number of things from the stack to make the sys .freeze execution transparent
# TODO: actually do this (e.g. by recoding the freeze startup in assembly)
# TODO: ... for now just flush the call stack on freeze
- # returns the number of allocations according to frozen alloc list fill state
+ # returns
+ # 0 <- the number of allocations according to frozen alloc list fill state
+ # 1 <- the current heap size (to detect re-allocs during freeze)
[[
/rbx :popqReg
@@ -612,6 +614,18 @@
/rdx 101 /rax :movqRegMemDisp8
/r13 114 /rax :movqRegMemDisp8
+ ::heapSize /rdx :movqImmReg
+ /rdx /rdx :movqMemReg
+ /rdx :pushqReg # store heap size for later return value
+
+ ::internalAllocateInteger /rax :movqImmReg
+ /rax :callqReg
+ 8 /rax :popqMemDisp8 # save heap size to return integer
+
+ /rdx :popqReg
+ /rax :pushqReg
+ /rdx :pushqReg # shuffle stack to access alloc count
+
::internalAllocateInteger /rax :movqImmReg
/rax :callqReg
# type zero does not need to be changed
diff --git a/compiler/standardClient.ey b/compiler/standardClient.ey
index 010e203..c8f2823 100644
--- a/compiler/standardClient.ey
+++ b/compiler/standardClient.ey
@@ -980,9 +980,8 @@
> -- /dump deffd
# TODO: why do we save section information, exactly?
-# FIXME: think real hard whether we can ignore the possibility of new allocations during freeze
{ ==filename # ==f (left on the stack a while and executed from sys .asm .programStart)
- sys .asm .patchProgramStart ==frozenAllocationCount
+ sys .asm .patchProgramStart ==frozenAllocationCount ==heapSize
# hex decoding
{ ==strNumber
@@ -1180,7 +1179,7 @@
==f
- sys .asm .patchProgramStart frozenAllocationCount neq {
+ sys .asm .patchProgramStart -- heapSize neq {
"freezing allocated new memory chunks, retrying..." dump
f filename sys .freeze
} rep
diff --git a/elymas/lib/sys/so.ey b/elymas/lib/sys/so.ey
index caac9c0..0203f18 100644
--- a/elymas/lib/sys/so.ey
+++ b/elymas/lib/sys/so.ey
@@ -656,7 +656,7 @@
} /resolveFunction deffd
{ ==filename # ==f (left on the stack a while and executed from sys .asm .programStart)
- sys .asm .patchProgramStart ==frozenAllocationCount
+ sys .asm .patchProgramStart ==frozenAllocationCount ==heapSize
{ 8 { _ 256 mod -01 256 div } rep -- } /uint64 deffd
{ _ 0 lt { 4294967296 add } rep 4294967295 band 4 { _ 256 mod -01 256 div } rep -- } /uint32 deffd
@@ -1034,7 +1034,7 @@
==f
- sys .asm .patchProgramStart frozenAllocationCount neq {
+ sys .asm .patchProgramStart -- heapSize neq {
"freezing allocated new memory chunks, retrying..." dump
f filename sys .so .freeze
} rep