Flutter Engine
The Flutter Engine
ffi_test_functions.cc
Go to the documentation of this file.
1// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5// This file contains test functions for the dart:ffi test cases.
6// This file is not allowed to depend on any symbols from the embedder and is
7// therefore not allowed to use `dart_api.h`. (The flutter/flutter integration
8// tests will run dart tests using this library only.)
9
10#include <stdarg.h>
11#include <stddef.h>
12#include <stdio.h>
13#include <stdlib.h>
14#include <sys/types.h>
15
16#include <cinttypes>
17#include <cmath>
18#include <iostream>
19#include <limits>
20#include <thread> // NOLINT
21
22#if defined(_WIN32)
23#include <windows.h>
24#else
25#include <sys/mman.h>
26#endif
27
29
30#if defined(_WIN32)
31#define DART_EXPORT extern "C" __declspec(dllexport)
32#else
33#define DART_EXPORT \
34 extern "C" __attribute__((visibility("default"))) __attribute((used))
35#endif
36
37namespace dart {
38
39#define CHECK(X) \
40 if (!(X)) { \
41 fprintf(stderr, "%s\n", "Check failed: " #X); \
42 return 1; \
43 }
44
45#define CHECK_EQ(X, Y) CHECK((X) == (Y))
46
47////////////////////////////////////////////////////////////////////////////////
48// Tests for Dart -> native calls.
49//
50// Note: If this interface is changed please also update
51// sdk/runtime/tools/dartfuzz/dartfuzz_ffi_api.dart
52
54 *reinterpret_cast<int*>(InduceACrash) = 123;
55}
56
57DART_EXPORT void SetGlobalVar(int32_t v) {
58 globalInt = v;
59}
60
62 return globalInt;
63}
64
66 return globalStruct;
67}
68
69// Sums two ints and adds 42.
70// Simple function to test trampolines.
71// Also used for testing argument exception on passing null instead of a Dart
72// int.
73DART_EXPORT int32_t SumPlus42(int32_t a, int32_t b) {
74 std::cout << "SumPlus42(" << a << ", " << b << ")\n";
75 const int32_t retval = 42 + a + b;
76 std::cout << "returning " << retval << "\n";
77 return retval;
78}
79
80// Tests for sign and zero extension return values when passed to Dart.
82 return 0xff;
83}
84
86 return 0xffff;
87}
88
90 return 0xffffffff;
91}
92
94 return 0x80;
95}
96
98 return 0x8000;
99}
100
102 return 0x80000000;
103}
104
105// Test that return values are truncated by callee before passed to Dart.
107 uint64_t v = 0xabcff;
108 // Truncated to 8 bits and zero extended, or truncated to 32 bits, depending
109 // on ABI.
110 return v;
111}
112
114 uint64_t v = 0xabcffff;
115 return v;
116}
117
119 uint64_t v = 0xabcffffffff;
120 return v;
121}
122
124 int64_t v = 0x8abc80;
125 return v;
126}
127
129 int64_t v = 0x8abc8000;
130 return v;
131}
132
134 int64_t v = 0x8abc80000000;
135 return v;
136}
137
138// Test that arguments are truncated correctly.
139DART_EXPORT intptr_t TakeMaxUint8(uint8_t x) {
140 std::cout << "TakeMaxUint8(" << static_cast<int>(x) << ")\n";
141 return x == 0xff ? 1 : 0;
142}
143
144DART_EXPORT intptr_t TakeMaxUint16(uint16_t x) {
145 std::cout << "TakeMaxUint16(" << x << ")\n";
146 return x == 0xffff ? 1 : 0;
147}
148
149DART_EXPORT intptr_t TakeMaxUint32(uint32_t x) {
150 std::cout << "TakeMaxUint32(" << x << ")\n";
151 return x == 0xffffffff ? 1 : 0;
152}
153
154DART_EXPORT intptr_t TakeMinInt8(int8_t x) {
155 std::cout << "TakeMinInt8(" << static_cast<int>(x) << ")\n";
156 const int64_t expected = -0x80;
157 const int64_t received = x;
158 return expected == received ? 1 : 0;
159}
160
161DART_EXPORT intptr_t TakeMinInt16(int16_t x) {
162 std::cout << "TakeMinInt16(" << x << ")\n";
163 const int64_t expected = -0x8000;
164 const int64_t received = x;
165 return expected == received ? 1 : 0;
166}
167
168DART_EXPORT intptr_t TakeMinInt32(int32_t x) {
169 std::cout << "TakeMinInt32(" << x << ")\n";
170 const int64_t expected = INT32_MIN;
171 const int64_t received = x;
172 return expected == received ? 1 : 0;
173}
174
175// Test that arguments are truncated correctly, including stack arguments
177 uint8_t b,
178 uint8_t c,
179 uint8_t d,
180 uint8_t e,
181 uint8_t f,
182 uint8_t g,
183 uint8_t h,
184 uint8_t i,
185 uint8_t j) {
186 std::cout << "TakeMaxUint8x10(" << static_cast<int>(a) << ", "
187 << static_cast<int>(b) << ", " << static_cast<int>(c) << ", "
188 << static_cast<int>(d) << ", " << static_cast<int>(e) << ", "
189 << static_cast<int>(f) << ", " << static_cast<int>(g) << ", "
190 << static_cast<int>(h) << ", " << static_cast<int>(i) << ", "
191 << static_cast<int>(j) << ")\n";
192 return (a == 0xff && b == 0xff && c == 0xff && d == 0xff && e == 0xff &&
193 f == 0xff && g == 0xff && h == 0xff && i == 0xff && j == 0xff)
194 ? 1
195 : 0;
196}
197
198// Performs some computation on various sized signed ints.
199// Used for testing value ranges for signed ints.
200DART_EXPORT int64_t IntComputation(int8_t a, int16_t b, int32_t c, int64_t d) {
201 std::cout << "IntComputation(" << static_cast<int>(a) << ", " << b << ", "
202 << c << ", " << d << ")\n";
203 const int64_t retval = d - c + b - a;
204 std::cout << "returning " << retval << "\n";
205 return retval;
206}
207
208// Used in regress_39044_test.dart.
209DART_EXPORT int64_t Regress39044(int64_t a, int8_t b) {
210 std::cout << "Regress39044(" << a << ", " << static_cast<int>(b) << ")\n";
211 const int64_t retval = a - b;
212 std::cout << "returning " << retval << "\n";
213 return retval;
214}
215
216DART_EXPORT intptr_t Regress40537(uint8_t x) {
217 std::cout << "Regress40537(" << static_cast<int>(x) << ")\n";
218 return x == 249 ? 1 : 0;
219}
220
222 std::cout << "Regress40537Variant2(" << static_cast<int>(x) << ")\n";
223 return x;
224}
225
227 std::cout << "Regress40537Variant3(" << static_cast<int>(x) << ")\n";
228 return x;
229}
230
231// Performs some computation on various sized unsigned ints.
232// Used for testing value ranges for unsigned ints.
234 uint16_t b,
235 uint32_t c,
236 uint64_t d) {
237 std::cout << "UintComputation(" << static_cast<int>(a) << ", " << b << ", "
238 << c << ", " << d << ")\n";
239 const uint64_t retval = d - c + b - a;
240 std::cout << "returning " << retval << "\n";
241 return retval;
242}
243
244// Multiplies pointer sized intptr_t by three.
245// Used for testing pointer sized parameter and return value.
246DART_EXPORT intptr_t Times3(intptr_t a) {
247 std::cout << "Times3(" << a << ")\n";
248 const intptr_t retval = a * 3;
249 std::cout << "returning " << retval << "\n";
250 return retval;
251}
252
253// Multiples a double by 1.337.
254// Used for testing double parameter and return value.
255// Also used for testing argument exception on passing null instead of a Dart
256// double.
258 std::cout << "Times1_337Double(" << a << ")\n";
259 const double retval = a * 1.337;
260 std::cout << "returning " << retval << "\n";
261 return retval;
262}
263
264// Multiples a float by 1.337.
265// Used for testing float parameter and return value.
267 std::cout << "Times1_337Float(" << a << ")\n";
268 const float retval = a * 1.337f;
269 std::cout << "returning " << retval << "\n";
270 return retval;
271}
272
273// Sums many ints.
274// Used for testing calling conventions. With so many integers we are using all
275// normal parameter registers and some stack slots.
276DART_EXPORT intptr_t SumManyInts(intptr_t a,
277 intptr_t b,
278 intptr_t c,
279 intptr_t d,
280 intptr_t e,
281 intptr_t f,
282 intptr_t g,
283 intptr_t h,
284 intptr_t i,
285 intptr_t j) {
286 std::cout << "SumManyInts(" << a << ", " << b << ", " << c << ", " << d
287 << ", " << e << ", " << f << ", " << g << ", " << h << ", " << i
288 << ", " << j << ")\n";
289 const intptr_t retval = a + b + c + d + e + f + g + h + i + j;
290 std::cout << "returning " << retval << "\n";
291 return retval;
292}
293
294// Sums many ints.
295// Used for testing calling conventions. With small integers on stack slots we
296// test stack alignment.
298 int16_t b,
299 int8_t c,
300 int16_t d,
301 int8_t e,
302 int16_t f,
303 int8_t g,
304 int16_t h,
305 int8_t i,
306 int16_t j) {
307 std::cout << "SumManySmallInts(" << static_cast<int>(a) << ", " << b << ", "
308 << static_cast<int>(c) << ", " << d << ", " << static_cast<int>(e)
309 << ", " << f << ", " << static_cast<int>(g) << ", " << h << ", "
310 << static_cast<int>(i) << ", " << j << ")\n";
311 const int16_t retval = a + b + c + d + e + f + g + h + i + j;
312 std::cout << "returning " << retval << "\n";
313 return retval;
314}
315
316// Used for testing floating point argument backfilling on Arm32 in hardfp.
317DART_EXPORT double SumFloatsAndDoubles(float a, double b, float c) {
318 std::cout << "SumFloatsAndDoubles(" << a << ", " << b << ", " << c << ")\n";
319 const double retval = a + b + c;
320 std::cout << "returning " << retval << "\n";
321 return retval;
322}
323
324// Very many small integers, tests alignment on stack.
326 int16_t a02,
327 int8_t a03,
328 int16_t a04,
329 int8_t a05,
330 int16_t a06,
331 int8_t a07,
332 int16_t a08,
333 int8_t a09,
334 int16_t a10,
335 int8_t a11,
336 int16_t a12,
337 int8_t a13,
338 int16_t a14,
339 int8_t a15,
340 int16_t a16,
341 int8_t a17,
342 int16_t a18,
343 int8_t a19,
344 int16_t a20,
345 int8_t a21,
346 int16_t a22,
347 int8_t a23,
348 int16_t a24,
349 int8_t a25,
350 int16_t a26,
351 int8_t a27,
352 int16_t a28,
353 int8_t a29,
354 int16_t a30,
355 int8_t a31,
356 int16_t a32,
357 int8_t a33,
358 int16_t a34,
359 int8_t a35,
360 int16_t a36,
361 int8_t a37,
362 int16_t a38,
363 int8_t a39,
364 int16_t a40) {
365 std::cout << "SumVeryManySmallInts(" << static_cast<int>(a01) << ", " << a02
366 << ", " << static_cast<int>(a03) << ", " << a04 << ", "
367 << static_cast<int>(a05) << ", " << a06 << ", "
368 << static_cast<int>(a07) << ", " << a08 << ", "
369 << static_cast<int>(a09) << ", " << a10 << ", "
370 << static_cast<int>(a11) << ", " << a12 << ", "
371 << static_cast<int>(a13) << ", " << a14 << ", "
372 << static_cast<int>(a15) << ", " << a16 << ", "
373 << static_cast<int>(a17) << ", " << a18 << ", "
374 << static_cast<int>(a19) << ", " << a20 << ", "
375 << static_cast<int>(a21) << ", " << a22 << ", "
376 << static_cast<int>(a23) << ", " << a24 << ", "
377 << static_cast<int>(a25) << ", " << a26 << ", "
378 << static_cast<int>(a27) << ", " << a28 << ", "
379 << static_cast<int>(a29) << ", " << a30 << ", "
380 << static_cast<int>(a31) << ", " << a32 << ", "
381 << static_cast<int>(a33) << ", " << a34 << ", "
382 << static_cast<int>(a35) << ", " << a36 << ", "
383 << static_cast<int>(a37) << ", " << a38 << ", "
384 << static_cast<int>(a39) << ", " << a40 << ")\n";
385 const int16_t retval = a01 + a02 + a03 + a04 + a05 + a06 + a07 + a08 + a09 +
386 a10 + a11 + a12 + a13 + a14 + a15 + a16 + a17 + a18 +
387 a19 + a20 + a21 + a22 + a23 + a24 + a25 + a26 + a27 +
388 a28 + a29 + a30 + a31 + a32 + a33 + a34 + a35 + a36 +
389 a37 + a38 + a39 + a40;
390 std::cout << "returning " << retval << "\n";
391 return retval;
392}
393
394// Very many floating points, tests alignment on stack, and packing in
395// floating point registers in hardfp.
397 double a02,
398 float a03,
399 double a04,
400 float a05,
401 double a06,
402 float a07,
403 double a08,
404 float a09,
405 double a10,
406 float a11,
407 double a12,
408 float a13,
409 double a14,
410 float a15,
411 double a16,
412 float a17,
413 double a18,
414 float a19,
415 double a20,
416 float a21,
417 double a22,
418 float a23,
419 double a24,
420 float a25,
421 double a26,
422 float a27,
423 double a28,
424 float a29,
425 double a30,
426 float a31,
427 double a32,
428 float a33,
429 double a34,
430 float a35,
431 double a36,
432 float a37,
433 double a38,
434 float a39,
435 double a40) {
436 std::cout << "SumVeryManyFloatsDoubles(" << a01 << ", " << a02 << ", " << a03
437 << ", " << a04 << ", " << a05 << ", " << a06 << ", " << a07 << ", "
438 << a08 << ", " << a09 << ", " << a10 << ", " << a11 << ", " << a12
439 << ", " << a13 << ", " << a14 << ", " << a15 << ", " << a16 << ", "
440 << a17 << ", " << a18 << ", " << a19 << ", " << a20 << ", " << a21
441 << ", " << a22 << ", " << a23 << ", " << a24 << ", " << a25 << ", "
442 << a26 << ", " << a27 << ", " << a28 << ", " << a29 << ", " << a30
443 << ", " << a31 << ", " << a32 << ", " << a33 << ", " << a34 << ", "
444 << a35 << ", " << a36 << ", " << a37 << ", " << a38 << ", " << a39
445 << ", " << a40 << ")\n";
446 const double retval = a01 + a02 + a03 + a04 + a05 + a06 + a07 + a08 + a09 +
447 a10 + a11 + a12 + a13 + a14 + a15 + a16 + a17 + a18 +
448 a19 + a20 + a21 + a22 + a23 + a24 + a25 + a26 + a27 +
449 a28 + a29 + a30 + a31 + a32 + a33 + a34 + a35 + a36 +
450 a37 + a38 + a39 + a40;
451 std::cout << "returning " << retval << "\n";
452 return retval;
453}
454
455// Sums an odd number of ints.
456// Used for testing calling conventions. With so many arguments, and an odd
457// number of arguments, we are testing stack alignment on various architectures.
458DART_EXPORT intptr_t SumManyIntsOdd(intptr_t a,
459 intptr_t b,
460 intptr_t c,
461 intptr_t d,
462 intptr_t e,
463 intptr_t f,
464 intptr_t g,
465 intptr_t h,
466 intptr_t i,
467 intptr_t j,
468 intptr_t k) {
469 std::cout << "SumManyInts(" << a << ", " << b << ", " << c << ", " << d
470 << ", " << e << ", " << f << ", " << g << ", " << h << ", " << i
471 << ", " << j << ", " << k << ")\n";
472 const intptr_t retval =
473 static_cast<uintptr_t>(a) + static_cast<uintptr_t>(b) +
474 static_cast<uintptr_t>(c) + static_cast<uintptr_t>(d) +
475 static_cast<uintptr_t>(e) + static_cast<uintptr_t>(f) +
476 static_cast<uintptr_t>(g) + static_cast<uintptr_t>(h) +
477 static_cast<uintptr_t>(i) + static_cast<uintptr_t>(j) +
478 static_cast<uintptr_t>(k);
479 std::cout << "returning " << retval << "\n";
480 return retval;
481}
482
483// Sums many doubles.
484// Used for testing calling conventions. With so many doubles we are using all
485// xmm parameter registers and some stack slots.
487 double b,
488 double c,
489 double d,
490 double e,
491 double f,
492 double g,
493 double h,
494 double i,
495 double j) {
496 std::cout << "SumManyDoubles(" << a << ", " << b << ", " << c << ", " << d
497 << ", " << e << ", " << f << ", " << g << ", " << h << ", " << i
498 << ", " << j << ")\n";
499 const double retval = a + b + c + d + e + f + g + h + i + j;
500 std::cout << "returning " << retval << "\n";
501 return retval;
502}
503
504// Sums many numbers.
505// Used for testing calling conventions. With so many parameters we are using
506// both registers and stack slots.
508 float b,
509 intptr_t c,
510 double d,
511 intptr_t e,
512 float f,
513 intptr_t g,
514 double h,
515 intptr_t i,
516 float j,
517 intptr_t k,
518 double l,
519 intptr_t m,
520 float n,
521 intptr_t o,
522 double p,
523 intptr_t q,
524 float r,
525 intptr_t s,
526 double t) {
527 std::cout << "SumManyNumbers(" << a << ", " << b << ", " << c << ", " << d
528 << ", " << e << ", " << f << ", " << g << ", " << h << ", " << i
529 << ", " << j << ", " << k << ", " << l << ", " << m << ", " << n
530 << ", " << o << ", " << p << ", " << q << ", " << r << ", " << s
531 << ", " << t << ")\n";
532 const double retval = a + b + c + d + e + f + g + h + i + j + k + l + m + n +
533 o + p + q + r + s + t;
534 std::cout << "returning " << retval << "\n";
535 return retval;
536}
537
538// Assigns 1337 to the second element and returns the address of that element.
539// Used for testing Pointer parameters and return values.
540DART_EXPORT int64_t* Assign1337Index1(int64_t* a) {
541 std::cout << "Assign1337Index1(" << a << ")\n";
542 std::cout << "val[0] = " << a[0] << "\n";
543 std::cout << "val[1] = " << a[1] << "\n";
544 a[1] = 1337;
545 std::cout << "val[1] = " << a[1] << "\n";
546 int64_t* retval = a + 1;
547 std::cout << "returning " << retval << "\n";
548 return retval;
549}
550
551// Transposes Coordinate by (10, 10) and returns next Coordinate.
552// Used for testing struct pointer parameter, struct pointer return value,
553// struct field access, and struct pointer field dereference.
555 std::cout << "TransposeCoordinate(" << coord << " {" << coord->x << ", "
556 << coord->y << ", " << coord->next << "})\n";
557 coord->x = coord->x + 10.0;
558 coord->y = coord->y + 10.0;
559 std::cout << "returning " << coord->next << "\n";
560 return coord->next;
561}
562
563// Takes a Coordinate array and returns a Coordinate pointer to the next
564// element.
565// Used for testing struct arrays.
567 std::cout << "CoordinateElemAt1(" << coord << ")\n";
568 std::cout << "sizeof(Coord): " << sizeof(Coord) << "\n";
569 std::cout << "coord[0] = {" << coord[0].x << ", " << coord[0].y << ", "
570 << coord[0].next << "}\n";
571 std::cout << "coord[1] = {" << coord[1].x << ", " << coord[1].y << ", "
572 << coord[1].next << "}\n";
573 Coord* retval = coord + 1;
574 std::cout << "returning " << retval << "\n";
575 return retval;
576}
577
578typedef Coord* (*CoordUnOp)(Coord* coord);
579
580// Takes a Coordinate Function(Coordinate) and applies it three times to a
581// Coordinate.
582// Used for testing function pointers with structs.
584 std::cout << "CoordinateUnOpTrice(" << &unop << ", " << coord << ")\n";
585 Coord* retval = unop(unop(unop(coord)));
586 std::cout << "returning " << retval << "\n";
587 return retval;
588}
589
590typedef intptr_t (*IntptrBinOp)(intptr_t a, intptr_t b);
591
592// Returns a closure.
593// Note this closure is not properly marked as DART_EXPORT or extern "C".
594// Used for testing passing a pointer to a closure to Dart.
596 std::cout << "IntptrAdditionClosure()\n";
597 IntptrBinOp retval = [](intptr_t a, intptr_t b) { return a + b; };
598 std::cout << "returning " << &retval << "\n";
599 return retval;
600}
601
602// Applies an intptr binop function to 42 and 74.
603// Used for testing passing a function pointer to C.
605 std::cout << "ApplyTo42And74()\n";
606 intptr_t retval = binop(42, 74);
607 std::cout << "returning " << retval << "\n";
608 return retval;
609}
610
611// Returns next element in the array, unless a null pointer is passed.
612// When a null pointer is passed, a null pointer is returned.
613// Used for testing null pointers.
615 std::cout << "NullableInt64ElemAt1(" << a << ")\n";
616 int64_t* retval;
617 if (a != nullptr) {
618 std::cout << "not null pointer, address: " << a << "\n";
619 retval = a + 1;
620 } else {
621 std::cout << "null pointer, address: " << a << "\n";
622 retval = nullptr;
623 }
624 std::cout << "returning " << retval << "\n";
625 return retval;
626}
627
628// A struct designed to exercise all kinds of alignment rules.
629// Note that offset32A (System V ia32, iOS arm) aligns doubles on 4 bytes while
630// offset32B (Arm 32 bit and MSVC ia32) aligns on 8 bytes.
631// TODO(37470): Add uncommon primitive data types when we want to support them.
633 // size32 size64 offset32A offset32B offset64
634 int8_t a; // 1 0 0 0
635 int16_t b; // 2 2 2 2
636 int32_t c; // 4 4 4 4
637 int64_t d; // 8 8 8 8
638 uint8_t e; // 1 16 16 16
639 uint16_t f; // 2 18 18 18
640 uint32_t g; // 4 20 20 20
641 uint64_t h; // 8 24 24 24
642 intptr_t i; // 4 8 32 32 32
643 double j; // 8 36 40 40
644 float k; // 4 44 48 48
645 VeryLargeStruct* parent; // 4 8 48 52 56
646 intptr_t numChildren; // 4 8 52 56 64
647 VeryLargeStruct* children; // 4 8 56 60 72
648 int8_t smallLastField; // 1 60 64 80
649 // sizeof 64 72 88
650};
651
652// Sums the fields of a very large struct, including the first field (a) from
653// the parent and children.
654// Used for testing alignment and padding in structs.
656 std::cout << "SumVeryLargeStruct(" << vls << ")\n";
657 std::cout << "offsetof(a): " << offsetof(VeryLargeStruct, a) << "\n";
658 std::cout << "offsetof(b): " << offsetof(VeryLargeStruct, b) << "\n";
659 std::cout << "offsetof(c): " << offsetof(VeryLargeStruct, c) << "\n";
660 std::cout << "offsetof(d): " << offsetof(VeryLargeStruct, d) << "\n";
661 std::cout << "offsetof(e): " << offsetof(VeryLargeStruct, e) << "\n";
662 std::cout << "offsetof(f): " << offsetof(VeryLargeStruct, f) << "\n";
663 std::cout << "offsetof(g): " << offsetof(VeryLargeStruct, g) << "\n";
664 std::cout << "offsetof(h): " << offsetof(VeryLargeStruct, h) << "\n";
665 std::cout << "offsetof(i): " << offsetof(VeryLargeStruct, i) << "\n";
666 std::cout << "offsetof(j): " << offsetof(VeryLargeStruct, j) << "\n";
667 std::cout << "offsetof(k): " << offsetof(VeryLargeStruct, k) << "\n";
668 std::cout << "offsetof(parent): " << offsetof(VeryLargeStruct, parent)
669 << "\n";
670 std::cout << "offsetof(numChildren): "
671 << offsetof(VeryLargeStruct, numChildren) << "\n";
672 std::cout << "offsetof(children): " << offsetof(VeryLargeStruct, children)
673 << "\n";
674 std::cout << "offsetof(smallLastField): "
675 << offsetof(VeryLargeStruct, smallLastField) << "\n";
676 std::cout << "sizeof(VeryLargeStruct): " << sizeof(VeryLargeStruct) << "\n";
677
678 std::cout << "vls->a: " << static_cast<int>(vls->a) << "\n";
679 std::cout << "vls->b: " << vls->b << "\n";
680 std::cout << "vls->c: " << vls->c << "\n";
681 std::cout << "vls->d: " << vls->d << "\n";
682 std::cout << "vls->e: " << static_cast<int>(vls->e) << "\n";
683 std::cout << "vls->f: " << vls->f << "\n";
684 std::cout << "vls->g: " << vls->g << "\n";
685 std::cout << "vls->h: " << vls->h << "\n";
686 std::cout << "vls->i: " << vls->i << "\n";
687 std::cout << "vls->j: " << vls->j << "\n";
688 std::cout << "vls->k: " << vls->k << "\n";
689 std::cout << "vls->parent: " << vls->parent << "\n";
690 std::cout << "vls->numChildren: " << vls->numChildren << "\n";
691 std::cout << "vls->children: " << vls->children << "\n";
692 std::cout << "vls->smallLastField: " << static_cast<int>(vls->smallLastField)
693 << "\n";
694
695 int64_t retval = 0;
696 retval += 0x0L + vls->a;
697 retval += vls->b;
698 retval += vls->c;
699 retval += vls->d;
700 retval += vls->e;
701 retval += vls->f;
702 retval += vls->g;
703 retval += vls->h;
704 retval += vls->i;
705 retval += vls->j;
706 retval += vls->k;
707 retval += vls->smallLastField;
708 std::cout << retval << "\n";
709 if (vls->parent != nullptr) {
710 std::cout << "has parent\n";
711 retval += vls->parent->a;
712 }
713 std::cout << "has " << vls->numChildren << " children\n";
714 for (intptr_t i = 0; i < vls->numChildren; i++) {
715 retval += vls->children[i].a;
716 }
717 std::cout << "returning " << retval << "\n";
718 return retval;
719}
720
722 uint8_t a0;
723 uint8_t a1;
724 uint8_t a2;
725 uint8_t a3;
726 uint8_t a4;
727 uint8_t a5;
728 uint8_t a6;
729 uint8_t a7;
730 uint8_t a8;
731};
732
734 return s9.a0 + s9.a1 + s9.a2 + s9.a3 + s9.a4 + s9.a5 + s9.a6 + s9.a7 + s9.a8;
735}
736
737DART_EXPORT int64_t
739 Struct9Uint8* in) {
740 std::cout << "SumReturnStruct9Uint8 in (" << in->a0 << ", " << in->a1 << ", "
741 << in->a2 << ", " << in->a3 << ", " << in->a4 << ", " << in->a5
742 << ", " << in->a6 << ", " << in->a7 << ", " << in->a8 << ")\n";
743
745
746 std::cout << "SumReturnStruct9Uint8 out (" << out.a0 << ", " << out.a1 << ", "
747 << out.a2 << ", " << out.a3 << ", " << out.a4 << ", " << out.a5
748 << ", " << out.a6 << ", " << out.a7 << ", " << out.a8 << ")\n";
749
750 return out.a0 + out.a1 + out.a2 + out.a3 + out.a4 + out.a5 + out.a6 + out.a7 +
751 out.a8;
752}
753
754// Allocates a multiple of the larest page size, so the last element of the
755// array is right at a page boundary. Explicitly allocate and make inaccessible
756// the next page to avoid flaky false-successes if the next page happens to be
757// allocated.
759 size_t size = sizeof(Struct9Uint8) * 64 * 1024;
760#if defined(_WIN32)
761 void* result =
762 VirtualAlloc(nullptr, size * 2, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
763 void* guard_page =
764 reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(result) + size);
765 DWORD old_prot;
766 if (VirtualProtect(guard_page, size, PAGE_NOACCESS, &old_prot) == 0) {
767 fprintf(stderr, "VirtualProtect failed\n");
768 abort();
769 }
770#else
771 void* result = mmap(nullptr, size * 2, PROT_READ | PROT_WRITE,
772 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
773 void* guard_page =
774 reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(result) + size);
775 if (mprotect(guard_page, size, PROT_NONE) != 0) {
776 fprintf(stderr, "mprotect failed\n");
777 abort();
778 }
779#endif
780 return reinterpret_cast<Struct9Uint8*>(result);
781}
782
784#if defined(_WIN32)
785 VirtualFree(address, 0, MEM_RELEASE);
786#else
787 size_t size = sizeof(Struct9Uint8) * 64 * 1024;
788 munmap(address, size * 2);
789#endif
790}
791
792// Sums numbers of various sizes.
793// Used for testing truncation and sign extension of non 64 bit parameters.
795 int16_t b,
796 int32_t c,
797 uint8_t d,
798 uint16_t e,
799 uint32_t f) {
800 std::cout << "SumSmallNumbers(" << static_cast<int>(a) << ", " << b << ", "
801 << c << ", " << static_cast<int>(d) << ", " << e << ", " << f
802 << ")\n";
803 int64_t retval = 0;
804 retval += a;
805 retval += b;
806 retval += c;
807 retval += d;
808 retval += e;
809 retval += f;
810 std::cout << "returning " << retval << "\n";
811 return retval;
812}
813
814// Checks whether the float is between 1336.0f and 1338.0f.
815// Used for testing rounding of Dart Doubles to floats in Pointer.store().
816DART_EXPORT uint8_t IsRoughly1337(float* a) {
817 std::cout << "IsRoughly1337(" << a[0] << ")\n";
818 uint8_t retval = (1336.0f < a[0] && a[0] < 1338.0f) ? 1 : 0;
819 std::cout << "returning " << static_cast<int>(retval) << "\n";
820 return retval;
821}
822
823// Does nothing with input.
824// Used for testing functions that return void
826 std::cout << "DevNullFloat(" << a << ")\n";
827 std::cout << "returning nothing\n";
828}
829
830// Invents an elite floating pointptr_t number.
831// Used for testing functions that do not take any arguments.
833 std::cout << "InventFloatValue()\n";
834 const float retval = 1337.0f;
835 std::cout << "returning " << retval << "\n";
836 return retval;
837}
838
839// Can't easily share this with the generated file.
841 int32_t a0;
842 int32_t a1;
843 int32_t a2;
844 int32_t a3;
845 int32_t a4;
846};
847
849 int64_t recursionCounter,
853 std::cout << "PassStruct20BytesHomogeneousInt32x10"
854 << "(" << recursionCounter << ", (" << a0.a0 << ", " << a0.a1
855 << ", " << a0.a2 << ", " << a0.a3 << ", " << a0.a4 << "), "
856 << reinterpret_cast<void*>(f) << ")\n";
857 a0.a0++;
858 const int32_t a0_a0_saved = a0.a0;
859
860 if (recursionCounter <= 0) {
861 return a0;
862 }
863
864 Struct20BytesHomogeneousInt32Copy result = f(recursionCounter - 1, a0);
865 result.a0++;
866 if (a0_a0_saved != a0.a0) {
867 result.a4 = 0;
868 }
869
870 return result;
871}
872
873// Can't easily share this with the generated file.
875 int16_t a0;
876 int16_t a1;
877};
878
879// Can't easily share this with the generated file.
883};
884
886 std::cout << "CallbackWithStruct"
887 << "(" << reinterpret_cast<void*>(f) << ")\n";
888
890 arg.a0.a0 = 10;
891 arg.a0.a1 = 11;
892 arg.a1.a0 = 12;
893 arg.a1.a1 = 13;
894
895 f(arg);
896}
897
898////////////////////////////////////////////////////////////////////////////////
899// Tests for callbacks.
900
901// Sanity test.
902DART_EXPORT intptr_t TestSimpleAddition(intptr_t (*add)(int, int)) {
903 const intptr_t result = add(10, 20);
904 printf("result %" PRIdPTR "\n", result);
905 CHECK_EQ(result, 30);
906 return 0;
907}
908
909//// Following tests are copied from above, with the role of Dart and C++ code
910//// reversed.
911
912DART_EXPORT intptr_t
913TestIntComputation(int64_t (*fn)(int8_t, int16_t, int32_t, int64_t)) {
914 const int64_t result = fn(125, 250, 500, 1000);
915 std::cout << "result " << result << "\n";
916 CHECK_EQ(result, 625);
917 CHECK_EQ(0x7FFFFFFFFFFFFFFFLL, fn(0, 0, 0, 0x7FFFFFFFFFFFFFFFLL));
918 CHECK_EQ(((int64_t)0x8000000000000000LL), fn(0, 0, 0, 0x8000000000000000LL));
919 return 0;
920}
921
922DART_EXPORT intptr_t
923TestUintComputation(uint64_t (*fn)(uint8_t, uint16_t, uint32_t, uint64_t)) {
924 CHECK_EQ(0x7FFFFFFFFFFFFFFFLL, fn(0, 0, 0, 0x7FFFFFFFFFFFFFFFLL));
925 CHECK_EQ(0x8000000000000000LL, fn(0, 0, 0, 0x8000000000000000LL));
926 CHECK_EQ(-1, (int64_t)fn(0, 0, 0, -1));
927 return 0;
928}
929
930DART_EXPORT intptr_t TestSimpleMultiply(double (*fn)(double)) {
931 CHECK_EQ(fn(2.0), 2.0 * 1.337);
932 return 0;
933}
934
935DART_EXPORT intptr_t TestSimpleMultiplyFloat(float (*fn)(float)) {
936 CHECK(::std::abs(fn(2.0) - 2.0 * 1.337) < 0.001);
937 return 0;
938}
939
940DART_EXPORT intptr_t TestManyInts(intptr_t (*fn)(intptr_t,
941 intptr_t,
942 intptr_t,
943 intptr_t,
944 intptr_t,
945 intptr_t,
946 intptr_t,
947 intptr_t,
948 intptr_t,
949 intptr_t)) {
950 CHECK_EQ(55, fn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
951 return 0;
952}
953
954DART_EXPORT intptr_t TestManyDoubles(double (*fn)(double,
955 double,
956 double,
957 double,
958 double,
959 double,
960 double,
961 double,
962 double,
963 double)) {
964 CHECK_EQ(55, fn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
965 return 0;
966}
967
968DART_EXPORT intptr_t TestManyArgs(double (*fn)(intptr_t a,
969 float b,
970 intptr_t c,
971 double d,
972 intptr_t e,
973 float f,
974 intptr_t g,
975 double h,
976 intptr_t i,
977 float j,
978 intptr_t k,
979 double l,
980 intptr_t m,
981 float n,
982 intptr_t o,
983 double p,
984 intptr_t q,
985 float r,
986 intptr_t s,
987 double t)) {
988 CHECK(210.0 == fn(1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9, 10.0, 11, 12.0, 13, 14.0,
989 15, 16.0, 17, 18.0, 19, 20.0));
990 return 0;
991}
992
993// Used for testing floating point argument backfilling on Arm32 in hardfp.
994DART_EXPORT intptr_t TestSumFloatsAndDoubles(double (*fn)(float,
995 double,
996 float)) {
997 CHECK_EQ(6.0, fn(1.0, 2.0, 3.0));
998 return 0;
999}
1000
1001// Very many small integers, tests alignment on stack.
1002DART_EXPORT intptr_t TestSumVeryManySmallInts(int16_t (*fn)(int8_t,
1003 int16_t,
1004 int8_t,
1005 int16_t,
1006 int8_t,
1007 int16_t,
1008 int8_t,
1009 int16_t,
1010 int8_t,
1011 int16_t,
1012 int8_t,
1013 int16_t,
1014 int8_t,
1015 int16_t,
1016 int8_t,
1017 int16_t,
1018 int8_t,
1019 int16_t,
1020 int8_t,
1021 int16_t,
1022 int8_t,
1023 int16_t,
1024 int8_t,
1025 int16_t,
1026 int8_t,
1027 int16_t,
1028 int8_t,
1029 int16_t,
1030 int8_t,
1031 int16_t,
1032 int8_t,
1033 int16_t,
1034 int8_t,
1035 int16_t,
1036 int8_t,
1037 int16_t,
1038 int8_t,
1039 int16_t,
1040 int8_t,
1041 int16_t)) {
1042 CHECK_EQ(40 * 41 / 2, fn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1043 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
1044 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40));
1045 return 0;
1046}
1047
1048// Very many floating points, tests alignment on stack, and packing in
1049// floating point registers in hardfp.
1050DART_EXPORT intptr_t TestSumVeryManyFloatsDoubles(double (*fn)(float,
1051 double,
1052 float,
1053 double,
1054 float,
1055 double,
1056 float,
1057 double,
1058 float,
1059 double,
1060 float,
1061 double,
1062 float,
1063 double,
1064 float,
1065 double,
1066 float,
1067 double,
1068 float,
1069 double,
1070 float,
1071 double,
1072 float,
1073 double,
1074 float,
1075 double,
1076 float,
1077 double,
1078 float,
1079 double,
1080 float,
1081 double,
1082 float,
1083 double,
1084 float,
1085 double,
1086 float,
1087 double,
1088 float,
1089 double)) {
1090 CHECK_EQ(40 * 41 / 2,
1091 fn(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0,
1092 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0,
1093 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0,
1094 35.0, 36.0, 37.0, 38.0, 39.0, 40.0));
1095 return 0;
1096}
1097
1098DART_EXPORT intptr_t TestStore(int64_t* (*fn)(int64_t* a)) {
1099 int64_t p[2] = {42, 1000};
1100 int64_t* result = fn(p);
1101 CHECK_EQ(*result, 1337);
1102 CHECK_EQ(p[1], 1337);
1103 CHECK_EQ(result, p + 1);
1104 return 0;
1105}
1106
1107DART_EXPORT intptr_t TestReturnNull(int32_t (*fn)()) {
1108 CHECK_EQ(fn(), 42);
1109 return 0;
1110}
1111
1112DART_EXPORT intptr_t TestNullPointers(int64_t* (*fn)(int64_t* ptr)) {
1113 CHECK_EQ(fn(nullptr), reinterpret_cast<void*>(sizeof(int64_t)));
1114 int64_t p[2] = {0};
1115 CHECK_EQ(fn(p), p + 1);
1116 return 0;
1117}
1118
1119DART_EXPORT intptr_t TestReturnVoid(intptr_t (*return_void)()) {
1120 CHECK_EQ(return_void(), 0);
1121 return 0;
1122}
1123
1124DART_EXPORT intptr_t TestThrowExceptionDouble(double (*fn)()) {
1125 CHECK_EQ(fn(), 42.0);
1126 return 0;
1127}
1128
1130 CHECK_EQ(fn(), nullptr);
1131 return 0;
1132}
1133
1134DART_EXPORT intptr_t TestThrowException(intptr_t (*fn)()) {
1135 CHECK_EQ(fn(), 42);
1136 return 0;
1137}
1138
1139DART_EXPORT intptr_t TestTakeMaxUint8x10(intptr_t (*fn)(uint8_t,
1140 uint8_t,
1141 uint8_t,
1142 uint8_t,
1143 uint8_t,
1144 uint8_t,
1145 uint8_t,
1146 uint8_t,
1147 uint8_t,
1148 uint8_t)) {
1149 CHECK_EQ(1, fn(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF));
1150 // Check the argument values are properly truncated.
1151 uint64_t v = 0xabcFF;
1152 CHECK_EQ(1, fn(v, v, v, v, v, v, v, v, v, v));
1153 return 0;
1154}
1155
1156DART_EXPORT intptr_t TestReturnMaxUint8(uint8_t (*fn)()) {
1157 std::cout << "TestReturnMaxUint8(fn): " << static_cast<int>(fn()) << "\n";
1158 CHECK_EQ(0xFF, fn());
1159 return 0;
1160}
1161
1162// Receives some pointer (Pointer<NativeType> in Dart) and writes some bits.
1164 uint8_t* p2 = reinterpret_cast<uint8_t*>(p);
1165 p2[0] = 42;
1166}
1167
1168// Manufactures some pointer (Pointer<NativeType> in Dart) with a bogus address.
1170 uint64_t bogus_address = 0x13370000;
1171 return reinterpret_cast<void*>(bogus_address);
1172}
1173
1174// Passes some pointer (Pointer<NativeType> in Dart) to Dart as argument.
1176 void* pointer = malloc(sizeof(int64_t));
1177 f(pointer);
1178 free(pointer);
1179}
1180
1181// Receives some pointer (Pointer<NativeType> in Dart) from Dart as return
1182// value.
1184 void* p = f();
1185 uint8_t* p2 = reinterpret_cast<uint8_t*>(p);
1186 p2[0] = 42;
1187}
1188
1189DART_EXPORT int32_t PassStruct(void*) {
1190 return 42;
1191}
1192
1195 uint64_t someValue;
1196};
1197
1199 return my_struct->someValue;
1200}
1201
1203 uint64_t val;
1204};
1205
1207 struct Struct46127 myStruct;
1208 myStruct.val = 123;
1209 return myStruct;
1210}
1211
1212#pragma pack(push, 1)
1214 int8_t a0;
1215 int16_t a1;
1216};
1217#pragma pack(pop)
1218
1220 return sizeof(Struct3BytesPackedIntCopy);
1221}
1222
1223// Define ssize_t for Windows as intptr_t.
1224#if defined(_WIN32)
1225typedef intptr_t ssize_t;
1226#endif
1227
1228#define DEFINE_SIZE_OF_AND_SIGN_OF(type_modifier, type, type2) \
1229 DART_EXPORT uint64_t FfiSizeOf_##type_modifier##_##type##_##type2() { \
1230 return sizeof(type_modifier type type2); \
1231 } \
1232 \
1233 DART_EXPORT uint64_t FfiSignOf_##type_modifier##_##type##_##type2() { \
1234 return std::numeric_limits<type_modifier type type2>::is_signed; \
1235 }
1236
1237#define TYPES(F) \
1238 F(, char, ) /* NOLINT */ \
1239 F(signed, char, ) /* NOLINT */ \
1240 F(unsigned, char, ) /* NOLINT */ \
1241 F(, short, ) /* NOLINT */ \
1242 F(unsigned, short, ) /* NOLINT */ \
1243 F(, int, ) /* NOLINT */ \
1244 F(unsigned, int, ) /* NOLINT */ \
1245 F(, long, ) /* NOLINT */ \
1246 F(unsigned, long, ) /* NOLINT */ \
1247 F(, long, long) /* NOLINT */ \
1248 F(unsigned, long, long) /* NOLINT */ \
1249 F(, intptr_t, ) /* NOLINT */ \
1250 F(, uintptr_t, ) /* NOLINT */ \
1251 F(, size_t, ) /* NOLINT */ \
1252 F(, wchar_t, ) /* NOLINT */
1253
1255
1256#undef DEFINE_SIZE_OF_AND_SIGN_OF
1257#undef TYPES
1258
1260 return WCHAR_MIN;
1261}
1263 return WCHAR_MAX;
1264}
1265
1266struct VarArgs {
1267 int32_t a;
1268};
1269
1271 va_list var_args;
1272 va_start(var_args, a0);
1273 VarArgs a1 = va_arg(var_args, VarArgs);
1274 va_end(var_args);
1275
1276 std::cout << "VariadicStructVarArgs"
1277 << "(" << a0.a << ", " << a1.a << ")"
1278 << "\n";
1279
1280 int64_t result = 0;
1281
1282 result += a0.a;
1283 result += a1.a;
1284
1285 std::cout << "result = " << result << "\n";
1286
1287 return result;
1288}
1289
1290////////////////////////////////////////////////////////////////////////////////
1291// Tests for async callbacks.
1292
1293DART_EXPORT void CallFunctionOnSameThread(int64_t response_id,
1294 void (*fn)(int64_t, int32_t)) {
1295 fn(response_id, 123);
1296}
1297
1299 void (*fn)(int64_t, int32_t)) {
1300 std::thread thread(fn, response_id, 123);
1301 thread.join();
1302}
1303
1305 void (*fn)(int64_t,
1306 int32_t)) {
1307 std::thread thread(fn, response_id, 123);
1308 thread.detach();
1309}
1310
1311////////////////////////////////////////////////////////////////////////////////
1312// Tests for isolate local callbacks.
1313
1314DART_EXPORT int32_t CallTwoIntFunction(int32_t (*fn)(int32_t, int32_t),
1315 int32_t a,
1316 int32_t b) {
1317 return fn(a, b);
1318}
1319
1320DART_EXPORT void CallTwoIntVoidFunction(void (*fn)(int32_t, int32_t),
1321 int32_t a,
1322 int32_t b) {
1323 fn(a, b);
1324}
1325
1326DART_EXPORT void* CallTwoIntPointerFunction(void* (*fn)(int32_t, int32_t),
1327 int32_t a,
1328 int32_t b) {
1329 return fn(a, b);
1330}
1331
1332DART_EXPORT int32_t CallTwoPointerIntFunction(int32_t (*fn)(void*, void*),
1333 void* a,
1334 void* b) {
1335 return fn(a, b);
1336}
1337
1338DART_EXPORT char TakeString(char* my_string) {
1339 std::cout << "TakeString(" << my_string << ")\n";
1340 return my_string[4];
1341}
1342
1343} // namespace dart
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19
static bool b
struct MyStruct s
struct MyStruct a[10]
DART_EXPORT_FIELD struct Coord globalStruct
DART_EXPORT_FIELD int32_t globalInt
#define CHECK(X)
#define CHECK_EQ(X, Y)
#define DART_EXPORT
#define TYPES(F)
#define DEFINE_SIZE_OF_AND_SIGN_OF(type_modifier, type, type2)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
GAsyncResult * result
double x
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: SkSLString.cpp:83
va_start(args, format)
va_end(args)
Definition: dart_vm.cc:33
DART_EXPORT int32_t SumPlus42(int32_t a, int32_t b)
DART_EXPORT void NativeTypePointerParam(void *p)
DART_EXPORT double SumVeryManyFloatsDoubles(float a01, double a02, float a03, double a04, float a05, double a06, float a07, double a08, float a09, double a10, float a11, double a12, float a13, double a14, float a15, double a16, float a17, double a18, float a19, double a20, float a21, double a22, float a23, double a24, float a25, double a26, float a27, double a28, float a29, double a30, float a31, double a32, float a33, double a34, float a35, double a36, float a37, double a38, float a39, double a40)
DART_EXPORT int32_t ReturnMinInt32v2()
DART_EXPORT int64_t WCharMaxValue()
DART_EXPORT intptr_t TestReturnVoid(intptr_t(*return_void)())
DART_EXPORT int32_t ReturnMinInt32()
DART_EXPORT intptr_t TestManyDoubles(double(*fn)(double, double, double, double, double, double, double, double, double, double))
DART_EXPORT int64_t * NullableInt64ElemAt1(int64_t *a)
DART_EXPORT int32_t PassStruct(void *)
DART_EXPORT void CallbackNativeTypePointerParam(void(*f)(void *))
DART_EXPORT intptr_t TestUintComputation(uint64_t(*fn)(uint8_t, uint16_t, uint32_t, uint64_t))
DART_EXPORT uint32_t ReturnMaxUint32v2()
DART_EXPORT uint8_t IsRoughly1337(float *a)
DART_EXPORT intptr_t TakeMinInt8(int8_t x)
DART_EXPORT char TakeString(char *my_string)
DART_EXPORT int16_t SumManySmallInts(int8_t a, int16_t b, int8_t c, int16_t d, int8_t e, int16_t f, int8_t g, int16_t h, int8_t i, int16_t j)
DART_EXPORT int64_t Regress39044(int64_t a, int8_t b)
DART_EXPORT int32_t GetGlobalVar()
DART_EXPORT uint8_t ReturnMaxUint8()
DART_EXPORT intptr_t TestThrowExceptionDouble(double(*fn)())
DART_EXPORT intptr_t TestReturnMaxUint8(uint8_t(*fn)())
DART_EXPORT intptr_t TestManyArgs(double(*fn)(intptr_t a, float b, intptr_t c, double d, intptr_t e, float f, intptr_t g, double h, intptr_t i, float j, intptr_t k, double l, intptr_t m, float n, intptr_t o, double p, intptr_t q, float r, intptr_t s, double t))
DART_EXPORT int16_t ReturnMinInt16()
DART_EXPORT double Times1_337Double(double a)
DART_EXPORT intptr_t TestThrowExceptionPointer(void *(*fn)())
DART_EXPORT void * NativeTypePointerReturn()
DART_EXPORT int32_t CallTwoIntFunction(int32_t(*fn)(int32_t, int32_t), int32_t a, int32_t b)
void * malloc(size_t size)
Definition: allocation.cc:19
DART_EXPORT void CallTwoIntVoidFunction(void(*fn)(int32_t, int32_t), int32_t a, int32_t b)
DART_EXPORT Struct20BytesHomogeneousInt32Copy PassStructRecursive(int64_t recursionCounter, Struct20BytesHomogeneousInt32Copy a0, Struct20BytesHomogeneousInt32Copy(*f)(int64_t, Struct20BytesHomogeneousInt32Copy))
DART_EXPORT uint64_t SizeOfStruct3BytesPackedInt()
DART_EXPORT void FreeStruct9Uint8(Struct9Uint8 *address)
DART_EXPORT int64_t SumVeryLargeStruct(VeryLargeStruct *vls)
DART_EXPORT intptr_t TestSimpleMultiplyFloat(float(*fn)(float))
DART_EXPORT intptr_t TakeMaxUint8x10(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f, uint8_t g, uint8_t h, uint8_t i, uint8_t j)
DART_EXPORT uint64_t Regress43693(Struct43693 *my_struct)
DART_EXPORT intptr_t ApplyTo42And74(IntptrBinOp binop)
DART_EXPORT intptr_t Regress40537Variant2(uint8_t x)
DART_EXPORT double SumFloatsAndDoubles(float a, double b, float c)
DART_EXPORT intptr_t TakeMinInt16(int16_t x)
DART_EXPORT uint32_t ReturnMaxUint32()
DART_EXPORT Struct46127 Regress46127()
DART_EXPORT intptr_t TakeMaxUint8(uint8_t x)
DART_EXPORT int64_t * Assign1337Index1(int64_t *a)
DART_EXPORT intptr_t TestSimpleAddition(intptr_t(*add)(int, int))
DART_EXPORT void CallFunctionOnSameThread(int64_t response_id, void(*fn)(int64_t, int32_t))
DART_EXPORT intptr_t Times3(intptr_t a)
DART_EXPORT uint16_t ReturnMaxUint16()
DART_EXPORT void DevNullFloat(float a)
DART_EXPORT intptr_t TestTakeMaxUint8x10(intptr_t(*fn)(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t))
DART_EXPORT uint16_t ReturnMaxUint16v2()
DART_EXPORT intptr_t TestSumVeryManySmallInts(int16_t(*fn)(int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t))
DART_EXPORT int16_t SumVeryManySmallInts(int8_t a01, int16_t a02, int8_t a03, int16_t a04, int8_t a05, int16_t a06, int8_t a07, int16_t a08, int8_t a09, int16_t a10, int8_t a11, int16_t a12, int8_t a13, int16_t a14, int8_t a15, int16_t a16, int8_t a17, int16_t a18, int8_t a19, int16_t a20, int8_t a21, int16_t a22, int8_t a23, int16_t a24, int8_t a25, int16_t a26, int8_t a27, int16_t a28, int8_t a29, int16_t a30, int8_t a31, int16_t a32, int8_t a33, int16_t a34, int8_t a35, int16_t a36, int8_t a37, int16_t a38, int8_t a39, int16_t a40)
DART_EXPORT void CallFunctionOnNewThreadNonBlocking(int64_t response_id, void(*fn)(int64_t, int32_t))
DART_EXPORT int8_t ReturnMinInt8()
DART_EXPORT intptr_t TestManyInts(intptr_t(*fn)(intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t))
DART_EXPORT intptr_t TestSimpleMultiply(double(*fn)(double))
DART_EXPORT intptr_t TestSumVeryManyFloatsDoubles(double(*fn)(float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double))
DART_EXPORT void CallbackNativeTypePointerReturn(void *(*f)())
DART_EXPORT Coord * CoordinateElemAt1(Coord *coord)
DART_EXPORT float InventFloatValue()
DART_EXPORT intptr_t TestThrowException(intptr_t(*fn)())
DART_EXPORT intptr_t TakeMinInt32(int32_t x)
DART_EXPORT intptr_t TestStore(int64_t *(*fn)(int64_t *a))
Coord *(* CoordUnOp)(Coord *coord)
DART_EXPORT Struct9Uint8 * AllocStruct9Uint8()
DART_EXPORT double SumManyDoubles(double a, double b, double c, double d, double e, double f, double g, double h, double i, double j)
DART_EXPORT intptr_t TestIntComputation(int64_t(*fn)(int8_t, int16_t, int32_t, int64_t))
DART_EXPORT int64_t SumSmallNumbers(int8_t a, int16_t b, int32_t c, uint8_t d, uint16_t e, uint32_t f)
DART_EXPORT float Times1_337Float(float a)
DART_EXPORT void CallFunctionOnNewThreadBlocking(int64_t response_id, void(*fn)(int64_t, int32_t))
DART_EXPORT intptr_t Regress40537(uint8_t x)
DART_EXPORT int64_t UintComputation(uint8_t a, uint16_t b, uint32_t c, uint64_t d)
DART_EXPORT intptr_t SumManyInts(intptr_t a, intptr_t b, intptr_t c, intptr_t d, intptr_t e, intptr_t f, intptr_t g, intptr_t h, intptr_t i, intptr_t j)
DART_EXPORT Coord GetGlobalStruct()
DART_EXPORT int64_t WCharMinValue()
DART_EXPORT uint8_t Regress40537Variant3(intptr_t x)
DART_EXPORT int64_t VariadicStructVarArgs(VarArgs a0,...)
DART_EXPORT int64_t SumReturnStruct9Uint8(Struct9Uint8(*callback)(Struct9Uint8 *), Struct9Uint8 *in)
DART_EXPORT void * CallTwoIntPointerFunction(void *(*fn)(int32_t, int32_t), int32_t a, int32_t b)
DART_EXPORT intptr_t SumManyIntsOdd(intptr_t a, intptr_t b, intptr_t c, intptr_t d, intptr_t e, intptr_t f, intptr_t g, intptr_t h, intptr_t i, intptr_t j, intptr_t k)
DART_EXPORT void InduceACrash()
DART_EXPORT int32_t CallTwoPointerIntFunction(int32_t(*fn)(void *, void *), void *a, void *b)
DART_EXPORT intptr_t TakeMaxUint32(uint32_t x)
DART_EXPORT double SumManyNumbers(intptr_t a, float b, intptr_t c, double d, intptr_t e, float f, intptr_t g, double h, intptr_t i, float j, intptr_t k, double l, intptr_t m, float n, intptr_t o, double p, intptr_t q, float r, intptr_t s, double t)
DART_EXPORT intptr_t TestNullPointers(int64_t *(*fn)(int64_t *ptr))
DART_EXPORT intptr_t TestReturnNull(int32_t(*fn)())
DART_EXPORT IntptrBinOp IntptrAdditionClosure()
DART_EXPORT int8_t ReturnMinInt8v2()
DART_EXPORT uint8_t ReturnMaxUint8v2()
DART_EXPORT int16_t ReturnMinInt16v2()
DART_EXPORT Coord * CoordinateUnOpTrice(CoordUnOp unop, Coord *coord)
DART_EXPORT int64_t SumStruct9Uint8(Struct9Uint8 s9)
DART_EXPORT int64_t IntComputation(int8_t a, int16_t b, int32_t c, int64_t d)
DART_EXPORT intptr_t TakeMaxUint16(uint16_t x)
DART_EXPORT intptr_t TestSumFloatsAndDoubles(double(*fn)(float, double, float))
DART_EXPORT void CallbackWithStruct(void(*f)(Struct8BytesNestedIntCopy))
intptr_t(* IntptrBinOp)(intptr_t a, intptr_t b)
DART_EXPORT void SetGlobalVar(int32_t v)
DART_EXPORT Coord * TransposeCoordinate(Coord *coord)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SIN Vec< N, float > abs(const Vec< N, float > &x)
Definition: SkVx.h:707
SkScalar h
double x
struct Coord * next
double y
Struct4BytesHomogeneousInt16Copy a1
Struct4BytesHomogeneousInt16Copy a0
VeryLargeStruct * parent
VeryLargeStruct * children
unsigned long DWORD
Definition: windows_types.h:22