Commit Graph

146 Commits

Author SHA1 Message Date
Ralf Jung
fc918a395a rename InterpretCx -> InterpCx
That's more consistent with InterpResult and InterpError.
2019-06-27 13:23:34 +02:00
Ralf Jung
9c32ede099 comment tweaks, better validation errors, update UI tests 2019-06-23 18:03:57 +02:00
Ralf Jung
c50b9d197f Centralize bounds, alignment and NULL checking for memory accesses in one function: memory.check_ptr_access
That function also takes care of converting a Scalar to a Pointer, should that be needed.  Not all accesses need that though: if the access has size 0, None is returned.
Everyone accessing memory based on a Scalar should use this method to get the Pointer they need.

All operations on the Allocation work on Pointer inputs and expect all the checks to have happened (and will ICE if the bounds are violated).
The operations on Memory work on Scalar inputs and do the checks themselves.

The only other public method to check pointers is memory.ptr_may_be_null, which is needed in a few places.
With this, we can make all the other methods (tests for a pointer being in-bounds and checking alignment) private helper methods, used to implement the two public methods.
That maks the public API surface much easier to use and harder to mis-use.

While I am at it, this also removes the assumption that the vtable part of a `dyn Trait`-fat-pointer is a `Pointer` (as opposed to a pointer cast to an integer, stored as raw bits).
2019-06-23 15:55:04 +02:00
Oliver Scherer
811b996e58 Change ByRef to a struct variant to clarify its fields via names 2019-06-19 19:43:13 +02:00
Oliver Scherer
23a1ebb3fc Remove the AllocId from ByRef values
`ByRef` const values have no identity beyond their value, we should not treat them as having identity. The `AllocId` often differed between equal constants, because of the way that the miri-engine evaluates constants.
2019-06-19 15:58:51 +02:00
Oliver Scherer
fb37bf0037 Weave the alignment through ByRef 2019-06-19 09:53:32 +02:00
Oliver Scherer
921f0d9ca9 Outright ignore any alignment in const_field 2019-06-19 09:52:36 +02:00
Oliver Scherer
870a6dc230 Don't ICE when pattern matching packed structs 2019-06-19 09:52:35 +02:00
Oliver Scherer
4b6f3868b3 Make interning explicitly care about types and the mutability of memory 2019-06-19 09:52:35 +02:00
Christian Poveda
681bd83828 Change to_ptr by force_ptr 2019-06-16 02:33:00 -05:00
Eduard-Mihai Burtescu
37799a5552 rustc: replace TyCtxt<'a, 'gcx, 'tcx> with TyCtxt<'tcx, 'gcx, 'tcx>. 2019-06-12 13:38:27 +03:00
Ralf Jung
8f05ff3e33 rename EvalResult -> InterpResult and EvalError -> InterpErrorInfo 2019-06-08 11:39:48 +02:00
Christian Poveda
31ab573052 Add const-eval support for indirects 2019-06-03 23:53:46 -05:00
Ralf Jung
823ffaa834 update comments 2019-06-02 10:36:18 +02:00
Ralf Jung
2ba7e776b6 FIXME 2019-06-02 10:36:18 +02:00
Ralf Jung
77be06b7ed no longer assume that there is a default tag: give the machine the chance to tag all allocations 2019-06-02 10:36:18 +02:00
bors
afaf976371 Auto merge of #61350 - RalfJung:alloc, r=oli-obk
light refactoring of global AllocMap

* rename AllocKind -> GlobalAlloc. This stores the allocation itself, not just its kind.
* rename the methods that allocate stuff to have consistent names.

Cc @oli-obk
2019-06-01 16:06:11 +00:00
Wesley Wiser
3b7223deaf Doc comment fixes for rustc::mir::interpret::InterpretCx 2019-05-31 05:01:35 -04:00
Ralf Jung
41c36fabef light refactoring of global AllocMap
* rename AllocKind -> GlobalAlloc. This stores the allocation itself, not just its kind.
* rename the methods that allocate stuff to have consistent names.
2019-05-30 13:05:05 +02:00
Mazdak Farrokhzad
16ef483b79
Rollup merge of #61164 - RalfJung:scalar, r=oli-obk
rename Scalar::Bits to Scalar::Raw and bits field to data

Also use this opportunity to seal some abstraction leaks (other modules constructing `Scalar::Bits` directly instead of using a constructor).

r? @oli-obk
2019-05-28 18:15:39 +02:00
bors
1a56ec4dae Auto merge of #59627 - LooMaclin:issue_57128_improve_miri_error_reporting_in_check_in_alloc, r=RalfJung
Improve miri error reporting in check_in_alloc

Fixes https://github.com/rust-lang/rust/issues/57128

r? @RalfJung @oli-obk
2019-05-27 12:46:12 +00:00
Ralf Jung
aad13a176a centralize Scalar size sanity checks and also do them in release builds 2019-05-26 14:13:12 +02:00
Ralf Jung
082da0c698 rename Scalar::Bits to Scalar::Raw and bits field to data 2019-05-26 11:08:03 +02:00
Santiago Pastorino
e6aa4b8033 Add comment to explain why we change the layout for Projection 2019-05-25 22:28:15 +02:00
bors
f492693982 Auto merge of #59276 - oli-obk:cleanups, r=eddyb
Cleanup (pretty) printing of `ty::Const`

r? @eddyb

addresses 5cd2806621 (r266243236) and 5cd2806621 (r266243336)
2019-05-25 16:08:11 +00:00
Oliver Scherer
fa17654f79 Make ConstValue::Slice solely take [u8] and str 2019-05-25 10:07:01 +02:00
Oliver Scherer
e694b63cd1 Don't use ty::Const without immediately interning 2019-05-25 10:07:01 +02:00
Santiago Pastorino
e38b399d03 Make eval_place_to_op iterate instead of recurse 2019-05-24 23:58:21 +02:00
Santiago Pastorino
6d7a36231a Make eval_place_to_mplace take PlaceBase::Static 2019-05-24 23:57:18 +02:00
Santiago Pastorino
8173febf93 Avoid catch-all arm, use Base(PlaceBase::Static(_)) 2019-05-24 21:13:19 +02:00
bors
e232636693 Auto merge of #59897 - tmandry:variantful-generators, r=eddyb
Multi-variant layouts for generators

This allows generators to overlap fields using variants, but doesn't do any such overlapping yet. It creates one variant for every state of the generator (unresumed, returned, panicked, plus one for every yield), and puts every stored local in each of the yield-point variants.

Required for optimizing generator layouts (#52924).

There was quite a lot of refactoring needed for this change. I've done my best in later commits to eliminate assumptions in the code that only certain kinds of types are multi-variant, and to centralize knowledge of the inner mechanics of generators in as few places as possible.

This change also emits debuginfo about the fields contained in each variant, as well as preserving debuginfo about stored locals while running in the generator.

Also, fixes #59972.

Future work:
- Use this change for an optimization pass that actually overlaps locals within the generator struct (#52924)
- In the type layout fields, don't include locals that are uninitialized for a particular variant, so miri and UB sanitizers can check our memory (see https://github.com/rust-lang/rust/issues/59972#issuecomment-483058172)
- Preserve debuginfo scopes across generator yield points
2019-05-04 03:18:14 +00:00
varkor
a29eca5d82 Fix issue with const params in operand.rs 2019-05-01 23:11:19 +01:00
varkor
f5712d2de0 Add ConstValue::Placeholder 2019-05-01 23:10:57 +01:00
Tyler Mandry
b8f6de4aca Generalize discriminant info calls for generators and ADTs 2019-04-25 10:28:09 -07:00
LooMaclin
15d50deeb4 Improve miri's error reporting in check_in_alloc 2019-04-19 02:10:59 +03:00
Ralf Jung
19485cc101 Miri: refactor new allocation tagging 2019-04-16 23:35:39 +02:00
Tyler Mandry
7c626a67ba Add discr_index to multi-variant layouts
We relax the assumption that the discriminant is always field 0, in
preparations for layouts like generators where this is not going to be
the case.
2019-04-11 17:44:43 -07:00
LooMaclin
e5b6fab576 Improve miri's error reporting in check_in_alloc 2019-04-09 00:39:57 +03:00
LooMaclin
2a738bb8ed Improve miri's error reporting in check_in_alloc 2019-04-08 23:34:28 +03:00
Ralf Jung
4d79d391b0 avoid reading from ZST locals 2019-04-08 13:40:43 +02:00
Ralf Jung
525c68cf95 make StorageLive lazy as well 2019-04-07 12:27:48 +02:00
Loo Maclin
3449fa90f8
Merge branch 'master' into issue_57128_improve_miri_error_reporting_in_check_in_alloc 2019-04-02 22:06:08 +03:00
LooMaclin
705d75ef1a Improve miri's error reporting in check_in_alloc 2019-04-02 06:33:54 +03:00
LooMaclin
725199ce65 Improve miri's error reporting in check_in_alloc 2019-04-02 05:58:25 +03:00
kenta7777
3c8caaca7d renames EvalErrorKind to InterpError 2019-04-02 01:02:18 +09:00
Eduard-Mihai Burtescu
5b7f4e9e21 rustc_target: factor out common fields of non-Single Variants. 2019-03-29 09:33:48 +02:00
kenta7777
630d5a4895 renames EvalContext to InterpretCx. 2019-03-26 13:06:15 +09:00
Oliver Scherer
5cd2806621 Revert the LazyConst PR 2019-03-16 21:04:10 +01:00
varkor
de4478af91 Refactor const_to_op 2019-03-06 09:58:27 +00:00
varkor
ed9227abbd Make adjustments for comments 2019-03-05 22:49:37 +00:00