summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendiadyoin1 <leon2002.la@gmail.com>2021-07-23 14:22:19 +0200
committerLinus Groh <mail@linusgroh.de>2021-11-07 22:42:23 +0000
commit83f50a1507cd7d1015828f72d490cb53c3a2c98f (patch)
treed8201c59a0b0deb84e177522234c4d4964cf681d
parent0d6d780183959ac14504614ae5608d1e024f69d4 (diff)
downloadserenity-83f50a1507cd7d1015828f72d490cb53c3a2c98f.zip
UserspaceEmulator: Raise an error on FPU stack underflow
Accessing an unset part of the FPU stack should not be a simple warning, but should trigger the FPU exception mechanism.
-rw-r--r--Userland/DevTools/UserspaceEmulator/SoftCPU.h2
-rw-r--r--Userland/DevTools/UserspaceEmulator/SoftFPU.cpp14
-rw-r--r--Userland/DevTools/UserspaceEmulator/SoftFPU.h5
3 files changed, 6 insertions, 15 deletions
diff --git a/Userland/DevTools/UserspaceEmulator/SoftCPU.h b/Userland/DevTools/UserspaceEmulator/SoftCPU.h
index 07b85a7034..086b9779bf 100644
--- a/Userland/DevTools/UserspaceEmulator/SoftCPU.h
+++ b/Userland/DevTools/UserspaceEmulator/SoftCPU.h
@@ -267,7 +267,7 @@ public:
ValueWithShadow<u8> dl() const { return const_gpr8(X86::RegisterDL); }
ValueWithShadow<u8> dh() const { return const_gpr8(X86::RegisterDH); }
- long double fpu_get(u8 index) const { return m_fpu.fpu_get(index); }
+ long double fpu_get(u8 index) { return m_fpu.fpu_get(index); }
long double fpu_pop() { return m_fpu.fpu_pop(); }
MMX mmx_get(u8 index) const { return m_fpu.mmx_get(index); };
diff --git a/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp b/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp
index ba63dd5fe9..91f9d4dd9c 100644
--- a/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp
+++ b/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp
@@ -38,15 +38,6 @@ ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, const char* messag
namespace UserspaceEmulator {
-ALWAYS_INLINE void SoftFPU::warn_if_fpu_not_set_absolute(u8 index) const
-{
- if (!fpu_is_set(index)) [[unlikely]] {
- // FIXME: Are we supposed to set a flag here?
- // We might need to raise a stack underflow here
- reportln("\033[31;1mWarning! Read of uninitialized value on the FPU Stack ({} abs)\033[0m\n", index);
- m_emulator.dump_backtrace();
- }
-}
ALWAYS_INLINE void SoftFPU::warn_if_mmx_absolute(u8 index) const
{
if (m_reg_is_mmx[index]) [[unlikely]] {
@@ -62,10 +53,11 @@ ALWAYS_INLINE void SoftFPU::warn_if_fpu_absolute(u8 index) const
}
}
-ALWAYS_INLINE long double SoftFPU::fpu_get(u8 index) const
+ALWAYS_INLINE long double SoftFPU::fpu_get(u8 index)
{
VERIFY(index < 8);
- warn_if_fpu_not_set_absolute(index);
+ if (!fpu_is_set(index))
+ fpu_set_stack_underflow();
warn_if_mmx_absolute(index);
u8 effective_index = (m_fpu_stack_top + index) % 8;
diff --git a/Userland/DevTools/UserspaceEmulator/SoftFPU.h b/Userland/DevTools/UserspaceEmulator/SoftFPU.h
index dbd19da11b..d5e4eaf42f 100644
--- a/Userland/DevTools/UserspaceEmulator/SoftFPU.h
+++ b/Userland/DevTools/UserspaceEmulator/SoftFPU.h
@@ -48,7 +48,7 @@ public:
ALWAYS_INLINE void set_c2(bool val) { m_fpu_c2 = val; }
ALWAYS_INLINE void set_c3(bool val) { m_fpu_c3 = val; }
- long double fpu_get(u8 index) const;
+ long double fpu_get(u8 index);
void fpu_push(long double value);
long double fpu_pop();
@@ -246,7 +246,7 @@ private:
set_tag_from_value_absolute((m_fpu_stack_top + index) % 8, val);
}
- ALWAYS_INLINE bool fpu_isnan(u8 index) const
+ ALWAYS_INLINE bool fpu_isnan(u8 index)
{
return isnan(fpu_get(index));
}
@@ -279,7 +279,6 @@ private:
}
void warn_if_mmx_absolute(u8 index) const;
void warn_if_fpu_absolute(u8 index) const;
- void warn_if_fpu_not_set_absolute(u8 index) const;
void mmx_common() { m_fpu_tw = 0; }