Commit graph

376 commits

Author SHA1 Message Date
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
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
85160e1baa feat(library/init/lean/ir/format): missing [inline] 2018-10-22 14:58:23 -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
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
12d8b0e7ef feat(library/init/data): annotate rbtree and rbmap functions 2018-10-19 14:57:31 -07: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
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
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
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
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
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
c0b76704a0 chore(library/init/lean/parser/level): typo 2018-10-12 11:56:34 -07:00
Leonardo de Moura
15a25d5aa9 chore(library/init/lean/parser): add a few comments 2018-10-11 15:54:57 -07:00
Sebastian Ullrich
8e0778e54a fix(library/init/lean/parser/token): parse whitespace after raw_ident 2018-10-08 09:30:48 -07:00
Sebastian Ullrich
4e3f9b46c2 refactor(library/init/lean/parser/token): remove weird with_source higher-order function 2018-10-05 08:52:04 -07:00
Sebastian Ullrich
ebeec844af perf(library/init/lean/parser): minor performance tweaks 2018-10-05 08:52:04 -07:00
Sebastian Ullrich
22714b9b10 perf(library/init/lean/parser/combinators): node: no need to fill up with syntax.missing anymore
Views now do iterated pattern matches instead of a single one
2018-10-04 14:27:24 -07:00
Sebastian Ullrich
959948b901 feat(library/init/lean): even more core.lean progress 2018-10-03 16:00:08 -07:00
Sebastian Ullrich
ca8e75be9e fix(library/init/lean/elaborator): check for and consume end of input 2018-10-03 16:00:08 -07:00
Sebastian Ullrich
5274be8c3e feat(library/init/lean/elaborator): local notation
Implemented by treating the parser cfg as a cache that can be recreated from the
elaborator state after e.g. a scope has ended
2018-10-03 16:00:08 -07:00
Sebastian Ullrich
0563c60b1a feat(library/init/lean/elaborator): add coroutine, use it to implement section/namespace elaborators (they don't do anything yet except for checking the end name) 2018-10-02 14:55:28 -07:00
Sebastian Ullrich
097b7be14f refactor(library/init/lean/parser/token): change raw view type to option syntax_atom and create raw_str to give some raw parsers view defaults 2018-10-02 14:55:28 -07:00
Sebastian Ullrich
533ac2d5b2 fix(library/init/lean/parser/declaration): attributes before visibility modifiers 2018-10-02 14:55:28 -07:00
Sebastian Ullrich
71fd8a59b4 feat(library/init/lean/parser/notation): simple term language for precedences 2018-10-02 14:55:28 -07:00
Sebastian Ullrich
b8b39585ec fix(library/init/lean/parser/command): variable may take unbracketed binder 2018-10-02 14:55:28 -07:00
Sebastian Ullrich
fc5120290f feat(library/init/lean/parser/term): inductive levels, let, structure instances 2018-10-02 14:55:28 -07:00
Leonardo de Moura
c3569dc72d feat(kernel): store structure name in proj-expressions 2018-10-02 09:23:11 -07:00
Leonardo de Moura
429f844fbe @chore(library/init/lean/parser/parsec): remove @[inline] annotations to reduce compilation time
We will mark them as `@[specialize]` as soon as we implement code specialization
2018-10-01 17:30:13 -07:00
Sebastian Ullrich
ab5460d010 perf(library/init/lean/parser/parsec): more [inline] attributes 2018-10-01 16:32:11 -07:00
Sebastian Ullrich
7d8c3c5db8 feat(library/init/lean/parser/term): use longest_match for Pratt parsing 2018-10-01 09:02:39 -07:00
Sebastian Ullrich
6a23ecfe9c fix(library/init/lean/parser/parsec): fix lookahead, longest_match 2018-10-01 09:02:39 -07:00
Sebastian Ullrich
b443006e8f fix(library/init/lean/parser/syntax): reprint: do not concatenate choice contents 2018-10-01 09:02:39 -07:00
Sebastian Ullrich
945bf39e05 feat(library/init/lean): progress 2018-09-28 20:50:18 -07:00
Sebastian Ullrich
df278096c4 fix(library/init/lean): fixes fixes fixes 2018-09-28 13:08:25 -07:00
Sebastian Ullrich
203545ce99 chore(library/init/lean/parser/trie): add debug print
Also make sure it's in the prelude, whoops
2018-09-28 13:08:24 -07:00
Sebastian Ullrich
5123148aa6 feat(library/init/data/string/basic): trim whitespace around symbols 2018-09-28 13:08:24 -07:00
Sebastian Ullrich
1733d3ec12 feat(library/init/lean/elaborator): default leading notation symbols to max_prec 2018-09-28 13:08:24 -07:00