-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathBytecodeGenerationTest.h
198 lines (157 loc) · 6.48 KB
/
BytecodeGenerationTest.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#pragma once
#include <cppunit/extensions/HelperMacros.h>
#include "../compiler/ClassGenerationContext.h"
#include "../compiler/MethodGenerationContext.h"
#include "../interpreter/bytecodes.h"
#include "TestWithParsing.h"
class BytecodeGenerationTest : public TestWithParsing {
// NOLINTNEXTLINE(misc-const-correctness)
CPPUNIT_TEST_SUITE(BytecodeGenerationTest);
CPPUNIT_TEST(testEmptyMethodReturnsSelf);
CPPUNIT_TEST(testPushConstant);
CPPUNIT_TEST(testIfPushConstantSame);
CPPUNIT_TEST(testIfPushConstantDifferent);
CPPUNIT_TEST(testExplicitReturnSelf);
CPPUNIT_TEST(testDupPopArgumentPop);
CPPUNIT_TEST(testDupPopArgumentPopImplicitReturnSelf);
CPPUNIT_TEST(testDupPopLocalPop);
CPPUNIT_TEST(testDupPopField0Pop);
CPPUNIT_TEST(testDupPopFieldPop);
CPPUNIT_TEST(testDupPopFieldReturnSelf);
CPPUNIT_TEST(testDupPopFieldNReturnSelf);
CPPUNIT_TEST(testSendDupPopFieldReturnLocal);
CPPUNIT_TEST(testSendDupPopFieldReturnLocalPeriod);
CPPUNIT_TEST(testBlockDupPopArgumentPopReturnArg);
CPPUNIT_TEST(testBlockDupPopArgumentImplicitReturn);
CPPUNIT_TEST(testBlockDupPopArgumentImplicitReturnDot);
CPPUNIT_TEST(testBlockDupPopLocalReturnLocal);
CPPUNIT_TEST(testBlockDupPopFieldReturnLocal);
CPPUNIT_TEST(testBlockDupPopFieldReturnLocalDot);
CPPUNIT_TEST(testPushLocalOpt);
CPPUNIT_TEST(testPushArgOpt);
CPPUNIT_TEST(testPushFieldOpt);
CPPUNIT_TEST(testBlockPushFieldOpt);
CPPUNIT_TEST(testPopLocalOpt);
CPPUNIT_TEST(testPopFieldOpt);
CPPUNIT_TEST(testWhileInliningWhileTrue);
CPPUNIT_TEST(testWhileInliningWhileFalse);
CPPUNIT_TEST(testInliningWhileLoopsWithExpandingBranches);
CPPUNIT_TEST(testInliningWhileLoopsWithContractingBranches);
CPPUNIT_TEST(testIfInlineAndConstantBcLength);
CPPUNIT_TEST(testIfTrueWithLiteralReturn);
CPPUNIT_TEST(testIfTrueWithSomethingAndLiteralReturn);
CPPUNIT_TEST(testIfTrueIfFalseArg);
CPPUNIT_TEST(testIfTrueIfFalseNlrArg1);
CPPUNIT_TEST(testIfTrueIfFalseNlrArg2);
CPPUNIT_TEST(testInliningOfOr);
CPPUNIT_TEST(testInliningOfAnd);
CPPUNIT_TEST(testInliningOfToDo);
CPPUNIT_TEST(testToDoBlockBlockInlinedSelf);
CPPUNIT_TEST(testToDoWithMoreEmbeddedBlocksAndArgAccess);
CPPUNIT_TEST(testIfArg);
CPPUNIT_TEST(testKeywordIfTrueArg);
CPPUNIT_TEST(testIfReturnNonLocal);
CPPUNIT_TEST(testJumpQueuesOrdering);
CPPUNIT_TEST(testNestedIfs);
CPPUNIT_TEST(testNestedIfsAndLocals);
CPPUNIT_TEST(testIncDecBytecodes);
CPPUNIT_TEST(testIfTrueAndIncField);
CPPUNIT_TEST(testIfTrueAndIncArg);
CPPUNIT_TEST(testFieldReadInlining);
CPPUNIT_TEST(testReturnField);
CPPUNIT_TEST(testTrivialMethodInlining);
CPPUNIT_TEST(testBlockIfTrueArg);
CPPUNIT_TEST(testBlockIfTrueMethodArg);
CPPUNIT_TEST(testIfTrueIfFalseReturn);
CPPUNIT_TEST(testBlockIfReturnNonLocal);
CPPUNIT_TEST(testIncField);
CPPUNIT_TEST(testIncFieldNonTrivial);
CPPUNIT_TEST(testReturnIncFieldFromBlock);
CPPUNIT_TEST(testReturnIncField);
CPPUNIT_TEST(testFieldReadIncWrite);
CPPUNIT_TEST_SUITE_END();
private:
void testEmptyMethodReturnsSelf();
void testPushConstant();
void testIfPushConstantSame();
void testIfPushConstantDifferent();
void testExplicitReturnSelf();
void testDupPopArgumentPop();
void testDupPopArgumentPopImplicitReturnSelf();
void testDupPopLocalPop();
void testDupPopField0Pop();
void testDupPopFieldPop();
void testDupPopFieldReturnSelf();
void testDupPopFieldNReturnSelf();
void testSendDupPopFieldReturnLocal();
void testSendDupPopFieldReturnLocalPeriod();
void testBlockDupPopArgumentPopReturnArg();
void testBlockDupPopArgumentImplicitReturn();
void testBlockDupPopArgumentImplicitReturnDot();
void testBlockDupPopLocalReturnLocal();
void testBlockDupPopFieldReturnLocal();
void testBlockDupPopFieldReturnLocalDot();
void testPushLocalOpt();
void testPushArgOpt();
void testPushFieldOpt();
void testBlockPushFieldOpt();
void testPopLocalOpt();
void testPopFieldOpt();
void testWhileInliningWhileTrue() {
testWhileInlining("whileTrue:", BC_JUMP_ON_FALSE_POP);
}
void testWhileInliningWhileFalse() {
testWhileInlining("whileFalse:", BC_JUMP_ON_TRUE_POP);
}
void testWhileInlining(const char* selector, uint8_t jumpBytecode);
void testInliningWhileLoopsWithExpandingBranches();
void testInliningWhileLoopsWithContractingBranches();
void testIfInlineAndConstantBcLength();
void testIfTrueWithLiteralReturn();
void ifTrueWithLiteralReturn(std::string literal, BC bytecode);
void testIfTrueWithSomethingAndLiteralReturn();
void ifTrueWithSomethingAndLiteralReturn(std::string literal, BC bytecode);
void testIfTrueIfFalseArg();
void testIfTrueIfFalseNlrArg1();
void testIfTrueIfFalseNlrArg2();
void testIfArg();
void ifArg(std::string selector, int8_t jumpBytecode);
void testKeywordIfTrueArg();
void testIfReturnNonLocal();
void ifReturnNonLocal(std::string selector, int8_t jumpBytecode);
void testInliningOfOr();
void inliningOfOr(std::string selector);
void testInliningOfAnd();
void inliningOfAnd(std::string selector);
void testInliningOfToDo();
void testToDoBlockBlockInlinedSelf();
void testToDoWithMoreEmbeddedBlocksAndArgAccess();
static void testJumpQueuesOrdering();
void testNestedIfs();
void testNestedIfsAndLocals();
void testIncDecBytecodes();
void incDecBytecodes(const std::string& sel, uint8_t bc);
void testIfTrueAndIncField();
void testIfTrueAndIncArg();
void testFieldReadInlining();
void testReturnField();
void returnField(size_t fieldNum, BC bytecode, bool isReturnFieldBc);
void testTrivialMethodInlining();
void trivialMethodInlining(const std::string& literal, BC bytecode);
void testBlockIfTrueArg();
void testBlockIfTrueMethodArg();
void testIfTrueIfFalseReturn();
void ifTrueIfFalseReturn(const std::string& sel1, const std::string& sel2,
BC bc);
void testBlockIfReturnNonLocal();
void blockIfReturnNonLocal(std::string sel, BC bc);
void testIncField();
void incField(size_t fieldNum);
void testIncFieldNonTrivial();
void incFieldNonTrivial(size_t fieldNum);
void testReturnIncField();
void returnIncField(size_t fieldNum);
void testReturnIncFieldFromBlock();
void returnIncFieldFromBlock(size_t fieldNum);
void testFieldReadIncWrite();
};