Unbox FunctionDebugContextData.
It is only a pointer and a Cell, which is quite small.
This commit is contained in:
parent
b10d89a096
commit
14ae76d96b
@ -54,7 +54,7 @@ pub fn create_mir_scopes(fcx: &FunctionContext) -> IndexVec<VisibilityScope, Mir
|
||||
let mut scopes = IndexVec::from_elem(null_scope, &mir.visibility_scopes);
|
||||
|
||||
let fn_metadata = match fcx.debug_context {
|
||||
FunctionDebugContext::RegularContext(box ref data) => data.fn_metadata,
|
||||
FunctionDebugContext::RegularContext(ref data) => data.fn_metadata,
|
||||
FunctionDebugContext::DebugInfoDisabled |
|
||||
FunctionDebugContext::FunctionWithoutDebugInfo => {
|
||||
return scopes;
|
||||
|
@ -97,7 +97,7 @@ impl<'tcx> CrateDebugContext<'tcx> {
|
||||
}
|
||||
|
||||
pub enum FunctionDebugContext {
|
||||
RegularContext(Box<FunctionDebugContextData>),
|
||||
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<bool>,
|
||||
source_location_override: Cell<bool>,
|
||||
}
|
||||
|
||||
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 */ }
|
||||
|
@ -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 */ }
|
||||
|
Loading…
x
Reference in New Issue
Block a user