From cea6dd61e148512d3d5cf513e4d45d64c2133d1b Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sun, 11 Aug 2024 22:37:49 +0100 Subject: [PATCH] Make VMFrame an AbstractVMObject MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It doesn’t need to be a VMObject, and ideally it wouldn’t be a AbstractVMObject either, but one step after another. Signed-off-by: Stefan Marr --- src/unitTests/CloneObjectsTest.cpp | 3 --- src/vmobjects/ObjectFormats.h | 2 +- src/vmobjects/VMFrame.cpp | 2 -- src/vmobjects/VMFrame.h | 19 +++++++++++++++++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/unitTests/CloneObjectsTest.cpp b/src/unitTests/CloneObjectsTest.cpp index 3b6c3400..0a326024 100644 --- a/src/unitTests/CloneObjectsTest.cpp +++ b/src/unitTests/CloneObjectsTest.cpp @@ -215,11 +215,8 @@ void CloneObjectsTest::testCloneFrame() { VMFrame* clone = orig->CloneForMovingGC(); CPPUNIT_ASSERT((intptr_t)orig != (intptr_t)clone); - CPPUNIT_ASSERT_EQUAL_MESSAGE("class differs!!", orig->clazz, clone->clazz); CPPUNIT_ASSERT_EQUAL_MESSAGE("objectSize differs!!", orig->totalObjectSize, clone->totalObjectSize); - CPPUNIT_ASSERT_EQUAL_MESSAGE("numberOfFields differs!!", - orig->numberOfFields, clone->numberOfFields); CPPUNIT_ASSERT_EQUAL_MESSAGE("GetPreviousFrame differs!!", orig->GetPreviousFrame(), clone->GetPreviousFrame()); diff --git a/src/vmobjects/ObjectFormats.h b/src/vmobjects/ObjectFormats.h index 5d855dc5..b0cd850d 100644 --- a/src/vmobjects/ObjectFormats.h +++ b/src/vmobjects/ObjectFormats.h @@ -141,7 +141,7 @@ typedef GCOop* gc_oop_t; // clang-format off class GCAbstractObject : public GCOop { public: typedef AbstractVMObject Loaded; }; class GCObject : public GCAbstractObject { public: typedef VMObject Loaded; }; -class GCFrame : public GCObject { public: typedef VMFrame Loaded; }; +class GCFrame : public GCAbstractObject { public: typedef VMFrame Loaded; }; class GCClass : public GCObject { public: typedef VMClass Loaded; }; class GCArray : public GCObject { public: typedef VMArray Loaded; }; class GCBlock : public GCObject { public: typedef VMBlock Loaded; }; diff --git a/src/vmobjects/VMFrame.cpp b/src/vmobjects/VMFrame.cpp index ff911c89..5ef396bf 100644 --- a/src/vmobjects/VMFrame.cpp +++ b/src/vmobjects/VMFrame.cpp @@ -55,8 +55,6 @@ VMFrame* VMFrame::EmergencyFrameFrom(VMFrame* from, long extraLength) { VMFrame* result = new (GetHeap(), additionalBytes) VMFrame(additionalBytes, method, from->GetPreviousFrame()); - result->clazz = nullptr; // result->SetClass(from->GetClass()); - // set Frame members result->SetContext(from->GetContext()); result->stack_ptr = diff --git a/src/vmobjects/VMFrame.h b/src/vmobjects/VMFrame.h index a6e853d9..86bb0ba0 100644 --- a/src/vmobjects/VMFrame.h +++ b/src/vmobjects/VMFrame.h @@ -31,7 +31,7 @@ class Universe; -class VMFrame : public VMObject { +class VMFrame : public AbstractVMObject { friend class Universe; friend class Interpreter; friend class Shell; @@ -44,7 +44,7 @@ class VMFrame : public VMObject { explicit VMFrame(size_t additionalBytes, VMMethod* method, VMFrame* previousFrame) - : VMObject(0, additionalBytes + sizeof(VMFrame)), bytecodeIndex(0), + : totalObjectSize(additionalBytes + sizeof(VMFrame)), bytecodeIndex(0), previousFrame(store_root(previousFrame)), context(nullptr), method(store_root(method)), arguments((gc_oop_t*)&(stack_ptr) + 1), locals(arguments + method->GetNumberOfArguments()), @@ -60,6 +60,20 @@ class VMFrame : public VMObject { } } + int64_t GetHash() const final { return 0; /* should never be called */ } + + inline VMClass* GetClass() const final { return nullptr; } + + inline size_t GetObjectSize() const final { return totalObjectSize; } + + void MarkObjectAsInvalid() final { + previousFrame = (GCFrame*)INVALID_GC_POINTER; + } + + bool IsMarkedInvalid() const final { + return previousFrame == (GCFrame*)INVALID_GC_POINTER; + } + inline VMFrame* GetPreviousFrame() const; inline void ClearPreviousFrame(); inline bool HasPreviousFrame() const; @@ -156,6 +170,7 @@ class VMFrame : public VMObject { make_testable(public); long bytecodeIndex; + size_t totalObjectSize; private: GCFrame* previousFrame;