aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2013-09-27 21:56:11 +0200
committerDrahflow <drahflow@gmx.de>2013-09-27 21:56:11 +0200
commitf6af44d6742d96ecf002eb24475ecc23bf3d2d72 (patch)
tree41580218c3f6dfaf8733e846146d2a682d8a85bd
parent7521804dd8818778311720e4b0e1d69a029debb3 (diff)
currentScope now in r14
-rw-r--r--compiler/elymasAsm.ey30
-rw-r--r--compiler/elymasAsmLib.ey14
-rw-r--r--compiler/elymasGlobal.ey158
-rw-r--r--compiler/elymasGlobalSys.ey12
-rw-r--r--compiler/elymasGlobalSysAsm.ey9
-rw-r--r--compiler/elymasGlobalSysOpt.ey16
-rw-r--r--elymas/lib/sys/opt.ey55
7 files changed, 103 insertions, 191 deletions
diff --git a/compiler/elymasAsm.ey b/compiler/elymasAsm.ey
index 1482095..77719ea 100644
--- a/compiler/elymasAsm.ey
+++ b/compiler/elymasAsm.ey
@@ -1131,24 +1131,6 @@
%0B
} /ud2 deff
- { ==regb ==rega
- rega bit64assert
- regb bit64assert
-
- 1 rega /none regb rex
- %87
- rega regb modrm11
- } /xchgqRegReg deff
-
- { ==mem ==reg
- reg bit64assert
- mem bit64assert
-
- 1 reg /none mem rex
- %87
- reg mem modrm00
- } /xchgqRegMem deff
-
{ ==dst ==src
dst bit64assert
src bit64assert
@@ -1158,6 +1140,16 @@
src dst modrm11
} /xchgqRegReg deff
+ memoryAddressingVariants keys { ==variant memoryAddressingVariants variant . =*parse
+ { parse ==mem ==reg
+ reg bit64assert
+
+ 1 reg mem .idx mem .base rex
+ %87
+ reg mem .encode
+ } /xchgqReg variant defOp
+ } each
+
/xor %31 defAsmAddq
# map "anonymous" allocations away from interpreter heap
@@ -1249,11 +1241,13 @@
/rsp /rbx xchgqRegMem
callStack /rbx movqImmReg
/r15 /rbx xchgqRegMem
+ /r14 8 /rbx xchgqRegMemDisp8
opcodes _ len dearray
callStack /rbx movqImmReg
/r15 /rbx xchgqRegMem
+ /r14 8 /rbx xchgqRegMemDisp8
valueStack /rbx movqImmReg
/rsp /rbx xchgqRegMem
/r15 popqReg
diff --git a/compiler/elymasAsmLib.ey b/compiler/elymasAsmLib.ey
index 3e8538b..f08c643 100644
--- a/compiler/elymasAsmLib.ey
+++ b/compiler/elymasAsmLib.ey
@@ -332,8 +332,7 @@
@noResetNecessary
# start from current scope and mark all reachable blocks
- currentScope /rdi :movqImmReg
- /rdi /rdi :movqMemReg
+ /r14 /rdi :movqRegReg
/markObject :callqLbl32
# start from stack and mark all reachable blocks
@@ -1059,19 +1058,16 @@
8 /r15 :subqImm8Reg
/r15 :popqMem
8 /r15 :subqImm8Reg
- currentScope /rbx :movqImmReg
- /rbx /rsi :movqMemReg
- /rsi /r15 :movqRegMem
+ /r14 /r15 :movqRegMem
+ /r14 /rsi :movqRegReg
8 /rdi :movqImmReg
internalAllocateScope /rax :movqImmReg
/rax :callqReg
- /rax /rbx :movqRegMem
+ /rax /r14 :movqRegReg
] /scopingFunctionHeader defv
[
- /r15 /rcx :movqMemReg
- currentScope /rax :movqImmReg
- /rcx /rax :movqRegMem
+ /r15 /r14 :movqMemReg
8 /r15 :addqImm8Reg
/r15 :pushqMem
8 /r15 :addqImm8Reg
diff --git a/compiler/elymasGlobal.ey b/compiler/elymasGlobal.ey
index 8feb719..4c863f2 100644
--- a/compiler/elymasGlobal.ey
+++ b/compiler/elymasGlobal.ey
@@ -60,8 +60,7 @@
/rcx :pushqReg
# scope resolution
- ::currentScope /rdi :movqImmReg
- /rdi /rdi :movqMemReg
+ /r14 /rdi :movqRegReg
/rbx /rsi :movqRegReg
::internalResolve /rax :movqImmReg
/rax :callqReg
@@ -123,8 +122,7 @@
@realObject # CHECK end of checking
# search for name in nametable
- ::currentScope /rax :movqImmReg
- /rax /rbx :movqMemReg # rbx == start of scope in heap
+ /r14 /rbx :movqRegReg # rbx == start of scope in heap
8 /rbx /rdx :movqMemDisp8Reg # rdx == start of nametable in heap
8 /rbx /rsi :movqMemDisp8Reg # rsi == start of nametable in heap
8 /rsi /rsi :addqMemDisp8Reg # rsi == end of nametable in heap (according to fill)
@@ -301,8 +299,7 @@
8 /r15 :subqImm8Reg
/r15 :popqMem
- ::currentScope /rdi :movqImmReg
- /rdi /rdi :movqMemReg
+ /r14 /rdi :movqRegReg
/rbx :popqReg
/rbx /rsi :movqRegReg
::internalResolve /rax :movqImmReg
@@ -360,12 +357,10 @@
/unscoped :jzLbl8
# save current scope
- ::currentScope /rax :movqImmReg
- /rax /rsi :movqMemReg
8 /r15 :subqImm8Reg
- /rsi /r15 :movqRegMem
+ /r14 /r15 :movqRegMem
# enter scope
- /rcx /rax :movqRegMem
+ /rcx /r14 :movqRegReg
# handle typed function
16 /rdx /rcx :movqMemDisp8Reg
@@ -378,9 +373,7 @@
16 /rax :addqImm8Reg
/rax :callqReg
- /r15 /rcx :movqMemReg
- ::currentScope /rax :movqImmReg
- /rcx /rax :movqRegMem
+ /r15 /r14 :movqMemReg
8 /r15 :addqImm8Reg
/r15 :pushqMem
8 /r15 :addqImm8Reg
@@ -402,10 +395,8 @@
@typedUnscoped
# save current scope
- ::currentScope /rax :movqImmReg
- /rax /rsi :movqMemReg
8 /r15 :subqImm8Reg
- /rsi /r15 :movqRegMem
+ /r14 /r15 :movqRegMem
/typed :jmpLbl32
@arrayFunction
@@ -475,9 +466,7 @@
16 /rax :addqImm8Reg
/rax :callqReg
- /r15 /rcx :movqMemReg
- ::currentScope /rax :movqImmReg
- /rcx /rax :movqRegMem
+ /r15 /r14 :movqMemReg
8 /r15 :addqImm8Reg
/r15 :pushqMem
8 /r15 :addqImm8Reg
@@ -502,9 +491,7 @@
/rax :movqImmOOBReg "ey*" "ey." ::linkAbs64
/rax :callqReg
- /r15 /rcx :movqMemReg
- ::currentScope /rax :movqImmReg
- /rcx /rax :movqRegMem
+ /r15 /r14 :movqMemReg
8 /r15 :addqImm8Reg
/r15 :pushqMem
8 /r15 :addqImm8Reg
@@ -909,13 +896,11 @@
# create a new scope capturing the current one
[
- ::currentScope /rbx :movqImmReg
-
INITIALSCOPESIZE /rdi :movqImmReg
- /rbx /rsi :movqMemReg
+ /r14 /rsi :movqRegReg
::internalAllocateScope /rax :movqImmReg
/rax :callqReg
- /rax /rbx :movqRegMem # switch to new scope
+ /rax /r14 :movqRegReg # switch to new scope
:retn
] /ey< defv
@@ -925,11 +910,8 @@
# 0 <- scope just exited
[
/rbx :popqReg
- ::currentScope /rax :movqImmReg
- /rax :pushqMem
- /rax /rcx :movqMemReg
- 16 /rcx /rcx :movqMemDisp8Reg
- /rcx /rax :movqRegMem
+ /r14 :pushqReg
+ 16 /r14 /r14 :movqMemDisp8Reg
/rbx :pushqReg
:retn
@@ -939,10 +921,7 @@
# 0 <- current scope
[
/rbx :popqReg
-
- ::currentScope /rax :movqImmReg
- /rax :pushqMem
-
+ /r14 :pushqReg
/rbx :pushqReg
:retn
] /eyscope defv
@@ -979,33 +958,34 @@
]] /eyquoted defv
> _ ==globalFunctions { defv }' ::allocateOffsetStruct
- <
- # untyped scoped function jumppad
- # rdi -> code block object to call
- # rsi -> scope to install
- [[
- 8 /r15 :subqImm8Reg
- /r15 :popqMem
-
- ::currentScope /rax :movqImmReg
- /rax /rcx :movqMemReg
- 8 /r15 :subqImm8Reg
- /rcx /r15 :movqRegMem
- /rsi /rax :movqRegMem
-
- 16 /rdi :addqImm8Reg
- /rdi :callqReg
-
- /r15 /rcx :movqMemReg
- ::currentScope /rax :movqImmReg
- /rcx /rax :movqRegMem
- 8 /r15 :addqImm8Reg
-
- /r15 :pushqMem
- 8 /r15 :addqImm8Reg
- :retn
- ]] /internalConstantNormalFunctionScopedUntypedJumpPad defv
- > { defv }' ::allocateOffsetStruct
+# FIXME delete this
+# <
+# # untyped scoped function jumppad
+# # rdi -> code block object to call
+# # rsi -> scope to install
+# [[
+# 8 /r15 :subqImm8Reg
+# /r15 :popqMem
+#
+# ::currentScope /rax :movqImmReg
+# /rax /rcx :movqMemReg
+# 8 /r15 :subqImm8Reg
+# /rcx /r15 :movqRegMem
+# /rsi /rax :movqRegMem
+#
+# 16 /rdi :addqImm8Reg
+# /rdi :callqReg
+#
+# /r15 /rcx :movqMemReg
+# ::currentScope /rax :movqImmReg
+# /rcx /rax :movqRegMem
+# 8 /r15 :addqImm8Reg
+#
+# /r15 :pushqMem
+# 8 /r15 :addqImm8Reg
+# :retn
+# ]] /internalConstantNormalFunctionScopedUntypedJumpPad defv
+# > { defv }' ::allocateOffsetStruct
<
# resolve identifier without quoting considerations and act accordingly
@@ -1018,8 +998,7 @@
/r15 :popqMem # store identifier
# scope resolution
- ::currentScope /rdi :movqImmReg
- /rdi /rdi :movqMemReg
+ /r14 /rdi :movqRegReg
/r15 /rsi :movqMemReg
::internalResolve /rax :movqImmReg
@@ -1076,8 +1055,7 @@
/r15 :popqMem # store identifier
# scope resolution
- ::currentScope /rdi :movqImmReg
- /rdi /rdi :movqMemReg
+ /r14 /rdi :movqRegReg
/r15 /rsi :movqMemReg
::internalResolve /rax :movqImmReg
@@ -1199,17 +1177,14 @@
16 /rbx :addqImm8Reg
[
- /rsi :movqImmOOBReg
+ 16 /r15 :subqImm8Reg
+ 8 /r15 :popqMemDisp8
+ /r14 /r15 :movqRegMem
+ /r14 :movqImmOOBReg
] ::loadToRdi
/rcx /rdi :movqRegMem
8 /rdi :addqImm8Reg
[
- 16 /r15 :subqImm8Reg
- 8 /r15 :popqMemDisp8
-
- ::currentScope /rax :movqImmReg
- /rsi /rax :xchgqRegMem
- /rsi /r15 :movqRegMem
/rdi :movqImmOOBReg
] ::loadToRdi
/rbx /rdi :movqRegMem
@@ -1217,9 +1192,7 @@
[
/rdi :callqReg
- /r15 /rsi :movqMemReg
- ::currentScope /rax :movqImmReg
- /rsi /rax :movqRegMem
+ /r15 /r14 :movqMemReg
8 /r15 :pushqMemDisp8
16 /r15 :addqImm8Reg
@@ -1346,8 +1319,7 @@
16 /rdi :addqImm8Reg
[
- ::currentScope /rax :movqImmReg
- /rax /rax :movqMemReg
+ /r14 /rax :movqRegReg
] ::loadToRdi
/rcx /rcx :testqRegReg
@@ -1432,8 +1404,7 @@
/alreadyOptimized :jcLbl8
/rax :pushqReg
- ::currentScope /rcx :movqImmReg
- /rcx :pushqMem
+ /r14 :pushqReg
/rax :pushqReg
/rax :movqImmOOBReg "sys" ::string
@@ -1480,8 +1451,7 @@
/r15 :popqMem # store identifier
# scope resolution
- ::currentScope /rdi :movqImmReg
- /rdi /rdi :movqMemReg
+ /r14 /rdi :movqRegReg
/r15 /rsi :movqMemReg
::internalResolve /rax :movqImmReg
/rax :callqReg
@@ -2263,8 +2233,7 @@
# create function object
/rax /rdi :movqRegReg
capturing {
- ::currentScope /rax :movqImmReg
- /rax /rsi :movqMemReg
+ /r14 /rsi :movqRegReg
} {
/rsi /rsi :xorqRegReg
} ? *
@@ -2304,8 +2273,7 @@
8 /rbp :addqImm8Reg
[
- ::currentScope /rax :movqImmReg
- /rax /rsi :movqMemReg
+ /r14 /rsi :movqRegReg
/rdx /rdx :xorqRegReg
::internalAllocateFunction /rax :movqImmReg
/rax :callqReg
@@ -2662,8 +2630,7 @@
[ /eydefv /eydeff /eydefq ] { ==name
# create function
name | 16 sub /rdi :movqImmReg # adjust for expected (but non-existent) code block header size
- ::currentScope /rsi :movqImmReg
- /rsi /rsi :movqMemReg
+ /r14 /rsi :movqRegReg
/rdx /rdx :xorqRegReg # untyped
::internalAllocateFunction /rax :movqImmReg
@@ -2692,8 +2659,7 @@
::internalAllocateScope /rax :movqImmReg
/rax :callqReg
- ::currentScope /rdi :movqImmReg
- /rax /rdi :movqRegMem
+ /rax /r14 :movqRegReg
globalFunctions keys eydeffd { | }' createScopeEntries
globalFunctions2 keys eydeffd { | }' createScopeEntries
@@ -2707,10 +2673,9 @@
{ ==name
[[
INITIALSCOPESIZE /rdi :movqImmReg
- ::currentScope /rsi :movqImmReg
8 /r15 :subqImm8Reg
- /rsi /rsi :movqMemReg
- /rsi /r15 :movqRegMem # save scope
+ /r14 /r15 :movqRegMem # save scope
+ /r14 /rsi :movqRegReg
::internalAllocateScope /rax :movqImmReg
/rax :callqReg
/rax :pushqReg
@@ -2721,17 +2686,14 @@
|eydefv /rax :movqImmReg
/rax :callqReg
- ::currentScope /rsi :movqImmReg
- /rsi :popqMem
+ /r14 :popqReg
]] :execute
} /enterSubScope deff
{
[[
- ::currentScope /rsi :movqImmReg
- /r15 /rax :movqMemReg
+ /r15 /r14 :movqMemReg
8 /r15 :addqImm8Reg
- /rax /rsi :movqRegMem
]] :execute
} /leaveSubScope deff
diff --git a/compiler/elymasGlobalSys.ey b/compiler/elymasGlobalSys.ey
index 55f2369..05017d7 100644
--- a/compiler/elymasGlobalSys.ey
+++ b/compiler/elymasGlobalSys.ey
@@ -10,19 +10,15 @@
8 /r15 :subqImm8Reg
/r15 :popqMem
- ::currentScope /rax :movqImmReg
8 /r15 :subqImm8Reg
- /rax /rcx :movqMemReg
- /rcx /r15 :movqRegMem
- /rax :popqMem # load scope from argument
+ /r14 /r15 :movqRegMem
+ /r14 :popqReg # load scope from argument
internalExecuteIdentifier /rax :movqImmReg
/rax :callqReg
- ::currentScope /rax :movqImmReg
- /rax :pushqMem
- /r15 /rcx :movqMemReg
- /rcx /rax :movqRegMem # restore old scope
+ /r14 :pushqReg
+ /r15 /r14 :movqMemReg
8 /r15 :addqImm8Reg
/r15 :pushqMem
diff --git a/compiler/elymasGlobalSysAsm.ey b/compiler/elymasGlobalSysAsm.ey
index 0c54b05..73719f9 100644
--- a/compiler/elymasGlobalSysAsm.ey
+++ b/compiler/elymasGlobalSysAsm.ey
@@ -243,9 +243,9 @@
::unusedHeapStart /rax :movqImmReg # 53
/rbx :movqImmOOBReg %EE %EE %EE %EE %EE %EE %EE %EE # 63
/rbx /rax :movqRegMem # 66
- ::currentScope /rax :movqImmReg # 76
- /rbx :movqImmOOBReg %EE %EE %EE %EE %EE %EE %EE %EE # 86
- /rbx /rax :movqRegMem # 89
+ 0 /rax :movqImmReg # 76 # TODO remove this line once r14 scoping is stable
+ /r14 :movqImmOOBReg %EE %EE %EE %EE %EE %EE %EE %EE # 86
+ /rbx /rax :movqRegReg # 89 # TODO remove this line once r14 scoping is stable
:globalAllocations .base /rax :movqImmReg # 99
/rbx :movqImmOOBReg %EE %EE %EE %EE %EE %EE %EE %EE # 109
/rbx /rax :movqRegMem # 112
@@ -282,8 +282,7 @@
::unusedHeapStart /rdx :movqImmReg
/rdx /rdx :movqMemReg
/rdx 55 /rax :movqRegMemDisp8
- ::currentScope /rdx :movqImmReg
- /rdx /rdx :movqMemReg
+ /r14 /rdx :movqRegReg
16 /rdx /rdx :movqMemDisp8Reg # unwind one scope
/rdx 78 /rax :movqRegMemDisp8
:globalAllocations .base /rdx :movqImmReg
diff --git a/compiler/elymasGlobalSysOpt.ey b/compiler/elymasGlobalSysOpt.ey
index 8bd2f90..4f2b9a6 100644
--- a/compiler/elymasGlobalSysOpt.ey
+++ b/compiler/elymasGlobalSysOpt.ey
@@ -104,22 +104,6 @@
:retn
]] /eyreplace defv
- # returns currentScope into userspace
- # 0 <- ::currentScope as integer
- [[
- /rbx :popqReg
-
- ::internalAllocateInteger /rax :movqImmReg
- /rax :callqReg
- /rax :pushqReg
-
- ::currentScope /rdx :movqImmReg
- /rdx 8 /rax :movqRegMemDisp8
-
- /rbx :pushqReg
- :retn
- ]] /eycurrentScope defv
-
# returns internalAllocateScope into userspace
# 0 <- ::internalAllocateScope as integer
[[
diff --git a/elymas/lib/sys/opt.ey b/elymas/lib/sys/opt.ey
index bfb7c59..c693f7f 100644
--- a/elymas/lib/sys/opt.ey
+++ b/elymas/lib/sys/opt.ey
@@ -10,13 +10,12 @@
[
8 /r15 :subqImm8Reg
- 0 /rbx :movqImmReg
- /rbx /rsi :movqMemReg
- /rsi /r15 :movqRegMem
+ /r14 /r15 :movqRegMem
+ /r14 /rsi :movqRegReg
8 /rdi :movqImmReg
0 /rax :movqImmReg
/rax :callqReg
- /rax /rbx :movqRegMem
+ /rax /r14 :movqRegReg
] ==:scopingHeaderPattern
[
@@ -43,20 +42,13 @@
] ==:constantActiveGeneralPattern
[
- 0 /rsi :movqImmReg
16 /r15 :subqImm8Reg
8 /r15 :popqMemDisp8
-
- 0 /rax :movqImmReg
- /rsi /rax :xchgqRegMem
- /rsi /r15 :movqRegMem
+ /r14 /r15 :movqRegMem
+ 0 /r14 :movqImmReg
0 /rdi :movqImmReg
/rdi :callqReg
-
- /r15 /rsi :movqMemReg
- 0 /rax :movqImmReg
- /rsi /rax :movqRegMem
-
+ /r15 /r14 :movqMemReg
8 /r15 :pushqMemDisp8
16 /r15 :addqImm8Reg
:retn
@@ -75,8 +67,7 @@
] ==:constantPassivePattern
[
- 0 /rax :movqImmReg
- /rax /rax :movqMemReg
+ /r14 /rax :movqRegReg
] ==:staticLoadPattern
[
@@ -349,8 +340,8 @@
}
{ constantNormalFunctionScopedUntypedPattern callTargetMatch }' {
- [ calledAddress 2 add _ 8 add range peek each ] 256 math .unbase ==functionScope
- [ calledAddress 36 add _ 8 add range peek each ] 256 math .unbase ==finalAddress
+ [ calledAddress 13 add _ 8 add range peek each ] 256 math .unbase ==functionScope
+ [ calledAddress 23 add _ 8 add range peek each ] 256 math .unbase ==finalAddress
[ CALLSCOPED finalAddress functionScope ] emitLogic
}
@@ -453,13 +444,12 @@
8 /r15 :subqImm8Reg
/r15 :popqMem
8 /r15 :subqImm8Reg
- ::currentScope /rbx :movqImmReg
- /rbx /rsi :movqMemReg
- /rsi /r15 :movqRegMem
+ /r14 /r15 :movqRegMem
+ /r14 /rsi :movqRegReg
8 /rdi :movqImmReg
::internalAllocateScope /rax :movqImmReg
/rax :callqReg
- /rax /rbx :movqRegMem
+ /rax /r14 :movqRegReg
] emitOpcodes
}" {
# "unscoping function" dump
@@ -497,19 +487,14 @@
{ action CALLSCOPED streq }' {
[
- 2 entry /rsi :movqImmReg
8 /r15 :subqImm8Reg
+ /r14 /r15 :movqRegMem
- ::currentScope /rax :movqImmReg
- /rsi /rax :xchgqRegMem
- /rsi /r15 :movqRegMem
+ 2 entry /r14 :movqImmReg
1 entry /rdi :movqImmReg
/rdi :callqReg
- /r15 /rsi :movqMemReg
- ::currentScope /rax :movqImmReg
- /rsi /rax :movqRegMem
-
+ /r15 /r14 :movqMemReg
8 /r15 :addqImm8Reg
] emitOpcodes
@@ -519,8 +504,7 @@
{ action [ STATIC STATICTYPED ] streq any }' {
[
- ::currentScope /rax :movqImmReg
- /rax /rax :movqMemReg
+ /r14 /rax :movqRegReg
2 entry { 16 /rax /rax :movqMemDisp8Reg } rep
3 entry {
@@ -536,8 +520,7 @@
{ action STATICWRITE streq }' {
[
- ::currentScope /rax :movqImmReg
- /rax /rax :movqMemReg
+ /r14 /rax :movqRegReg
2 entry { 16 /rax /rax :movqMemDisp8Reg } rep
3 entry {
@@ -583,9 +566,7 @@
isScoping {
[
- /r15 /rcx :movqMemReg
- ::currentScope /rax :movqImmReg
- /rcx /rax :movqRegMem
+ /r15 /r14 :movqMemReg
16 /r15 :addqImm8Reg
8 neg /r15 :jmpqMemDisp8
] emitOpcodes