Skip to content

Commit 464b254

Browse files
jensjohacommit-bot@chromium.org
authored andcommitted
[CFE] Test for FFI and incremental compilation
This currently crashes the compiler. Bug: #39840 Change-Id: I59d625158c8011846a3181eba8b4da2ce4b49cd2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128731 Reviewed-by: Daco Harkes <[email protected]> Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent 8b290d9 commit 464b254

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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.md file.
4+
5+
# Test FFI compilation.
6+
7+
type: newworld
8+
worlds:
9+
- entry: main.dart
10+
sources:
11+
main.dart: |
12+
import 'lib.dart';
13+
14+
main() {
15+
Coordinate coordinate = new Coordinate.allocate(42.0, 42.0, null);
16+
print(coordinate.x);
17+
print(coordinate.y);
18+
print(coordinate.next);
19+
}
20+
lib.dart: |
21+
import 'dart:ffi';
22+
23+
class Coordinate extends Struct {
24+
@Double()
25+
double x;
26+
27+
@Double()
28+
double y;
29+
30+
Pointer<Coordinate> next;
31+
32+
factory Coordinate.allocate(double x, double y, Pointer<Coordinate> next) {
33+
return null;
34+
}
35+
}
36+
expectedLibraryCount: 2
37+
- entry: main.dart
38+
worldType: updated
39+
expectInitializeFromDill: false
40+
invalidate:
41+
- main.dart
42+
sources:
43+
main.dart: |
44+
import 'lib.dart';
45+
46+
main() {
47+
Coordinate coordinate = new Coordinate.allocate(42.0, 42.0, null);
48+
print(coordinate.x);
49+
print(coordinate.y);
50+
print(coordinate.next);
51+
done();
52+
}
53+
54+
done() {
55+
print("Done!");
56+
}
57+
expectedLibraryCount: 2
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
main = <No Member>;
2+
library from "org-dartlang-test:///lib.dart" as lib {
3+
4+
import "dart:ffi";
5+
6+
@#C3
7+
class Coordinate extends dart.ffi::Struct {
8+
@#C3
9+
static final field dart.core::int* #sizeOf = (#C6).{dart.core::List::[]}(dart.ffi::_abi());
10+
@#C3
11+
constructor #fromPointer(dynamic #pointer) → dynamic
12+
: super dart.ffi::Struct::_fromPointer(#pointer)
13+
;
14+
static factory allocate(dart.core::double* x, dart.core::double* y, dart.ffi::Pointer<lib::Coordinate*>* next) → lib::Coordinate* {
15+
return null;
16+
}
17+
get #_ptr_x() → dart.ffi::Pointer<dart.ffi::Double*>*
18+
return this.{dart.ffi::Struct::_addressOf}.{dart.ffi::Pointer::cast}<dart.ffi::Double*>();
19+
get x() → dart.core::double*
20+
return dart.ffi::_loadDouble(this.{lib::Coordinate::#_ptr_x}, #C7);
21+
set x(dart.core::double* #v) → void
22+
return dart.ffi::_storeDouble(this.{lib::Coordinate::#_ptr_x}, #C7, #v);
23+
get #_ptr_y() → dart.ffi::Pointer<dart.ffi::Double*>*
24+
return this.{dart.ffi::Struct::_addressOf}.{dart.ffi::Pointer::_offsetBy}((#C9).{dart.core::List::[]}(dart.ffi::_abi())).{dart.ffi::Pointer::cast}<dart.ffi::Double*>();
25+
get y() → dart.core::double*
26+
return dart.ffi::_loadDouble(this.{lib::Coordinate::#_ptr_y}, #C7);
27+
set y(dart.core::double* #v) → void
28+
return dart.ffi::_storeDouble(this.{lib::Coordinate::#_ptr_y}, #C7, #v);
29+
get #_ptr_next() → dart.ffi::Pointer<dart.ffi::Pointer<lib::Coordinate*>*>*
30+
return this.{dart.ffi::Struct::_addressOf}.{dart.ffi::Pointer::_offsetBy}((#C11).{dart.core::List::[]}(dart.ffi::_abi())).{dart.ffi::Pointer::cast}<dart.ffi::Pointer<lib::Coordinate*>*>();
31+
get next() → dart.ffi::Pointer<lib::Coordinate*>*
32+
return dart.ffi::_loadPointer<dart.ffi::Pointer<lib::Coordinate*>*>(this.{lib::Coordinate::#_ptr_next}, #C7);
33+
set next(dart.ffi::Pointer<lib::Coordinate*>* #v) → void
34+
return dart.ffi::_storePointer<dart.ffi::Pointer<lib::Coordinate*>*>(this.{lib::Coordinate::#_ptr_next}, #C7, #v);
35+
}
36+
}
37+
library from "org-dartlang-test:///main.dart" as main {
38+
39+
import "org-dartlang-test:///lib.dart";
40+
41+
static method main() → dynamic {
42+
lib::Coordinate* coordinate = lib::Coordinate::allocate(42.0, 42.0, null);
43+
dart.core::print(coordinate.{lib::Coordinate::x});
44+
dart.core::print(coordinate.{lib::Coordinate::y});
45+
dart.core::print(coordinate.{lib::Coordinate::next});
46+
}
47+
}
48+
constants {
49+
#C1 = "vm:entry-point"
50+
#C2 = null
51+
#C3 = dart.core::pragma {name:#C1, options:#C2}
52+
#C4 = 24
53+
#C5 = 20
54+
#C6 = <dart.core::int*>[#C4, #C5, #C4]
55+
#C7 = 0
56+
#C8 = 8
57+
#C9 = <dart.core::int*>[#C8, #C8, #C8]
58+
#C10 = 16
59+
#C11 = <dart.core::int*>[#C10, #C10, #C10]
60+
}

pkg/front_end/testcases/incremental_initialize_from_dill/status.status

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
# BSD-style license that can be found in the LICENSE.md file.
44

55
# Status file for the test suite ../test/incremental_load_from_dill_test.dart.
6+
7+
ffi_01: Crash # http://dartbug.com/39840

0 commit comments

Comments
 (0)