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 Jun 14, 2024
1 parent dea5797 commit 903818c
Show file tree
Hide file tree
Showing 9 changed files with 2,309 additions and 379 deletions.
31 changes: 31 additions & 0 deletions notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
live_analysis

get-ből való kiindulás azért jobb mert valaminek be kell állítania az értékét

egy adott getből keresem vissza hogy milyen utakon lehet visszamenni az őt beállító utasításokig
multimap jó

listákban tartom az összes változóra a set-jeit és a get-jeit

jump + sets [T,p]
T - target, ahova ugrunk
p - position, ahonnan ugrottunk
+ listában a set-ek amelyek abban a blokban vannak

dump!!! - variableRange

[] hátra
() előre

s g
s ( g )

s [ ( g ) ]

[ (s ) g ]

[ s [ g ] g ] ( g )



s [ g ][ s g ]
35 changes: 35 additions & 0 deletions src/interpreter/ByteCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,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 @@ -707,6 +708,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 @@ -818,6 +827,7 @@ class CallIndirect : public ByteCode {
}

ByteCodeStackOffset calleeOffset() const { return m_calleeOffset; }
void setCalleeOffset(ByteCodeStackOffset o) { m_calleeOffset = o; }
uint32_t tableIndex() const { return m_tableIndex; }
FunctionType* functionType() const { return m_functionType; }
ByteCodeStackOffset* stackOffsets() const
Expand Down Expand Up @@ -876,6 +886,14 @@ class Move : 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;
}

protected:
ByteCodeStackOffset m_srcOffset;
Expand Down Expand Up @@ -977,7 +995,9 @@ class Load32 : public ByteCode {
}

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

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

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

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

ByteCodeStackOffset srcOffset() const { return m_srcOffset; }
void setSrcOffset(ByteCodeStackOffset o) { m_srcOffset = o; }
int32_t offset() const { return m_offset; }
void setOffset(int32_t offset)
{
Expand Down Expand Up @@ -1136,6 +1159,7 @@ class JumpIfFalse : public ByteCode {
}

ByteCodeStackOffset srcOffset() const { return m_srcOffset; }
void setSrcOffset(ByteCodeStackOffset o) { m_srcOffset = o; }
int32_t offset() const { return m_offset; }
void setOffset(int32_t offset)
{
Expand Down Expand Up @@ -1170,11 +1194,15 @@ class Select : public ByteCode {
}

ByteCodeStackOffset condOffset() const { return m_condOffset; }
void setCondOffset(ByteCodeStackOffset o) { m_condOffset = o; }
uint16_t valueSize() const { return m_valueSize; }
bool isFloat() const { return m_isFloat != 0; }
ByteCodeStackOffset src0Offset() const { return m_src0Offset; }
void setSrc0Offset(ByteCodeStackOffset o) { m_src0Offset = o; }
ByteCodeStackOffset src1Offset() const { return m_src1Offset; }
void setSrc1Offset(ByteCodeStackOffset o) { m_src1Offset = o; }
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
void setDstOffset(ByteCodeStackOffset o) { m_dstOffset = o; }

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

ByteCodeStackOffset condOffset() const { return m_condOffset; }
void setCondOffset(ByteCodeStackOffset o) { m_condOffset = o; }
int32_t defaultOffset() const { return m_defaultOffset; }
static inline size_t offsetOfDefault() { return offsetof(BrTable, m_defaultOffset); }

Expand Down Expand Up @@ -1414,7 +1443,9 @@ class MemoryLoad : public ByteCode {

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

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

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

#if !defined(NDEBUG)
void dump(size_t pos)
Expand Down Expand Up @@ -2063,6 +2096,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 @@ -2143,6 +2177,7 @@ class GlobalSet32 : public ByteCode {
{
}

void setSrcOffset(ByteCodeStackOffset o) { m_srcOffset = o; }
ByteCodeStackOffset srcOffset() const { return m_srcOffset; }
uint32_t index() const { return m_index; }

Expand Down
Loading

0 comments on commit 903818c

Please sign in to comment.