arch-arm: Speedup ARM execution by avoiding expensive RTTI check
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Wed, 26 Feb 2020 13:46:24 +0000 (13:46 +0000)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Tue, 10 Mar 2020 11:24:13 +0000 (11:24 +0000)
getArmSystem is the building block for a lot of ArmSystem getters
a client can use to check for a specific feature.
This method is called very often during simulation and it is basically
casting a System pointer into an ArmSystem pointer.
To do so, it is using dynamic casting to check if the system is really
an ArmSystem. This is very expensive and usually not needed.

The only chance arm code would use a non ArmSystem is when in SE mode.
But if that's the case, we can just replace the assertion with a

assert(FullSystem).

Testing Linux boot with this patch provides a speedup of nearly 2x!
(atomic mode).

This is partially related to:

JIRA: https://gem5.atlassian.net/browse/GEM5-337

Since the PAuth patch changed the purifyTagged helper (on the critical
path of simulation) to rely more heavilly on getArmSystem (via
ArmSystem:: static methods)

Change-Id: Idbf079548ffe03513b4fc58c76f0d69613952a50
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Ciro Santilli <ciro.santilli@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/25964
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/arm/system.cc

index d4013391684010a3e7ea942da79454444dd4d8ef..f9bfdec929c63e3fbce811096a3454ee3ee8888e 100644 (file)
@@ -183,9 +183,8 @@ ArmSystem::initState()
 ArmSystem*
 ArmSystem::getArmSystem(ThreadContext *tc)
 {
-    ArmSystem *a_sys = dynamic_cast<ArmSystem *>(tc->getSystemPtr());
-    assert(a_sys);
-    return a_sys;
+    assert(FullSystem);
+    return static_cast<ArmSystem *>(tc->getSystemPtr());
 }
 
 bool