From 494f6a858e47db3e5352468f504e82af01b931f9 Mon Sep 17 00:00:00 2001 From: Jason Power Date: Tue, 28 Aug 2012 17:57:51 -0500 Subject: Ruby: Correct DataBlock =operator The =operator for the DataBlock class was incorrectly interpreting the class member m_alloc. This variable stands for whether the assigned memory for the data block needs to be freed or not by the class itself. It seems that the =operator interpreted the variable as whether the memory is assigned to the data block. This wrong interpretation was causing values not to propagate to RubySystem::m_mem_vec_ptr. This caused major issues with restoring from checkpoints when using a protocol which verified that the cache data was consistent with the backing store (i.e. MOESI-hammer). --- src/mem/ruby/common/DataBlock.cc | 10 +--------- src/mem/ruby/common/DataBlock.hh | 2 ++ 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'src/mem/ruby/common') diff --git a/src/mem/ruby/common/DataBlock.cc b/src/mem/ruby/common/DataBlock.cc index 5aba4332a..59a0f692a 100644 --- a/src/mem/ruby/common/DataBlock.cc +++ b/src/mem/ruby/common/DataBlock.cc @@ -87,14 +87,6 @@ DataBlock::setData(uint8* data, int offset, int len) DataBlock & DataBlock::operator=(const DataBlock & obj) { - if (this == &obj) { - // assert(false); - } else { - if (!m_alloc) - m_data = new uint8[RubySystem::getBlockSizeBytes()]; - memcpy(m_data, obj.m_data, RubySystem::getBlockSizeBytes()); - m_alloc = true; - } - + memcpy(m_data, obj.m_data, RubySystem::getBlockSizeBytes()); return *this; } diff --git a/src/mem/ruby/common/DataBlock.hh b/src/mem/ruby/common/DataBlock.hh index 7bd92710d..0ab4cfc01 100644 --- a/src/mem/ruby/common/DataBlock.hh +++ b/src/mem/ruby/common/DataBlock.hh @@ -29,6 +29,7 @@ #ifndef __MEM_RUBY_COMMON_DATABLOCK_HH__ #define __MEM_RUBY_COMMON_DATABLOCK_HH__ +#include #include #include @@ -72,6 +73,7 @@ class DataBlock inline void DataBlock::assign(uint8* data) { + assert(data != NULL); if (m_alloc) { delete [] m_data; } -- cgit v1.2.3