Skip to content

Rustup #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 30 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2671cf3
Update to some cleanups in rustc
oli-obk Dec 15, 2017
a23e587
stop using Instance::def_ty
arielb1 Dec 17, 2017
5147655
Merge branch 'master' into def_ty
oli-obk Dec 19, 2017
30496f5
update compiletest dependency
dwrensha Dec 31, 2017
03aa876
pass typecheck
dwrensha Jan 2, 2018
cabdc55
update log deps
dwrensha Jan 6, 2018
33af320
update for rust/47205
dwrensha Jan 15, 2018
d289c0f
partially deal with rust/46479
dwrensha Jan 15, 2018
9e04368
Rustup
bjorn3 Jan 14, 2018
3e339bc
rustup
bjorn3 Jan 27, 2018
9be04c0
Rustup
bjorn3 Mar 17, 2018
a204cb4
Add stack guard shim
bjorn3 Mar 17, 2018
aa5972d
Get the tests one step further
oli-obk Mar 18, 2018
1e094e5
WIP fix alignment issue
bjorn3 Mar 18, 2018
3038274
Dont claim to have marked static initialized
bjorn3 Mar 19, 2018
bad9fa5
Use elem align as src align in copy intrinsic
bjorn3 Mar 19, 2018
5db2aba
Hack: copy init_static from rustc CompileTimeEvaluator to try to fix …
bjorn3 Mar 19, 2018
896996b
Maybe prevent marking statics as immutable
bjorn3 Mar 19, 2018
907e67f
Fix init_static
bjorn3 Mar 23, 2018
5831309
travis: cache build dir
bjorn3 Mar 23, 2018
a86348b
Fix it
bjorn3 Mar 23, 2018
57e63b8
Fix (try 2)
bjorn3 Mar 23, 2018
654cd94
FIx (try 3)
bjorn3 Mar 23, 2018
6e60b79
Fix (try 4)
bjorn3 Mar 23, 2018
3656c03
Partially fix it
bjorn3 Mar 24, 2018
2137351
Rustup
bjorn3 Mar 31, 2018
5b8781c
Fix some more tests with some unsafe code
bjorn3 Apr 4, 2018
054b0db
Remove unsafe code
bjorn3 Apr 7, 2018
77413d7
Some cleanups
bjorn3 Apr 7, 2018
2e1b165
Update Cargo.lock and some improvements
bjorn3 Apr 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion miri/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ impl<'mir, 'tcx: 'mir> Machine<'mir, 'tcx> for Evaluator<'tcx> {
cid: GlobalId<'tcx>,
) -> EvalResult<'tcx, AllocId> {
if let Some(alloc_id) = ecx.memory.data.mut_statics.get(&cid) {
return Ok(alloc_id);
return Ok(*alloc_id);
}
let mir = ecx.load_mir(cid.instance.def)?;
let layout = ecx.layout_of(mir.return_ty().subst(ecx.tcx.tcx, cid.instance.substs))?;
Expand All @@ -287,6 +287,7 @@ impl<'mir, 'tcx: 'mir> Machine<'mir, 'tcx> for Evaluator<'tcx> {
.interpret_interner
.get_cached(cid.instance.def_id())
.expect("uncached static");
// TODO: do a recursive copy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, no recursive copy. if you have

static FOO: &'static Foo = &BAR;
static BAR: Foo = Foo { field: &FOO };

Then BAR would end up referring to a copy of FOO instead of referring to it directly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't evaluate the static in the same EvalContext as far as I know, so we have to copy it anyway. A cache could be used just like ecx.memory.data.mut_static to prevent duplication.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do it. Just push a stackframe for it as you had before 907e67f

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the while ecx.step()? {} will step out of the frame present at the beginning of the init_static function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, you can solve that by recording the stack size before pushing the frame (self.frames().len()) in a variable and looping until you're back at the same frame.

ecx.memory.copy(MemoryPointer::new(ptr, 0).into(), layout.align, to_ptr.into(), layout.align, layout.size.bytes(), true)?;
ecx.memory.mark_static_initialized(to_ptr.alloc_id, ::syntax::ast::Mutability::Mutable)?;
assert!(ecx.memory.data.mut_statics.insert(cid, to_ptr.alloc_id).is_none());
Expand Down