systemc: Remove a redundant injectException for Thread's throw_it.

For some reason lost to the sands of time, the throw_it function was
virtual for the Thread class, and that class would call the base
class's throw_it, and then also injectException itself. That would
result in the exception being injected into the thread twice which is
incorrect.

Since it's not clear what the original intention of this code was, the
throw_it function is now no longer virtual, and the one useful aspect
of it, a check if the process is already terminated, was moved into the
base class function.

Change-Id: I7fb14baa7728bd1e9206011870b6ccaa9c4e8c64
Reviewed-on: https://gem5-review.googlesource.com/c/13312
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
This commit is contained in:
Gabe Black
2018-10-06 02:58:02 -07:00
parent 9677f2da71
commit a7d99be947
5 changed files with 5 additions and 53 deletions

View File

@@ -37,7 +37,6 @@ if env['USE_SYSTEMC']:
Source('object.cc')
Source('port.cc')
Source('process.cc')
Source('process_types.cc')
Source('python.cc')
Source('scheduler.cc')
Source('sched_event.cc')

View File

@@ -206,9 +206,10 @@ Process::throw_it(ExceptionWrapperBase &exc, bool inc_kids)
if (inc_kids)
forEachKid([&exc](Process *p) { p->throw_it(exc, true); });
// Only inject an exception into threads that have started.
if (!_needsStart)
injectException(exc);
if (_needsStart || _terminated)
return;
injectException(exc);
}
void

View File

@@ -84,7 +84,7 @@ class Process : public ::sc_core::sc_process_b, public ListNode
void kill(bool inc_kids);
void reset(bool inc_kids);
virtual void throw_it(ExceptionWrapperBase &exc, bool inc_kids);
void throw_it(ExceptionWrapperBase &exc, bool inc_kids);
void injectException(ExceptionWrapperBase &exc);
ExceptionWrapperBase *excWrapper;

View File

@@ -1,46 +0,0 @@
/*
* Copyright 2018 Google, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Gabe Black
*/
#include "systemc/core/process_types.hh"
namespace sc_gem5
{
void
Thread::throw_it(ExceptionWrapperBase &exc, bool inc_kids)
{
Process::throw_it(exc, inc_kids);
if (_terminated)
return;
injectException(exc);
}
} // namespace sc_gem5

View File

@@ -63,8 +63,6 @@ class Thread : public Process
const char *kind() const override { return "sc_thread_process"; }
void throw_it(ExceptionWrapperBase &exc, bool inc_kids) override;
sc_core::sc_curr_proc_kind
procKind() const override
{