]> git.lizzy.rs Git - rust.git/commitdiff
Make zst accesses in allocations take the regular path.
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Tue, 13 Nov 2018 09:19:12 +0000 (10:19 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Sat, 24 Nov 2018 10:36:31 +0000 (11:36 +0100)
Speeding up zst accesses should be done on a higher level.

src/librustc/mir/interpret/allocation.rs

index 42bcd3a90276071b13ed81eb85b91533129a2e59..ba2755b29f0b81fbb4084d44fac27b95a80c443f 100644 (file)
@@ -116,12 +116,7 @@ pub fn check_bytes(
         size: Size,
         allow_ptr_and_undef: bool,
     ) -> EvalResult<'tcx> {
-        // Empty accesses don't need to be valid pointers, but they should still be non-NULL
         let align = Align::from_bytes(1).unwrap();
-        if size.bytes() == 0 {
-            self.check_align(ptr, align)?;
-            return Ok(());
-        }
         // Check bounds, align and relocations on the edges
         self.get_bytes_with_undef_and_ptr(cx, ptr, size, align)?;
         // Check undef and ptr
@@ -138,12 +133,7 @@ pub fn read_bytes(
         ptr: Pointer<Tag>,
         size: Size,
     ) -> EvalResult<'tcx, &[u8]> {
-        // Empty accesses don't need to be valid pointers, but they should still be non-NULL
         let align = Align::from_bytes(1).unwrap();
-        if size.bytes() == 0 {
-            self.check_align(ptr, align)?;
-            return Ok(&[]);
-        }
         self.get_bytes(cx, ptr, size, align)
     }
 
@@ -153,12 +143,7 @@ pub fn write_bytes(
         ptr: Pointer<Tag>,
         src: &[u8],
     ) -> EvalResult<'tcx> {
-        // Empty accesses don't need to be valid pointers, but they should still be non-NULL
         let align = Align::from_bytes(1).unwrap();
-        if src.is_empty() {
-            self.check_align(ptr, align)?;
-            return Ok(());
-        }
         let bytes = self.get_bytes_mut(
             cx, ptr, Size::from_bytes(src.len() as u64), align,
         )?;
@@ -173,12 +158,7 @@ pub fn write_repeat(
         val: u8,
         count: Size
     ) -> EvalResult<'tcx> {
-        // Empty accesses don't need to be valid pointers, but they should still be non-NULL
         let align = Align::from_bytes(1).unwrap();
-        if count.bytes() == 0 {
-            self.check_align(ptr, align)?;
-            return Ok(());
-        }
         let bytes = self.get_bytes_mut(cx, ptr, count, align)?;
         for b in bytes {
             *b = val;
@@ -329,7 +309,6 @@ fn get_bytes_internal(
         align: Align,
         check_defined_and_ptr: bool,
     ) -> EvalResult<'tcx, &[u8]> {
-        assert_ne!(size.bytes(), 0, "0-sized accesses should never even get a `Pointer`");
         self.check_align(ptr.into(), align)?;
         self.check_bounds(cx, ptr, size)?;