diff options
| -rw-r--r-- | compiler/elymasAsmLib.ey | 94 | ||||
| -rw-r--r-- | compiler/elymasGlobal.ey | 4 | ||||
| -rw-r--r-- | compiler/standardClient.ey | 16 | ||||
| -rw-r--r-- | elymas/memdump.ey | 70 | ||||
| -rw-r--r-- | notes | 46 |
5 files changed, 115 insertions, 115 deletions
diff --git a/compiler/elymasAsmLib.ey b/compiler/elymasAsmLib.ey index 91e3689..14e297c 100644 --- a/compiler/elymasAsmLib.ey +++ b/compiler/elymasAsmLib.ey @@ -471,11 +471,7 @@ /markInteger :jzLbl32 /rax :decqReg /markString :jzLbl32 - /rax :decqReg - /markScope :jzLbl32 - /rax :decqReg - /markNameTable :jzLbl32 - /rax :decqReg + 3 /rax :subqImm8Reg /markExtensionArea :jzLbl32 /rax :decqReg /markFunction :jzLbl32 @@ -485,6 +481,10 @@ /markArray :jzLbl32 /rax :decqReg /markFunctionType :jzLbl32 + /rax :decqReg + /markScope :jzLbl32 + /rax :decqReg + /markNameTable :jzLbl32 @markInvalidType /rax /rbx :movqRegReg # for easier inspection @@ -501,46 +501,6 @@ # " string marked\n" outputError :retn - @markScope - # /rdi :pushqReg - # "scope marked\n" outputError - # /rdi :popqReg - - /rcx :pushqReg - /rsi :pushqReg - /rdi /ecx :movlMemReg - /rdi /rsi :movqRegReg - 8 /rcx :subqImm8Reg - @markScopeLoop - /rsi /rcx /rdi :movqMemIndexReg - /markObject :callqLbl32 - 8 /rcx :subqImm8Reg - /markScopeLoop :jnzLbl8 - /rsi :popqReg - /rcx :popqReg - :retn - - @markNameTable - # /rdi :pushqReg - # "name table marked\n" outputError - # /rdi :popqReg - - /rcx :pushqReg - /rsi :pushqReg - 8 /rdi /ecx :movlMemDisp8Reg - /rdi /rsi :movqRegReg - 16 /rcx :subqImm8Reg - /markNameTableEmpty :jzLbl8 - @markNameTableLoop - /rsi /rcx /rdi :movqMemIndexReg - /markObject :callqLbl32 - 16 /rcx :subqImm8Reg - /markNameTableLoop :jnzLbl8 - @markNameTableEmpty - /rsi :popqReg - /rcx :popqReg - :retn - @markExtensionArea # /rdi :pushqReg # "extension area marked\n" outputError @@ -663,6 +623,46 @@ /rcx :popqReg :retn + @markScope + # /rdi :pushqReg + # "scope marked\n" outputError + # /rdi :popqReg + + /rcx :pushqReg + /rsi :pushqReg + /rdi /ecx :movlMemReg + /rdi /rsi :movqRegReg + 8 /rcx :subqImm8Reg + @markScopeLoop + /rsi /rcx /rdi :movqMemIndexReg + /markObject :callqLbl32 + 8 /rcx :subqImm8Reg + /markScopeLoop :jnzLbl8 + /rsi :popqReg + /rcx :popqReg + :retn + + @markNameTable + # /rdi :pushqReg + # "name table marked\n" outputError + # /rdi :popqReg + + /rcx :pushqReg + /rsi :pushqReg + 8 /rdi /ecx :movlMemDisp8Reg + /rdi /rsi :movqRegReg + 16 /rcx :subqImm8Reg + /markNameTableEmpty :jzLbl8 + @markNameTableLoop + /rsi /rcx /rdi :movqMemIndexReg + /markObject :callqLbl32 + 16 /rcx :subqImm8Reg + /markNameTableLoop :jnzLbl8 + @markNameTableEmpty + /rsi :popqReg + /rcx :popqReg + :retn + # allocate next chunk of memory from the operating system @allocateFromSystem @@ -776,7 +776,7 @@ # CHECK this is just sanity checking 7 /rdi /al :movbMemDisp8Reg %F0 /al :andbImmReg - %20 /al :cmpbImmReg + %90 /al :cmpbImmReg /isScope :jeLbl8 "object resolving in is not a scope" outputError @@ -956,7 +956,7 @@ /rax :callqReg # set type and existence of all pointers - %26 7 /rax :orbImmMemDisp8 + %96 7 /rax :orbImmMemDisp8 16 /rax :popqMemDisp8 # set parent :retn diff --git a/compiler/elymasGlobal.ey b/compiler/elymasGlobal.ey index 01db3b8..b3f3ab6 100644 --- a/compiler/elymasGlobal.ey +++ b/compiler/elymasGlobal.ey @@ -208,7 +208,7 @@ ::internalAllocateAndZero /rax :movqImmReg /rax :callqReg - %30 7 /rax :orbImmMemDisp8 # set type + %A0 7 /rax :orbImmMemDisp8 # set type /rdx :popqReg 8 /rdx /rcx :movqMemDisp8Reg /rcx 8 /rax :movqRegMemDisp8 # copy fill @@ -226,7 +226,7 @@ INITIALNAMETABLESIZE 16 mul 16 add /rdi :movqImmReg ::internalAllocateAndZero /rax :movqImmReg /rax :callqReg - %30 7 /rax :orbImmMemDisp8 # set type + %A0 7 /rax :orbImmMemDisp8 # set type 16 8 /rax :orbImmMemDisp8 # set initial fill 16 /rax /rdi :leaqMemDisp8Reg # load first entry address diff --git a/compiler/standardClient.ey b/compiler/standardClient.ey index 1fb102f..801a003 100644 --- a/compiler/standardClient.ey +++ b/compiler/standardClient.ey @@ -505,8 +505,8 @@ object sys .typed .type [ literal # integer literal # string - literal # scope - invalid # name table + unknown + unknown invalid # extension area { object sys .typed .inputs ==in in len 1 neq { "multi-input function in typeStack" die } rep @@ -518,8 +518,8 @@ invalid # function code { [ 1 0 object len 1 sub ] 0 object * typeStackInternal } # array invalid # function type - unknown - unknown + literal # scope + invalid # name table unknown unknown unknown @@ -792,8 +792,8 @@ sys .typed .type [ { o base16encode64 sys .err .writeall } # integer { "\"" o "\"" cat cat sys .err .writeall } # string - { "<scope: " o sys .asm .rawAddress base16encode64 cat ">" cat sys .err .writeall } - invalid # name table + unknown + unknown invalid # extension area { "<function: " o sys .asm .rawAddress base16encode64 cat ">" cat sys .err .writeall } { "<function code: " o sys .asm .rawAddress base16encode64 cat ">" cat sys .err .writeall } @@ -803,8 +803,8 @@ "" indent { " " cat } rep "]" cat sys .err .writeall } # array invalid # function type - unknown - unknown + { "<scope: " o sys .asm .rawAddress base16encode64 cat ">" cat sys .err .writeall } + invalid # name table unknown unknown unknown diff --git a/elymas/memdump.ey b/elymas/memdump.ey index ef43d52..65557f8 100644 --- a/elymas/memdump.ey +++ b/elymas/memdump.ey @@ -71,7 +71,7 @@ ELFBASE 56 add peek64 65536 mod _ dump ==phdrCount } eachWhile } /peekElf64 deffst -HEAPBASE peekElf64 %FFFFFFFFFFFF0000 band %2E00000000000000 eq assert +HEAPBASE peekElf64 %FFFFFFFFFFFF0000 band %9E00000000000000 eq assert sys .asm .|programStart sys .asm .rawCodeAddress { add peekElf64 }_ =*peekProgramStart 2 peekProgramStart _ dump ==initialRsp @@ -122,6 +122,40 @@ sys .asm .|programStart sys .asm .rawCodeAddress { add peekElf64 }_ =*peekProgra addr 16 add peekElf64 "len:" -01 out addr 24 add peekElf64 256 math .base str .fromArray 0 out } + { :errornous_2 } + { :errornous_3 } + { :extension_area + addr peekElf64 %00000000FFFFFFFF band _ "len:" -01 out 8 div 1 -01 range { + 8 mul addr add peekElf64 dumpElf + } each + } + { :function + addr 8 add peekElf64 dumpElf + addr 16 add peekElf64 dumpElf + addr 24 add peekElf64 dumpElf + } + { :function_code + addr 16 add peekElf64 %FFFF band %B848 eq + addr 26 add peekElf64 %FFFF band %E0FF eq and + { + addr 18 add peekElf64 16 sub dumpElf + } { + addr 8 add peekElf64 _ "oplen:" -01 out ==oplen + addr peekElf64 %00000000FFFFFFFF band _ "len:" -01 out 8 div 2 oplen 8 div add -01 range { + 8 mul addr add peekElf64 dumpElf + } each + } ? * + } + { :array + addr peekElf64 %00000000FFFFFFFF band _ "len:" -01 out 8 div 1 -01 range { + 8 mul addr add peekElf64 dumpElf + } each + } + { :function_type + addr peekElf64 %00000000FFFFFFFF band _ "len:" -01 out 8 div 1 -01 range { + 8 mul addr add peekElf64 dumpElf + } each + } # more physical scope dumping, but harder to follow output # { :scope # addr peekElf64 %00000000FFFFFFFF band _ "len:" -01 out 8 div 1 -01 range { @@ -161,40 +195,6 @@ sys .asm .|programStart sys .asm .rawCodeAddress { add peekElf64 }_ =*peekProgra 16 mul addr add peekElf64 dumpElf } each } - { :extension_area - addr peekElf64 %00000000FFFFFFFF band _ "len:" -01 out 8 div 1 -01 range { - 8 mul addr add peekElf64 dumpElf - } each - } - { :function - addr 8 add peekElf64 dumpElf - addr 16 add peekElf64 dumpElf - addr 24 add peekElf64 dumpElf - } - { :function_code - addr 16 add peekElf64 %FFFF band %B848 eq - addr 26 add peekElf64 %FFFF band %E0FF eq and - { - addr 18 add peekElf64 16 sub dumpElf - } { - addr 8 add peekElf64 _ "oplen:" -01 out ==oplen - addr peekElf64 %00000000FFFFFFFF band _ "len:" -01 out 8 div 2 oplen 8 div add -01 range { - 8 mul addr add peekElf64 dumpElf - } each - } ? * - } - { :array - addr peekElf64 %00000000FFFFFFFF band _ "len:" -01 out 8 div 1 -01 range { - 8 mul addr add peekElf64 dumpElf - } each - } - { :function_type - addr peekElf64 %00000000FFFFFFFF band _ "len:" -01 out 8 div 1 -01 range { - 8 mul addr add peekElf64 dumpElf - } each - } - { :errornous_9 } - { :errornous_A } { :errornous_B } { :errornous_C } { :errornous_D } @@ -193,29 +193,6 @@ Overhead: 1/32. * Exact length * data (UTF-8) -=== Scope === -* Length in bytes (including header) - bit 63-60: 0 0 1 0 - bit 59: reserved for GC - bit 58: parent pointer exists (for scopes) (always 1 for now) - bit 57: extension area pointer exists (always 1 for now) -* name table (mapping entry names to offsets) -* parent scope (0 if no parent) -* extension area pointer (0 if no extra members (yet)) -* data - [ <reference> ]* - -=== Name Table === -( TODO: create a hash-table based implementation here ) -* Length in bytes (including header) - bit 63-60: 0 0 1 1 - bit 59: reserved for GC -* End of fill in bytes (i.e. if this field == length, table is full) -* data - [ <string reference>, <execution mode> ]* - ( TODO: Oh, the performance... ) - The 0th string maps to 0 and so on. - === Extension Area === * Length in bytes (including header) bit 63-60: 0 1 0 0 @@ -257,6 +234,29 @@ Overhead: 1/32. ( TODO: Think about representing this directly as array pointers ) ( TODO: Think about moving the counts to the beginning ) +=== Scope === +* Length in bytes (including header) + bit 63-60: 1 0 0 1 + bit 59: reserved for GC + bit 58: parent pointer exists (for scopes) (always 1 for now) + bit 57: extension area pointer exists (always 1 for now) +* name table (mapping entry names to offsets) +* parent scope (0 if no parent) +* extension area pointer (0 if no extra members (yet)) +* data + [ <reference> ]* + +=== Name Table === +( TODO: create a hash-table based implementation here ) +* Length in bytes (including header) + bit 63-60: 1 0 1 0 + bit 59: reserved for GC +* End of fill in bytes (i.e. if this field == length, table is full) +* data + [ <string reference>, <execution mode> ]* + ( TODO: Oh, the performance... ) + The 0th string maps to 0 and so on. + = Musings About The Optimizer = Main problem: How do we find out if the names mean what we believe they do? |
