aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2019-08-07 21:26:23 +0200
committerDrahflow <drahflow@gmx.de>2019-08-07 21:26:23 +0200
commitd78f3ade1e47e09fc7bc8c9b8473a15d9a916482 (patch)
tree5bbc0b760c07c587ee538ed2dd7ae9283c5cf56d
parentcfefa2999e22f721619f0f8f84deef7db7beabe5 (diff)
Mark top of stack
-rw-r--r--compiler/elymasAsm.ey3
-rw-r--r--compiler/elymasAsmLib.ey3
-rw-r--r--doc/notes4
3 files changed, 10 insertions, 0 deletions
diff --git a/compiler/elymasAsm.ey b/compiler/elymasAsm.ey
index e792b21..110080e 100644
--- a/compiler/elymasAsm.ey
+++ b/compiler/elymasAsm.ey
@@ -5,6 +5,7 @@
16 ==STACKSTART
6148914691236517205 ==STACKBOTTOMMARKER
+ 6148914691236517206 ==STACKTOPMARKER
4 ==ERRORMARKER
3 ==HASHPOSITIONS # number of positions to probe on collisions
@@ -68,6 +69,7 @@
# stack layout
# %0 : stack size
# %8 : current stack pointer
+ # %10 : stack top marker
# ... : real stack
# <end> : stack bottom marker
[ /bootStack /bootCallStack ] {
@@ -78,6 +80,7 @@
[
PAGESIZE imm64
stack .base PAGESIZE add 8 sub imm64
+ STACKTOPMARKER imm64
] { i sys .asm .poke i 1 add =i } each
stack .base PAGESIZE add 8 sub =i
diff --git a/compiler/elymasAsmLib.ey b/compiler/elymasAsmLib.ey
index 72d0a71..696609d 100644
--- a/compiler/elymasAsmLib.ey
+++ b/compiler/elymasAsmLib.ey
@@ -764,6 +764,7 @@
/markObject :callqLbl32
# start from stack and mark all reachable blocks
+ # TODO: validate current stack has a STACKTOPMARKER
:STACKBOTTOMMARKER /rcx :movqImmReg
/rsi :popqReg # load original stack pointer
/rsi :pushqReg
@@ -1949,6 +1950,8 @@
:STACKBOTTOMMARKER /rdx :movqImmReg
/rdx /rdi :movqRegMem
/rdi 8 /rax :movqRegMemDisp8
+ :STACKTOPMARKER /rdx :movqImmReg
+ /rdx 16 /rax :movqRegMemDisp8
:retn
] /internalAllocateStack defv
diff --git a/doc/notes b/doc/notes
index d5385cb..295cd68 100644
--- a/doc/notes
+++ b/doc/notes
@@ -128,6 +128,9 @@ quote begin marker
0101010101010101010101010101010101010101010101010101010101010101
bottom of stack marker
+0101010101010101010101010101010101010101010101010101010101010110
+top of stack marker
+
0000000000000000000000000000000000000000000000000000000000000100
error data marker (only for external debugging)
@@ -291,6 +294,7 @@ Overhead: 1/32.
bit 63-60: 1 0 1 1
bit 59: reserved for GC
* Current stack pointer value
+* top of stack marker
* <data ...>
* bottom of stack marker