Commit graph

74 commits

Author SHA1 Message Date
Clement Courbet
2c002718e0
perf: fix implementation of move constructors and move assignment ope… (#4700)
…rators

Right now those constructors result in a copy instead of the desired
move. We've measured that expr copying and assignment by itself uses
around 10% of total runtime on our workloads.

See #4698 for details.
2024-08-02 17:55:03 +00:00
Leonardo de Moura
b8b6b219c3
chore: move trace.cpp to kernel (#4014)
Motivation: trace kernel `is_def_eq`
2024-04-28 17:24:48 +00:00
int-y1
ce4ae37c19 chore: fix more typos in comments 2023-10-08 14:37:34 -07:00
Leonardo de Moura
2472a6a1ea chore: fix build
Another ugly hack to survive until we port the code generator to Lean.
2022-07-08 10:34:50 -07:00
Leonardo de Moura
bf91956449 fix: add workaround for issue #1293
This is a temporary hack until we port the C++ code to Lean.

closes #1293
2022-07-07 23:39:35 -07:00
Leonardo de Moura
6ef81e1cdf fix: bug at the code specialization cache
closes #1292
2022-07-07 22:59:18 -07:00
Leonardo de Moura
944063682e fix: another specialize.cpp bug
This is just a workaround. This code has to be ported to Lean.

The issue has been reported at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/.28kernel.29.20unknown.20constant/near/283750650
2022-05-25 20:36:18 -07:00
Leonardo de Moura
999e125e3f feat: mark arguments such as {_ : BEq α} as specialization target
We want to specialize functions such as
```
def find? {_ : BEq α} {_ : Hashable α} : PersistentHashMap α β → α → Option β
  | { root := n, .. }, k => findAux n (hash k |>.toUSize) k
```
2022-01-17 13:05:50 -08:00
Sebastian Ullrich
292fb257a7 perf: do not specialize Prop typeclasses 2021-12-22 17:48:11 -08:00
Sebastian Ullrich
399ad64854 perf: do not specialize Inhabited 2021-12-22 17:48:11 -08:00
Sebastian Ullrich
45e8d9af43 feat: support [nospecialize] on typeclasses 2021-12-22 17:48:11 -08:00
Leonardo de Moura
50ac21d0a6 refactor: move is_constructor_app to inductive.cpp 2021-11-25 11:31:00 -08:00
Leonardo de Moura
c8406a301d chore: reduce src/include/lean 2021-09-07 08:24:54 -07:00
Leonardo de Moura
152572386b chore: fix comment 2021-08-27 10:43:51 -07:00
Leonardo de Moura
6713d8777a fix: work duplication bug at specialize.cpp
closes #646
2021-08-27 10:35:27 -07:00
Sebastian Ullrich
2b451a3fed chore: remove obsolete serializer code 2021-07-22 18:59:39 +02:00
Leonardo de Moura
ea91317f1a fix: avoid nontermination due to respecialization 2021-03-15 19:12:57 -07:00
Leonardo de Moura
fdbb87c1fd fix: specialize.cpp 2021-02-28 08:29:50 -08:00
Leonardo de Moura
df9cde94e6 feat: add support for re-specialization 2021-02-27 16:44:34 -08:00
Leonardo de Moura
340cade575 fix: bug at specialize.cpp 2020-12-20 17:48:46 -08:00
Leonardo de Moura
76eb163a0f chore: use new pretty printer at specialize trace messages 2020-12-20 16:44:55 -08:00
Leonardo de Moura
7b5f283507 chore: remove Expr.localE constructor
It was used by the old frontend
2020-11-01 09:37:48 -08:00
Leonardo de Moura
bad6233389 chore: remove legacy support for modification objects 2020-10-26 08:10:51 -07:00
Leonardo de Moura
8383177c96 fix: nonoptimal specialization
@Kha Here is the fix for the problem I told you this morning.
Please, take a look at `specialize.cpp` and see whether it makes sense.
2020-09-24 12:40:28 -07:00
Leonardo de Moura
7c76a19885 chore: fix includes 2020-05-22 14:17:25 -07:00
Leonardo de Moura
8bdca35282 chore: use #include <lean/runtime/...> for runtime .h files 2020-05-18 11:30:07 -07:00
Leonardo de Moura
85092412c7 refactor: remove Expr.FVar hack
@Kha @dselsam:
This hack was preventing us from making `Expr` a "real" Lean type.
This was bad for a few reasons:
- It was hard to extend/modify `Expr` in Lean since we would also have
to modify the C++ code that creates the `Expr` objects with the hidden
fields.
- `Expr.lam` and `Expr.forallE` were not following the Lean layout
standard where we sort fields by size. @Kha: recall we used that to
avoid a UB. The issue with `Expr.lam` and `Expr.forallE` is that they
have a "visible" field (`BinderInfo`), which is smaller than
hidden fields such as hash code.
- `Expr.fvar` had only one field at `Expr.lean,` but four behind the
scenes.

I added a new constructor `Local` that is only accessible from C++.
It is only used in legacy code we inherited from Lean2.
We will eventually delete it.

This refactoring was quite painful since many parts of the codebase
were mixing the new `Expr.fvar` with the old `Expr.local`.
I doubt I would be able to do it without the new staging framework
@Kha built.

BTW, some of the patches are horrible. I didn't care much since we
are going to deleted the super ugly files. That being said,
you should expect new weird bevaior due to `Expr.fvar` vs `Expr.local`.

Next step: use the new `ExprCachedData` to make all `Expr` hidden visibles
accessible from Lean.

checkpoint
2019-11-15 14:04:26 -08:00
Leonardo de Moura
aa9080e9e7 feat: do not specialize functions inside functions marked with @[specialize] 2019-11-13 13:32:52 -08:00
Leonardo de Moura
ec0e74f5f8 chore(library/init/lean): export as C functions 2019-08-16 20:52:10 -07:00
Leonardo de Moura
dae30a4ea6 chore(library/compiler/specialize): remove broken assertions 2019-08-16 09:46:05 -07:00
Leonardo de Moura
61beb56a83 chore(*): fix some compilation warnings 2019-08-15 09:26:13 -07:00
Leonardo de Moura
85d151a335 feat(library/compiler): use eta expansion at eager_lambda_lifting 2019-07-09 16:34:20 -07:00
Leonardo de Moura
6727c1fa68 feat(library/compiler/specialize): switch to specExtension in Lean 2019-06-27 10:08:39 -07:00
Leonardo de Moura
3c0caee73b chore(library/compiler/specialize): cleanup
Preparing to implement environment extension in Lean.
2019-06-27 09:32:25 -07:00
Leonardo de Moura
14d77f8204 feat(library/compiler/specialize): use new attribute manager 2019-06-26 15:09:14 -07:00
Leonardo de Moura
edeae776da chore(library/module): module::add for declarations is not needed anymore 2019-05-14 11:23:35 -07:00
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