aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/elymasAsmLib.ey4
-rw-r--r--compiler/elymasGlobal.ey12
-rw-r--r--doc/notes1
-rw-r--r--elymas/lib/sys/opt.ey42
4 files changed, 52 insertions, 7 deletions
diff --git a/compiler/elymasAsmLib.ey b/compiler/elymasAsmLib.ey
index 2347495..fdf97b8 100644
--- a/compiler/elymasAsmLib.ey
+++ b/compiler/elymasAsmLib.ey
@@ -1378,6 +1378,9 @@
[[
/rdi :pushqReg
/rsi :pushqReg
+
+ 58 /rsi :btqImm8Mem
+ /noSlotFound :jcLbl32 # nametable has template bit set, cannot modify
8 /rdi /rcx :movqMemDisp8Reg # load cached hash value
/rcx /rcx :testqRegReg
@@ -1439,6 +1442,7 @@
trySlot
> --
+ @noSlotFound
/rax /rax :xorqRegReg # no slot found
/rdx /rdx :xorqRegReg
16 /rsp :addqImm8Reg
diff --git a/compiler/elymasGlobal.ey b/compiler/elymasGlobal.ey
index 90fbfda..e7cea98 100644
--- a/compiler/elymasGlobal.ey
+++ b/compiler/elymasGlobal.ey
@@ -1809,12 +1809,12 @@
%30 -101* /eydefvst defv
%31 -101* /eydeffst defv
%33 -101* /eydefmst defv
- %40 -101* /eydefvc defv
- %41 -101* /eydeffc defv
- %43 -101* /eydefmc defv
- %C0 -101* /eydefvd defv
- %C1 -101* /eydeffd defv
- %C3 -101* /eydefmd defv
+ %50 -101* /eydefvc defv
+ %51 -101* /eydeffc defv
+ %53 -101* /eydefmc defv
+ %D0 -101* /eydefvd defv
+ %D1 -101* /eydeffd defv
+ %D3 -101* /eydefmd defv
--
# retype a function
diff --git a/doc/notes b/doc/notes
index e768ddd..a01083d 100644
--- a/doc/notes
+++ b/doc/notes
@@ -275,6 +275,7 @@ Overhead: 1/32.
* Length in bytes (including header)
bit 63-60: 1 0 1 0
bit 59: reserved for GC
+ bit 58: template table, needs copy on write
* Number of keys (also next scope entry index to assign)
* Hash buckets (16 bytes each)
[
diff --git a/elymas/lib/sys/opt.ey b/elymas/lib/sys/opt.ey
index 506e0d1..0adef46 100644
--- a/elymas/lib/sys/opt.ey
+++ b/elymas/lib/sys/opt.ey
@@ -19,6 +19,8 @@
} ":" defq
sys .asm "::" via
sys .asm .|peek ==:peek
+ { [ -01 _ 4 add range peek each ] 256 math .unbase } =*:peeku32
+ { [ -01 _ 8 add range peek each ] 256 math .unbase } =*:peeku64
[
8 /r15 :subqImm8Reg
@@ -218,6 +220,35 @@
} each
} /testAllocatedScopeEscape deffst
+ 0 ==templateNametable
+ {
+ 1 ==templatable
+ executingScope ::rawAddress 8 add peeku64 ==nameTableAddress
+ nameTableAddress {
+ nameTableAddress peeku32 ==nameTableLength
+ 0 nameTableLength 16 sub 16 div range 16 mul nameTableAddress 16 add add { ==entryAddr
+ entryAddr peeku64 ==keyAddr
+ keyAddr {
+ entryAddr 8 add peeku32 %10 band not {
+ 0 =templatable
+ "NOT templatable because" dump
+ nameTableAddress dump
+ keyAddr ::rawObject dump
+ } rep
+ } { } ? *
+ } each
+ } {
+ 0 =templatable
+ } ? *
+
+ templatable {
+ nameTableAddress =templateNametable
+ "Setting template bit on " dump
+ nameTableAddress dump
+ nameTableAddress 7 add _ sys .asm .peek %04 bor -01 sys .asm .poke # set template bit
+ } rep
+ } /testNametableTemplatability deffst
+
{ ==logic
[ NOP ] ==last
[ logic { ==entry 0 entry * ==action
@@ -757,8 +788,8 @@
# [ :ud2 ] emitOpcodes # enable for further development
-
newLogic
+ testNametableTemplatability
testScopeModifications
containsScopeModifications not {
rewriteConstantPipe
@@ -806,6 +837,15 @@
/r15 /r14 :movqRegReg
] emitOpcodes
}" ? *
+
+ templateNametable {
+ [
+ templateNametable /rax :movqImmReg
+ /rax 8 /r14 :movqRegMemDisp8
+ ] emitOpcodes
+
+ templateNametable emitReference
+ } { } ? *
}" {
[
8 /r15 :subqImm8Reg