From 14ae76d96b87d6b3e8cbe9264534e148ee88fb89 Mon Sep 17 00:00:00 2001 From: Mark-Simulacrum Date: Thu, 15 Dec 2016 15:08:18 -0700 Subject: [PATCH] Unbox FunctionDebugContextData. It is only a pointer and a Cell, which is quite small. --- src/librustc_trans/debuginfo/create_scope_map.rs | 2 +- src/librustc_trans/debuginfo/mod.rs | 14 ++++---------- src/librustc_trans/debuginfo/source_loc.rs | 10 ++-------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/librustc_trans/debuginfo/create_scope_map.rs b/src/librustc_trans/debuginfo/create_scope_map.rs index e0c1a80be39..23f415d95cf 100644 --- a/src/librustc_trans/debuginfo/create_scope_map.rs +++ b/src/librustc_trans/debuginfo/create_scope_map.rs @@ -54,7 +54,7 @@ pub fn create_mir_scopes(fcx: &FunctionContext) -> IndexVec data.fn_metadata, + FunctionDebugContext::RegularContext(ref data) => data.fn_metadata, FunctionDebugContext::DebugInfoDisabled | FunctionDebugContext::FunctionWithoutDebugInfo => { return scopes; diff --git a/src/librustc_trans/debuginfo/mod.rs b/src/librustc_trans/debuginfo/mod.rs index f59ecf1d678..1bf3c0acec5 100644 --- a/src/librustc_trans/debuginfo/mod.rs +++ b/src/librustc_trans/debuginfo/mod.rs @@ -97,7 +97,7 @@ impl<'tcx> CrateDebugContext<'tcx> { } pub enum FunctionDebugContext { - RegularContext(Box), + RegularContext(FunctionDebugContextData), DebugInfoDisabled, FunctionWithoutDebugInfo, } @@ -107,7 +107,7 @@ impl FunctionDebugContext { span: Span) -> &'a FunctionDebugContextData { match *self { - FunctionDebugContext::RegularContext(box ref data) => data, + FunctionDebugContext::RegularContext(ref data) => data, FunctionDebugContext::DebugInfoDisabled => { span_bug!(span, "{}", @@ -134,7 +134,6 @@ impl FunctionDebugContext { pub struct FunctionDebugContextData { fn_metadata: DISubprogram, source_locations_enabled: Cell, - source_location_override: Cell, } pub enum VariableAccess<'a> { @@ -293,10 +292,9 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, }; // Initialize fn debug context (including scope map and namespace map) - let fn_debug_context = box FunctionDebugContextData { + let fn_debug_context = FunctionDebugContextData { fn_metadata: fn_metadata, source_locations_enabled: Cell::new(false), - source_location_override: Cell::new(false), }; return FunctionDebugContext::RegularContext(fn_debug_context); @@ -503,11 +501,7 @@ pub fn declare_local<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>, match variable_kind { ArgumentVariable(_) | CapturedVariable => { - assert!(!bcx.fcx() - .debug_context - .get_ref(span) - .source_locations_enabled - .get()); + assert!(!bcx.fcx().debug_context.get_ref(span).source_locations_enabled.get()); source_loc::set_debug_location(cx, None, UnknownLocation); } _ => { /* nothing to do */ } diff --git a/src/librustc_trans/debuginfo/source_loc.rs b/src/librustc_trans/debuginfo/source_loc.rs index 1aee27c144a..86ecc0e65a9 100644 --- a/src/librustc_trans/debuginfo/source_loc.rs +++ b/src/librustc_trans/debuginfo/source_loc.rs @@ -36,15 +36,9 @@ pub fn set_source_location(fcx: &FunctionContext, set_debug_location(fcx.ccx, builder, UnknownLocation); return; } - FunctionDebugContext::RegularContext(box ref data) => data + FunctionDebugContext::RegularContext(ref data) => data }; - if function_debug_context.source_location_override.get() { - // Just ignore any attempts to set a new debug location while - // the override is active. - return; - } - let dbg_loc = if function_debug_context.source_locations_enabled.get() { let (scope, span) = match debug_loc { DebugLoc::ScopeAt(scope, span) => (scope, span), @@ -72,7 +66,7 @@ pub fn set_source_location(fcx: &FunctionContext, /// first real statement/expression of the function is translated. pub fn start_emitting_source_locations(fcx: &FunctionContext) { match fcx.debug_context { - FunctionDebugContext::RegularContext(box ref data) => { + FunctionDebugContext::RegularContext(ref data) => { data.source_locations_enabled.set(true) }, _ => { /* safe to ignore */ }