diff options
author | John Hodge <tpg@mutabah.net> | 2019-11-09 21:08:42 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2019-11-09 21:08:42 +0800 |
commit | 6be15b07fb5d56e1b2064ef2dd9bbf8ec8658d9a (patch) | |
tree | b8e75bfe203e6ae019550e5635a12dcd1248b76c | |
parent | 9addf62c2793fad9cf6807f106fd4f5bf13806af (diff) | |
download | mrust-6be15b07fb5d56e1b2064ef2dd9bbf8ec8658d9a.tar.gz |
Standalone MIRI - Tweaks on windows
-rw-r--r-- | src/trans/codegen_mmir.cpp | 4 | ||||
-rw-r--r-- | tools/standalone_miri/debug.hpp | 2 | ||||
-rw-r--r-- | tools/standalone_miri/miri.cpp | 27 | ||||
-rw-r--r-- | tools/standalone_miri/module_tree.cpp | 4 | ||||
-rw-r--r-- | tools/standalone_miri/value.cpp | 4 |
5 files changed, 32 insertions, 9 deletions
diff --git a/src/trans/codegen_mmir.cpp b/src/trans/codegen_mmir.cpp index 58739805..c5d4e9de 100644 --- a/src/trans/codegen_mmir.cpp +++ b/src/trans/codegen_mmir.cpp @@ -994,7 +994,7 @@ namespace for(const auto& v : lit.as_List()) { emit_literal_as_bytes(v, *te.inner, out_relocations, base_ofs); - size_t size = Target_GetSizeOf(sp, m_resolve, *te.inner, size); + size_t size = Target_GetSizeOf_Required(sp, m_resolve, *te.inner); base_ofs += size; } } break; @@ -1331,7 +1331,7 @@ namespace { case ::MIR::Terminator::TAGDEAD: throw ""; TU_ARM(term, Incomplete, _e) (void)_e; - m_of << "INCOMPLTE\n"; + m_of << "INCOMPLETE\n"; break; TU_ARM(term, Return, _e) (void)_e; m_of << "RETURN\n"; diff --git a/tools/standalone_miri/debug.hpp b/tools/standalone_miri/debug.hpp index 9de6231b..9c60a0b6 100644 --- a/tools/standalone_miri/debug.hpp +++ b/tools/standalone_miri/debug.hpp @@ -34,7 +34,7 @@ public: template<typename T> DebugSink& operator<<(const T& v) { - if( m_stderr_too ) + if( m_stderr_too && s_out_file ) { ::std::cerr << v; } diff --git a/tools/standalone_miri/miri.cpp b/tools/standalone_miri/miri.cpp index 4eadac66..951b3ccd 100644 --- a/tools/standalone_miri/miri.cpp +++ b/tools/standalone_miri/miri.cpp @@ -1758,8 +1758,25 @@ bool InterpreterThread::step_one(Value& out_thread_result) LOG_ASSERT(v.read_usize(0) == Allocation::PTR_BASE, "Function pointer value invalid - " << v); fcn_alloc_ptr = v.get_relocation(0); LOG_ASSERT(fcn_alloc_ptr, "Calling value with no relocation - " << v); - LOG_ASSERT(fcn_alloc_ptr.get_ty() == RelocationPtr::Ty::Function, "Calling value that isn't a function pointer"); - fcn_p = &fcn_alloc_ptr.fcn(); + switch(fcn_alloc_ptr.get_ty()) + { + case RelocationPtr::Ty::Function: + fcn_p = &fcn_alloc_ptr.fcn(); + break; + case RelocationPtr::Ty::FfiPointer: + if( !fcn_alloc_ptr.ffi().layout ) + { +#ifdef _WIN32 + if( fcn_alloc_ptr.ffi().ptr_value == AcquireSRWLockExclusive ) + { + LOG_TODO(""); + break; + } +#endif + } + default: + LOG_ERROR("Calling value that isn't a function pointer - " << v); + } } LOG_DEBUG("Call " << *fcn_p); @@ -1883,7 +1900,9 @@ bool InterpreterThread::call_path(Value& ret, const ::HIR::Path& path, ::std::ve { // TODO: Support overriding certain functions { - if( path == ::HIR::SimplePath { "std", { "sys", "imp", "c", "SetThreadStackGuarantee" } } ) + if( path == ::HIR::SimplePath { "std", { "sys", "imp", "c", "SetThreadStackGuarantee" } } + || path == ::HIR::SimplePath { "std", { "sys", "windows", "c", "SetThreadStackGuarantee" } } + ) { ret = Value::new_i32(120); //ERROR_CALL_NOT_IMPLEMENTED return true; @@ -1891,7 +1910,7 @@ bool InterpreterThread::call_path(Value& ret, const ::HIR::Path& path, ::std::ve // - No guard page needed if( path == ::HIR::SimplePath { "std", {"sys", "imp", "thread", "guard", "init" } } - || path == ::HIR::SimplePath { "std", {"sys", "unix", "thread", "guard", "init" } } + || path == ::HIR::SimplePath { "std", {"sys", "unix", "thread", "guard", "init" } } ) { ret = Value::with_size(16, false); diff --git a/tools/standalone_miri/module_tree.cpp b/tools/standalone_miri/module_tree.cpp index 91d82d85..1f233f16 100644 --- a/tools/standalone_miri/module_tree.cpp +++ b/tools/standalone_miri/module_tree.cpp @@ -866,6 +866,10 @@ bool Parser::parse_one() { term = ::MIR::Terminator::make_Diverge({}); } + else if( lex.consume_if("INCOMPLETE") ) + { + term = ::MIR::Terminator::make_Incomplete({}); + } else if( lex.consume_if("IF") ) { auto val = H::parse_lvalue(*this, var_names); diff --git a/tools/standalone_miri/value.cpp b/tools/standalone_miri/value.cpp index a497f0bd..58934200 100644 --- a/tools/standalone_miri/value.cpp +++ b/tools/standalone_miri/value.cpp @@ -543,8 +543,8 @@ void Allocation::write_ptr(size_t ofs, size_t ptr_ofs, RelocationPtr reloc) } void Allocation::set_reloc(size_t ofs, size_t len, RelocationPtr reloc) { - LOG_ASSERT(ofs % POINTER_SIZE == 0, ""); - LOG_ASSERT(len == POINTER_SIZE, ""); + LOG_ASSERT(ofs % POINTER_SIZE == 0, "Allocation::set_reloc(" << ofs << ", " << len << ", " << reloc << ")"); + LOG_ASSERT(len == POINTER_SIZE, "Allocation::set_reloc(" << ofs << ", " << len << ", " << reloc << ")"); // Delete any existing relocation at this position for(auto it = this->relocations.begin(); it != this->relocations.end();) { |