aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2015-06-19 10:53:11 +0200
committerDrahflow <drahflow@gmx.de>2015-06-19 10:53:11 +0200
commit7d93ed172d7c22af7800f3dd23863f0203f7fdae (patch)
treea38cb6db9b16ce65b898ee02ec846feb01f5b54c
parentdc029b2f218feb125b74f5fffc5bd64ec9459f03 (diff)
Position markers for stack subeffect isolation
-rw-r--r--TODO5
-rw-r--r--compiler/elymasGlobal.ey84
-rw-r--r--doc/notes6
-rw-r--r--elymas/lib/sys/opt.ey67
4 files changed, 158 insertions, 4 deletions
diff --git a/TODO b/TODO
index 78e5e34..769449c 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,8 @@
+* allow stack manipulation at site of position tags
* apply the trace extractor to non-tail situations
* implement the GC-based function opcode forwarding
-* allow stack manipulation at site of uppermost ARRAYMARKER
+* inline loop similar to each
+* forward scope-cannot-escape information
* utf8
* regex substitution
* asm-based regex engine
@@ -8,6 +10,7 @@
* txt .consume .u sollte nicht negative Zahlen liefern
* evtl. BigNums bauen und die Int-Funktionen entsprechend machen
* trigonometrics
+* document new , functions
* testsuite (incl. coverage test)
diff --git a/compiler/elymasGlobal.ey b/compiler/elymasGlobal.ey
index 3fc309f..2ecf6b9 100644
--- a/compiler/elymasGlobal.ey
+++ b/compiler/elymasGlobal.ey
@@ -13,6 +13,7 @@
1 ==ARRAYMARKER
2 ==QUOTEMARKER
+ 3 ==POSITIONMARKER
<
[
@@ -1084,6 +1085,89 @@
:retn
]] /eyrange defv
+ # put a position marker onto the stack
+ [[
+ /rax :popqReg
+ POSITIONMARKER :pushqImm32
+ /rax :pushqReg
+ :retn
+ ]] /ey, defv
+
+ # delete topmost position marker and shift stack
+ [[
+ /rbx :popqReg
+ /rsp /rsi :movqRegReg
+ POSITIONMARKER /rax :movqImmReg
+ /rdx :popqReg
+ /rax /rdx :cmpqRegReg
+ /done :jzLbl8
+ @loop
+ 8 /rsi :addqImm8Reg
+ /rdx /rsi :xchgqRegMem
+ /rax /rdx :cmpqRegReg
+ /loop :jnzLbl8
+ @done
+ /rbx :pushqReg
+ :retn
+ ]] /ey,-- defv
+
+ # move topmost position marker left/upwards and shift stack
+ [[
+ /rbx :popqReg
+ /rsp /rsi :movqRegReg
+ POSITIONMARKER /rax :movqImmReg
+ /rdx :popqReg
+ /rax /rdx :cmpqRegReg
+ /done :jzLbl8
+ @loop
+ 8 /rsi :addqImm8Reg
+ /rdx /rsi :xchgqRegMem
+ /rax /rdx :cmpqRegReg
+ /loop :jnzLbl8
+ @done
+ /rdx 8 /rsi :movqRegMemDisp8
+ /rbx :pushqReg
+ :retn
+ ]] /ey--, defv
+
+ # access element left (higher up in stack) of topmost position marker
+ [[
+ /rbx :popqReg
+ /rsp /rdi :movqRegReg
+ POSITIONMARKER /rax :movqImmReg
+ /rcx /rcx :xorqRegReg
+ /rcx :decqReg
+ :repnz :scasq
+ /rdi :pushqMem
+ /rbx :pushqReg
+ :retn
+ ]] /ey_, defv
+
+ # access element right (lower in stack) of topmost position marker
+ [[
+ /rbx :popqReg
+ /rsp /rdi :movqRegReg
+ POSITIONMARKER /rax :movqImmReg
+ /rcx /rcx :xorqRegReg
+ /rcx :decqReg
+ :repnz :scasq
+ 16 neg /rdi :pushqMemDisp8
+ /rbx :pushqReg
+ :retn
+ ]] /ey,_ defv
+
+ # delete stack up to and including topmost position marker
+ [[
+ /rbx :popqReg
+ POSITIONMARKER /rax :movqImmReg
+ @loop
+ /rdx :popqReg
+ /rax /rdx :cmpqRegReg
+ /loop :jnzLbl8
+ /rbx :pushqReg
+ :retn
+ ]] /ey,--- defv
+
# create a new scope capturing the current one
[
::INITIALSCOPESIZE /rdi :movqImmReg
diff --git a/doc/notes b/doc/notes
index a01083d..d4d1a6c 100644
--- a/doc/notes
+++ b/doc/notes
@@ -70,11 +70,11 @@ $: <open>
%: <open>
&: <open>
': type assignment
-(: tuple begin
-): tuple end
+(: <open>
+): <open>
*: apply function
+: <open>
-,: <open>
+,: position markers
-: stack manipulation
.: field dereference
/: stringify
diff --git a/elymas/lib/sys/opt.ey b/elymas/lib/sys/opt.ey
index ca3f37a..01cf0ff 100644
--- a/elymas/lib/sys/opt.ey
+++ b/elymas/lib/sys/opt.ey
@@ -6,6 +6,7 @@
> /ops sys .asm .defv
1 ==ARRAYMARKER # FIXME unify with elymasGlobal.ey
+ 3 ==POSITIONMARKER # FIXME unify with elymasGlobal.ey
4 ==INITIALSCOPESIZE # FIXME take this from the compiler directory
sys .asm .ops ==:sysasmops
@@ -345,6 +346,7 @@
/quoted /range "''" ".?" ".?'" ".|" ";"
/keys /dom /add /and /band /bor /bxor /div /eq /ge /gt /le /lt
/mod /mul /neq /or /sub /udiv /umod /xor /bnot /neg /not
+ "," ",--" "--," "_," ",_" ",---"
] { | ::rawCodeAddress } [ 0 ] [ 0 ] '' * ==:SCOPEIGNORANTFUNCTIONS
[
"|" "=" /def
@@ -1981,6 +1983,71 @@
ARRAYMARKER :pushqImm32
] ] =entry
}
+ { action CALL eq { 1 entry * "," | ::rawCodeAddress eq }' andif }' {
+ [ NATIVENOSCOPE [
+ POSITIONMARKER :pushqImm32
+ ] ] =entry
+ }
+ { action CALL eq { 1 entry * ",--" | ::rawCodeAddress eq }' andif }' {
+ [ NATIVENOSCOPE [[
+ /rsp /rsi :movqRegReg
+ POSITIONMARKER /rax :movqImmReg
+ /rdx :popqReg
+ /rax /rdx :cmpqRegReg
+ /done :jzLbl8
+ @loop
+ 8 /rsi :addqImm8Reg
+ /rdx /rsi :xchgqRegMem
+ /rax /rdx :cmpqRegReg
+ /loop :jnzLbl8
+ @done
+ ]] ] =entry
+ }
+ { action CALL eq { 1 entry * "--," | ::rawCodeAddress eq }' andif }' {
+ [ NATIVENOSCOPE [[
+ /rsp /rsi :movqRegReg
+ POSITIONMARKER /rax :movqImmReg
+ /rdx :popqReg
+ /rax /rdx :cmpqRegReg
+ /done :jzLbl8
+ @loop
+ 8 /rsi :addqImm8Reg
+ /rdx /rsi :xchgqRegMem
+ /rax /rdx :cmpqRegReg
+ /loop :jnzLbl8
+ @done
+ /rdx 8 /rsi :movqRegMemDisp8
+ ]] ] =entry
+ }
+ { action CALL eq { 1 entry * "_," | ::rawCodeAddress eq }' andif }' {
+ [ NATIVENOSCOPE [[
+ /rsp /rdi :movqRegReg
+ POSITIONMARKER /rax :movqImmReg
+ /rcx /rcx :xorqRegReg
+ /rcx :decqReg
+ :repnz :scasq
+ /rdi :pushqMem
+ ]] ] =entry
+ }
+ { action CALL eq { 1 entry * ",_" | ::rawCodeAddress eq }' andif }' {
+ [ NATIVENOSCOPE [[
+ /rsp /rdi :movqRegReg
+ POSITIONMARKER /rax :movqImmReg
+ /rcx /rcx :xorqRegReg
+ /rcx :decqReg
+ :repnz :scasq
+ 16 neg /rdi :pushqMemDisp8
+ ]] ] =entry
+ }
+ { action CALL eq { 1 entry * ",---" | ::rawCodeAddress eq }' andif }' {
+ [ NATIVENOSCOPE [[
+ POSITIONMARKER /rax :movqImmReg
+ @loop
+ /rdx :popqReg
+ /rax /rdx :cmpqRegReg
+ /loop :jnzLbl8
+ ]] ] =entry
+ }
] conds
last