@@ -131,7 +131,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
131
131
Ok ( ( ) )
132
132
}
133
133
134
- /// Decides whether it is okay to call the method with signature `real_sig` using signature `sig`
134
+ /// Decides whether it is okay to call the method with signature `real_sig` using signature `sig`.
135
+ /// FIXME: This should take into account the platform-dependent ABI description.
135
136
fn check_sig_compat (
136
137
& mut self ,
137
138
sig : ty:: FnSig < ' tcx > ,
@@ -284,12 +285,6 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
284
285
trace ! ( "arg_locals: {:?}" , self . frame( ) . mir. args_iter( ) . collect:: <Vec <_>>( ) ) ;
285
286
trace ! ( "arg_operands: {:?}" , arg_operands) ;
286
287
match sig. abi {
287
- Abi :: Rust | Abi :: C => {
288
- for ( arg_local, ( arg_val, arg_ty) ) in arg_locals. zip ( args) {
289
- let dest = self . eval_lvalue ( & mir:: Lvalue :: Local ( arg_local) ) ?;
290
- self . write_value ( arg_val, dest, arg_ty) ?;
291
- }
292
- }
293
288
Abi :: RustCall => {
294
289
assert_eq ! ( args. len( ) , 2 ) ;
295
290
@@ -332,8 +327,13 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
332
327
} else {
333
328
bug ! ( "rust-call ABI tuple argument was {:?}, {:?}" , arg_ty, layout) ;
334
329
}
330
+ } ,
331
+ _ => {
332
+ for ( arg_local, ( arg_val, arg_ty) ) in arg_locals. zip ( args) {
333
+ let dest = self . eval_lvalue ( & mir:: Lvalue :: Local ( arg_local) ) ?;
334
+ self . write_value ( arg_val, dest, arg_ty) ?;
335
+ }
335
336
}
336
- _ => unimplemented ! ( ) ,
337
337
}
338
338
Ok ( ( ) )
339
339
} ,
@@ -520,7 +520,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
520
520
// Still, we can make many things mostly work by "emulating" or ignoring some functions.
521
521
match & path[ ..] {
522
522
"std::io::_print" => {
523
- trace ! ( "Ignoring output." ) ;
523
+ trace ! ( "Ignoring output. To run programs that print, make sure you have a libstd with full MIR. " ) ;
524
524
self . goto_block ( destination. unwrap ( ) . 1 ) ;
525
525
Ok ( ( ) )
526
526
} ,
@@ -595,15 +595,16 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
595
595
}
596
596
597
597
"__rust_maybe_catch_panic" => {
598
+ // fn __rust_maybe_catch_panic(f: fn(*mut u8), data: *mut u8, data_ptr: *mut usize, vtable_ptr: *mut usize) -> u32
598
599
// We abort on panic, so not much is going on here, but we still have to call the closure
599
600
let u8_ptr_ty = self . tcx . mk_mut_ptr ( self . tcx . types . u8 ) ;
600
601
let f = args[ 0 ] . read_ptr ( & self . memory ) ?;
601
- let data = args[ 1 ] . read_ptr ( & self . memory ) ?; // FIXME: Why does value_to_primval(args[2], u8_ptr_ty)?.to_ptr()? here end up doing the Wrong Thing (TM)?
602
+ let data = args[ 1 ] . read_ptr ( & self . memory ) ?;
602
603
let f_instance = self . memory . get_fn ( f. alloc_id ) ?;
603
604
self . write_primval ( dest, PrimVal :: Bytes ( 0 ) , dest_ty) ?;
604
605
605
- // Now we make a functon call. TODO: Consider making this re-usable? EvalContext::step does sth. similar for the TLS dtors,
606
- // and of coruse eval_main.
606
+ // Now we make a function call. TODO: Consider making this re-usable? EvalContext::step does sth. similar for the TLS dtors,
607
+ // and of course eval_main.
607
608
let mir = self . load_mir ( f_instance. def ) ?;
608
609
self . push_stack_frame (
609
610
f_instance,
@@ -614,11 +615,13 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
614
615
) ?;
615
616
616
617
let arg_local = self . frame ( ) . mir . args_iter ( ) . next ( ) . ok_or ( EvalError :: AbiViolation ( "Argument to __rust_maybe_catch_panic does not take enough arguments." . to_owned ( ) ) ) ?;
617
- let dest = self . eval_lvalue ( & mir:: Lvalue :: Local ( arg_local) ) ?;
618
- self . write_value ( Value :: ByVal ( PrimVal :: Ptr ( data) ) , dest, u8_ptr_ty) ?;
618
+ let arg_dest = self . eval_lvalue ( & mir:: Lvalue :: Local ( arg_local) ) ?;
619
+ self . write_value ( Value :: ByVal ( PrimVal :: Ptr ( data) ) , arg_dest, u8_ptr_ty) ?;
620
+
621
+ // We ourselbes return 0
622
+ self . write_primval ( dest, PrimVal :: Bytes ( 0 ) , dest_ty) ?;
619
623
620
624
// Don't fall through
621
- // FIXME: Do we have to do self.dump_local(ret) anywhere?
622
625
return Ok ( ( ) ) ;
623
626
}
624
627
0 commit comments