Commit graph

15058 commits

Author SHA1 Message Date
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
Leonardo de Moura
8ce945bc24 fix(CMakeLists): trying again to fix new build system
Trying to find a solution that works in all platforms.
2018-10-19 10:25:28 -07:00
Leonardo de Moura
45b505e808 fix(CMakeLists): OSX build using make 2018-10-19 10:04:57 -07:00
Leonardo de Moura
3b22c976e8 fix(Makefile): new lean makefile 2018-10-19 10:00:35 -07:00
Sebastian Ullrich
ce7f7c8a14 feat(library,src/CMakeLists): use simple Makefile by Simon Hudon to bring back some degree of parallel compilation 2018-10-19 09:52:01 +02:00
Sebastian Ullrich
7d82149231 feat(shell/lean): bring back --deps option 2018-10-19 09:52:01 +02:00
Sebastian Ullrich
daf142240b fix(tests/lean/parsec1): fix test 2018-10-19 09:52:01 +02:00
Leonardo de Moura
0f7745a3e0 feat(library/init/lean/parser/parsec): mark whitespace and num with [noinline]
We want them to be specialized for a given monad stack, but not
inlined. If we inline them, then every occurrence of `whitespace` and
`num` will specialize the nested `take_while?` application.
This is bad since we don't cache them.
2018-10-18 16:33:10 -07:00
Leonardo de Moura
677864dee5 feat(library/init/lean/parser/parsec): mark some of the parsec functions with @[specialize] 2018-10-18 16:23:47 -07:00
Leonardo de Moura
880137f0ed feat(library/init/lean/parser/basic): mark tokens with @[nospecialize] 2018-10-18 15:20:54 -07:00
Leonardo de Moura
c35ee19353 feat(library/compiler/specialize): eta-expand specialization 2018-10-18 14:28:22 -07:00
Leonardo de Moura
4d5252525d feat(library/compiler/specialize): cache specialization results
Specialization is still disabled. I will continue testing it, and enable
it in a future commit.
2018-10-18 13:09:19 -07:00
Leonardo de Moura
3fa4b1600d fix(library/compiler/specialize): register auxiliary declarations created by the specializer in the environment 2018-10-18 07:32:16 -07:00
Leonardo de Moura
38bc3beffb fix(library/init): alternative instances
Both `alternative` and `monad` implement `applicative`. However,
their default implementations for `seq_right` and `seq_left` are
different. The `alternative` implementation uses the inefficient default
version for `seq_right` available at `applicative`:
```
(seq_right := λ α β a b, const α id <$> a <*> b)
```
instead of the more efficient
```
(seq_right := λ α β x y, x >>= λ _, y)
```
defined at `monad` using the `bind` operator.

This commit makes sure the `applicative` instances for `reader_t`,
`state_t`, `option` and `parsec_t` use the efficient version.
I found the problem when inspecting the generated code for:
```
def symbol (s : string) : parsec' unit :=
(str s *> whitespace) <?> ("'" ++ s ++ "'")
```
2018-10-17 14:25:50 -07:00
Leonardo de Moura
17cb9b4532 chore(library/init/data/repr): remove unnecessary definition 2018-10-17 12:32:38 -07:00
Leonardo de Moura
69070f43eb chore(library/local_context): remove user_name indexing
The datastructures at `local_context` used to manage used user_names
introduce a lot of overhead. They do guarantee that `get_unused_name` is
`O(log(n))`, but they slowdown much more common operations such as:
local declaration creation/deletion. We create/delete local declarations
much more often than we use `get_unused_name`.

The corelib build time is now 34.18 secs on my desktop. It was 39.5 secs.
2018-10-17 09:24:40 -07:00
Leonardo de Moura
1af1a8996b chore(library/init/core): classical.some ==> classical.choose
To avoid confusion with `option.some`.
2018-10-17 09:04:52 -07:00
Leonardo de Moura
72a6e64d8f chore(library/compiler/specialize): leftovers 2018-10-17 08:38:30 -07:00
Leonardo de Moura
a40c526e48 feat(library/compiler/csimp): add basic constant folding for nat operations 2018-10-17 08:38:30 -07:00
Leonardo de Moura
fa9d6b4ddf chore(library/init): missing [inline] and remove unnecessary defs 2018-10-17 08:38:30 -07:00
Sebastian Ullrich
1d0456adf5 fix(library/init/lean/parser/term): revert refactoring that broke sort_apps of Type 2018-10-17 09:13:52 +02:00
Leonardo de Moura
5683143e8d chore(library/init/data/to_string): remove unnecessary definition 2018-10-16 16:18:07 -07:00
Leonardo de Moura
2a4dc2cb5b fix(library/compiler/specialize): incorrect abstraction order 2018-10-16 16:15:47 -07:00
Leonardo de Moura
611f6ae780 feat(library/compiler/specialize): code specialization
TODO:
- Cache results at `specialize_ext`
- Cleanup

It is not feasible to run code specializer without cache: code explosion.
2018-10-16 15:50:42 -07:00
Leonardo de Moura
af682a0981 feat(library/compiler/specialize): refine candidate selection heuristics 2018-10-16 15:50:42 -07:00
Leonardo de Moura
f80ea590ba fix(library/compiler/specialize): typo 2018-10-16 15:50:42 -07:00
Sebastian Ullrich
f29d886c29 fix(library/init/lean/parser/string_literal): letter escapes 2018-10-16 22:43:30 +02:00