17 const char* kScript = R
"(
29 Invoke(root_library,
"test");
33 CompilerPass::kComputeSSA,
44 kMatchAndMoveFunctionEntry,
45 kMatchAndMoveCheckStackOverflow,
47 {kMatchDartReturn, &ret},
51 EXPECT(ret->value()->BindsToConstant());
52 EXPECT(ret->value()->BoundConstant().IsString());
53 const String& ret_str = String::Cast(ret->value()->BoundConstant());
54 EXPECT(ret_str.Equals(
"aaaabbbbcccc"));
59 const char* kScript = R
"(
61 return '$s' '${'d' 'e'}';
66 const auto& root_library = Library::Handle(
LoadTestScript(kScript));
69 Invoke(root_library,
"main");
73 CompilerPass::kComputeSSA,
85 kMatchAndMoveFunctionEntry,
86 kMatchAndMoveCheckStackOverflow,
88 kMatchAndMoveCreateArray,
89 {kMatchAndMoveStoreIndexed, &store1},
90 {kMatchAndMoveStoreIndexed, &store2},
91 kMatchAndMoveStaticCall,
98 EXPECT(store1->index()->BindsToConstant());
99 EXPECT(store1->index()->BoundConstant().IsInteger());
100 EXPECT(Integer::Cast(store1->index()->BoundConstant()).AsInt64Value() == 0);
102 EXPECT(!store1->value()->BindsToConstant());
105 EXPECT(store2->index()->BindsToConstant());
106 EXPECT(store2->index()->BoundConstant().IsInteger());
107 EXPECT(Integer::Cast(store2->index()->BoundConstant()).AsInt64Value() == 1);
109 EXPECT(store2->value()->BindsToConstant());
110 EXPECT(store2->value()->BoundConstant().IsString());
111 EXPECT(String::Cast(store2->value()->BoundConstant()).Equals(
"de"));
116 const char* kScript = R
"(
118 return '' 'a' '$s' '' 'b' '';
123 const auto& root_library = Library::Handle(
LoadTestScript(kScript));
126 Invoke(root_library,
"main");
130 CompilerPass::kComputeSSA,
143 kMatchAndMoveFunctionEntry,
144 kMatchAndMoveCheckStackOverflow,
145 kMoveDebugStepChecks,
146 kMatchAndMoveCreateArray,
147 {kMatchAndMoveStoreIndexed, &store1},
148 {kMatchAndMoveStoreIndexed, &store2},
149 {kMatchAndMoveStoreIndexed, &store3},
150 kMatchAndMoveStaticCall,
157 EXPECT(store1->index()->BindsToConstant());
158 EXPECT(store1->index()->BoundConstant().IsInteger());
159 EXPECT(Integer::Cast(store1->index()->BoundConstant()).AsInt64Value() == 0);
161 EXPECT(store1->value()->BindsToConstant());
162 EXPECT(store1->value()->BoundConstant().IsString());
163 EXPECT(String::Cast(store1->value()->BoundConstant()).Equals(
"a"));
166 EXPECT(store2->index()->BindsToConstant());
167 EXPECT(store2->index()->BoundConstant().IsInteger());
168 EXPECT(Integer::Cast(store2->index()->BoundConstant()).AsInt64Value() == 1);
170 EXPECT(!store2->value()->BindsToConstant());
173 EXPECT(store3->index()->BindsToConstant());
174 EXPECT(store3->index()->BoundConstant().IsInteger());
175 EXPECT(Integer::Cast(store3->index()->BoundConstant()).AsInt64Value() == 2);
177 EXPECT(store3->value()->BindsToConstant());
178 EXPECT(store3->value()->BoundConstant().IsString());
179 EXPECT(String::Cast(store3->value()->BoundConstant()).Equals(
"b"));
184 const char* kScript = R
"(
186 return '' 'a' '' 'b' '$s' '' 'c' '' 'd' '';
191 const auto& root_library = Library::Handle(
LoadTestScript(kScript));
194 Invoke(root_library,
"main");
198 CompilerPass::kComputeSSA,
211 kMatchAndMoveFunctionEntry,
212 kMatchAndMoveCheckStackOverflow,
213 kMoveDebugStepChecks,
214 kMatchAndMoveCreateArray,
215 {kMatchAndMoveStoreIndexed, &store1},
216 {kMatchAndMoveStoreIndexed, &store2},
217 {kMatchAndMoveStoreIndexed, &store3},
218 kMatchAndMoveStaticCall,
225 EXPECT(store1->index()->BindsToConstant());
226 EXPECT(store1->index()->BoundConstant().IsInteger());
227 EXPECT(Integer::Cast(store1->index()->BoundConstant()).AsInt64Value() == 0);
229 EXPECT(store1->value()->BindsToConstant());
230 EXPECT(store1->value()->BoundConstant().IsString());
231 EXPECT(String::Cast(store1->value()->BoundConstant()).Equals(
"ab"));
234 EXPECT(store2->index()->BindsToConstant());
235 EXPECT(store2->index()->BoundConstant().IsInteger());
236 EXPECT(Integer::Cast(store2->index()->BoundConstant()).AsInt64Value() == 1);
238 EXPECT(!store2->value()->BindsToConstant());
241 EXPECT(store3->index()->BindsToConstant());
242 EXPECT(store3->index()->BoundConstant().IsInteger());
243 EXPECT(Integer::Cast(store3->index()->BoundConstant()).AsInt64Value() == 2);
245 EXPECT(store3->value()->BindsToConstant());
246 EXPECT(store3->value()->BoundConstant().IsString());
247 EXPECT(String::Cast(store3->value()->BoundConstant()).Equals(
"cd"));
251 const char* kScript = R
"(
257 const auto& root_library = Library::Handle(
LoadTestScript(kScript));
260 Invoke(root_library,
"test");
264 CompilerPass::kComputeSSA,
275 kMatchAndMoveFunctionEntry,
276 kMatchAndMoveCheckStackOverflow,
277 kMoveDebugStepChecks,
278 kMatchAndMoveStaticCall,
279 kMatchAndMoveStaticCall,
280 {kMatchAndMoveInstanceCall, &call_add},
286 EXPECT(call_add !=
nullptr);
287 EXPECT(call_add->function_name().Equals(
"add"));
288 EXPECT(call_add->entry_kind() == Code::EntryKind::kUnchecked);
309 const char* kScript = R
"(
310 int callClosure(int Function(int) fun, int value) => fun(value);
311 test() => callClosure((int a) => a + 1, 10);
314 const auto& root_library = Library::Handle(
LoadTestScript(kScript));
315 Invoke(root_library,
"test");
317 const auto& callClosureFunction =
318 Function::Handle(
GetFunction(root_library,
"callClosure"));
319 TestPipeline pipeline(callClosureFunction, CompilerPass::kJIT);
321 CompilerPass::kComputeSSA,
327 ILMatcher cursor(flow_graph, entry,
true);
329 std::initializer_list<MatchCode> expected = {
330 kMatchAndMoveFunctionEntry,
331 kMatchAndMoveCheckStackOverflow,
333 kMatchAndMoveCheckNull,
334 kMatchAndMoveLoadField,
337 kMatchAndMoveRecordCoverage,
339 kMatchAndMoveClosureCall,
348 StreamingFlowGraphBuilder_StaticGetFinalFieldWithTrivialInitializer) {
349 const char* kScript = R
"(
350 final int x = 0xFEEDFEED;
356 const auto& root_library = Library::Handle(
LoadTestScript(kScript));
359 Invoke(root_library,
"test");
363 CompilerPass::kComputeSSA,
373 kMatchAndMoveFunctionEntry,
374 kMatchAndMoveCheckStackOverflow,
375 kMoveDebugStepChecks,
376 {kMatchDartReturn, &return_instr},
379 EXPECT(return_instr !=
nullptr);
380 ConstantInstr* const_value =
381 return_instr->value()->definition()->AsConstant();
382 EXPECT(const_value !=
nullptr);
383 EXPECT(const_value->value().IsInteger());
384 EXPECT_EQ(0xFEEDFEED, Integer::Cast(const_value->value()).AsInt64Value());
FunctionEntryInstr * normal_entry() const