Skip to content

Commit

Permalink
[WIP] Implement live variable analysis
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Laszlo Kulcsar <kuladam@inf.u-szeged.hu>
  • Loading branch information
kulcsaradam committed Mar 19, 2024
1 parent a22a568 commit ddfeaf8
Show file tree
Hide file tree
Showing 6 changed files with 829 additions and 3 deletions.
29 changes: 28 additions & 1 deletion src/interpreter/ByteCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef __WalrusByteCode__
#define __WalrusByteCode__

#include "Walrus.h"
#if !defined(NDEBUG)
#include <cinttypes>
#include "runtime/Module.h"
Expand Down Expand Up @@ -663,6 +664,7 @@ class BinaryOperation : public ByteCode {
const ByteCodeStackOffset* srcOffset() const { return m_srcOffset; }
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
void setDstOffset(ByteCodeStackOffset o) { m_dstOffset = o; }
void setSrcOffset(ByteCodeStackOffset o, size_t index) { m_srcOffset[index] = o; }
#if !defined(NDEBUG)
void dump(size_t pos)
{
Expand Down Expand Up @@ -705,6 +707,14 @@ class UnaryOperation : public ByteCode {
}
ByteCodeStackOffset srcOffset() const { return m_srcOffset; }
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
void setDstOffset(ByteCodeStackOffset newOffset)
{
m_dstOffset = newOffset;
}
void setSrcOffset(ByteCodeStackOffset newOffset)
{
m_srcOffset = newOffset;
}
#if !defined(NDEBUG)
void dump(size_t pos)
{
Expand Down Expand Up @@ -874,6 +884,14 @@ class Move32 : public ByteCode {

ByteCodeStackOffset srcOffset() const { return m_srcOffset; }
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
void setDstOffset(ByteCodeStackOffset newOffset)
{
m_dstOffset = newOffset;
}
void setSrcOffset(ByteCodeStackOffset newOffset)
{
m_srcOffset = newOffset;
}

#if !defined(NDEBUG)
void dump(size_t pos)
Expand Down Expand Up @@ -951,7 +969,9 @@ class Load32 : public ByteCode {
}

ByteCodeStackOffset srcOffset() const { return m_srcOffset; }
void setSrcOffset(Walrus::ByteCodeStackOffset o) { m_srcOffset = o; }
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
void setDstOffset(Walrus::ByteCodeStackOffset o) { m_dstOffset = o; }

#if !defined(NDEBUG)
void dump(size_t pos)
Expand Down Expand Up @@ -1003,7 +1023,9 @@ class Store32 : public ByteCode {
}

ByteCodeStackOffset src0Offset() const { return m_src0Offset; }
void setSrc0Offset(Walrus::ByteCodeStackOffset o) { m_src0Offset = o; }
ByteCodeStackOffset src1Offset() const { return m_src1Offset; }
void setSrc1Offset(Walrus::ByteCodeStackOffset o) { m_src1Offset = o; }

#if !defined(NDEBUG)
void dump(size_t pos)
Expand Down Expand Up @@ -1388,7 +1410,9 @@ class MemoryLoad : public ByteCode {

uint32_t offset() const { return m_offset; }
ByteCodeStackOffset srcOffset() const { return m_srcOffset; }
void setSrcOffset(Walrus::ByteCodeStackOffset o) { m_srcOffset = o; }
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
void setDstOffset(Walrus::ByteCodeStackOffset o) { m_dstOffset = o; }

#if !defined(NDEBUG)
void dump(size_t pos)
Expand Down Expand Up @@ -1486,7 +1510,9 @@ class MemoryStore : public ByteCode {

uint32_t offset() const { return m_offset; }
ByteCodeStackOffset src0Offset() const { return m_src0Offset; }
void setSrc0Offset(Walrus::ByteCodeStackOffset o) { m_src0Offset = o; }
ByteCodeStackOffset src1Offset() const { return m_src1Offset; }
void setSrc1Offset(Walrus::ByteCodeStackOffset o) { m_src1Offset = o; }

#if !defined(NDEBUG)
void dump(size_t pos)
Expand Down Expand Up @@ -2037,6 +2063,7 @@ class GlobalGet32 : public ByteCode {
}

ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
void setDstOffset(ByteCodeStackOffset o) { m_dstOffset = o; }
uint32_t index() const { return m_index; }

#if !defined(NDEBUG)
Expand Down Expand Up @@ -2255,7 +2282,7 @@ class End : public ByteCode {
{
}

ByteCodeStackOffset* resultOffsets() const
ByteCodeStackOffset* resultOffsets()
{
return reinterpret_cast<ByteCodeStackOffset*>(reinterpret_cast<size_t>(this) + sizeof(End));
}
Expand Down
Loading

0 comments on commit ddfeaf8

Please sign in to comment.