Commit Graph

51 Commits

Author SHA1 Message Date
Steve Dunham
ed3fe023cb [ fix ] include ambient CFLAGS/LDFLAGS in ccompilerArgs test 2024-04-27 15:31:59 -07:00
Hattori, Hiroki
1dc7b74e4e
[RefC] Suppress arglist wrapper (#3177)
* [RefC] Suppress code generation for unnecessary arglist wrappers.

* [RefC] cleanup dead code of arglist.

* Removed Value_Arglist to reduce Closure's allocation overhead.

* fix linter error

* [RefC] make trampoline() safety.

* [RefC] cleanup cStatementsFromANF to keep code simple.

* fix linter error

* fix linter error

* In another time, another galaxy. THE LINTER INVADORS conquaer the all humanity and make them slaves. Under 2024, a only leaved job for every humans is adjusting spaces of source code, or just type gg0vG$== in vim.

* [ test ] update golden value

* added supports 32 params on closure.

* [RefC] [Cleanup] removing duplicate codes.

* [RefC] Switch calling conventions based on the number of arguments to avoid limits on the number of arguments and to reduce stack usage.

* [RefC] Argument that are too large are placed on the heap, as are closures.

* [RefC] use idris2_malloc instead of malloc.

* [RefC] [Cleanup] Keep pure things pure.

* [RefC] Mapped some special constructors to NULL. This reduces malloc cost and generates simpler code in ConCase. But not work yet.

* [RefC] fix merge failure.

* [RefC] stringOps.c replace  NULL for NIL.

* [RefC] cleanup

* [RefC] ConstCase now generate simple if-then statements instead of using helpers. This reduces malloc/free costs.

* fix indentation

* fix whitespaces

* [RefC] The name field in Value_Constructor was restored for tycon. But changed to static const*. Hopefully the C compiler will remove the common string constants. The smartest thing to do would be to create a dummy global variable and use its address as a tag, but that would depend on the C compiler to resolve conflicts.

* [refc] a big changes of the space

* [RefC] Little tricks to reduce temporary variables

* spaces

* [RefC] fix compiler warnings

* [RefC] [test]  Perform memory leak analysis, if valgrind is installed.

* [RefC] Fix invalid memory read. Fix C compiler warnings.

* [RefC] Fix invalid memory read of strSubstr. [test] Perform memory leak analysis, if valgrind is installed.

* [test] fix junk line

* linter

* linter

* linter

* linter

* [RefC] merge with erase_trivial_constuctors

* merge w/ erase_trivial_constructors

* Revert "merge w/ erase_trivial_constructors"

This reverts commit be593a3715.

* Revert "[RefC] merge with erase_trivial_constuctors"

This reverts commit 3c21eb45d8.

* merge w/ upstream/main

* fix merge failure

* rename

* fix renaming

* [RefC] fix merge fail

* [RefC] renamed C functions for safty.

* [RefC] cleanup

* [RefC] Fix constructor tag of UnconsResult.CHARACTER.

---------

Co-authored-by: Mathew Polzin <matt.polzin@gmail.com>
Co-authored-by: Guillaume Allais <guillaume.allais@ens-lyon.org>
2024-04-17 15:48:43 +01:00
G. Allais
fee293b575
[ re #3177 ] Separate the renaming from the rest (#3248) 2024-04-03 17:22:19 +01:00
Hattori, Hiroki
ddc634b1b2
[RefC] Unbox small integers. (#3181) 2024-03-21 07:32:37 -05:00
Hattori, Hiroki
1906c75433
[RefC] [Cleanup] Erase trivial constructors; Stop copying constructor name. (#3206) 2024-02-20 08:01:06 -06:00
Hattori, Hiroki
034f1e89c4
[RefC] [Cleanup] erase ReturnStatement (#3210)
* [RefC] [Cleanup] erase ReturnStatement

* [Test] Specify LC_ALL=C.UTF-8 for sort command to avoid false failure from locale.
2024-02-15 08:16:46 -06:00
Alex1005a
196d08dd6d
Implement Precise Reference Counting for C backend (#2989)
* start implement drop spec

* [RefC] remove vars after prim function call

* [RefC] gc pointer processing changed

* [RefC] fix memory leak in stringIteratorToString

* [RefC] runtime.c refactoring

* Implement basic reuse analisis

* [RefC] do not delete reusable variables in value in let

* [RefC] Use names instead tags in reuse map

* [RefC] Don't set all fields to null in reuse constructor

* Use record syntax in RefC

* Add some utility functions to RefC

* Sort output in garbageCollect refc test

* Add memory leak test for RefC

* [RefC] Remove variable only from body in let

Co-authored-by: G. Allais <guillaume.allais@ens-lyon.org>

* [RefC] Remove borrowed set from env

* [RefC] Use Ref variable for Enviroment instead of passing as an argument

* [RefC] Use locally function as combinator

* [RefC] removing unnecessary dup and remove during pattern matching

* Update refcTests and refcMemoryLeakTests

* Remove some test files

* move CHANGELOG entry to CHANGELOG_NEXT

* Move refc-memory tests

* Change calling convention test

* [RefC] [Test] Reuse test

---------

Co-authored-by: G. Allais <guillaume.allais@ens-lyon.org>
Co-authored-by: Mathew Polzin <matt.polzin@gmail.com>
2024-02-12 00:43:17 -06:00
HIROKI, Hattori
e417031c31 [RefC] added new test for basic pattern matches. 2024-01-30 18:21:51 +09:00
HIROKI, Hattori
af4e888857 [RefC] [Cleanup] Pattern matching generates simpler code. Reduce malloc/free costs. 2024-01-23 21:59:23 +09:00
Hattori, Hiroki
5f643c04d1
[RefC] [Test] Valgrind support & Fix invalid memory read of strSubstr (#3196) 2024-01-22 07:25:22 -06:00
Mathew Polzin
073fbef3d1
Remove use of deprecated getByte function (#3190)
* Add CHANGELOG_NEXT entry
2024-01-14 11:26:51 -06:00
Hattori, Hiroki
844ea28149
- [RefC] delete unnecessary conversion to keep code simply. (#3176)
* - [RefC] delete unnecessary conversion to keep code simply.
- [RefC] rename some C functions to confliction safe.

* make the linter feels good.

* Get me a job as a linter slave.

* [RefC] Added hard fail for unsupported primitives.

* Fix typo.
2024-01-14 11:17:34 -06:00
Guillaume Allais
915b340b2e [ re #3177 ] Test to see the change in calling conventions 2024-01-03 12:23:52 +00:00
Adam Brouwers-Harries
45a5d23539 Re-add redirects now linker issue seems to be fixed 2023-12-14 20:00:53 +00:00
Adam Brouwers-Harries
da62db17fd Remove -PIE from linker args, as it seems to cause issues on the NIX CI 2023-12-14 14:25:11 +00:00
Adam Brouwers-Harries
84c58b4bd9 Temporarily remove pipes to /dev/null to try and debug CI issues 2023-12-14 12:19:32 +00:00
Adam Brouwers-Harries
ecfe1bde70 use in cccompilerTest, correctly set DYLD_LIBRARY_PATH, use idrisGetEnv in CC.idr and update envvars documentation 2023-12-13 15:21:41 +00:00
Adam Brouwers-Harries
c11e0c1e66 Correctly add newline to end of test program 2023-12-12 21:46:11 +00:00
Adam Brouwers-Harries
98026cc3e4 [test] Correctly clang-format test inputs 2023-12-12 21:40:06 +00:00
Adam Brouwers-Harries
170e52b3c1 [fix] correctly pass environment vars to the RefC compiler 2023-12-12 21:25:47 +00:00
Robert Wright
09466a96bb Add testing utilities script 2023-09-07 14:57:22 +01:00
G. Allais
85bb822f3b
[ perf ] manually eta-expand unsaturated io_bind calls (#2785) 2022-12-01 15:31:00 +00:00
Hattori, Hiroki
5c9f8e36a1
[ RefC ] Add 16 and 32 bit access to base/Data.Buffer . (#2609)
* Fix symbom mangling

* Revert "Fix symbom mangling"

This reverts commit 6481e80155.

* Fix typo

* [RefC] Add missed prims of setBuffer* .

* [ fix ] formatting

* [ re #2609 ] Use 'UInt' instead of 'Word'

More descriptive/to the point / Less assumed knowledge.

There are no *LE suffixes for UInt8, since endianness is to do with
multiple bytes and UInt8 is a single one.

Co-authored-by: Guillaume Allais <guillaume.allais@ens-lyon.org>
Co-authored-by: Thomas E. Hansen <teh6@st-andrews.ac.uk>
2022-11-15 12:15:06 +01:00
CodingCellist
70ef197cf6
[ base ] Deprecate setByte in favour of setBits8 (#2764)
* [ base ] Deprecate setByte in favour of setBits8
           Deprecate getByte; fix Core.Binary.Prims

Along with `setByte`, the `getByte` function should similarly be
deprecated since it also assumes the value will have the given size,
rather than guaranteeing it in the type.

CI highlighted some required changes in `Core.Binary.Prims` thanks to
`-Werror`. The fix was to add some `cast` calls where the old `getByte`
and `setByte` used to be.

The RefC buffer test will need updating once we remove the functions
completely. Added a note for future peeps.
2022-11-15 10:42:07 +01:00
Steve Dunham
a0d9e2bbba
Update tests using base64 utility to also work on macos (#2536)
* Update tests using base64 utility to also work on macos

* Fix invocation of base64 in refc/buffer test.
2022-07-13 06:46:31 -07:00
Stefan Höck
5a962929e7
[ fix ] issue 2537 (#2538)
Co-authored-by: Zoe Stafford <zoepolarsax@gmail.com>
2022-07-07 09:54:52 +01:00
György Kurucz
7a5f63eab0 [ fix ] Add missing cases for BITS types in extractInt
e79e4277 ("[ fix ] Make Bits types use int switch statement in RefC")
made the RefC backend generate code calling `extractInt` with Bits
types, bit did not add the extra cases to `extractInt`. This commit adds
the missing cases.

Fixes #2452
2022-05-04 10:18:58 +01:00
vfrinken
b1f45f2748
RefC backend improvements (#2425)
* RefC backend improvements

1. OnCollect had the wrong number of arguments. The code creator expects
   3 arguments, but onCollect in prim.h expected 4 arguments. The first of which
   was an erased arguments. That is now fixed.

2. OnCollect did not call `newReference` when creating a new reference to the pointer
   and the freeing function

3. OnCollect and OnCollectAny still had a spurious printf statement

Those issues have been fixed, the test case can be found in
  tests/refc/garbageCollect

4. The IORef mechanism expects that the %World token will be passed around
   consistently. This is not the case. States in Control.App make use of
   IORefs, but the function created from Control.App.prim_app_bind
   had the world token erased to NULL.
   Now, IORefs are managed using a global variable,
   IORef_Storage * global_IORef_Storage;
   referenced in cBackend.h, defined in the created .c file, and set to NULL
   in main();

5. While multithreading and forking is still not supported, compiling a program
   that makes use of Control.App demands a C implementation of prim_fork.
   Files support/refc/threads.c and support/refc/threads.h provide a
   dummy implementation for it, so that Control.App programs compile and run.

A test for these 2 issues is given in tests/refc/issue2424

* format changes

to make the linter happy

* format changes

to make the linter happy

* format changes

to make the linter happy

* spelling mistake braket -> bracket

Co-authored-by: Volkmar Frinken <volkmar@onutechnology.com>
2022-04-27 13:59:32 +01:00
octeep
f137d96cd6 update refc/buffer to check how many bytes have been read 2022-01-24 15:58:32 +00:00
Jason Dagit
50c5be30d7 RefC: add test for issue1778 2022-01-20 14:10:57 +00:00
octeep
f7bcd1f0b2 make readBufferData return the number of bytes that have been read 2022-01-19 17:35:14 +00:00
Denis Buzdalov
a09c5082c5
[ base ] Use Fin n as index in Bits (#2192) 2021-12-16 18:26:52 +00:00
Guillaume ALLAIS
8e8988ff5a [ re #1191 ] test case 2021-11-24 21:15:43 +00:00
Zoe Stafford
5c41c81883
Optimise away case statements on unit-y types (#1844) 2021-10-13 15:46:02 +01:00
Stiopa Koltsov
9f61e542b4 Move rm -rf to the beginning of the test
While the discussion about how to refactor test framework is not
finished (#1654), make this change: move `rm -rf build` in the
beginning of the test. For these reasons:

* it is useful to inspect the contents of the `build` directory
  especially after the test failure
* if build crashes mid-test (e.g. process killed), next run should
  not be affected by the `build` directory from the previous run
2021-07-13 22:54:53 +01:00
Stefan Höck
6ed266d306
[ new ] Missing integer type interfaces (#1629)
Co-authored-by: Guillaume ALLAIS <guillaume.allais@ens-lyon.org>
2021-06-28 20:00:10 +01:00
Kamiλ Shakirov
8e30b296c0
[ refactor ] Remove Data.Strings module (#1607) 2021-06-28 13:48:37 +01:00
Robert Wright
1875f62248 Remove freeBuffer function
Each backend is now responsible for freeing Buffers in the same way as other objects
2021-06-14 15:06:44 +01:00
Robert Wright
195e690ddc Fix RefC Buffer getInt function to work with large values 2021-06-14 15:06:44 +01:00
Robert Wright
c6a5827319 Add RefC readBufferData/writeBufferData support 2021-06-14 15:06:44 +01:00
Robert Wright
aa94dd2351 Add RefC Char pattern matching support 2021-06-07 15:15:37 +01:00
madman-bob
98d67499db
RefC Integer Support (#1480)
* Add utility functions to treat All as a heterogeneous container
* Distinguish RefC Int and Bits types
* Change RefC Integers to be arbitrary precision
* Add RefC Bits maths operations
* Make RefC div and mod Euclidean
* Add RefC bit-ops tests
* Add RefC integer comparison tests
* Add RefC IntN support
2021-06-03 10:44:42 +01:00
Robert Wright
5aef7a2dff fixup! 04dfba03 2021-05-20 14:25:16 +01:00
Robert Wright
c57bb5a65f Add RefC StringIterator support 2021-05-20 14:25:16 +01:00
Robert Wright
cd3906645b Add RefC getArgs support 2021-05-20 14:25:16 +01:00
Robert Wright
f3aae06b28 Add RefC Clock support 2021-05-20 14:25:16 +01:00
Robert Wright
cf2b05ce02 Add RefC Buffer support 2021-05-20 14:25:16 +01:00
Robert Wright
204b96fe6c Add RefC math library linking 2021-05-20 14:25:16 +01:00
Robert Wright
c34c6e0959 Complete RefC standard String support
- Fix off-by-one error in String reverse
- Correct order of arguments in strSubstr
- Actually use start index of strSubstr
- Reduce memory usage of strSubstr in case of overrunning string end
- Add fastPack/fastUnpack/fastConcat
- Use unsigned chars for character comparisons
- Fix generated C character encodings
2021-05-20 14:25:16 +01:00
Z-snails
4eac2dd0b9
[ new ] support record projections in refc backend (#1054) 2021-02-10 14:46:41 +00:00