Commit graph

133 commits

Author SHA1 Message Date
Leonardo de Moura
74f48414f1 feat: add option --exitOnPanic (short version -e)
Lean does not exit on panic anymore.
The old behavior (`std::exit(1)`) produces a horrible debugging
experience for the elaborator since all trace messages are lost.
The new command line option restores the old behavior.

cc @Kha @dselsam
2019-12-19 09:24:37 -08:00
Leonardo de Moura
54e5ca0c7b fix: lean_nat_abs
It must not assume a nonnegative big integer is a big nat.
2019-12-14 08:08:41 -08:00
Sebastian Ullrich
90b91760aa fix: SMALL_ALLOCATOR=OFF 2019-10-29 13:41:16 -07:00
Sebastian Ullrich
58dd7346e4 fix: build with SMALL_ALLOCATOR=OFF 2019-10-29 17:07:42 +01:00
Leonardo de Moura
411f397654 refactor(library/init/data/list): new name convention for List functions
cc @dselsam @kha
2019-10-01 15:15:02 -07:00
Leonardo de Moura
3d7a7c7e91 feat(library/init/util): add panic primitive 2019-09-30 16:23:18 -07:00
Leonardo de Moura
a4b860b92a fix(runtime): missing Array.data primitive 2019-09-19 10:27:10 -07:00
Leonardo de Moura
a7d616605a fix(runtime/lean): missing primitive 2019-09-19 09:54:03 -07:00
Leonardo de Moura
dc82c5cc70 chore(runtime/object): fix compilation error in debug mode on OSX 2019-08-28 15:43:21 -03:00
Leonardo de Moura
f40617d8dd feat(CMakeLists, runtime): add CHECK_RC_OVERFLOW cmake option 2019-08-28 15:35:46 -03:00
Leonardo de Moura
a944d158a3 feat(CMakeLists.txt): add SMALL_RC cmake option
When used with `COMPRESSED_OBJECT_HEADER`, Lean uses a compressed
object header where only 32-bits are reserved for the RC.
The motivation is performance, in our experiments, it is faster to
access a 32-bit counter than a 45-bit one.
With a smaller RC, we can use 8-bits for the memory kind information,
and speedup its access.
2019-08-28 14:54:08 -03:00
Leonardo de Moura
cb1680e096 chore(runtime/object): use same idiom we used at del_core 2019-08-24 12:02:09 -07:00
Leonardo de Moura
9d09325d1e fix(runtime): ensure we can disable LEAN_SMALL_ALLOCATOR 2019-08-24 11:18:07 -07:00
Leonardo de Moura
86c2c32810 fix(runtime/object): memory leak 2019-08-24 10:24:39 -07:00
Leonardo de Moura
fb4e2daf74 fix(runtime/object): debug build 2019-08-24 09:51:37 -07:00
Leonardo de Moura
720c3ca3e4 fix(runtime): size_t issue OSX vs Linux 2019-08-24 09:30:12 -07:00
Leonardo de Moura
140708fe8d chore(runtime): style 2019-08-24 07:40:56 -07:00
Leonardo de Moura
70f3537a29 feat(runtime): add lean_panic and variants 2019-08-24 07:40:39 -07:00
Leonardo de Moura
e7c8e66986 fix(runtime/object): remove incorrect assertions
They are not true when LEAN_COMPRESSED_OBJECT_HEADER is defined.
2019-08-24 07:40:38 -07:00
Leonardo de Moura
6553c5531c fix(runtime): bugs at compact.cpp and object size calculation 2019-08-24 07:40:38 -07:00
Leonardo de Moura
124c5da414 fix(runtime): disable compressed headers and fix bugs 2019-08-24 07:40:38 -07:00
Leonardo de Moura
3b762d4dc0 refactor(runtime): C backend 2019-08-24 07:40:38 -07:00
Leonardo de Moura
dcd15f3424 refactor(runtime): C backend 2019-08-24 07:40:38 -07:00
Sebastian Ullrich
2c12f9d0f6 chore(runtime/object): LEAN_FAKE_FREE: assert on double-free 2019-07-30 17:52:43 -07:00
Leonardo de Moura
2ad33a23db chore(runtime,library/init/lean): remove evalConst 2019-07-19 11:04:57 -07:00
Leonardo de Moura
c9cd693b8e feat(runtime/object): avoid recursion at mark_mt and mark_persistent
Reason: potential stack overflows
2019-07-10 11:27:49 -07:00
Sebastian Ullrich
723e9cc430 chore(runtime/object): fix usize_to_nat name 2019-07-05 16:26:54 -07:00
Sebastian Ullrich
2c9dce6eed fix(runtime/mpz): use size_t instead of unsigned long for Windows compatibility 2019-07-05 11:24:15 +02:00
Leonardo de Moura
3651dc7618 feat(library/init/lean): add evalConst
The implementation is good enough for implementing extensible parsers,
elaborators and tactics, but there are a few TODOs

1- We should have a better story for standalone applications.
   Most of them don't need `evalConst`, and the global table is
   just initialization overhead.

2- The global table introduces a dependency on the `Lean.Name`
   implementation. So, all standalone applications will depend on it.

3- We are not storing arity 0 constants in the table.
   This one should be easy to fix in the future.
2019-06-07 16:31:28 -07:00
Leonardo de Moura
c3a7cc4617 feat(library/init/lean/compiler/ir/emitcpp): register functions 2019-06-07 15:34:55 -07:00
Leonardo de Moura
30a6a2ade8 feat(library/init/data, runtime): remove parray support from runtime, and implement them in Lean using Scala/Clojure Radix trees
The Scala/Clojure approach for persistent arrays works great with our
`reset/reuse`. We seem to be much more efficient than their
implementations because of `reset/reuse`. The new approach also seems
better than the old one implemented in the runtime, and has a few
advantages:
1- The reroot procedure used in the old approach required
synchronization for multi-threaded code, or we would need to perform
deep copies when sending `parray` objects between threads.
2- We don't need any runtime extension for the new approach.
3- The old approach used "trail lists" for undoing array updates.
This works well for bactracking search use cases, but it is bad
in use cases where we are simultaneously updating the persistent
arrays that have shared nodes.
2019-06-02 09:18:19 -07:00
Leonardo de Moura
013f0c9edb feat(library/init/lean/compiler/ir/rc): missing optimization 2019-05-22 18:46:43 -07:00
Leonardo de Moura
ae8a51c718 feat(library/init/lean/runtime): expose runtime limit 2019-05-21 14:24:16 -07:00
Leonardo de Moura
18aa7de408 feat(library/init/data): add ByteArray 2019-05-08 16:43:00 -07:00
Leonardo de Moura
a32fcf33c7 feat(util/array_ref): simple wrapper for creating Lean array objects in C++ 2019-04-29 17:10:35 -07:00
Leonardo de Moura
5c7849a869 feat(runtime): eager heap initialization 2019-04-25 18:10:36 -07:00
Leonardo de Moura
32f41f60d3 feat(runtime/object): add dbgTraceIfShared primitive for debugging RC reuse issues 2019-04-19 16:26:45 -07:00
Leonardo de Moura
ee050431e0 feat(runtime): add primitive hash functions 2019-04-03 04:01:36 -07:00
Leonardo de Moura
42fbe3c18c chore(library/init,runtime,library/compiler): add fix primitive back
The new `partial def`s allow us to define `fix` in Lean, but the Lean
implementation is not as efficient as the native one. The native one
in C++ use weak pointers to prevent a closure allocation at every
recursive invocation.

This commit also fixes the `fixCore` helper functions that were broken
after we switched to camelCase.

We have updated the test `fix1.lean` to demonstrate the native
implementation is faster. Here are the numbers on my desktop.

```
./run.sh fix1.lean 24
721420279
Time for 'native fix': 816ms
721420279
Time for 'fix in lean': 1.34s
```
2019-03-27 17:13:53 -07:00
Leonardo de Moura
d536ee347d chore(runtime/object): remove fixpoint* primitives 2019-03-27 13:17:25 -07:00
Leonardo de Moura
4b83585103 chore(stage0, runtime): update stage0 and remove old String API 2019-03-26 15:51:13 -07:00
Leonardo de Moura
dd48d5ae18 feat(runtime/object): implement string primitives using Nat index 2019-03-26 15:27:14 -07:00
Leonardo de Moura
0d5ac5288a feat(runtime): increase small nat size
In 64-bit machines, the max small nat value should now be (2^63 - 1), and on 32-bit
machines (2^32 - 1).

The main motivation for this modification are the array indexing
operations. With the new representation, if a Nat index is not small,
then it must not be a valid index. This was not true in 64-bit
machines. Example: an array of size 2^33 would fit in memory, and but
an index `i` > 2^32 - 1 would not be a small nat value.
2019-03-26 14:21:03 -07:00
Leonardo de Moura
b0da4360d0 chore(runtime, library/init/data/string/basic): prepare to change String.Pos 2019-03-26 12:25:12 -07:00
Leonardo de Moura
1da4782483 feat(runtime, library/init/io): add io.ref 2019-03-16 22:16:28 -07:00
Leonardo de Moura
64e60f77b3 chore(runtime/object): remove dead code 2019-03-12 12:25:11 -07:00
Leonardo de Moura
b320452f70 chore(runtime/object): remove iterator primitives from runtime
They are now implemented in Lean.
2019-03-12 07:09:48 -07:00
Leonardo de Moura
cf3bbd7e25 feat(runtime): add utf8_prev and utf8_set
Next goal: implement string.iterator in Lean
2019-03-11 18:05:40 -07:00
Leonardo de Moura
ff3bf508aa feat(library/init/fix, runtime): add fixpoint2, ..., fixpoint6
The idea is to avoid allocating tuples when creating the fixpoint of
nary functions. For example, consider the new tests:
- tests/playground/fix.lean
- tests/playground/fix_with_tuples.lean

The second one (`fix_with_tuples`) uses the `fix` operator and tuples. For input = 20,
it creates more than 1 million extra objects. The first implementation
(`fix.lean`) using `fix₂` avoids this overhead.

TODO: Add support for pattern #N with N > 9 at
```
def expand_extern_pattern_aux (args : list string) : nat → string.iterator → string → string
```
2019-03-10 11:19:02 -07:00
Leonardo de Moura
4ca9c6f22e feat(runtime): add efficient fixpoint implementation 2019-03-10 10:09:57 -07:00