33 @pragma("vm:never-inline")
51 nullable_tag, nullable_tag, nullable_tag, nullable_tag,
52 nullable_tag, null_assert_tag), std::free);
57 Invoke(root_library,
"main");
74 kMatchAndMoveBranchTrue,
76 {kMatchAndMoveStoreField, &store1},
78 {kMatchAndMoveStoreField, &store2},
81 EXPECT(store1->ShouldEmitStoreBarrier() ==
false);
82 EXPECT(store2->ShouldEmitStoreBarrier() ==
true);
99 @pragma("vm:never-inline")
112 main() { foo(0); foo(10); }
113 )", TestCase::LateTag()), std::free);
115 const auto& root_library = Library::Handle(
LoadTestScript(kScript.get()));
117 Invoke(root_library,
"main");
131 kMatchAndMoveBranchFalse,
135 {kMatchAndMoveStoreField, &store},
143 SetFlagScope<bool> sfs(&FLAG_trace_write_barrier_elimination,
true));
144 const char* nullable_tag = TestCase::NullableTag();
151 Utils::CStringUniquePtr(OS::SCreate(
nullptr, R
"(
156 @pragma("vm:never-inline")
162 List<C%s> array = List<C%s>.filled(%d, null);
174 )", TestCase::LateTag(), nullable_tag, nullable_tag, length), std::free);
181 const auto& root_library = Library::Handle(
184 Invoke(root_library,
"main");
187 TestPipeline pipeline(
function, CompilerPass::kJIT);
188 FlowGraph* flow_graph = pipeline.
RunPasses({});
193 StoreFieldInstr* store_into_c =
nullptr;
194 StoreIndexedInstr* store_into_array_before_loop =
nullptr;
195 StoreIndexedInstr* store_into_array_after_loop =
nullptr;
197 ILMatcher cursor(flow_graph, entry);
200 {kMatchAndMoveStoreIndexed, &store_into_array_before_loop},
204 kMatchAndMoveBranchTrue,
206 {kMatchAndMoveStoreField, &store_into_c},
210 kMatchAndMoveBranchFalse,
212 {kMatchAndMoveStoreIndexed, &store_into_array_after_loop},
215 EXPECT(store_into_c->ShouldEmitStoreBarrier() ==
false);
216 EXPECT(store_into_array_before_loop->ShouldEmitStoreBarrier() ==
false);
217 EXPECT(store_into_array_after_loop->ShouldEmitStoreBarrier() ==
218 (
length > Array::kMaxLengthForWriteBarrierElimination));
229 SetFlagScope<bool> sfs(&FLAG_trace_write_barrier_elimination,
true));
230 const char* kScript = R
"(
232 final root = List<dynamic>.filled(128, null);
233 List<dynamic> last = root;
234 for (int i = 0; i < 10 * 1024; ++i) {
235 final nc = List<dynamic>.filled(128, null);
244 const auto& root_library = Library::Handle(
LoadTestScript(kScript));
246 Invoke(root_library,
"main");
249 TestPipeline pipeline(
function, CompilerPass::kJIT);
250 FlowGraph* flow_graph = pipeline.
RunPasses({});
260 kMatchAndMoveCreateArray,
262 kMatchAndMoveBranchTrue,
263 kMatchAndMoveCreateArray,
264 {kMatchAndMoveStoreIndexed, &store_into_phi},
268 EXPECT(store_into_phi->array()->definition()->IsPhi());
269 EXPECT(store_into_phi->ShouldEmitStoreBarrier());
274 SetFlagScope<bool> sfs(&FLAG_trace_write_barrier_elimination,
true));
275 const char* kScript = R
"(
277 late var x = new B();
289 foo(A a) => C(a, a.x);
294 const auto& root_library = Library::Handle(
LoadTestScript(kScript));
296 Invoke(root_library,
"main");
299 TestPipeline pipeline(
function, CompilerPass::kJIT);
300 FlowGraph* flow_graph = pipeline.
RunPasses({});
311 kMatchAndMoveAllocateObject,
312 kMatchAndMoveLoadField,
313 {kMatchAndMoveStoreField, &store1},
314 {kMatchAndMoveStoreField, &store2},
318 EXPECT(!store1->ShouldEmitStoreBarrier());
319 EXPECT(!store2->ShouldEmitStoreBarrier());
324 SetFlagScope<bool> sfs(&FLAG_trace_write_barrier_elimination,
true));
325 const char* kScript = R
"(
338 late var x = new B();
345 const auto& root_library = Library::Handle(
LoadTestScript(kScript));
347 Invoke(root_library,
"main");
350 TestPipeline pipeline(
function, CompilerPass::kJIT);
351 FlowGraph* flow_graph = pipeline.
RunPasses({});
356 StoreFieldInstr* store1 =
nullptr;
357 StoreFieldInstr*
store2 =
nullptr;
359 ILMatcher cursor(flow_graph, entry);
362 kMatchAndMoveAllocateObject,
363 kMatchAndMoveLoadStaticField,
364 {kMatchAndMoveStoreField, &store1},
365 {kMatchAndMoveStoreField, &store2},
369 EXPECT(!store1->ShouldEmitStoreBarrier());
#define RELEASE_ASSERT(cond)
GraphEntryInstr * graph_entry() const
FunctionEntryInstr * normal_entry() const
bool TryMatch(std::initializer_list< MatchCode > match_codes, MatchOpCode insert_before=kInvalidMatchOpCode)
static char * SCreate(Zone *zone, const char *format,...) PRINTF_ATTRIBUTE(2
static const char * NullAssertTag()
static const char * NullableTag()
FlowGraph * RunPasses(std::initializer_list< CompilerPass::Id > passes)
std::unique_ptr< char, decltype(std::free) * > CStringUniquePtr
#define DECLARE_FLAG(type, name)
Dart_NativeFunction function
SI void store2(uint16_t *ptr, U16 r, U16 g)
LibraryPtr LoadTestScript(const char *script, Dart_NativeEntryResolver resolver, const char *lib_uri)
ObjectPtr Invoke(const Library &lib, const char *name)
FunctionPtr GetFunction(const Library &lib, const char *name)
static void TestWBEForArrays(int length)
#define ISOLATE_UNIT_TEST_CASE(name)
#define RESOLVED_USER_TEST_URI