aboutsummaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2013-08-04 10:33:43 +0200
committerDrahflow <drahflow@gmx.de>2013-08-04 10:33:43 +0200
commitff63946ecb886b867531576eae30ad8e0ede3fd5 (patch)
tree23225f4a39dbc1af9c12e96b3e8b0ef89d4095ff /compiler
parentee30d4f0b27967facbb0fc8b3833ab45727b7465 (diff)
Removed crashes due to GC following freeze residue
Diffstat (limited to 'compiler')
-rw-r--r--compiler/elymasAsmLib.ey2
-rw-r--r--compiler/elymasGlobalSysAsm.ey16
2 files changed, 16 insertions, 2 deletions
diff --git a/compiler/elymasAsmLib.ey b/compiler/elymasAsmLib.ey
index 40cdb69..d224300 100644
--- a/compiler/elymasAsmLib.ey
+++ b/compiler/elymasAsmLib.ey
@@ -86,7 +86,7 @@
# current end of heap memory (grows upwards)
[ HEAPBASE ] ==heapEnd
- # next free byte at end of heap
+ # index of next cell likely to be free
[ HEAPBASE ] ==unusedHeapStart
# current parser scope
diff --git a/compiler/elymasGlobalSysAsm.ey b/compiler/elymasGlobalSysAsm.ey
index fd3f983..cd92b32 100644
--- a/compiler/elymasGlobalSysAsm.ey
+++ b/compiler/elymasGlobalSysAsm.ey
@@ -223,6 +223,13 @@
/rbx :movqImmOOBReg %EE %EE %EE %EE %EE %EE %EE %EE # 86
/rbx /rax :movqRegMem # 89
+ # empty encoding buffer to ensure the GC does not follow residue from freeze into unallocated memory
+ :quoteEncodingBuffer /rdi :movqImmReg
+ :STACKSIZE 8 sub /rcx :movqImmReg
+ 3 /rcx :shrqImm8Reg
+ /rax /rax :xorqRegReg
+ :reprcx :stosq
+
|ey* /rax :movqImmReg
/rax :callqReg
:ud2
@@ -231,12 +238,18 @@
<
# patch programStart to current program state
+ # this function must be called first in sys .freeze because it has to unwind the exactly
+ # 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
[[
/rbx :popqReg
eyprogramStart /rax :movqImmReg
/rsp 2 /rax :movqRegMemDisp8
- /r15 12 /rax :movqRegMemDisp8
+ # /r15 12 /rax :movqRegMemDisp8 # TODO: something like this (but correctly adjusted) would be right
+ :mainCallStack .base :STACKSIZE add /rdx :movqImmReg # TODO whereas this just flushes the stack
+ /rdx 12 /rax :movqRegMemDisp8
::heapEnd /rdx :movqImmReg
/rdx /rdx :movqMemReg
/rdx 32 /rax :movqRegMemDisp8
@@ -245,6 +258,7 @@
/rdx 55 /rax :movqRegMemDisp8
::currentScope /rdx :movqImmReg
/rdx /rdx :movqMemReg
+ 16 /rdx /rdx :movqMemDisp8Reg # unwind one scope
/rdx 78 /rax :movqRegMemDisp8
/rbx :pushqReg