Commit graph

980 commits

Author SHA1 Message Date
Leonardo de Moura
148c0324c4 fix: do not extract closed terms from join point applications 2020-02-15 15:43:24 -08:00
Leonardo de Moura
0cf226220c fix: remove incorrect assertion
Note that `get_cases_on_minors_range` is now parametric on `m_before_erasure`:
`get_cases_on_minors_range(env(), const_name(fn), m_before_erasure)`
2020-02-13 18:26:12 -08:00
Sebastian Ullrich
47f3d54acb fix: interpreter: do not consume values in explicit unbox instructions 2020-02-06 09:36:19 -08:00
Leonardo de Moura
38e6961003 feat: MutQuot by implementedBy 2020-02-04 16:51:08 -08:00
Leonardo de Moura
850b1c90a0 feat: mark as irrelevant functions that return types 2020-02-04 15:55:21 -08:00
Leonardo de Moura
8628b52b21 feat: missing support for Empty.rec 2020-01-03 18:23:52 -08:00
Sebastian Ullrich
2791cdf326 fix: interpreter::call_boxed: support under-application
/cc @leodemoura
2020-01-01 21:15:05 +01:00
Leonardo de Moura
73e114c6a2 chore: remove unnecessary argument 2020-01-01 09:19:00 -08:00
Sebastian Ullrich
b439de68a5 feat: support nested interpreter executions and make sure closures are run in compatible environments
/cc @leodemoura
2019-12-31 00:07:45 +01:00
Leonardo de Moura
28a4859832 feat: expose evalConst
@Kha Could you please check `lean_eval_const`?
2019-12-30 11:41:36 -08:00
Sebastian Ullrich
a2d668ec99 fix: leaks 2019-12-22 17:24:57 -08:00
Sebastian Ullrich
3b37737c8a fix: leaks 2019-12-22 15:09:19 -08:00
Sebastian Ullrich
948b0bf1f1 fix: interpreter::call_boxed: support over-application
MetaHasEval instances were not fully eta-expanded
2019-12-05 13:21:08 +01:00
Sebastian Ullrich
1afd3b9d01 refactor: interpreter::run_main: use call_boxed 2019-12-05 13:21:08 +01:00
Sebastian Ullrich
44ce73ced9 refactor: call generated boxed wrapper instead of reinventing it in the interpreter 2019-12-05 13:21:08 +01:00
Sebastian Ullrich
e3e50b7940 chore: rename confusing interpreter function 2019-12-05 13:21:08 +01:00
Sebastian Ullrich
c93fb5c4b2 chore: interpreter: rename misleading accessor 2019-11-19 09:36:59 +01:00
Leonardo de Moura
46adfcfdb6 refactor: Name fully implemented in Lean 2019-11-18 19:54:05 -08:00
Leonardo de Moura
043e011b72 fix: bug at USet
@Kha: I found the bug. The issue was at `USet`. The argument is a
usize scalar. So, we should use `var` instead of `eval_arg`.
2019-11-18 19:51:53 -08:00
Leonardo de Moura
b78ac59523 refactor: Level fully implemented in Lean 2019-11-17 08:24:09 -08:00
Leonardo de Moura
a3ccbe66cf refactor: Expr fully implemented in Lean
No hidden fields.
2019-11-16 12:10:49 -08: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
beac2a1af5 fix: treat panic as unreachable at ll_infer_type_fn
Motivation: ensure the correct type `IRType` is inferred for definitions
such as
```
def f (n : UInt32) : UInt32 :=
if n == 0 then panic! "foo"
else n+1
```
2019-11-14 21:56:09 -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
b709979102 feat: improve arity guesser for IO extern primitives 2019-10-23 17:29:41 -07:00
Leonardo de Moura
39e8499c7b fix: new offset at param_borrow 2019-10-11 16:27:29 -07:00
Leonardo de Moura
02ab51505c fix: adjust ir_interpreter
IRType is not a scalar type anymore.
2019-10-11 15:00:26 -07:00
Leonardo de Moura
7adf00666b feat: expose getCtorLayout 2019-10-11 14:34:30 -07:00
Leonardo de Moura
321d9a8a89 chore: update stage0 2019-10-11 10:57:51 -07:00
Leonardo de Moura
c81ab9759f feat: add elimDeadBranches 2019-10-07 13:59:00 -07:00
Leonardo de Moura
81847302a7 feat(library/compiler): replace @[effectful] with @[neverExtract] 2019-10-01 14:06:08 -07:00
Leonardo de Moura
75bdc8712e feat(library/compiler): disable a few optimizations for declarations tagged with @[effectful]
@kha @dselsam:
The main motivation for this change are functions such as `panic`.
I marked `panic` with the attribute `@[effectful]`.
Here is the summary of the changes. If `f` is marked as `@[effectful]`
1- Compiler will not perform common subexpression elimination on terms of the form `f ...`.
2- Compiler will not extract closed terms of the form `f ...`.
3- Compiler will throw an error if `f` is partially applied.
2019-09-30 16:53:11 -07:00
Sebastian Ullrich
ce558b6a9e doc(library/compiler/ir_interpreter): update docs 2019-09-20 10:46:33 +02:00
Leonardo de Moura
0bd268fc96 fix(library/compiler/erase_irrelevant): add elim_array_cases 2019-09-19 10:47:05 -07:00
Sebastian Ullrich
31c170117e feat(frontends/lean/builtin_cmds,library/compiler/ir_interpreter): reimplement #eval 2019-09-19 17:52:18 +02:00
Sebastian Ullrich
61819bee6d refactor(library/compiler/ir_interpreter): make box_t/unbox_t total 2019-09-19 17:51:51 +02:00
Sebastian Ullrich
a083cab532 fix(library/compiler/ir_interpreter): fix UB sequencing found by GCC 2019-09-17 09:51:24 +02:00
Leonardo de Moura
06327238e6 fix(library/compiler/erase_irrelevant): assertion violation
cc @Kha
2019-09-16 07:21:19 -07:00
Leonardo de Moura
306ff7d7e5 fix(library/compiler): fixes #34
`csimp` assumes constructors and `casesOn` applications match.  That
is, given `I.casesOn x ...`, then if `x` is an constructor, then it is
a constructor of the inductive datatype `I`.
The transformation `erase_irrelevant` was violating this property when
it mixes `Decidable` and `Bool`. We fix this issue by mapping
`Decidable.casesOn`, `Decidable.isTrue` and `Decidable.isFalse` to
`Bool.casesOn`, `Bool.true` and `Bool.false` respectively.
2019-09-13 10:20:50 -07:00
Sebastian Ullrich
a1bc3164e8 refactor(library/compiler/ir_interpreter): remove case type inference 2019-09-12 18:38:10 +02:00
Sebastian Ullrich
6c4976e044 perf(library/compiler/ir_interpreter): push_frame: avoid frame copy
6.4% speedup on unionfind
2019-09-12 18:26:15 +02:00
Sebastian Ullrich
7c6668d5c2 perf(library/compiler/ir_interpreter): no need for decl lookup at tail recursion 2019-09-12 18:26:15 +02:00
Sebastian Ullrich
8dd851d64f perf(library/compiler/ir_interpreter): cache environment lookup in existing symbol cache 2019-09-12 18:26:15 +02:00
Sebastian Ullrich
0c71a493d0 feat(library/compiler/ir_interpreter): check system at the start of each function 2019-09-12 18:26:15 +02:00
Sebastian Ullrich
ea9a5de498 fix(library/compiler/ir_interpreter): values of unboxed types should be stored unboxed
We previously boxed all such values to `object *`s. However, because this does not correspond to the IR types, there are
no `dec` instructions to actually free these values.
2019-09-12 18:26:15 +02:00
Sebastian Ullrich
79588d2ce6 refactor(library/compiler/ir_interpreter): replace C++ template with Python template 2019-09-12 18:26:15 +02:00
Sebastian Ullrich
944de141d3 perf(library/compiler/ir_interpreter): use specialized stubs 2019-09-12 18:26:15 +02:00
Sebastian Ullrich
693fc63702 fix(library/compiler/ir_interpreter): constants do not have to be persistent anymore, so stop leaking them 2019-09-12 18:26:15 +02:00
Sebastian Ullrich
8da203b91a perf(compiler/ir_interpreter): do not allocate temp closure for saturated partial applications 2019-09-12 18:26:15 +02:00
Sebastian Ullrich
237e4a4489 feat(library/compiler/ir_interpreter): multi-threading support 2019-09-12 18:26:15 +02:00