diff options
| author | Drahflow <drahflow@gmx.de> | 2013-09-28 21:54:36 +0200 |
|---|---|---|
| committer | Drahflow <drahflow@gmx.de> | 2013-09-28 21:54:36 +0200 |
| commit | 99e0fad4803fa1b36b3b65ad5dfa1f2abdd3b418 (patch) | |
| tree | 00fe8b524e578ac7380586a6240af11ab2a117b7 /elymas/lib/sys/opt.ey | |
| parent | 55cb8cb3c9c768f9f088dabe47e8939b2b8d4d1b (diff) | |
Rewriting * when types are predictable
Diffstat (limited to 'elymas/lib/sys/opt.ey')
| -rw-r--r-- | elymas/lib/sys/opt.ey | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/elymas/lib/sys/opt.ey b/elymas/lib/sys/opt.ey index b82156f..4afda2e 100644 --- a/elymas/lib/sys/opt.ey +++ b/elymas/lib/sys/opt.ey @@ -127,6 +127,8 @@ /STATICWRITE ==:STATICWRITE /STATICDOT ==:STATICDOT /NATIVE ==:NATIVE + /UNTYPEDSCOPEDSTAR ==:UNTYPEDSCOPEDSTAR + /UNTYPEDUNSCOPEDSTAR ==:UNTYPEDUNSCOPEDSTAR { =*f ==t t { f } { 0 } ? * @@ -241,6 +243,50 @@ } each } /rewriteConstantDot deffst + { _ ==logic + 1 logic len range { ==i i logic * ==entry 0 entry * ==action i 1 sub logic * ==last + [ + { action CALL streq + { 1 entry * "*" | +rawCodeAddress eq }' andif + { 0 last * STATICTYPED streq }' andif + }' { + 4 last * +rawObject ==executedObject + executedObject sys .typed .type ==type + + type [ + { "failed to optimize 'execution' of integer typed object" die } + { } # TODO string case + { "failed to optimize 'execution' of scope typed object" die } + { "failed to optimize 'execution' of name table" die } + { "failed to optimize 'execution' of extension area" die } + { + # TODO think about handling typed functions + executedObject sys .typed .inputs len { } { + # handle untyped function + executedObject sys .capturedScope { + -- # ignore concrete scope + [ UNTYPEDSCOPEDSTAR ] i logic =[] + } { + [ UNTYPEDUNSCOPEDSTAR ] i logic =[] + } ? * + } ? * + } + { "failed to optimize 'execution' of raw function opcodes object" die } + { } # TODO array code + { "failed to optimize 'execution' of function type descriptor" die } + { "objects of type 09 should not appear" die } + { "objects of type 10 should not appear" die } + { "objects of type 11 should not appear" die } + { "objects of type 12 should not appear" die } + { "objects of type 13 should not appear" die } + { "objects of type 14 should not appear" die } + { "objects of type 15 should not appear" die } + ] * * + } + ] conds + } each + } /rewriteConstantStar deffst + { ==logic [ NOP ] ==last [ logic { ==entry 0 entry * ==action @@ -480,6 +526,7 @@ containsScopeModifications not |rewriteConstantPipe rep containsScopeModifications not |rewriteConstantEquals rep containsScopeModifications not |rewriteConstantDot rep + containsScopeModifications not |rewriteConstantStar rep rewriteStackOps { =*entry 0 entry ==action [ @@ -588,6 +635,29 @@ ] emitOpcodes } + { action UNTYPEDSCOPEDSTAR streq }' { + [ + /rax :popqReg + 8 /r15 :subqImm8Reg + /r14 /r15 :movqRegMem + 8 /rax /r14 :movqMemDisp8Reg + 24 /rax /rax :movqMemDisp8Reg + 16 /rax :addqImm8Reg + /rax :callqReg + /r15 /r14 :movqMemReg + 8 /r15 :addqImm8Reg + ] emitOpcodes + } + + { action UNTYPEDUNSCOPEDSTAR streq }' { + [ + /rax :popqReg + 24 /rax /rax :movqMemDisp8Reg + 16 /rax :addqImm8Reg + /rax :callqReg + ] emitOpcodes + } + { action NATIVE streq }' { 1 entry emitOpcodes } |
