-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a way to express native effects in Dart expressions in kernel. This CL adds a `void _nativeEffect(Object)` to `dart:internal`. The semantics of `_nativeEffect` are to not execute its arguments and return `null`. This CL uses this `_nativeEffect` to make sure that we never execute the struct constructor invocations used to simulate the native behavior of FFI trampolines. Closes: #45607 TEST=tests/ffi(_2)/native_effect_test.dart Change-Id: Ie06de145e49f8b1cae9e148c2d5d97d5cd8e6878 Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,dart-sdk-linux-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194421 Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com>
- Loading branch information
Showing
11 changed files
with
158 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2021, 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. | ||
// | ||
// SharedObjects=ffi_test_functions | ||
|
||
// Tests that the dart:internal _nativeEffect flow graph builder works. | ||
|
||
import 'dart:ffi'; | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
import 'dylib_utils.dart'; | ||
|
||
void main() { | ||
testReturnStruct1ByteInt(); | ||
} | ||
|
||
final ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions"); | ||
|
||
final returnStruct1ByteInt = ffiTestFunctions.lookupFunction< | ||
Struct1ByteInt Function(Int8), | ||
Struct1ByteInt Function(int)>("ReturnStruct1ByteInt"); | ||
|
||
void testReturnStruct1ByteInt() { | ||
final result = returnStruct1ByteInt(1); | ||
Expect.equals(1, result.a0); | ||
} | ||
|
||
class Struct1ByteInt extends Struct { | ||
@Int8() | ||
external int a0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2021, 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. | ||
// | ||
// SharedObjects=ffi_test_functions | ||
|
||
// Tests that the dart:internal _nativeEffect flow graph builder works. | ||
|
||
import 'dart:ffi'; | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
import 'dylib_utils.dart'; | ||
|
||
void main() { | ||
testReturnStruct1ByteInt(); | ||
} | ||
|
||
final ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions"); | ||
|
||
final returnStruct1ByteInt = ffiTestFunctions.lookupFunction< | ||
Struct1ByteInt Function(Int8), | ||
Struct1ByteInt Function(int)>("ReturnStruct1ByteInt"); | ||
|
||
void testReturnStruct1ByteInt() { | ||
final result = returnStruct1ByteInt(1); | ||
Expect.equals(1, result.a0); | ||
} | ||
|
||
class Struct1ByteInt extends Struct { | ||
@Int8() | ||
int a0; | ||
} |