mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
use proper span for TLS dtors; fix some nits
This commit is contained in:
parent
a66f359d91
commit
14b16dcf45
@ -100,7 +100,6 @@ impl Pointer {
|
||||
}
|
||||
|
||||
pub fn is_null_ptr(&self) -> bool {
|
||||
// FIXME: Is this the right way?
|
||||
return *self == Pointer::from_int(0)
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ use eval_context::{EvalContext, StackPopCleanup};
|
||||
use lvalue::{Global, GlobalId, Lvalue};
|
||||
use value::{Value, PrimVal};
|
||||
use memory::Pointer;
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use syntax::codemap::Span;
|
||||
|
||||
impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
pub fn inc_step_counter_and_check_limit(&mut self, n: u64) -> EvalResult<'tcx> {
|
||||
@ -36,10 +36,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
trace!("Running TLS dtor {:?} on {:?}", instance, ptr);
|
||||
// TODO: Potientiually, this has to support all the other possible instances? See eval_fn_call in terminator/mod.rs
|
||||
let mir = self.load_mir(instance.def)?;
|
||||
// FIXME: Are these the right dummy values?
|
||||
self.push_stack_frame(
|
||||
instance,
|
||||
DUMMY_SP,
|
||||
mir.span,
|
||||
mir,
|
||||
Lvalue::from_ptr(Pointer::zst_ptr()),
|
||||
StackPopCleanup::None,
|
||||
@ -51,7 +50,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
} else {
|
||||
return Err(EvalError::AbiViolation("TLS dtor does not take enough arguments.".to_owned()));
|
||||
}
|
||||
|
||||
|
||||
return Ok(true);
|
||||
}
|
||||
return Ok(false);
|
||||
|
@ -1,6 +1,6 @@
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::mir;
|
||||
use rustc::ty::{self, TypeVariants, Ty, TyS, TypeAndMut};
|
||||
use rustc::ty::{self, TypeVariants, Ty, TypeAndMut};
|
||||
use rustc::ty::layout::Layout;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::attr;
|
||||
@ -600,19 +600,19 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
let key_ptr = args[0].read_ptr(&self.memory)?;
|
||||
|
||||
// Extract the function type out of the signature (that seems easier than constructing it ourselves...)
|
||||
// FIXME: Or should we instead construct the type we expect it to have?
|
||||
let dtor_fn_ty = match self.operand_ty(&arg_operands[1]) {
|
||||
&TyS { sty: TypeVariants::TyAdt(_, ref substs), .. } => {
|
||||
let dtor_fn_ty = match self.operand_ty(&arg_operands[1]).sty {
|
||||
TypeVariants::TyAdt(_, ref substs) => {
|
||||
substs.type_at(0)
|
||||
}
|
||||
_ => return Err(EvalError::AbiViolation("Wrong signature used for pthread_key_create: Second argument must be option of a function pointer.".to_owned()))
|
||||
};
|
||||
let dtor_ptr = self.value_to_primval(args[1], dtor_fn_ty)?.to_ptr()?;
|
||||
// TODO: The null-pointer case here is entirely untested
|
||||
let dtor = if dtor_ptr.is_null_ptr() { None } else { Some(self.memory.get_fn(dtor_ptr.alloc_id)?) };
|
||||
|
||||
// Figure out how large a pthread TLS key actually is. This is libc::pthread_key_t.
|
||||
let key_size = match self.operand_ty(&arg_operands[0]) {
|
||||
&TyS { sty: TypeVariants::TyRawPtr(TypeAndMut { ty, .. }), .. } => {
|
||||
let key_size = match self.operand_ty(&arg_operands[0]).sty {
|
||||
TypeVariants::TyRawPtr(TypeAndMut { ty, .. }) => {
|
||||
let layout = self.type_layout(ty)?;
|
||||
layout.size(&self.tcx.data_layout)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user