Commit graph

8630 commits

Author SHA1 Message Date
Daniel Kochmański
9e79ae1a09 cmp: rework c2call-global for readibility 2023-12-28 12:46:24 +01:00
Daniel Kochmański
cb0d8274ae cmp: cleanup in the file cmppass2-call 2023-12-28 12:46:24 +01:00
Daniel Kochmański
923d9706f1 cmp: inl: introduce a macro WITH-INLINE-BLOCKS
This macro captures a common invocation scheme.
2023-12-28 12:46:24 +01:00
Daniel Kochmański
9229976731 cmp: inl: remove dead (and invalid!) code
C inliners for arithmetic operations assumed that there may be more than two
arguments and worked similar to reduce:

    ARG_n+3 <- (inline-binop ARG_n+2 ARG_n+1) op ARG_n

that said ECL has compiler macros that simplify the arithmetic so there are
always at most two arguments, so it is enough to inline:

    (inline-binop ARG1 ARG2)

As for the incorrect code -- when there were remaining arguments, the result of
the previous operation was saved with save-inline-loc, but(!) save-inline-loc
expected an inlined argument, while inline-binop calls produce-inline-loc that
returns a "normal" location - that's probably some change from the past, because
produce-inline-loc seems to clearly indicate that it should return inlined value
- and save-inline-loc would always error because of the argument type mismatch.

This commit removes the dead code and now unused save-inline-loc function.
2023-12-28 12:46:24 +01:00
Daniel Kochmański
c6955e41c5 cmp: inl: move code around in the cxx backend inliners
After understanding better the code I've moved argument inlining and function
inlining close to each other, also negate-argument clearly belongs in there too.

INLINED-ARG is now a structure (not a naked list) - that helps with
understanding abstractions better.
2023-12-28 12:46:24 +01:00
Daniel Kochmański
48c39c8083 cmp: inl: remove maybe-save-value and introduce inline-arg0 instead
This function has very clear resemblence of inline-args so it is moved to
cmpc-opt-inl.
2023-12-28 12:46:24 +01:00
Daniel Kochmański
a12d24a8bf cmp: exit manager: implement branching directly in the module
Instead of open-coding branching manually in individual operators we introduce
separate unwinding operators.
2023-12-28 12:46:24 +01:00
Daniel Kochmański
bb42ed7194 cmp: compute-unwind: make all arguments explicit
Instead of relying on *UNWIND-PROTECT* we accept explicit arguments.
2023-12-28 12:46:24 +01:00
Daniel Kochmański
909e5693ab cmp: tagbody: move tag allocation before branching
This is a cosmetic change for readibility.
2023-12-28 12:46:24 +01:00
Daniel Kochmański
bc01ff1a3c cmp: unwind-cjump: avoid recursive call to unwind-exit
Previously our call for conditional jumps worked like:

  unwind-exit -> unwind-cjump -> unwind-exit -> unwind-{label,exit}

The roundtrip to unwind-exit makes tracking invocations harder. The new
invocation chain is:

  unwind-exit -> unwind-cjump -> unwind-{label,exit}
2023-12-28 12:46:24 +01:00
Daniel Kochmański
b9605fd3e4 cmp: exit manager: introduce operators UNWIND-FLEE and UNWIND-COND
The operator UNWIND-FLEE is used to perform a dynamic unwind. Previously we've
opencoded this type of exits in appropriate operators.

The operator UNWIND-COND is used to perform a conditional unwind. It is expected
to be called to produce the IF statement body. With this commit all every
transfer of control goes through the exit manager.

Ultimately we will want to include the if test directly in UNWIND-COND.
2023-12-28 12:46:24 +01:00
Daniel Kochmański
dfa02ba434 cmp: unwind-label: relax conditions for carrying the value
There is no need to carry the location value across the unwind when the
destination is not special, because then we may assign the destination before we
unwind the stack. That allows us to skip examining the unwind requirements.
2023-12-28 12:46:24 +01:00
Daniel Kochmański
d13d400654 cmp: move the variable *DESTINATION* to cmpc 2023-12-28 12:46:24 +01:00
Daniel Kochmański
c2ffcc5deb cmp: introduce a separate environment for functions
There is an environment for the backend, and there is a separate environment for
each function.
2023-12-28 12:46:21 +01:00
Daniel Kochmański
def52d9657 cmp: pull emit-toplevel-form into emit-entry-fun
Instead of mincing blocks form-by-form, we put them all in a single function
environment and make them share locals.
2023-12-28 12:42:39 +01:00
Daniel Kochmański
364deb0551 cmp: remove unused bindings
EMIT-TOPLEVEL-FORM bound *compile-file-truename* and *compile-file-position* to
be immedietely rebound in T2EXPR (to the same value!).

*COMPILE-TO-LINKING-CALL* is not used anywhere.
2023-12-28 12:42:39 +01:00
Daniel Kochmański
141231f2fe cmp: remove dead code 2023-12-28 12:42:39 +01:00
Daniel Kochmański
397dc995d4 cmp: cosmetic changes, elaborate in a comment 2023-12-28 12:42:39 +01:00
Daniel Kochmański
b4da521398 cmp: set-loc: fix a braino (don't access special variable)
set-loc saves the location to the destination, and while doing so it coerces the
former to the type of the latter. Our code used *destination* as the argument to
LOC-REPRESENTATION-TYPE, but DESTINATION and *DESTINATION* may not be the same.
2023-12-28 12:42:39 +01:00
Daniel Kochmański
b3e85f1014 cmp: move misplaced comment to cmpc-inl-sysfun 2023-12-28 12:42:39 +01:00
Daniel Kochmański
f074f1087b cmp: cleanup: remove unused function 2023-12-28 12:42:39 +01:00
Daniel Kochmański
125605b1d0 Merge branch 'read-line' into 'develop'
Fix stream-read-line return

See merge request embeddable-common-lisp/ecl!312
2023-12-28 10:52:08 +00:00
Daniel Kochmański
1be34217a8 seqmacros: do-sublist: fix an invalid declaration
ECL declared the argument %sublist as CONS while it may be either CONS or NIL.
Reported by Alex Wood from Clasp.
2023-12-16 19:23:36 +01:00
Daniel Kochmański
f4af0cc9e3 INSTALL: add an extra hint for emscripten re stack size
Fixes #726.
2023-12-09 09:24:58 +01:00
Daniel Kochmański
1615d72900 cmp: don't attempt to inline constant values with make-load forms
This recent regression caused issues when we try to inline values of constants
that are structures. Fixes #727.
2023-12-07 14:28:01 +01:00
Marius Gerbershagen
758ebc6230 Merge branch 'cmpc-refactor' into 'develop'
cmp: further refactor

See merge request embeddable-common-lisp/ecl!311
2023-12-05 20:26:02 +00:00
Tarn W. Burton
ac0f992296
Add tests for Gray read-line 2023-12-04 15:23:38 -05:00
Daniel Kochmański
5a5b327124 cmp: t1/c1expr: top-level symbol macro expansions remain top-level 2023-12-04 21:10:00 +01:00
Daniel Kochmański
6db9231366 cmp: t1epxr*: account for top level forms expanding to atoms 2023-12-04 20:59:29 +01:00
Tarn W. Burton
4ede355c26
Allow empty string for EOF in read-line 2023-12-04 13:01:40 -05:00
Daniel Kochmański
af9d9092c8 cmp: add a comment explaning slots in the structure LABEL 2023-11-25 18:50:13 +01:00
Daniel Kochmański
c2057879e4 cmp: utils: introduce a macro with-lexical-scope
This macro introduces a semantical demarcation of an inner lexical scope.
2023-11-25 18:50:13 +01:00
Daniel Kochmański
f57fa4fab3 cmp: set-loc: accept explicit destination argument
Most of the time when we've used SET-LOC we've rebound *DESTINATION* for that
particular operation. Instead of doing so right now the argument is explicit and
when we want to use the *DESTINATION* then we simply use it (literally 2 cases).
2023-11-25 18:50:13 +01:00
Daniel Kochmański
ef4ab04eda cmp: implement foreign data locations
Instead of directly opencoding them in t3-defcallback we take a more organized
approach where we work with locations. This is part of larger refactor.
2023-11-25 18:50:13 +01:00
Daniel Kochmański
ef36cf53e0 cmp: abstract away STACK emitter with a macro
We also get rid of (STACK <int>) exit in favor of an explicit frame. This was
used only by UNWIND-PROTECT for no apparent reason.
2023-11-25 18:50:13 +01:00
Daniel Kochmański
f72726a032 cmp: abstract away FRAME emitter with a macro 2023-11-25 18:50:13 +01:00
Daniel Kochmański
11aa544292 cmp: rewrite c2progn for readibility 2023-11-25 18:50:13 +01:00
Daniel Kochmański
521e815158 cmp: rewrite c2tagbody-body for readibility 2023-11-25 18:50:13 +01:00
Daniel Kochmański
938a757220 cmp: merge operators with-exit-label and with-optional-exit-label
Their core difference was that the latter coudl reuse the destination. We make
the exit argument explicit and optional in with-exit-label.
2023-11-25 18:50:13 +01:00
Daniel Kochmański
62c68c5bbc cmp: factor out emit-entry-fun from ctop-write 2023-11-25 18:50:13 +01:00
Daniel Kochmański
abd109c982 cmp: further rewrite the exit manager for clearity
This commit makes the exit type explicit and removes a need to test the result
of UNWIND-COND.
2023-11-25 18:50:13 +01:00
Daniel Kochmański
c03d856556 cmp: rewrite the exit manager for clearity
This commit rewrites UNWIND-EXIT to explicitly handle conditional jumps. We
remove misleading SET-JUMP-{TRUE,FALSE} and implement them locally.
2023-11-25 18:50:11 +01:00
Daniel Kochmański
f0634e3301 cmp: remove invalid optimization from unwind-exit
The optimization assumed, that we don't need to unwind stacks when there are no
bds nor stack frame changes. That leads to a corrupted IHS environment among
other things.
2023-11-25 18:48:59 +01:00
Daniel Kochmański
38e45ad026 cmp: exit manager has now two main ops UNWIND-EXIT and UNWIND-JUMP
unwind-exit assigns the destination and jumps to the target
unwind-jump ignores the destination and jumps to the target
2023-11-25 18:48:59 +01:00
Daniel Kochmański
4d412cc6f9 cmp: LABEL captures the current *UNWIND-PROTECT* as LABEL-DENV
Thanks to this change we may get rid of explicit TAG-UNWIND-PROTECT slot in
favor of relying on the tag label. Also rename TAG-LABEL to TAG-JUMP to
emphasize similarity to BLK-EXIT.
2023-11-25 18:48:59 +01:00
Daniel Kochmański
2f997ab990 cmp: refactor the exit manager to compute unwind-exit delta 2023-11-25 18:48:59 +01:00
Daniel Kochmański
94148e0e34 cmp: rename the location tag VALUES to VALUEZ
This tag is distinct from the Common Lisp operator so we use a distinct name to
avoid possible confusion.
2023-11-25 18:48:59 +01:00
Daniel Kochmański
55863c3f28 cmp: rename the location tag RETURN to LEAVE
This tag is distinct from the Common Lisp operator so we use a distinct name to
avoid possible confusion.
2023-11-25 18:48:59 +01:00
Daniel Kochmański
b8528d0d1c cmp: exit manager: remove the dead code for typed return locations
We never bind *EXIT* to returns other than 'RETURN.
2023-11-25 18:48:59 +01:00
Daniel Kochmański
2e941b417c cmp: small cleanup of internal errors in the exit manager 2023-11-25 18:48:59 +01:00