Commit graph

15034 commits

Author SHA1 Message Date
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
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
3f2c5c8b75 chore(library/compiler/csimp): fix assertion 2018-10-15 17:39:44 -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
effccf9a6d chore(library/init): mark a few combinators with [specialize] 2018-10-15 13:47:26 -07:00
Leonardo de Moura
42c056862d feat(library/compiler/compiler): cache stage1 result before specialization 2018-10-15 13:08:48 -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
10b99a678c chore(util/list_ref): add objects a list of objects 2018-10-15 11:57:12 -07:00
Leonardo de Moura
8837217a2e chore(kernel/expr): dead decls 2018-10-15 11:10:11 -07:00
Leonardo de Moura
611af5c186 feat(library/compiler/csimp): improve heuristic for deciding whether we should apply float_cases_on or not. 2018-10-15 09:50:02 -07:00
Sebastian Ullrich
db6b9db07e fix(tests/lean/parser1): fix reprinting (`eoi node was missing) 2018-10-15 12:47:32 +02:00
Sebastian Ullrich
a820b9955f perf(library/init/lean/parser/term): index term parsers by leading token
66% speedup on core.lean
2018-10-15 10:21:08 +02:00
Sebastian Ullrich
2df885d9a3 fix(library/init/lean/parser/token): broken end of comment 2018-10-13 12:01:48 -07:00
Sebastian Ullrich
eff43fab08 chore(library/init/lean/expander): comment 2018-10-13 08:11:36 -07:00
Sebastian Ullrich
8a88d4d5e2 feat(library/init/lean/parser/token): string literals
hard-coded for now because we do not have general support for variable-length
tokens yet
2018-10-13 08:11:36 -07:00
Sebastian Ullrich
758d258210 fix(library/init/lean/parser/term): rename term.ident to ident_univs to remove confusion with ident
`protected` didn't do anything here
2018-10-13 08:11:36 -07:00
Sebastian Ullrich
fdc06b39cd test(tests/lean/parser1): fix reprint check 2018-10-13 08:01:39 -07:00
Leonardo de Moura
5810418ddd perf(library/init/lean/ir/extract_cpp): use derive to speedup type class resolution
This modification reduced processing time for this file to 1.49 secs
from 2.30 secs on my office desktop.
2018-10-12 12:27:08 -07:00
Leonardo de Moura
17d6ef3abe chore(library/init/lean/ir/parser): minimize <|> inlining 2018-10-12 11:57:42 -07:00
Leonardo de Moura
4788c8c52c chore(library/type_context): remove dead code 2018-10-12 11:57:41 -07:00