Commit graph

15084 commits

Author SHA1 Message Date
Leonardo de Moura
7ec00c97e9 feat(library/compiler/csimp): float all cases
Motivation: explicit control flow graph

TODO: disabled `split_entries` for now.
I believe the new feature exposed a bug at `move_to_entries`.
I will fix this new issue in another commit.
2018-10-25 15:41:11 -07:00
Leonardo de Moura
4ba3cc390f fix(library/compiler/specialize): assertion violation lean_assert(!has_fvar(code));
We were getting assertion violations when compiling corelib in debug
mode. There were two problems:

1- We were not capturing free variables occurring in types.
2- A paremeter could depend on a free variable associated with a let-declaration.
2018-10-25 13:23:43 -07:00
Leonardo de Moura
8175dab1a6 chore(library/compiler/csimp): remove leftover assertion used yesterday when debugging code 2018-10-25 12:55:25 -07:00
Leonardo de Moura
b18135a4c8 feat(library/compiler/csimp): cheap float cases 2018-10-25 11:15:21 -07:00
Leonardo de Moura
96ef30e827 chore(library/init/lean/parser/parsec): remove private
Motivation: allow us to change the attribute in other files
2018-10-25 10:55:32 -07:00
Leonardo de Moura
370f67b27b feat(library/init/lean/parser/parsec): mark *_mk_res functions as [inline_if_reduce] 2018-10-25 10:10:54 -07:00
Leonardo de Moura
628b0c7919 feat(library/compiler): add [inline_if_reduce] attribute 2018-10-25 10:01:26 -07:00
Leonardo de Moura
a1798a2c24 feat(library/compiler/csimp): new joint point placement and preservation algorithm 2018-10-24 16:46:16 -07:00
Leonardo de Moura
43ceb6bfbe refactor(kernel/local_ctx): simplify local_ctx
Remark: we still need to revise the classes: `type_context` and `local_context`.
2018-10-24 10:02:38 -07:00
Leonardo de Moura
5eaed3a21a chore(library/compiler/csimp): make sure local_ctx is monotonically increasing
We need this feature to implement the new join point management system
for csimp.
2018-10-24 08:55:00 -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
3ee863da68 feat(library/compiler/erase_irrelevant): eliminate cases_on for builtin types 2018-10-23 14:58:38 -07:00
Leonardo de Moura
cbbae4b331 chore(library/vm): remove vm_platform and vm_pos_info 2018-10-23 12:55:34 -07:00
Leonardo de Moura
392f019184 chore(tests/lean/parsec1): fix test 2018-10-23 12:54:29 -07:00
Leonardo de Moura
de1dc3be88 chore(library/vm): remove vm_array
We are currently not using arrays in the old VM.
2018-10-23 12:49:25 -07:00
Leonardo de Moura
9256618d67 chore(library/vm): remove vm_name 2018-10-23 11:32:56 -07:00
Leonardo de Moura
243b6a70e1 chore(library/vm): remove vm_options 2018-10-23 11:32:56 -07:00
Leonardo de Moura
f7f981285b chore(tests/lean/run/display_hw_term_hack_deps): remove old test 2018-10-23 11:32:56 -07:00
Leonardo de Moura
9d32aff0c6 chore(library/init/meta): remove rest of old meta folder 2018-10-23 11:32:56 -07:00
Leonardo de Moura
8d47d2a026 chore(library/vm,library/init/meta): remove vm_format, and some obsolete meta objects 2018-10-23 11:32:56 -07:00
Leonardo de Moura
65815c512c chore(library/vm): remove interaction_state 2018-10-23 11:32:56 -07:00
Leonardo de Moura
4cb6b1f9d5 chore(library/tactic): reduce dependencies 2018-10-23 11:32:56 -07:00
Leonardo de Moura
d07f115f21 chore(library/compiler/util): fix style 2018-10-23 11:32:56 -07:00
Leonardo de Moura
139414b995 chore(tests/lean/parser1): update expected output
cc @kha
2018-10-23 11:32:56 -07:00
Leonardo de Moura
9a71c2dbb6 feat(library/init/lean/ir): remove support for functions with multiple return values
This feature was originally added to implement the state monad.
It is not needed anymore since we have a better encoding that doesn't
require this feature and avoids memory allocations.
2018-10-22 17:39:40 -07:00
Leonardo de Moura
17377c55f3 feat(library/compiler/extract_closed): create an auxiliary constant of arity 0 for constant with arity > 0
This transformation is useful for caching the construction of closures
at runtime. For example, consider the following piece of code
```
λ α a,
  @tree.cases_on a visit._main._lambda_1
    (λ a_a a_a_1 a_a_2,
       let _x_1 := visit._main  a_a,
           _x_2 := visit._main._lambda_5 a_a_1 a_a_2
       in bind._main     _x_1 _x_2)
```
where `visit._main._lambda_1` is of the form
```
visit._main._lambda_1 :=
λ _x, ...
```
At runtime, we will create a closure object for `visit._main._lambda_1`
since it has arity 1, but no arguments have been provided.
This commit implements a new transformation that creates an auxiliary
declaration with arity 0.
```
visit._main._closed_1 :=
visit._main._lambda_1
```
Its value is cached by the runtime. That is, the closure is created only
once.

@kha This optimizations reduces the number of closures by another 200k
at `parser1.lean`. We are now under 2million :)
2018-10-22 16:13:58 -07:00
Leonardo de Moura
01229425a2 feat(library/compiler/compiler): inline "small" stage2 declarations at csimp after erasure 2018-10-22 15:49:07 -07:00
Leonardo de Moura
85160e1baa feat(library/init/lean/ir/format): missing [inline] 2018-10-22 14:58:23 -07:00
Leonardo de Moura
83abbcb9a6 fix(library/compiler/erase_irrelevant): preserve builtin runtime types
`uint32` is a definition, and `type_checker::whnf` unfolds it.
To preserve the information at `erase_irrelevant`, we use a custom
`whnf_type` method that stops reduction as soon as a builtin runtime
type is found.
2018-10-22 13:58:08 -07:00
Sebastian Ullrich
08d8856112 perf(library/init/lean/parser/token): replace longest_match in token with custom implementation 2018-10-22 22:33:58 +02:00
Sebastian Ullrich
163f996d00 perf(library/init/lean/parser): inline some trivial functions 2018-10-22 22:23:54 +02:00
Leonardo de Moura
19be59065a perf(library/init/lean/parser/parsec): mark bind_mk_res and orelse_mk_res with @[inline]
A few weeks ago, it was not feasible to inline `bind_mk_res` and
`orelse_mk_res` because the compilation time would increase a lot.
Since then I have improved the heuristics for deciding whether to float
`cases_on` or not.
So, I tried today to mark them with `@[inline]` again.
The corelib build time increased only 1.2 secs, but the `parser1.lean` runtime improved:
Before:
```
num. allocated objects:  18025367
num. allocated closures: 2988476
```
After:
```
num. allocated objects:  15774515
num. allocated closures: 2488695
```
I used my desktop to collect the numbers above.
2018-10-22 11:11:21 -07:00
Leonardo de Moura
0bcd07f076 feat(library/compiler/compiler): cache "stage2" 2018-10-22 10:19:39 -07:00
Leonardo de Moura
e0bb21ba0b chore(library): remove noncomputable module 2018-10-22 09:39:03 -07:00
Leonardo de Moura
77e3c18cb0 feat(library/module): noncomputable keyword is now used only to disable code generation
We do not try to check whether code generation will succeed or not for
some declaration. In the future, we should probably rename it to
`nocode` or something similar.

cc @kha
2018-10-22 09:35:05 -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
89afabae29 refactor(library/init/lean/parser/parsec): make sure custom error message doesn't need to be inhabited 2018-10-21 10:57:23 -07:00
Leonardo de Moura
bf15bd36c1 fix(library/compiler): join point arity confusion
We must make sure we do not accidentally change the arity of a join
point. The arity is the number of nested lambda expressions.
For example, suppose we have
```
let jp := fun (x : unit), t
```
where `jp` is a join point of arity 1, i.e., `t` is not a lambda.
All "jumps" will be of the form: `jp ()`.
Now, suppose we simplify `t` and it becomes a lambda `fun (y : nat), y`.
We should to represent `jp` as
```
let jp := fun (x : unit) (y : nat), y
```
Because we would be changing `jp`'s arity.
We have the same problem with `cases_on` applications in LCNF.
So, we fix the problem using the same approach: an auxiliary
`let`-declaration. The simplified join point above is encoded as
```
let jp := fun (x : unit),
  let _z := fun (y : nat), y
  in _z
```

cc @kha This is the bug that I mentioned on slack :)
2018-10-20 18:18:41 -07:00
Leonardo de Moura
db647139a2 feat(kernel): use cheap_beta_reduce at infer_lambda too 2018-10-20 17:28:45 -07:00
Leonardo de Moura
0b38547e97 feat(kernel): move cheap_beta_reduce to kernel and use it at infer_let 2018-10-20 17:13:41 -07:00
Leonardo de Moura
980790573b fix(library/print): bug at print_let 2018-10-20 17:02:22 -07:00
Leonardo de Moura
dbe2678795 fix(library/compiler/specialize): we should specialize even if only a few "specialization arguments" have been provided
This fixes a performance bottleneck at `term_parser.run`.
The `longest_match` application there was not being specialized.
2018-10-20 09:37:21 -07:00
Leonardo de Moura
4929af1dd3 feat(library/compiler/extract_closed): extract_closed is working 2018-10-19 18:32:49 -07:00
Leonardo de Moura
356928c873 feat(library/compiler): add extract_closed skeleton 2018-10-19 16:14:59 -07:00
Leonardo de Moura
eb02add3de feat(library/compiler): simplify again after lambda lifting
Motivation: we avoid the creation of closures at join point declarations.
2018-10-19 15:17:07 -07:00
Leonardo de Moura
12d8b0e7ef feat(library/init/data): annotate rbtree and rbmap functions 2018-10-19 14:57:31 -07:00
Leonardo de Moura
ad4e04685c fix(library/compiler/specialize): we must consider lambdas at FixedInst arguments
Otherwise, we will never specialize type class arguments such as `[decidable_rel lt]`
2018-10-19 14:56:18 -07:00
Leonardo de Moura
d623c6ef43 chore(library/compiler/lambda_lifting): do not need type_checker::state 2018-10-19 14:41:39 -07:00
Leonardo de Moura
17b9b21555 feat(library/compiler/csimp): allow csimp to be used after erasure 2018-10-19 12:02:29 -07:00
Leonardo de Moura
3f927a6d4f fix(library/Makefile): remove generated file 2018-10-19 10:32:30 -07:00