提交 14b16dcf 编写于 作者: R Ralf Jung

use proper span for TLS dtors; fix some nits

上级 a66f359d
......@@ -100,7 +100,6 @@ pub fn never_ptr() -> Self {
}
pub fn is_null_ptr(&self) -> bool {
// FIXME: Is this the right way?
return *self == Pointer::from_int(0)
}
}
......
......@@ -14,7 +14,7 @@
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 @@ pub fn step(&mut self) -> EvalResult<'tcx, bool> {
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 @@ pub fn step(&mut self) -> EvalResult<'tcx, bool> {
} else {
return Err(EvalError::AbiViolation("TLS dtor does not take enough arguments.".to_owned()));
}
return Ok(true);
}
return Ok(false);
......
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 @@ fn call_c_abi(
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)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册