diff options
| author | John Hodge <tpg@ucc.asn.au> | 2019-08-04 13:00:02 +0800 |
|---|---|---|
| committer | John Hodge <tpg@ucc.asn.au> | 2019-08-04 13:00:02 +0800 |
| commit | 982826e4b309979bee8fe10f6ff537b4922e6316 (patch) | |
| tree | 4be2ab029181b5d4e867f06078f489e8895abb17 /tools/standalone_miri/value.cpp | |
| parent | 4afb6ca5c167c8757bddf6dc44dd0f8bce7f8490 (diff) | |
| download | mrust-982826e4b309979bee8fe10f6ff537b4922e6316.tar.gz | |
Standalone MIRI - General improvements
Diffstat (limited to 'tools/standalone_miri/value.cpp')
| -rw-r--r-- | tools/standalone_miri/value.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/tools/standalone_miri/value.cpp b/tools/standalone_miri/value.cpp index 01f0fbbc..232613b7 100644 --- a/tools/standalone_miri/value.cpp +++ b/tools/standalone_miri/value.cpp @@ -540,7 +540,27 @@ void Allocation::write_bytes(size_t ofs, const void* src, size_t count) void Allocation::write_ptr(size_t ofs, size_t ptr_ofs, RelocationPtr reloc) { this->write_usize(ofs, ptr_ofs); - this->relocations.push_back(Relocation { ofs, /*POINTER_SIZE,*/ ::std::move(reloc) }); + this->set_reloc(ofs, POINTER_SIZE, ::std::move(reloc)); +} +void Allocation::set_reloc(size_t ofs, size_t len, RelocationPtr reloc) +{ + LOG_ASSERT(ofs % POINTER_SIZE == 0, ""); + LOG_ASSERT(len == POINTER_SIZE, ""); + // Delete any existing relocation at this position + for(auto it = this->relocations.begin(); it != this->relocations.end();) + { + if( ofs <= it->slot_ofs && it->slot_ofs < ofs + len ) + { + // Slot starts in this updated region + // - TODO: Split in half? + it = this->relocations.erase(it); + continue ; + } + // TODO: What if the slot ends in the new region? + // What if the new region is in the middle of the slot + ++ it; + } + this->relocations.push_back(Relocation { ofs, /*len,*/ ::std::move(reloc) }); } ::std::ostream& operator<<(::std::ostream& os, const Allocation& x) { @@ -664,6 +684,11 @@ Value Value::new_i32(int32_t v) { rv.write_i32(0, v); return rv; } +Value Value::new_i64(int64_t v) { + auto rv = Value( ::HIR::TypeRef(RawType::I64) ); + rv.write_i64(0, v); + return rv; +} void Value::create_allocation() { |
