Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTFE engine refactor #53424

Merged
merged 32 commits into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7d4f5f7
Move some value-and-memory related things out of eval_context
RalfJung Aug 9, 2018
ad2de8b
miri/CTFE refactor
RalfJung Aug 13, 2018
7483ea8
generalize truncate and sign_extend to take a Size
RalfJung Aug 14, 2018
689c711
remove cur_frame from memory (validation is gone, new validation will…
RalfJung Aug 15, 2018
0807ad1
fix union field access and DST computations and dumping of places
RalfJung Aug 15, 2018
e860ab2
Tweak logging
RalfJung Aug 15, 2018
09b15e9
fix dropping with vtables
RalfJung Aug 15, 2018
1e137a7
fix drop typing; use same machinery for validating (sanity checking) …
RalfJung Aug 15, 2018
e314a4e
fix accessing unsized fields
RalfJung Aug 15, 2018
61e7ba1
fix dynamically determining size and alignment
RalfJung Aug 16, 2018
23d86b0
try_read_value_from_ptr -> try_read_value_from_mplace
RalfJung Aug 16, 2018
ad009ae
fix using copy_op to transmute
RalfJung Aug 16, 2018
730098b
avoid allocating for ZST
RalfJung Aug 16, 2018
b1df2ae
fix computing layout when calling virtual fn
RalfJung Aug 16, 2018
aa760a5
finally remove all traces of signs from memory
RalfJung Aug 16, 2018
f2aeb5b
fix operator handling when using 128bit intrinsics
RalfJung Aug 16, 2018
5099933
move validation to its own file
RalfJung Aug 17, 2018
ad8deba
fix formatting nits
RalfJung Aug 17, 2018
6f5cf12
test for detecting bad data inside trait objects / slices
RalfJung Aug 17, 2018
956b51f
optimize validation iterating over the elements of an array
RalfJung Aug 17, 2018
0b8c691
fix UI tests
RalfJung Aug 17, 2018
e3b4f8e
better error message when using NULL in to_ptr
RalfJung Aug 18, 2018
42a1239
avoid some redundant alignment checks
RalfJung Aug 18, 2018
49999e9
optimize sanity check path printing
RalfJung Aug 18, 2018
c3d392f
fix validating fat raw pointers
RalfJung Aug 19, 2018
8ad4047
optimize creating a stack frame
RalfJung Aug 19, 2018
54c81ac
in a Use statement, exploit the fact that type and hence layout are t…
RalfJung Aug 20, 2018
128c634
also avoid recomputing the layout for unary and binary ops, where pos…
RalfJung Aug 20, 2018
f3e7efc
fix layout sanity check
RalfJung Aug 20, 2018
14dc780
fix a comment in validity
RalfJung Aug 20, 2018
899bc14
fix validating fat pointers to user-defined unsized types
RalfJung Aug 22, 2018
4fec615
fix error reporting in validation
RalfJung Aug 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ define_dep_nodes!( <'tcx>
// queries). Making them anonymous avoids hashing the result, which
// may save a bit of time.
[anon] EraseRegionsTy { ty: Ty<'tcx> },
[anon] ConstValueToAllocation { val: &'tcx ty::Const<'tcx> },
[anon] ConstToAllocation { val: &'tcx ty::Const<'tcx> },

[input] Freevars(DefId),
[input] MaybeUnusedTraitImport(DefId),
Expand Down
6 changes: 0 additions & 6 deletions src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,6 @@ impl_stable_hash_for!(enum mir::interpret::ScalarMaybeUndef {
Undef
});

impl_stable_hash_for!(enum mir::interpret::Value {
Scalar(v),
ScalarPair(a, b),
ByRef(ptr, align)
});

impl_stable_hash_for!(struct mir::interpret::Pointer {
alloc_id,
offset
Expand Down
38 changes: 23 additions & 15 deletions src/librustc/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub use self::error::{
FrameInfo, ConstEvalResult,
};

pub use self::value::{Scalar, Value, ConstValue, ScalarMaybeUndef};
pub use self::value::{Scalar, ConstValue, ScalarMaybeUndef};

use std::fmt;
use mir;
Expand Down Expand Up @@ -135,7 +135,7 @@ impl<'tcx> Pointer {
Pointer { alloc_id, offset }
}

pub(crate) fn wrapping_signed_offset<C: HasDataLayout>(self, i: i64, cx: C) -> Self {
pub fn wrapping_signed_offset<C: HasDataLayout>(self, i: i64, cx: C) -> Self {
Pointer::new(
self.alloc_id,
Size::from_bytes(cx.data_layout().wrapping_signed_offset(self.offset.bytes(), i)),
Expand All @@ -147,7 +147,7 @@ impl<'tcx> Pointer {
(Pointer::new(self.alloc_id, Size::from_bytes(res)), over)
}

pub(crate) fn signed_offset<C: HasDataLayout>(self, i: i64, cx: C) -> EvalResult<'tcx, Self> {
pub fn signed_offset<C: HasDataLayout>(self, i: i64, cx: C) -> EvalResult<'tcx, Self> {
Ok(Pointer::new(
self.alloc_id,
Size::from_bytes(cx.data_layout().signed_offset(self.offset.bytes(), i)?),
Expand Down Expand Up @@ -567,25 +567,33 @@ pub fn write_target_uint(
}
}

pub fn write_target_int(
endianness: layout::Endian,
mut target: &mut [u8],
data: i128,
) -> Result<(), io::Error> {
let len = target.len();
match endianness {
layout::Endian::Little => target.write_int128::<LittleEndian>(data, len),
layout::Endian::Big => target.write_int128::<BigEndian>(data, len),
}
}

pub fn read_target_uint(endianness: layout::Endian, mut source: &[u8]) -> Result<u128, io::Error> {
match endianness {
layout::Endian::Little => source.read_uint128::<LittleEndian>(source.len()),
layout::Endian::Big => source.read_uint128::<BigEndian>(source.len()),
}
}

////////////////////////////////////////////////////////////////////////////////
// Methods to faciliate working with signed integers stored in a u128
////////////////////////////////////////////////////////////////////////////////

pub fn sign_extend(value: u128, size: Size) -> u128 {
let size = size.bits();
// sign extend
let shift = 128 - size;
// shift the unsigned value to the left
// and back to the right as signed (essentially fills with FF on the left)
(((value << shift) as i128) >> shift) as u128
}

pub fn truncate(value: u128, size: Size) -> u128 {
let size = size.bits();
let shift = 128 - size;
// truncate (shift left to drop out leftover values, shift right to fill with zeroes)
(value << shift) >> shift
}

////////////////////////////////////////////////////////////////////////////////
// Undefined byte tracking
////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading