Skip to content

Commit

Permalink
Make VMFrame an AbstractVMObject
Browse files Browse the repository at this point in the history
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 <git@stefan-marr.de>
  • Loading branch information
smarr committed Aug 11, 2024
1 parent 3ea7997 commit cea6dd6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
3 changes: 0 additions & 3 deletions src/unitTests/CloneObjectsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/vmobjects/ObjectFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; };
Expand Down
2 changes: 0 additions & 2 deletions src/vmobjects/VMFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ VMFrame* VMFrame::EmergencyFrameFrom(VMFrame* from, long extraLength) {
VMFrame* result = new (GetHeap<HEAP_CLS>(), additionalBytes)
VMFrame(additionalBytes, method, from->GetPreviousFrame());

result->clazz = nullptr; // result->SetClass(from->GetClass());

// set Frame members
result->SetContext(from->GetContext());
result->stack_ptr =
Expand Down
19 changes: 17 additions & 2 deletions src/vmobjects/VMFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

class Universe;

class VMFrame : public VMObject {
class VMFrame : public AbstractVMObject {
friend class Universe;
friend class Interpreter;
friend class Shell;
Expand All @@ -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()),
Expand All @@ -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;
Expand Down Expand Up @@ -156,6 +170,7 @@ class VMFrame : public VMObject {
make_testable(public);

long bytecodeIndex;
size_t totalObjectSize;

private:
GCFrame* previousFrame;
Expand Down

0 comments on commit cea6dd6

Please sign in to comment.