Commit graph

38 commits

Author SHA1 Message Date
Leonardo de Moura
3b3e50d315 chore(library/module): std::shared_ptr<modification> ==> modification*
Remark: this commit introduce memory leaks, but this is just an
intermediate step to get modification objects in Lean.
Recall that, we will eventually remove modification objects from Lean.
2019-05-13 15:05:21 -07:00
Leonardo de Moura
edb4d76ecd feat(kernel/environment): environment as a Lean object 2019-05-13 12:41:33 -07:00
Leonardo de Moura
ad2e7a2d60 chore(library/compiler/specialize): remove dead code
In LCNF, a type `ty` at `let x : ty := v in t` must not be irrelevant.
2019-04-17 08:11:39 -07:00
Leonardo de Moura
32a309c566 fix(library/compiler/specialize): make sure specialize generates valid LCNF 2019-04-17 07:34:42 -07:00
Leonardo de Moura
5e9f2e4e6a chore(library/compiler/specialize): remove leftover that is now a noop 2019-04-17 07:14:35 -07:00
Leonardo de Moura
12595fb501 feat(library/compiler/specialize): cache whenever possible
There were many opportunities for reusing previously specialized code at
stdlib
2019-03-29 15:21:17 -07:00
Leonardo de Moura
427d3b4d40 chore(library/compiler/specialize): reduce stack consumption 2019-03-28 15:05:48 -07:00
Leonardo de Moura
b1e812ea9d feat(library/compiler/specialize): restrict the kind of argument that can be specialized 2019-03-13 16:39:30 -07:00
Leonardo de Moura
62df218a8e fix(library/compiler/specialize): another bug 2019-03-12 14:08:52 -07:00
Leonardo de Moura
e858d7f5b8 fix(library/compiler/specialize): yet another specializer bug
@kha I found yet another bug in the specializer code :(
The bug is related to the previous bug fix where we try avoid
duplication of work by lambda abstracting let-variables.
We knew this could introduce type errors, but I thought it would only
happen in very complicated programs that make a heavy use of dependent
types. Actually, this is not the case. I just found an instance when
I was playing with the new parser.
2019-03-12 12:25:32 -07:00
Leonardo de Moura
b43ebab32c fix(library/compiler/specialize): we should not lambda abstract join points 2019-03-08 11:54:51 -08:00
Leonardo de Moura
7b1d15ec43 fix(library/compiler/specialize): avoid work duplication in the specializer 2019-03-08 11:21:49 -08:00
Sebastian Ullrich
57b2607463 fix(library/compiler/specialize): declare specialized functions before caller 2019-02-06 09:36:36 -08:00
Leonardo de Moura
a3db4e8e09 chore(*): style 2018-11-15 10:59:17 -08:00
Leonardo de Moura
439d0319f0 fix(library/compiler/specialize): array out of bounds 2018-11-14 13:42:50 -08:00
Leonardo de Moura
b56674cc25 fix(library/compiler/specialize): remove bogus optimization 2018-11-07 18:00:28 -08: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
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
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
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
72a6e64d8f chore(library/compiler/specialize): leftovers 2018-10-17 08:38:30 -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
Leonardo de Moura
88de81077c feat(library/compiler/specialize): do not specialize instances unless they are marked with [specialize]
@kha: I changed the specialization candidate selection procedure.
Now, instances are not considered for specializations unless we mark
them with `[specialize]`. The idea is that an instance application is
morally just creating the "dictionary" for invoking a polymorphic
function.
2018-10-15 18:29:29 -07:00
Leonardo de Moura
4cfe44bed0 feat(library/compiler/specialize): add nospecialize attribute
@kha I had to add this attribute because the specializer was generated
many specialization candidates for functions that take `[has_tokens ...]`
as an argument. Moreover, these candidates had a lot of
dependencies. I am trying to workaround this issue by marking the
instances with the new attribute `[nospecialize]`.
I did not mark instances created by `[derive]`. It is quite tedious to
do it.

BTW, when I was investigating the problem I stumbled at `node.view`.
Its type is:
```
node.view :
  Π {α : Type} {m : Type → Type} [_inst_1 : monad m] [_inst_2 : monad_except (parsec.message syntax) m]
  [_inst_3 : monad_parsec syntax m] [_inst_4 : alternative m] (k : syntax_node_kind) (rs : list (m syntax))
  [i : @has_view syntax_node_kind k α], @has_view (m syntax) (@node m _inst_1 _inst_2 _inst_3 _inst_4 k rs) α
```
This looks wrong: the view depends on `[monad_parsec syntax m]`

We should also make sure definitions do not have unnecessary type
class instances. Otherwise, we will put additional stress on the code
specializer. One option is to change the frontend and filter unused
instances.
2018-10-15 17:44:26 -07:00
Leonardo de Moura
ba55ecf063 chore(library/compiler/specialize): fix debug build 2018-10-15 17:19:28 -07:00
Leonardo de Moura
777119ceab feat(library/compiler/specialize): collect dependencies 2018-10-15 17:15:42 -07:00
Leonardo de Moura
4f73cb18bb feat(library/compiler/specialize): more detailed spec_info 2018-10-15 15:48:02 -07:00
Leonardo de Moura
9bd09de9e2 feat(library/compiler/specialize): find candidates for specialization 2018-10-15 15:29:38 -07:00
Leonardo de Moura
8f76df4823 feat(library/compiler): add [specialize] attribute 2018-10-15 13:02:11 -07:00
Leonardo de Moura
9ca4c362ae feat(library/compiler/specialize): add spec_info
Store which arguments can be specialized.
2018-10-15 12:54:34 -07:00
Leonardo de Moura
27e6f7f424 feat(library/compiler): invoke specialize skeleton 2018-10-09 15:23:42 -07:00
Leonardo de Moura
e18af852c8 feat(library/compiler): add code specialization skeleton 2018-10-05 17:30:27 -07:00