Commit graph

158 commits

Author SHA1 Message Date
Sebastian Ullrich
25ffbdda57 chore(src/*): fix style 2019-02-07 15:41:12 +01:00
Leonardo de Moura
3444a295e7 feat(library/compiler,runtime): builtin support for lean.name 2019-02-05 12:57:46 -08:00
Leonardo de Moura
687e9d076d feat(library/compiler): add _apply and _closure instructions to LLNF 2018-11-07 13:30:28 -08:00
Leonardo de Moura
adff01bba4 fix(library/vm/vm): handle InvokeJP at pc manipulation methods 2018-11-01 16:01:36 -07:00
Leonardo de Moura
f22bdec775 feat(library/vm): add support for join-points in the old VM
Motivation: to make progress in the new compiler stack, we have
to preserve join points during lambda lifting. Right now, they are
lifted as regular lambdas. So, to keep them, we need some basic
support for them in the old VM. The implementation here is quick and
dirty. This is not an issue since this code will be deleted soon.
2018-11-01 14:07:59 -07:00
Leonardo de Moura
12a01d101c refactor(library/compiler/llnf): memory cell reuse instruction set 2018-10-31 09:35:22 -07:00
Leonardo de Moura
abc107d963 chore(library/vm/vm): remove dead code 2018-10-30 14:27:47 -07:00
Leonardo de Moura
d3c37fee7a perf(library/vm/vm): inline Updt/UpdtCidx/Reset 2018-10-30 14:01:32 -07:00
Leonardo de Moura
b6bc0bb284 feat(library/compiler/llnf): add reset.idx obj primitive
The idea is to make it clear the intent, and simplify the IR conversion.
2018-10-30 13:48:09 -07:00
Leonardo de Moura
bcc4956ca5 feat(library/compiler/llnf): reuse constructor memory cells
This commit also add two new instructions to the old VM: `updt` and
`updt_cidx`.
They allow us to test the new new memory reuse technique.

TODO: We need to reset fields after we project. Otherwise, we prevent
destructive updates on nested objects.
2018-10-29 18:46:26 -07:00
Leonardo de Moura
ecf30e93a3 chore(library/vm): remove Destruct instruction 2018-10-29 13:18:33 -07:00
Leonardo de Moura
d871c4f7d8 feat(library/compiler): replace simp_inductive with llnf 2018-10-29 13:07:46 -07:00
Leonardo de Moura
70746b499e chore(library/vm): remove BuiltinCases and NatCases instructions
They are not needed anymore.
2018-10-23 15:09:55 -07:00
Leonardo de Moura
9256618d67 chore(library/vm): remove vm_name 2018-10-23 11:32:56 -07:00
Sebastian Ullrich
d9208e2b8b feat(library/vm/vm): add profiler.perf_script_file option
sample usage:
$ lean -Dprofiler.perf_script_file=parser1.script parser1.lean
$ gprof2dot -f perf < parser1.script > parser1.dot
2018-10-22 15:01:49 +02:00
Leonardo de Moura
cf5141f8ad chore(library/vm/vm): fix style 2018-10-03 13:25:54 -07:00
Leonardo de Moura
13f0a7cd81 chore(frontends/lean, library/vm): save some debugging help code 2018-10-03 13:20:24 -07:00
Leonardo de Moura
85c58e8f0e feat(library/compiler): add support for string literals in the old VM 2018-10-02 18:56:13 -07:00
Leonardo de Moura
58e91559d0 feat(*): use new inductive datatype module 2018-09-06 18:09:22 -07:00
Leonardo de Moura
8ed89c6ac3 chore(library): remove normalize.cpp
The command `#reduce` was also temporarily removed.
2018-09-04 10:51:14 -07:00
Leonardo de Moura
4917ab0c65 chore(library): remove congr_lemma 2018-08-23 16:48:43 -07:00
Leonardo de Moura
d334bb1fa7 chore(*): remove more stuff 2018-08-23 15:56:31 -07:00
Sebastian Ullrich
6384d118a8 fix(frontends/lean/builtin_cmds,library/vm/vm): fix debug build 2018-08-22 14:32:03 -07:00
Sebastian Ullrich
57c25ce01d feat(src/library/vm/vm): profile: record and display self times 2018-07-30 17:30:20 -07:00
Leonardo de Moura
13c532d0d4 fix(*): truncation bugs
- Lean strings (like std::string) may contain null characters. The
  codebase was ignoring this issue.

- We now have a wrapper `string_ref` for wrapping Lean string objects in
  C++. This wrapper also implements correctly the coercions std::string <-> string_ref.
  Remark: I also found a few places where the code relies on the
  following property which is not true
  Forall s : std::string, std::string(s.c_str()) == s

- `name` object wrapper was assuming that all numerals were small
  `nat` values. This is true in most cases, but the system would
  crash when processing if it is a big number.

- The commit tries to make sure runtime/util/kernel are correct.
  Modules that will be deleted contain many `TODO` comments
  indicating they may crash and/or produce incorrect results
  when strings contain null characters and numerals are big.

cc @kha

@kha: I thought about using `string` instead of `string_ref`.
We consistently use `std::string`. So, it should be fine, but I
was concerned about code readability.

After we bootstrap Lean4, we will be able to delete `lean::list`
template, and rename `lean::list_ref` to `lean::list`.

I am going to add `pair_ref` for wrapping Lean pair objects.
If we use `lean::string` instead of `lean::string_ref`, then
we should also use `lean::pair` instead of `lean::pair_ref`.
But, there is a problem in this case since we have
https://github.com/leanprover/lean4/blob/master/src/util/pair.h#L13
:(
2018-06-15 16:05:11 -07:00
Leonardo de Moura
b2f3d3f456 chore(*): remove redundant code 2018-05-22 16:46:04 -07:00
Leonardo de Moura
4de9b8c177 chore(library/vm): rename constants 2018-05-20 12:30:15 -07:00
Leonardo de Moura
0556412f8d refactor(*): add runtime folder
@kha The runtime folder includes what is needed to link a
standalone Lean program. It is still contains some unnecessary files.
We will be able to remove them after we release Lean4.
2018-05-14 14:23:56 -07:00
Leonardo de Moura
1e11611388 chore(library): cleanup constants.txt 2018-04-12 16:43:11 -07:00
Leonardo de Moura
39ef7aeee2 chore(util): remove memory_pool
memory_pool object introduces memory contention and unnecessary
complexity. Moreover, it actually reduces performance when we compile
Lean using JEMALLOC.

Here are the numbers for corelib

jemalloc with memory_pool:    13.83 secs
jemalloc without memory_pool: 13.60 secs
2018-04-12 16:43:10 -07:00
Leonardo de Moura
db4b00c7d8 chore(util,library): remove small_object_allocator
We use small_object_allocator to allocate vm_obj's.
However small_object_allocator is not thread safe. So, we need to copy
vm_obj's between threads. Moreover, in our experiments, we observed that
JEMALLOC is actually faster than the small_object_allocator.

Here are numbers for the reduced corelib.

small_object_allocator:  15.62 secs
gcc 4.9 allocator:       16.19 secs
jemalloc:                13.83 secs
2018-04-12 16:43:10 -07:00
Sebastian Ullrich
f247363305 feat(library/time_task): print cumulative times on --profile 2018-02-19 09:13:24 -08:00
Leonardo de Moura
aa24c15e61 feat(library/vm): basic performance counters
@kha I have added a few performance counters.
I collect their values at each snapshot.
Right now, I am printing only the values in the last snapshot, but if we want
we can even display their progress over time.

Right now, I track the following information
- number of allocated closures
- number of allocated constructors/objects
- number of allocated big numbers
2018-02-16 14:37:11 -08:00
Leonardo de Moura
3771748b4c chore(library/native): remove dead code
The deleted code was not finished, and we are going to add a new IR
and compiler.
2018-02-07 17:29:25 -08:00
Leonardo de Moura
8ffdef0b3a feat(library/vm/vm): add # when displaying simple VM objects.
See explanation at issue #1861.
2017-11-06 19:15:57 -08:00
Leonardo de Moura
cd8c154bcd feat(library/compiler/vm_compiler): clear runtime cost model
The equation compiler uses different strategies for processing
recursive equations. Some of them may produce unclear runtime cost
model. For example, the following fibonacci functions was running in
linear time instead of exponential time because the equation compiler
used the brec_on recursor.

def fib : nat → nat
| 0     := 1
| 1     := 1
| (n+2) := fib (n+1) + fib n

@dselsam and @jroesch have reported examples were the equation compiler
produces a negative performance impact. The new test (`eval` function)
captures the problem reported by @jroesch. In this example, the runtime
should not depend on the "amount of fuel".

This commit addresses this issue.
2017-11-01 14:11:09 -07:00
Leonardo de Moura
482e06427b feat(library/equations_compiler): meta mutual definitions
closes #1622
2017-10-30 15:06:12 -07:00
Leonardo de Moura
7caa88b61e refactor(library/vm/vm): remove unnecessary field from vm_decl_cell 2017-10-30 15:00:13 -07:00
Leonardo de Moura
e30f2f6604 fix(library/vm/vm): bug at update_vm_constructor 2017-10-23 10:55:26 -07:00
Leonardo de Moura
9399ce8346 feat(library/vm/vm_string): provide native implementation of type string in the VM
closes #1175

The types `string_imp` and `string.iterator_imp` were supposed to be
marked private, but we cannot do it because we need to provide
`string_imp.mk`, `string_imp.cases_on`, `string.iterator_imp.mk` and
`string.iterator_imp.cases_on` in the VM since we use a different
internal representation. Note that marking them as private does not
work since users can still access `string_imp.cases_on` using
meta-programming.
So, we need better support for private declarations.

Missing feature, char literals do not support non ASCII values.
That is, in the current implementation, we cannot write 'α'.
This will be implemented in the future.

The VM native implementation does not behave correctly for huge
strings (i.e., strings with more than 4G characters).
The problem is that the current implementation relies on
```
size_t force_to_size_t(vm_obj const & o, size_t def)
```
We may also have overflow problems in the string.iterator implementation
code. This is not a big deal right now, since I doubt we will try
to process string with more than 2^32 characters.

@Kha the `core_lib` and tests seem to be working correctly, but
we need more tests.
2017-10-23 10:55:26 -07:00
Leonardo de Moura
56215b36e8 fix(*): [[fallthrough]] ==> /* fall-thru */
Older gcc compilers generate a warning when the attribute is used.
I found out that GCC 7 will not produce a warning if comments
such as /* fall-thru */ or /* FALLTHRU */ are used instead of the
attribute [[fallthrough]]
2017-05-31 21:18:47 -07:00
Leonardo de Moura
ac17270894 fix(*): more gcc 7 warnings 2017-05-31 17:29:30 -07:00
Gabriel Ebner
7353a54aac fix(library/vm/vm): prevent segfault 2017-05-18 09:41:31 -07:00
Gabriel Ebner
9424e6fa24 refactor(frontends/lean/definition_cmds): make profiling threshold configurable 2017-04-23 11:22:41 -07:00
Leonardo de Moura
470f2bc547 feat(library/compiler, library/vm): remove additional irrelevant information 2017-04-16 12:46:14 -07:00
Gabriel Ebner
fa19b3c94d fix(library/vm/vm): prevent segfault in out-of-memory conditions 2017-03-23 09:00:59 +01:00
Sebastian Ullrich
5d68938a9c feat(frontends/lean): expr literals ```(...) 2017-03-05 08:37:16 -08:00
Sebastian Ullrich
44b27a9a44 chore(library/vm/vm): fix comment 2017-02-23 01:52:13 +01:00
Leonardo de Moura
3f87fd15eb feat(library/vm): add liveness analysis, and support destructive updates for lean arrays 2017-02-21 15:09:37 -08:00
Leonardo de Moura
87eaedc580 feat(library/vm): shrink VM stack eagerly
TODO: liveness analysis objects on the VM stack
2017-02-20 23:10:50 -08:00