Skip to content

Commit bfdbb4c

Browse files
committed
[WIP] Implement live variable analysis
Signed-off-by: Adam Laszlo Kulcsar <[email protected]>
1 parent a22a568 commit bfdbb4c

File tree

6 files changed

+894
-3
lines changed

6 files changed

+894
-3
lines changed

src/interpreter/ByteCode.h

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ class BinaryOperation : public ByteCode {
663663
const ByteCodeStackOffset* srcOffset() const { return m_srcOffset; }
664664
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
665665
void setDstOffset(ByteCodeStackOffset o) { m_dstOffset = o; }
666+
void setSrcOffset(ByteCodeStackOffset o, size_t index) { m_srcOffset[index] = o; }
666667
#if !defined(NDEBUG)
667668
void dump(size_t pos)
668669
{
@@ -705,6 +706,14 @@ class UnaryOperation : public ByteCode {
705706
}
706707
ByteCodeStackOffset srcOffset() const { return m_srcOffset; }
707708
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
709+
void setDstOffset(ByteCodeStackOffset newOffset)
710+
{
711+
m_dstOffset = newOffset;
712+
}
713+
void setSrcOffset(ByteCodeStackOffset newOffset)
714+
{
715+
m_srcOffset = newOffset;
716+
}
708717
#if !defined(NDEBUG)
709718
void dump(size_t pos)
710719
{
@@ -874,6 +883,14 @@ class Move32 : public ByteCode {
874883

875884
ByteCodeStackOffset srcOffset() const { return m_srcOffset; }
876885
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
886+
void setDstOffset(ByteCodeStackOffset newOffset)
887+
{
888+
m_dstOffset = newOffset;
889+
}
890+
void setSrcOffset(ByteCodeStackOffset newOffset)
891+
{
892+
m_srcOffset = newOffset;
893+
}
877894

878895
#if !defined(NDEBUG)
879896
void dump(size_t pos)
@@ -951,7 +968,9 @@ class Load32 : public ByteCode {
951968
}
952969

953970
ByteCodeStackOffset srcOffset() const { return m_srcOffset; }
971+
void setSrcOffset(ByteCodeStackOffset o) { m_srcOffset = o; }
954972
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
973+
void setDstOffset(ByteCodeStackOffset o) { m_dstOffset = o; }
955974

956975
#if !defined(NDEBUG)
957976
void dump(size_t pos)
@@ -1003,7 +1022,9 @@ class Store32 : public ByteCode {
10031022
}
10041023

10051024
ByteCodeStackOffset src0Offset() const { return m_src0Offset; }
1025+
void setSrc0Offset(ByteCodeStackOffset o) { m_src0Offset = o; }
10061026
ByteCodeStackOffset src1Offset() const { return m_src1Offset; }
1027+
void setSrc1Offset(ByteCodeStackOffset o) { m_src1Offset = o; }
10071028

10081029
#if !defined(NDEBUG)
10091030
void dump(size_t pos)
@@ -1144,11 +1165,15 @@ class Select : public ByteCode {
11441165
}
11451166

11461167
ByteCodeStackOffset condOffset() const { return m_condOffset; }
1168+
void setCondOffset(ByteCodeStackOffset o) { m_condOffset = o; }
11471169
uint16_t valueSize() const { return m_valueSize; }
11481170
bool isFloat() const { return m_isFloat != 0; }
11491171
ByteCodeStackOffset src0Offset() const { return m_src0Offset; }
1172+
void setSrc0Offset(ByteCodeStackOffset o) { m_src0Offset = o; }
11501173
ByteCodeStackOffset src1Offset() const { return m_src1Offset; }
1174+
void setSrc1Offset(ByteCodeStackOffset o) { m_src1Offset = o; }
11511175
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
1176+
void setDstOffset(ByteCodeStackOffset o) { m_dstOffset = o; }
11521177

11531178
#if !defined(NDEBUG)
11541179
void dump(size_t pos)
@@ -1388,7 +1413,9 @@ class MemoryLoad : public ByteCode {
13881413

13891414
uint32_t offset() const { return m_offset; }
13901415
ByteCodeStackOffset srcOffset() const { return m_srcOffset; }
1416+
void setSrcOffset(ByteCodeStackOffset o) { m_srcOffset = o; }
13911417
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
1418+
void setDstOffset(ByteCodeStackOffset o) { m_dstOffset = o; }
13921419

13931420
#if !defined(NDEBUG)
13941421
void dump(size_t pos)
@@ -1486,7 +1513,9 @@ class MemoryStore : public ByteCode {
14861513

14871514
uint32_t offset() const { return m_offset; }
14881515
ByteCodeStackOffset src0Offset() const { return m_src0Offset; }
1516+
void setSrc0Offset(ByteCodeStackOffset o) { m_src0Offset = o; }
14891517
ByteCodeStackOffset src1Offset() const { return m_src1Offset; }
1518+
void setSrc1Offset(ByteCodeStackOffset o) { m_src1Offset = o; }
14901519

14911520
#if !defined(NDEBUG)
14921521
void dump(size_t pos)
@@ -2037,6 +2066,7 @@ class GlobalGet32 : public ByteCode {
20372066
}
20382067

20392068
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
2069+
void setDstOffset(ByteCodeStackOffset o) { m_dstOffset = o; }
20402070
uint32_t index() const { return m_index; }
20412071

20422072
#if !defined(NDEBUG)
@@ -2255,7 +2285,7 @@ class End : public ByteCode {
22552285
{
22562286
}
22572287

2258-
ByteCodeStackOffset* resultOffsets() const
2288+
ByteCodeStackOffset* resultOffsets()
22592289
{
22602290
return reinterpret_cast<ByteCodeStackOffset*>(reinterpret_cast<size_t>(this) + sizeof(End));
22612291
}

0 commit comments

Comments
 (0)