aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2015-06-11 11:27:25 +0200
committerDrahflow <drahflow@gmx.de>2015-06-11 11:27:25 +0200
commiteefcf44946b306122e17216fd984749b56f5be3a (patch)
treefa1f278916c2c1455ddd8833bd7fd21d3703da44
parent044ad8735191a58db275ccf1927441340dd76c94 (diff)
Fix GC killing to-be-emitted reference targets
-rw-r--r--TODO1
-rw-r--r--compiler/elymasGlobalSysAsm.ey11
-rw-r--r--elymas/lib/sys/opt.ey33
3 files changed, 24 insertions, 21 deletions
diff --git a/TODO b/TODO
index 1c5c6b9..4793238 100644
--- a/TODO
+++ b/TODO
@@ -23,3 +23,4 @@
* better interactive error handling when interpreting from stdin
* document ALL THE LIBRARIES
* consider https://en.wikipedia.org/wiki/Hindley%E2%80%93Milner_type_system and finally make the stuff typed correctly
+* rewrite constant . resolutions to constants
diff --git a/compiler/elymasGlobalSysAsm.ey b/compiler/elymasGlobalSysAsm.ey
index 7416270..e131e3e 100644
--- a/compiler/elymasGlobalSysAsm.ey
+++ b/compiler/elymasGlobalSysAsm.ey
@@ -266,17 +266,8 @@
/rsi /ecx :movlMemReg
8 /rsi :addqImm8Reg
3 /rcx :shrqImm8Reg
- /rcx :decqReg
- /noReferencesToCopy :jzLbl8
-
- @referencesCopyLoop
- /rsi /rax :movqMemReg
- 8 /rax /rax :movqMemDisp8Reg
- :stosq
- 8 /rsi :addqImm8Reg
- /referencesCopyLoop :loopLbl8
+ :repnz :movsq
- @noReferencesToCopy
/rbp /rdi :xchgqRegReg
::internalAllocateCodeFromEncodingBuffer /rax :movqImmReg
diff --git a/elymas/lib/sys/opt.ey b/elymas/lib/sys/opt.ey
index 3c7e19c..29e6d26 100644
--- a/elymas/lib/sys/opt.ey
+++ b/elymas/lib/sys/opt.ey
@@ -295,13 +295,16 @@
} /holdsInt deffd
[
- "|" "=" "/" "?" "[" "]" /cat /dearray /def /die /len
+ "/" "?" "[" "]" /cat /dearray /die /len
/quoted /range "''" ".?" ".?'" ".|" ";"
+ /keys /dom /add /and /band /bor /bxor /div /eq /ge /gt /le /lt
+ /mod /mul /neq /or /sub /udiv /umod /xor /bnot /neg /not
+ ] { | ::rawCodeAddress } [ 0 ] [ 0 ] '' * ==:SCOPEIGNORANTFUNCTIONS
+ [
+ "|" "=" /def
/defv /deff /defq /defm /defvs /deffs /defms /defvt
/defft /defmt /defvst /deffst /defmst /defvc /deffc
/defmc /defvd /deffd /defmd
- /keys /dom /add /and /band /bor /bxor /div /eq /ge /gt /le /lt
- /mod /mul /neq /or /sub /udiv /umod /xor /bnot /neg /not
] { | ::rawCodeAddress } [ 0 ] [ 0 ] '' * ==:SCOPETIGHTFUNCTIONS
[
/defvs /deffs /defms /defvst /deffst /defmst
@@ -329,29 +332,37 @@
0 ==allocatedScopeMightEscape
{ _ ==logic
+ 0 ==needsAScope
+
logic { ==entry 0 entry * ==action
[
{ action NOP eq }' { }
{ action PUSH eq }' { }
{ action CALLSCOPED eq }' { }
- { action STATIC eq }' { }
- { action STATICTYPED eq }' { }
- { action STATICWRITE eq }' { }
- { action STATICDOT eq }' { }
+ { action STATIC eq }' { 1 =needsAScope }
+ { action STATICTYPED eq }' { 1 =needsAScope }
+ { action STATICWRITE eq }' { 1 =needsAScope }
+ { action STATICDOT eq }' { 1 =needsAScope }
{ action ARRAYSTAR eq }' { }
{ action UNTYPEDSCOPEDSTAR eq }' { }
{ action STRINGSTAR eq }' { }
- { action NATIVENOSCOPE eq }' { }
- { action CONDITIONALTAIL eq }' { }
+ { action NATIVENOSCOPE eq }' { 1 =needsAScope }
+ { action CONDITIONALTAIL eq }' { 1 =needsAScope }
- { action CALL eq { 1 entry * SCOPETIGHTFUNCTIONS eq any } andif }' { }
+ { action CALL eq { 1 entry * SCOPEIGNORANTFUNCTIONS eq any } andif }' { }
+ { action CALL eq { 1 entry * SCOPETIGHTFUNCTIONS eq any } andif }' { 1 =needsAScope }
# TODO handle more known-harmless unscoped global functions
{ 1 }' {
1 =allocatedScopeMightEscape
+ 1 =needsAScope
}
] conds
} each
+
+ needsAScope not isScoping and {
+ 0 =isScoping
+ } rep
} /testAllocatedScopeEscape deffst
0 ==templateNametable
@@ -1816,7 +1827,7 @@
[
{ ref 105553116266496 lt } { } # HEAPBASE # FIXME: use a global constant
{ ref 123145302310912 ge } { } # %700000000000
- { 1 } { newReferences [ ref ] cat =newReferences }
+ { 1 } { newReferences [ ref ::rawObject ] cat =newReferences }
] conds
} /emitReference deffst