summaryrefslogtreecommitdiff
path: root/language/bytecode.ott
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-02-26 20:56:14 +0000
committerAlasdair Armstrong2018-02-26 20:57:16 +0000
commita8d905a0628c783b564e1ac35de3c93e9dad2956 (patch)
tree2216ad70bcf4ca534b7a99bf68fe62037ff3354b /language/bytecode.ott
parent0073077e7dfec96811b2ea5b024bb63cf2ef4b54 (diff)
Add some obvious optimisations to C backend.
With these optimisations on, now get about 10x performance over OCaml.
Diffstat (limited to 'language/bytecode.ott')
-rw-r--r--language/bytecode.ott25
1 files changed, 18 insertions, 7 deletions
diff --git a/language/bytecode.ott b/language/bytecode.ott
index e0d7db24..e9e6eb77 100644
--- a/language/bytecode.ott
+++ b/language/bytecode.ott
@@ -44,13 +44,14 @@ grammar
% Fragments are small pure snippets of (abstract) C code, mostly
% expressions, used by the aval and cval types.
fragment :: 'F_' ::=
- | id :: :: id
- | string :: :: lit
- | have_exception :: :: have_exception
- | current_exception :: :: current_exception
- | fragment op fragment' :: :: op
- | op fragment :: :: unary
- | fragment . string :: :: field
+ | id :: :: id
+ | string :: :: lit
+ | have_exception :: :: have_exception
+ | current_exception :: :: current_exception
+ | fragment op fragment' :: :: op
+ | op fragment :: :: unary
+ | string ( fragment0 , ... , fragmentn ) :: :: call
+ | fragment . string :: :: field
% init / clear -> create / kill
@@ -130,6 +131,10 @@ instr :: 'I_' ::=
| goto string :: :: goto
| match_failure :: :: match_failure
+% For optimising away allocations.
+ | reset ctyp id :: :: reset
+ | ctyp id = cval :: :: reinit
+
cdef :: 'CDEF_' ::=
| register id : ctyp :: :: reg_dec
| ctype_def :: :: type
@@ -145,3 +150,9 @@ cdef :: 'CDEF_' ::=
| function id mid ( id0 , ... , idn ) {
instr0 ; ... ; instrm
} :: :: fundef
+ | startup id {
+ instr0 ; ... ; instrn
+ } :: :: startup
+ | finish id {
+ instr0 ; ... ; instrn
+ } :: :: finish