17#if defined(DART_PRECOMPILER)
24 import 'dart:typed_data';
26 foo(Uint8List list, int from) {
27 if (from >= list.length) {
37 FlowGraph* flow_graph = pipeline.RunPasses({});
39 auto entry = flow_graph->graph_entry()->normal_entry();
42 LoadFieldInstr* load_field =
nullptr;
43 GenericCheckBoundInstr* bounds_check =
nullptr;
44 LoadFieldInstr* load_untagged =
nullptr;
45 LoadIndexedInstr* load_indexed =
nullptr;
47 ILMatcher cursor(flow_graph, entry);
50 {kMatchAndMoveLoadField, &load_field},
54 {kMatchAndMoveGenericCheckBound, &bounds_check},
55 {kMatchAndMoveLoadField, &load_untagged},
57 {kMatchAndMoveLoadIndexed, &load_indexed},
62 EXPECT(load_field->InputAt(0)->definition()->IsParameter());
63 EXPECT(bounds_check->length()
65 ->OriginalDefinitionIgnoreBoxingAndConstraints() == load_field);
66 EXPECT(load_untagged->InputAt(0)->definition()->IsParameter());
67 EXPECT(load_indexed->InputAt(0)->definition() == load_untagged);
74 const char* kTemplate =
76 import 'dart:typed_data';
78 void reverse%s(%s list) {
79 final length = list.length;
80 final halfLength = length >> 1;
81 for (int i = 0; i < halfLength; ++i) {
82 final tmp = list[length-i-1];
83 list[length-i-1] = list[i];
89 char script_buffer[1024];
90 char uri_buffer[1024];
92 auto& lib = Library::Handle();
95 auto check_il = [&](
const char*
name) {
97 Utils::SNPrint(script_buffer,
sizeof(script_buffer), kTemplate,
name,
name);
98 Utils::SNPrint(uri_buffer,
sizeof(uri_buffer),
"file:///reverse-%s.dart",
100 Utils::SNPrint(function_name,
sizeof(function_name),
"reverse%s",
name);
106 TestPipeline pipeline(
function, CompilerPass::kAOT);
107 FlowGraph* flow_graph = pipeline.RunPasses({});
108 auto entry = flow_graph->graph_entry()->normal_entry();
111 ILMatcher cursor(flow_graph, entry);
115 kMatchAndMoveLoadField,
117 kMatchAndMoveBranchTrue,
122 kMatchAndMoveGenericCheckBound,
124 kMatchAndMoveLoadField,
126 kMatchAndMoveLoadIndexed,
129 kMatchAndMoveGenericCheckBound,
131 kMatchAndMoveLoadField,
133 kMatchAndMoveLoadIndexed,
136 kMatchAndMoveCheckWritable,
138 kMatchAndMoveLoadField,
140 kMatchAndMoveStoreIndexed,
144 kMatchAndMoveLoadField,
146 kMatchAndMoveStoreIndexed,
150 kMatchAndMoveBranchFalse,
156 check_il(
"Uint8List");
157 check_il(
"Int8List");
158 check_il(
"Uint8ClampedList");
159 check_il(
"Int16List");
160 check_il(
"Uint16List");
161 check_il(
"Int32List");
162 check_il(
"Uint32List");
163 check_il(
"Int64List");
164 check_il(
"Uint64List");
165 check_il(
"Float32List");
166 check_il(
"Float64List");
171 const char* kTemplate =
173 import 'dart:typed_data';
174 void set%s(%s list, int index, %s value) {
179 char script_buffer[1024];
180 char uri_buffer[1024];
182 auto& lib = Library::Handle();
183 auto&
function = Function::Handle();
184 auto& arguments = Array::Handle();
185 auto&
result = Object::Handle();
187 const intptr_t
kIndex = 1;
188 const intptr_t kLastStage = 3;
191 const TypedDataBase&
data,
const Object&
value,
194 Utils::SNPrint(script_buffer,
sizeof(script_buffer), kTemplate,
name,
name,
196 Utils::SNPrint(uri_buffer,
sizeof(uri_buffer),
"file:///set-%s.dart",
name);
197 Utils::SNPrint(function_name,
sizeof(function_name),
"set%s",
name);
203 TestPipeline pipeline(
function, CompilerPass::kAOT);
204 FlowGraph* flow_graph = pipeline.RunPasses({});
205 auto entry = flow_graph->graph_entry()->normal_entry();
208 ILMatcher cursor(flow_graph, entry,
true);
212 kMatchAndMoveLoadField,
216 kMatchAndMoveGenericCheckBound,
220 kMatchAndMoveLoadField,
222 kMatchAndMoveOptionalUnbox,
224 kMatchAndMoveStoreIndexed,
232 pipeline.CompileGraphAndAttachFunction();
234 arguments = Array::New(3);
235 arguments.SetAt(0, stage == 0 ? Object::null_object() :
data);
237 1, stage == 1 ? Object::null_object() : Smi::Handle(Smi::New(
kIndex)));
238 arguments.SetAt(2, stage == 2 ? Object::null_object() :
value);
244 if (stage == kLastStage) {
254 const auto& uint8_list =
255 TypedData::Handle(TypedData::New(kTypedDataUint8ArrayCid, 16));
256 const auto& uint8c_list =
257 TypedData::Handle(TypedData::New(kTypedDataUint8ClampedArrayCid, 16));
258 const auto& int16_list =
259 TypedData::Handle(TypedData::New(kTypedDataInt16ArrayCid, 16));
260 const auto& uint16_list =
261 TypedData::Handle(TypedData::New(kTypedDataUint16ArrayCid, 16));
262 const auto& int32_list =
263 TypedData::Handle(TypedData::New(kTypedDataInt32ArrayCid, 16));
264 const auto& uint32_list =
265 TypedData::Handle(TypedData::New(kTypedDataUint32ArrayCid, 16));
266 const auto& int64_list =
267 TypedData::Handle(TypedData::New(kTypedDataInt64ArrayCid, 16));
268 const auto& uint64_list =
269 TypedData::Handle(TypedData::New(kTypedDataUint64ArrayCid, 16));
270 const auto& float32_list =
271 TypedData::Handle(TypedData::New(kTypedDataFloat32ArrayCid, 16));
272 const auto& float64_list =
273 TypedData::Handle(TypedData::New(kTypedDataFloat64ArrayCid, 16));
274 const auto& int8_list =
275 TypedData::Handle(TypedData::New(kTypedDataInt8ArrayCid, 16));
276 const auto& int_value = Integer::Handle(Integer::New(42));
277 const auto& float_value = Double::Handle(Double::New(4.2));
280 const intptr_t first_stage = kLastStage;
281 for (intptr_t stage = first_stage; stage <= kLastStage; ++stage) {
282 run_test(
"Uint8List",
"int", int8_list, int_value, stage);
283 run_test(
"Int8List",
"int", uint8_list, int_value, stage);
284 run_test(
"Uint8ClampedList",
"int", uint8c_list, int_value, stage);
285 run_test(
"Int16List",
"int", int16_list, int_value, stage);
286 run_test(
"Uint16List",
"int", uint16_list, int_value, stage);
287 run_test(
"Int32List",
"int", int32_list, int_value, stage);
288 run_test(
"Uint32List",
"int", uint32_list, int_value, stage);
289 run_test(
"Int64List",
"int", int64_list, int_value, stage);
290 run_test(
"Uint64List",
"int", uint64_list, int_value, stage);
291 run_test(
"Float32List",
"double", float32_list, float_value, stage);
292 run_test(
"Float64List",
"double", float64_list, float_value, stage);
#define RELEASE_ASSERT(cond)
Dart_NativeFunction function
LibraryPtr LoadTestScript(const char *script, Dart_NativeEntryResolver resolver, const char *lib_uri)
@ kMatchAndMoveBranchTrue
FunctionPtr GetFunction(const Library &lib, const char *name)
const char *const function_name
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
void run_test(skiatest::Reporter *reporter, Context *context, SkISize surfaceSize, SkISize recordingSize, SkISize replayOffset, DrawCallback draw, const std::vector< Expectation > &expectations)
#define ISOLATE_UNIT_TEST_CASE(name)