aboutsummaryrefslogtreecommitdiff
path: root/elymas/lib
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2013-12-31 00:54:59 +0100
committerDrahflow <drahflow@gmx.de>2013-12-31 00:54:59 +0100
commit643d6dca1e6026ebf8cfa551ae3e95cc69003c47 (patch)
treedf79289945ee98efee9be9ca201eb1a6fda8c840 /elymas/lib
parent9699795a62506f69cb83fa35cb58e7641690eb5f (diff)
Less memory usage still
Also, sys .opt now needs less luck to execute correctly.
Diffstat (limited to 'elymas/lib')
-rw-r--r--elymas/lib/sys/opt.ey54
-rw-r--r--elymas/lib/sys/so.ey7
2 files changed, 45 insertions, 16 deletions
diff --git a/elymas/lib/sys/opt.ey b/elymas/lib/sys/opt.ey
index 9da4424..a59886f 100644
--- a/elymas/lib/sys/opt.ey
+++ b/elymas/lib/sys/opt.ey
@@ -1,10 +1,24 @@
<
+ txt .consume .|hu "%" deffd
+
<
- "../compiler/elymasAsm.ey" include
- assembler /ops sys .asm .defv
- > --
+ "../compiler/elymasAsmOps.ey" include
+ > /ops sys .asm .defv
- sys .asm .ops ":" via
+ sys .asm .ops ==:sysasmops
+ {
+ quoted {
+ _ sys .typed .type 1 eq {
+ sysasmops -01 .|
+ } {
+ "sysasmops" "|" | -102 "." |
+ } ? *
+ } {
+ sysasmops -01 .
+ } ? *
+ } ":" defq
+ sys .asm "::" via
+ sys .asm .|peek ==:peek
[
8 /r15 :subqImm8Reg
@@ -147,8 +161,6 @@
] any
} /holdsInt deffd
- { -1010 lt -012 ? } /max deffd
-
{ ==o ==executingScope
0 ==containsScopeModifications # TODO: replace <, > by macros ( {, scope } * respectively) then remove this
@@ -233,7 +245,7 @@
{ 0 secondLast * STATICTYPED streq }' andif
}' {
1 last * ::rawObject ==constant
- 4 secondLast * ::rawObject ==relevantScope
+ 4 secondLast * ==relevantScope
constant relevantScope sys .resolveInfo {
==mode -- ==parentCount 32 add ==offsetInScope ==inExtensionArea
@@ -411,7 +423,7 @@
{ 1 entry * "*" | ::rawCodeAddress eq }' andif
{ 0 last * STATICTYPED streq }' andif
}' {
- 4 last * ::rawObject ==executedObject
+ 4 last * ==executedObject
executedObject sys .typed .type ==type
type [
@@ -544,9 +556,6 @@
} each last ]
} /rewriteSimpleFunctions deffst
- sys .asm "::" via
- sys .asm .|peek ==:peek
-
o ::rawAddress ==addr
[ addr _ 4 add range peek each ] 256 math .unbase ==totalLength
[ addr 8 add _ 4 add range peek each ] 256 math .unbase ==codeLength
@@ -586,6 +595,10 @@
calledAddress ==j
{ { j }' { =j }' peek generalMatch }' /callTargetMatch deff
[
+ { calledAddress 105553116266496 lt }' { # HEAPBASE # FIXME: should use global constant
+ [ CALL calledAddress ] emitLogic
+ }
+
{ constantActiveGeneralPattern callTargetMatch }' {
[ calledAddress 3 add _ 8 add range peek each ] 256 math .unbase ==calledConstant
@@ -624,7 +637,7 @@
{ staticLoadFromScopePattern callTargetMatch }' {
[ loadStart 4 add _ 4 add range peek each ] 256 math .unbase ==offsetInScope
[ calledAddress 8 sub _ 8 add range peek each ] 256 math .unbase ==exampleObjectOffset
- [ calledAddress exampleObjectOffset add _ 8 add range peek each ] 256 math .unbase ==exampleObject
+ [ calledAddress exampleObjectOffset add _ 8 add range peek each ] 256 math .unbase ::rawObject ==exampleObject
[ STATICTYPED offsetInScope parentCount 0 exampleObject ] emitLogic
}
@@ -632,7 +645,7 @@
{ staticLoadFromExtensionPattern callTargetMatch }' {
[ loadStart 14 add _ 4 add range peek each ] 256 math .unbase ==offsetInScope
[ calledAddress 8 sub _ 8 add range peek each ] 256 math .unbase ==exampleObjectOffset
- [ calledAddress exampleObjectOffset add _ 8 add range peek each ] 256 math .unbase ==exampleObject
+ [ calledAddress exampleObjectOffset add _ 8 add range peek each ] 256 math .unbase ::rawObject ==exampleObject
[ STATICTYPED offsetInScope parentCount 1 exampleObject ] emitLogic
}
@@ -926,6 +939,10 @@
newOpcodes newReferences o ::replace
1 executingScope # return something different from o to signal successful optimization
+
+ [ ] _ =newOpcodes
+ _ =newReferences
+ =newLogic
} /optimize deffd
0 ==recursionDepth
@@ -937,4 +954,15 @@
} /hook sys .opt .deff
> --
+# ensure that the optimizer is run often enough to finish optimize itself
+# while in practice this is also achieved by the next freeze, it should be done explicitely
+100 { scope ==s
+ "{" s sys .executeIdentifier =s
+ 1 1
+ "add" s sys .executeIdentifier =s
+ "--" s sys .executeIdentifier =s
+ "}" s sys .executeIdentifier =s
+ *
+} rep
+
# vim: syn=elymas
diff --git a/elymas/lib/sys/so.ey b/elymas/lib/sys/so.ey
index d474d4c..468ec0f 100644
--- a/elymas/lib/sys/so.ey
+++ b/elymas/lib/sys/so.ey
@@ -572,7 +572,7 @@
i sys .asm .globalAllocSize ==?dataSize
>
} each
- ] ==allocSections
+ ] ==?allocSections
4096 ==:PAGESIZE
@@ -840,10 +840,11 @@
data str .fromArray out .writeall
} each
+ 1 ==:WRITE
+
[ ] _ =fileHeaders
=metaSections
-
- 1 ==:WRITE
+ < > =stringTable
allocSections { ==section
section .dataOffset fileOffset sub str .alloc out .writeall