Unbox FunctionDebugContextData.
It is only a pointer and a Cell, which is quite small.
This commit is contained in:
parent
b10d89a096
commit
14ae76d96b
3 changed files with 7 additions and 19 deletions
|
@ -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 mut scopes = IndexVec::from_elem(null_scope, &mir.visibility_scopes);
|
||||||
|
|
||||||
let fn_metadata = match fcx.debug_context {
|
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::DebugInfoDisabled |
|
||||||
FunctionDebugContext::FunctionWithoutDebugInfo => {
|
FunctionDebugContext::FunctionWithoutDebugInfo => {
|
||||||
return scopes;
|
return scopes;
|
||||||
|
|
|
@ -97,7 +97,7 @@ impl<'tcx> CrateDebugContext<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum FunctionDebugContext {
|
pub enum FunctionDebugContext {
|
||||||
RegularContext(Box<FunctionDebugContextData>),
|
RegularContext(FunctionDebugContextData),
|
||||||
DebugInfoDisabled,
|
DebugInfoDisabled,
|
||||||
FunctionWithoutDebugInfo,
|
FunctionWithoutDebugInfo,
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ impl FunctionDebugContext {
|
||||||
span: Span)
|
span: Span)
|
||||||
-> &'a FunctionDebugContextData {
|
-> &'a FunctionDebugContextData {
|
||||||
match *self {
|
match *self {
|
||||||
FunctionDebugContext::RegularContext(box ref data) => data,
|
FunctionDebugContext::RegularContext(ref data) => data,
|
||||||
FunctionDebugContext::DebugInfoDisabled => {
|
FunctionDebugContext::DebugInfoDisabled => {
|
||||||
span_bug!(span,
|
span_bug!(span,
|
||||||
"{}",
|
"{}",
|
||||||
|
@ -134,7 +134,6 @@ impl FunctionDebugContext {
|
||||||
pub struct FunctionDebugContextData {
|
pub struct FunctionDebugContextData {
|
||||||
fn_metadata: DISubprogram,
|
fn_metadata: DISubprogram,
|
||||||
source_locations_enabled: Cell<bool>,
|
source_locations_enabled: Cell<bool>,
|
||||||
source_location_override: Cell<bool>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum VariableAccess<'a> {
|
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)
|
// 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,
|
fn_metadata: fn_metadata,
|
||||||
source_locations_enabled: Cell::new(false),
|
source_locations_enabled: Cell::new(false),
|
||||||
source_location_override: Cell::new(false),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return FunctionDebugContext::RegularContext(fn_debug_context);
|
return FunctionDebugContext::RegularContext(fn_debug_context);
|
||||||
|
@ -503,11 +501,7 @@ pub fn declare_local<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
|
||||||
|
|
||||||
match variable_kind {
|
match variable_kind {
|
||||||
ArgumentVariable(_) | CapturedVariable => {
|
ArgumentVariable(_) | CapturedVariable => {
|
||||||
assert!(!bcx.fcx()
|
assert!(!bcx.fcx().debug_context.get_ref(span).source_locations_enabled.get());
|
||||||
.debug_context
|
|
||||||
.get_ref(span)
|
|
||||||
.source_locations_enabled
|
|
||||||
.get());
|
|
||||||
source_loc::set_debug_location(cx, None, UnknownLocation);
|
source_loc::set_debug_location(cx, None, UnknownLocation);
|
||||||
}
|
}
|
||||||
_ => { /* nothing to do */ }
|
_ => { /* nothing to do */ }
|
||||||
|
|
|
@ -36,15 +36,9 @@ pub fn set_source_location(fcx: &FunctionContext,
|
||||||
set_debug_location(fcx.ccx, builder, UnknownLocation);
|
set_debug_location(fcx.ccx, builder, UnknownLocation);
|
||||||
return;
|
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 dbg_loc = if function_debug_context.source_locations_enabled.get() {
|
||||||
let (scope, span) = match debug_loc {
|
let (scope, span) = match debug_loc {
|
||||||
DebugLoc::ScopeAt(scope, span) => (scope, span),
|
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.
|
/// first real statement/expression of the function is translated.
|
||||||
pub fn start_emitting_source_locations(fcx: &FunctionContext) {
|
pub fn start_emitting_source_locations(fcx: &FunctionContext) {
|
||||||
match fcx.debug_context {
|
match fcx.debug_context {
|
||||||
FunctionDebugContext::RegularContext(box ref data) => {
|
FunctionDebugContext::RegularContext(ref data) => {
|
||||||
data.source_locations_enabled.set(true)
|
data.source_locations_enabled.set(true)
|
||||||
},
|
},
|
||||||
_ => { /* safe to ignore */ }
|
_ => { /* safe to ignore */ }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue