Skip to content

Commit cc6501c

Browse files
committed
Start rewriting live analysis
Signed-off-by: Ádám László Kulcsár <[email protected]>
1 parent b9ee310 commit cc6501c

File tree

14 files changed

+1837
-40
lines changed

14 files changed

+1837
-40
lines changed

src/interpreter/ByteCode.cpp

Lines changed: 640 additions & 6 deletions
Large diffs are not rendered by default.

src/interpreter/ByteCode.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef __WalrusByteCode__
1818
#define __WalrusByteCode__
1919

20+
#include "Walrus.h"
2021
#if !defined(NDEBUG)
2122
#include <cinttypes>
2223
#include "runtime/Module.h"
@@ -932,6 +933,12 @@ class ByteCode {
932933

933934
Opcode opcode() const;
934935
size_t getSize() const;
936+
std::vector<Walrus::ByteCodeStackOffset> getByteCodeStackOffsets(FunctionType* funcType) const;
937+
void setByteCodeOffset(size_t index, Walrus::ByteCodeStackOffset offset, Walrus::ByteCodeStackOffset original);
938+
void dump() const
939+
{
940+
return;
941+
}
935942

936943
protected:
937944
friend class Interpreter;
@@ -964,6 +971,8 @@ class ByteCodeOffset2 : public ByteCode {
964971

965972
ByteCodeStackOffset stackOffset1() const { return m_stackOffset1; }
966973
ByteCodeStackOffset stackOffset2() const { return m_stackOffset2; }
974+
void setStackOffset1(Walrus::ByteCodeStackOffset o) { m_stackOffset1 = o; }
975+
void setStackOffset2(Walrus::ByteCodeStackOffset o) { m_stackOffset2 = o; }
967976

968977
protected:
969978
ByteCodeStackOffset m_stackOffset1;
@@ -982,6 +991,7 @@ class ByteCodeOffset3 : public ByteCode {
982991
ByteCodeStackOffset stackOffset1() const { return m_stackOffsets[0]; }
983992
ByteCodeStackOffset stackOffset2() const { return m_stackOffsets[1]; }
984993
ByteCodeStackOffset stackOffset3() const { return m_stackOffsets[2]; }
994+
void setStackOffset(uint8_t index, Walrus::ByteCodeStackOffset o) { m_stackOffsets[index] = o; }
985995

986996
protected:
987997
ByteCodeStackOffset m_stackOffsets[3];
@@ -997,6 +1007,7 @@ class ByteCodeOffsetValue : public ByteCode {
9971007
}
9981008

9991009
ByteCodeStackOffset stackOffset() const { return m_stackOffset; }
1010+
void setStackOffset(ByteCodeStackOffset o) { m_stackOffset = o; }
10001011
uint32_t uint32Value() const { return m_value; }
10011012
int32_t int32Value() const { return static_cast<int32_t>(m_value); }
10021013

@@ -1016,7 +1027,9 @@ class ByteCodeOffset2Value : public ByteCode {
10161027
}
10171028

10181029
ByteCodeStackOffset stackOffset1() const { return m_stackOffset1; }
1030+
void setStackOffset1(ByteCodeStackOffset o) { m_stackOffset1 = o; }
10191031
ByteCodeStackOffset stackOffset2() const { return m_stackOffset2; }
1032+
void setStackOffset2(ByteCodeStackOffset o) { m_stackOffset2 = o; }
10201033
uint32_t uint32Value() const { return m_value; }
10211034
int32_t int32Value() const { return static_cast<int32_t>(m_value); }
10221035

@@ -1041,7 +1054,9 @@ class ByteCodeOffset2ValueMemIdx : public ByteCode {
10411054
uint16_t memIndex() const { return m_memIndex; }
10421055
uint16_t alignment() const { return m_alignment; }
10431056
ByteCodeStackOffset stackOffset1() const { return m_stackOffset1; }
1057+
void setStackOffset1(ByteCodeStackOffset o) { m_stackOffset1 = o; }
10441058
ByteCodeStackOffset stackOffset2() const { return m_stackOffset2; }
1059+
void setStackOffset2(ByteCodeStackOffset o) { m_stackOffset2 = o; }
10451060
uint32_t uint32Value() const { return m_value; }
10461061
int32_t int32Value() const { return static_cast<int32_t>(m_value); }
10471062

@@ -1066,6 +1081,7 @@ class ByteCodeOffset4 : public ByteCode {
10661081
ByteCodeStackOffset src1Offset() const { return m_stackOffsets[1]; }
10671082
ByteCodeStackOffset src2Offset() const { return m_stackOffsets[2]; }
10681083
ByteCodeStackOffset dstOffset() const { return m_stackOffsets[3]; }
1084+
void setStackOffset(size_t index, ByteCodeStackOffset o) { m_stackOffsets[index] = o; }
10691085

10701086
protected:
10711087
ByteCodeStackOffset m_stackOffsets[4];
@@ -1235,6 +1251,7 @@ class BinaryOperation : public ByteCodeOffset3 {
12351251
const ByteCodeStackOffset* srcOffset() const { return stackOffsets(); }
12361252
ByteCodeStackOffset dstOffset() const { return stackOffset3(); }
12371253
void setDstOffset(ByteCodeStackOffset o) { m_stackOffsets[2] = o; }
1254+
void setSrcOffsset(ByteCodeStackOffset o, size_t index) { m_stackOffsets[index] = o; }
12381255
#if !defined(NDEBUG)
12391256
void dump(size_t pos)
12401257
{
@@ -1394,6 +1411,11 @@ class Call : public ByteCode {
13941411
return reinterpret_cast<ByteCodeStackOffset*>(reinterpret_cast<size_t>(this) + sizeof(Call));
13951412
}
13961413

1414+
void setStackOffset(size_t index, ByteCodeStackOffset o)
1415+
{
1416+
reinterpret_cast<ByteCodeStackOffset*>(reinterpret_cast<size_t>(this) + sizeof(Call))[index] = o;
1417+
}
1418+
13971419
uint16_t parameterOffsetsSize() const
13981420
{
13991421
return m_parameterOffsetsSize;
@@ -1444,13 +1466,21 @@ class CallIndirect : public ByteCode {
14441466
}
14451467

14461468
ByteCodeStackOffset calleeOffset() const { return m_calleeOffset; }
1469+
void setCalleeOffset(ByteCodeStackOffset o) { m_calleeOffset = o; }
14471470
uint32_t tableIndex() const { return m_tableIndex; }
14481471
FunctionType* functionType() const { return m_functionType; }
14491472
ByteCodeStackOffset* stackOffsets() const
14501473
{
14511474
return reinterpret_cast<ByteCodeStackOffset*>(reinterpret_cast<size_t>(this) + sizeof(CallIndirect));
14521475
}
14531476

1477+
void setStackOffset(size_t index, ByteCodeStackOffset o)
1478+
{
1479+
(reinterpret_cast<ByteCodeStackOffset*>(reinterpret_cast<size_t>(this) + sizeof(CallIndirect)))[index] = o;
1480+
1481+
// *(reinterpret_cast<ByteCodeStackOffset*>(reinterpret_cast<size_t>(this) + sizeof(Call) + index * sizeof(ByteCodeStackOffset))) = o;
1482+
}
1483+
14541484
uint16_t parameterOffsetsSize() const
14551485
{
14561486
return m_parameterOffsetsSize;
@@ -1761,11 +1791,15 @@ class Select : public ByteCode {
17611791
}
17621792

17631793
ByteCodeStackOffset condOffset() const { return m_condOffset; }
1794+
void setCondOffset(ByteCodeStackOffset o) { m_condOffset = o; }
17641795
uint16_t valueSize() const { return m_valueSize; }
17651796
bool isFloat() const { return m_isFloat != 0; }
17661797
ByteCodeStackOffset src0Offset() const { return m_src0Offset; }
1798+
void setSrc0Offset(ByteCodeStackOffset o) { m_src0Offset = o; }
17671799
ByteCodeStackOffset src1Offset() const { return m_src1Offset; }
1800+
void setSrc1Offset(ByteCodeStackOffset o) { m_src1Offset = o; }
17681801
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
1802+
void setDstOffset(ByteCodeStackOffset o) { m_dstOffset = o; }
17691803

17701804
#if !defined(NDEBUG)
17711805
void dump(size_t pos)
@@ -1798,6 +1832,7 @@ class BrTable : public ByteCode {
17981832
}
17991833

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

@@ -1871,6 +1906,10 @@ class MemoryInit : public ByteCode {
18711906
{
18721907
return m_srcOffsets;
18731908
}
1909+
void setStackOffset(size_t index, ByteCodeStackOffset o)
1910+
{
1911+
m_srcOffsets[index] = o;
1912+
}
18741913

18751914
uint16_t memIndex() const { return m_memIndex; }
18761915

@@ -3110,6 +3149,10 @@ class TableCopy : public ByteCode {
31103149
{
31113150
return m_srcOffsets;
31123151
}
3152+
void setStackOffset(size_t index, ByteCodeStackOffset o)
3153+
{
3154+
m_srcOffsets[index] = o;
3155+
}
31133156

31143157
#if !defined(NDEBUG)
31153158
void dump(size_t pos)
@@ -3174,6 +3217,11 @@ class TableInit : public ByteCode {
31743217
{
31753218
return m_srcOffsets;
31763219
}
3220+
void setStackOffset(size_t index, ByteCodeStackOffset o)
3221+
{
3222+
m_srcOffsets[index] = o;
3223+
}
3224+
31773225
#if !defined(NDEBUG)
31783226
void dump(size_t pos)
31793227
{
@@ -3391,6 +3439,10 @@ class Throw : public ByteCode {
33913439
{
33923440
return reinterpret_cast<ByteCodeStackOffset*>(reinterpret_cast<size_t>(this) + sizeof(Throw));
33933441
}
3442+
void setDataOffset(size_t index, ByteCodeStackOffset o)
3443+
{
3444+
reinterpret_cast<ByteCodeStackOffset*>(reinterpret_cast<size_t>(this) + sizeof(Throw))[index] = o;
3445+
}
33943446

33953447
uint32_t offsetsSize() const
33963448
{
@@ -3466,6 +3518,11 @@ class End : public ByteCode {
34663518
return reinterpret_cast<ByteCodeStackOffset*>(reinterpret_cast<size_t>(this) + sizeof(End));
34673519
}
34683520

3521+
void setResultOffset(size_t index, ByteCodeStackOffset o)
3522+
{
3523+
reinterpret_cast<ByteCodeStackOffset*>(reinterpret_cast<size_t>(this) + sizeof(End))[index] = o;
3524+
}
3525+
34693526
uint32_t offsetsSize() const
34703527
{
34713528
return m_offsetsSize;

src/jit/Backend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void JITArg::set(Operand* operand)
9898
Instruction* instr = VARIABLE_GET_IMM(*operand);
9999

100100
#if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
101-
ASSERT(instr->opcode() == ByteCode::Const32Opcode);
101+
// ASSERT(instr->opcode() == ByteCode::Const32Opcode);
102102

103103
this->argw = static_cast<sljit_s32>(reinterpret_cast<Const32*>(instr->byteCode())->value());
104104
#else /* !SLJIT_32BIT_ARCHITECTURE */

0 commit comments

Comments
 (0)