efb60eac59
Closes [#54250](https://github.com/dart-lang/sdk/issues/54250). TEST=test/ffi Change-Id: I2299e019b6c0b0db74662e4f9439feac46bc9b40 CoreLibraryReviewExempt: FFI only Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341420 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Lasse Nielsen <lrn@google.com> Auto-Submit: Shikhar <shikharish05@gmail.com> Reviewed-by: Daco Harkes <dacoharkes@google.com>
37 lines
774 B
Dart
37 lines
774 B
Dart
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// VMOptions=--deterministic --optimization-counter-threshold=100
|
|
|
|
import 'dart:ffi';
|
|
|
|
import "package:ffi/ffi.dart";
|
|
|
|
main(List<String> arguments) {
|
|
for (int i = 0; i < 1000; i++) {
|
|
testCompoundLoadAndStore();
|
|
}
|
|
print('done');
|
|
}
|
|
|
|
const count = 10;
|
|
|
|
testCompoundLoadAndStore() {
|
|
final foos = calloc<Foo>(count);
|
|
final reference = foos.ref;
|
|
reference.a = count;
|
|
|
|
for (var j = 1; j < count; j++) {
|
|
final foo = foos + j;
|
|
foo.ref = reference;
|
|
}
|
|
|
|
calloc.free(foos);
|
|
}
|
|
|
|
final class Foo extends Struct {
|
|
@Int8()
|
|
external int a;
|
|
}
|