about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-04-27 14:16:49 +0800
committerkennytm <kennytm@gmail.com>2018-04-27 16:23:29 +0800
commitf1a4c10fb444f7af5fbbfcd3055cef68a1578d72 (patch)
tree68c13998527cba6aec92d46a8384ff1d9223a6cb /src
parente9b67d221fd2392f1de4b7f874744535f3a43135 (diff)
parent2e4f66a86f7baa5644d18bb2adc07a8cd1c7409d (diff)
downloadrust-f1a4c10fb444f7af5fbbfcd3055cef68a1578d72.tar.gz
rust-f1a4c10fb444f7af5fbbfcd3055cef68a1578d72.zip
Rollup merge of #50246 - nnethercote:no-dump_allocs, r=Mark-Simulacrum
Make dump_{alloc,allocs,local}() no-ops when tracing is disabled.

Because they traverse data structures and build up strings, which is
wasted effort if those strings aren't printed.

The patch also removes some now-unnecessary log_enabled! tests at call
sites.

This is a big win for the Debug and Opt runs of coercions, tuple-stress, html5ever, and encoding.
```
coercions-opt
        avg: -7.8%      min: -14.8%     max: 0.1%
coercions
        avg: -8.0%      min: -12.8%     max: 0.1%
tuple-stress
        avg: -7.2%      min: -10.8%     max: -0.7%
tuple-stress-opt
        avg: -6.9%      min: -10.7%     max: 0.6%
html5ever
        avg: -4.6%      min: -7.3%      max: -0.3%
encoding
        avg: -2.4%      min: -4.5%      max: 0.1%
html5ever-opt
        avg: -2.7%      min: -4.2%      max: -0.2%
encoding-opt
        avg: -1.4%      min: -2.4%      max: 0.0%
```
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/interpret/eval_context.rs7
-rw-r--r--src/librustc_mir/interpret/memory.rs6
-rw-r--r--src/librustc_mir/interpret/place.rs4
3 files changed, 11 insertions, 6 deletions
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs
index 4b57c641546..f6e9994b5da 100644
--- a/src/librustc_mir/interpret/eval_context.rs
+++ b/src/librustc_mir/interpret/eval_context.rs
@@ -768,9 +768,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
             }
         }
 
-        if log_enabled!(::log::Level::Trace) {
-            self.dump_local(dest);
-        }
+        self.dump_local(dest);
 
         Ok(())
     }
@@ -1572,6 +1570,9 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
 
     pub fn dump_local(&self, place: Place) {
         // Debug output
+        if !log_enabled!(::log::Level::Trace) {
+            return;
+        }
         match place {
             Place::Local { frame, local } => {
                 let mut allocs = Vec::new();
diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs
index 5e156e9271f..7f8205b8327 100644
--- a/src/librustc_mir/interpret/memory.rs
+++ b/src/librustc_mir/interpret/memory.rs
@@ -334,11 +334,17 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
 
     /// For debugging, print an allocation and all allocations it points to, recursively.
     pub fn dump_alloc(&self, id: AllocId) {
+        if !log_enabled!(::log::Level::Trace) {
+            return;
+        }
         self.dump_allocs(vec![id]);
     }
 
     /// For debugging, print a list of allocations and all allocations they point to, recursively.
     pub fn dump_allocs(&self, mut allocs: Vec<AllocId>) {
+        if !log_enabled!(::log::Level::Trace) {
+            return;
+        }
         use std::fmt::Write;
         allocs.sort();
         allocs.dedup();
diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs
index 42cb149d682..d03204bfab1 100644
--- a/src/librustc_mir/interpret/place.rs
+++ b/src/librustc_mir/interpret/place.rs
@@ -219,9 +219,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
             }
         };
 
-        if log_enabled!(::log::Level::Trace) {
-            self.dump_local(place);
-        }
+        self.dump_local(place);
 
         Ok(place)
     }