Files
sdk/BUILD.gn
T
Liam Appelbe 4679c040c6 [vm] Sync ffi callbacks can enter owned target isolate
Adds a new code path for NativeCallable.isolateLocal invocations. If
the current thread is not entered into any isolate, but owns the
target isolate, then it enters the target isolate, invokes, then exits
the isolate.

Fixes: https://github.com/dart-lang/sdk/issues/61623
TEST=tests/ffi/function_callbacks_isolate_ownership_test.dart
Change-Id: I401f185fadf7d2a55190dafd15387e1c418c67c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452380
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2026-02-05 01:29:23 -08:00

497 lines
16 KiB
Plaintext

# Copyright (c) 2016, 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.
import("build/config/gclient_args.gni")
import("sdk_args.gni")
targeting_fuchsia = target_os == "fuchsia"
# This target will be built if no target is specified when invoking ninja.
group("default") {
if (targeting_fuchsia) {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
deps = [ ":runtime" ]
}
group("most") {
import("runtime/runtime_args.gni")
if (targeting_fuchsia) {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
deps = [
":analysis_server",
":create_sdk",
":dart2js",
":dartanalyzer",
":ddc",
":runtime",
]
}
group("runtime") {
import("runtime/runtime_args.gni")
if (targeting_fuchsia) {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
deps = [
"runtime/bin:dart",
"runtime/bin:dartvm",
"runtime/bin:ffi_test_dynamic_library",
"runtime/bin:ffi_test_functions",
"runtime/bin:process_test",
"runtime/bin:run_vm_tests",
"runtime/vm:kernel_platform_files($host_toolchain)",
"samples/embedder:kernel",
"samples/ffi/http:fake_http",
"samples/ffi/httpIG:fake_httpIG",
"utils/dartdev",
"utils/kernel-service",
]
# The following dependencies allow dartdev to start the resident frontend
# server and DDS.
if (dart_target_arch != "ia32" && dart_target_arch != "x86") {
deps += [
"runtime/bin:dartaotruntime",
"runtime/bin:dartaotruntime_product",
"utils/dartdev:dartdev_aot_snapshot",
"utils/dds:dds_aot",
"utils/dtd:dtd_aot",
"utils/kernel-service:frontend_server_aot_product",
]
} else {
deps += [
"utils/dds",
"utils/dtd",
"utils/kernel-service:frontend_server",
]
}
# AOT samples use dlopen to load AOT snapshots and it works only on
# 64-bit Linux right now.
if ((is_linux || is_mac) &&
(dart_target_arch == "x64" || dart_target_arch == "arm64")) {
deps += [ "samples/embedder:aot" ]
}
if (!is_win) {
# The test isn't run on windows
deps += [ "runtime/bin:entrypoints_verification_test" ]
}
# This flag is set in runtime/runtime_args.gni
# The analyze_snapshot tool is only supported on 64 bit AOT builds running
# under linux and android platforms
if (build_analyze_snapshot) {
deps += [
# The `analyze_snapshot` tests require the `analyze_snapshot` as well as
# `gen_snapshot` binaries.
"runtime/bin:analyze_snapshot",
"runtime/bin:analyze_snapshot($host_toolchain)",
"runtime/bin:gen_snapshot",
"runtime/bin:gen_snapshot($host_toolchain)",
]
}
if (is_linux || is_android) {
deps += [ "runtime/bin:abstract_socket_test" ]
} else if (is_fuchsia) {
deps += [ ":fuchsia_test_package" ]
} else if (is_win) {
deps += [ "runtime/bin:create_process_test_helper" ]
}
}
# A separate target and not included in group("runtime"). This way the target\
# "runtime" does not get many executables extra as build output.
group("run_ffi_unit_tests") {
deps = [ "runtime/bin/ffi_unit_test:run_ffi_unit_tests" ]
}
group("runtime_precompiled") {
import("runtime/runtime_args.gni")
deps = [
"runtime/bin:dartaotruntime",
"runtime/bin:gen_snapshot",
"runtime/bin:gen_snapshot($host_toolchain)",
"runtime/bin:process_test",
"runtime/vm:kernel_platform_files($host_toolchain)",
]
if (is_linux || is_android) {
deps += [ "runtime/bin:abstract_socket_test" ]
}
if (dart_dynamic_modules) {
deps += [ "utils/dart2bytecode:dart2bytecode_snapshot" ]
deps += [ "utils/modular_aot_compiler:modular_aot_compiler_snapshot" ]
deps += [ "utils/dynamic_module_runner:dynamic_module_runner_snapshot" ]
}
}
group("create_sdk") {
public_deps = [ "sdk:create_sdk" ]
}
group("create_platform_sdk") {
public_deps = [ "sdk:create_platform_sdk" ]
}
group("dart2js") {
import("runtime/runtime_args.gni")
if (dart_target_arch != "ia32" && dart_target_arch != "x86") {
deps = [
":runtime_precompiled",
"utils/compiler:dart2js_sdk_aot",
]
} else {
deps = [ "utils/compiler:dart2js" ]
}
}
group("dart2wasm_platform") {
deps = [
":runtime_precompiled",
"utils/dart2wasm:compile_dart2wasm_js_compatibility_platform",
"utils/dart2wasm:compile_dart2wasm_platform",
"utils/dart2wasm:dart2wasm_snapshot",
]
if (defined(is_product)) {
if (is_product) {
deps += [ "utils/dart2wasm:dart2wasm_product_snapshot" ]
} else {
deps += [ "utils/dart2wasm:dart2wasm_asserts_snapshot" ]
}
}
}
group("dart2wasm") {
deps = [
":dart2wasm_platform",
"utils/dart2wasm:test_wasm_modules",
]
}
group("dart2wasm_benchmark") {
deps = [
":dart2wasm_platform",
"third_party/binaryen:wasm-opt",
]
}
group("dartanalyzer") {
deps = [ "utils/dartanalyzer" ]
}
group("ddc") {
import("runtime/runtime_args.gni")
if (dart_target_arch != "ia32" && dart_target_arch != "x86") {
deps = [
":runtime_precompiled",
"utils/bazel:kernel_worker_aot",
"utils/ddc:dartdevc_aot",
]
} else {
deps = [
"utils/bazel:kernel_worker",
"utils/ddc:dartdevc",
]
}
}
group("analysis_server") {
deps = [ "utils/analysis_server" ]
}
group("tools") {
deps = [
"utils:compile_platform.exe",
"utils:gen_kernel.exe",
]
}
# This is the target that is built on the dart2js build bots.
# It must depend on anything that is required by the dart2js
# test suites.
group("dart2js_bot") {
deps = [
":create_sdk",
"utils/compiler:compile_dart2js_platform",
]
}
if (is_fuchsia) {
import("third_party/fuchsia/gn-sdk/src/component.gni")
import("third_party/fuchsia/gn-sdk/src/package.gni")
import("utils/aot_snapshot.gni")
import("utils/application_snapshot.gni")
# TODO(b/399714829): Test packages should be created at test-time, not build-time.
# tests/ffi/**_test.dart except those with compile-time errors
test_sources = [
"tests/ffi/abi_specific_int_test.dart",
"tests/ffi/abi_test.dart",
"tests/ffi/address_of_array_generated_test.dart",
"tests/ffi/address_of_cast_test.dart",
"tests/ffi/address_of_struct_generated_test.dart",
"tests/ffi/address_of_test.dart",
"tests/ffi/address_of_typeddata_generated_test.dart",
"tests/ffi/aliasing_test.dart",
"tests/ffi/allocator_test.dart",
"tests/ffi/array_compound_elements_test.dart",
"tests/ffi/array_primitive_elements_generated_test.dart",
"tests/ffi/async_void_function_callbacks_test.dart",
"tests/ffi/bool_test.dart",
"tests/ffi/c_types_test.dart",
"tests/ffi/callback_unwind_error_test.dart",
"tests/ffi/calloc_test.dart",
"tests/ffi/data_not_asan_test.dart",
"tests/ffi/data_test.dart",
"tests/ffi/deeply_immutable_c_api_finalizer_test.dart",
"tests/ffi/dl_api_exit_enter_isolate_test.dart",
"tests/ffi/dylib_close_test.dart",
"tests/ffi/dylib_isolates_test.dart",
"tests/ffi/dylib_open_test.dart",
"tests/ffi/expando_test.dart",
"tests/ffi/extension_methods_test.dart",
"tests/ffi/external_typed_data_finalizer_test.dart",
"tests/ffi/external_typed_data_test.dart",
"tests/ffi/ffi_callback_unique_test.dart",
"tests/ffi/ffi_induce_a_crash_test.dart",
"tests/ffi/ffi_native_test.dart",
"tests/ffi/finalizer_external_size_accounting_test.dart",
"tests/ffi/function_callbacks_isolate_ownership_test.dart",
"tests/ffi/function_callbacks_many_test.dart",
"tests/ffi/function_callbacks_structs_by_value_generated_test.dart",
"tests/ffi/function_callbacks_structs_by_value_native_callable_generated_test.dart",
"tests/ffi/function_callbacks_structs_by_value_test.dart",
"tests/ffi/function_callbacks_subtype_test.dart",
"tests/ffi/function_callbacks_test.dart",
"tests/ffi/function_callbacks_varargs_generated_test.dart",
"tests/ffi/function_callbacks_varargs_native_callable_generated_test.dart",
"tests/ffi/function_callbacks_very_many_test.dart",
"tests/ffi/function_struct_by_value_out_of_bounds_test.dart",
"tests/ffi/function_structs_by_value_generated_args_leaf_test.dart",
"tests/ffi/function_structs_by_value_generated_args_native_leaf_test.dart",
"tests/ffi/function_structs_by_value_generated_args_native_test.dart",
"tests/ffi/function_structs_by_value_generated_args_test.dart",
"tests/ffi/function_structs_by_value_generated_compounds_sizeof_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_arg_leaf_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_arg_native_leaf_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_arg_native_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_arg_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_leaf_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_native_leaf_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_native_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_test.dart",
"tests/ffi/function_structs_test.dart",
"tests/ffi/function_test.dart",
"tests/ffi/function_varargs_generated_leaf_test.dart",
"tests/ffi/function_varargs_generated_native_leaf_test.dart",
"tests/ffi/function_varargs_generated_native_test.dart",
"tests/ffi/function_varargs_generated_test.dart",
"tests/ffi/function_varargs_name_test.dart",
"tests/ffi/function_varargs_test.dart",
"tests/ffi/function_very_many_test.dart",
"tests/ffi/hardfp_test.dart",
"tests/ffi/has_symbol_test.dart",
"tests/ffi/inline_array_multi_dimensional_test.dart",
"tests/ffi/inline_array_test.dart",
"tests/ffi/inline_array_variable_length_test.dart",
"tests/ffi/invoke_callback_after_suspension_test.dart",
"tests/ffi/isolate_local_function_callbacks_test.dart",
"tests/ffi/msan_test.dart",
"tests/ffi/native_assets/asset_absolute_test.dart",
"tests/ffi/native_assets/asset_executable_test.dart",
"tests/ffi/native_assets/asset_library_annotation_test.dart",
"tests/ffi/native_assets/asset_process_test.dart",
"tests/ffi/native_assets/asset_relative_test.dart",
"tests/ffi/native_assets/asset_system_test.dart",
"tests/ffi/native_assets/infer_native_assets_yaml_dart_kernel_snapshot_test.dart",
"tests/ffi/native_assets/infer_native_assets_yaml_isolate_spawnuri_2_test.dart",
"tests/ffi/native_assets/infer_native_assets_yaml_isolate_spawnuri_3_test.dart",
"tests/ffi/native_assets/infer_native_assets_yaml_isolate_spawnuri_test.dart",
"tests/ffi/native_assets/infer_native_assets_yaml_process_run_test.dart",
"tests/ffi/native_assets/process_test.dart",
"tests/ffi/native_callables_async_structs_by_value_generated_test.dart",
"tests/ffi/native_callables_sync_structs_by_value_generated_test.dart",
"tests/ffi/native_effect_test.dart",
"tests/ffi/negative_function_test.dart",
"tests/ffi/pointer_arithmetic_operators_test.dart",
"tests/ffi/regress_37254_test.dart",
"tests/ffi/regress_39044_test.dart",
"tests/ffi/regress_39063_test.dart",
"tests/ffi/regress_39885_test.dart",
"tests/ffi/regress_40537_test.dart",
"tests/ffi/regress_43016_test.dart",
"tests/ffi/regress_43693_test.dart",
"tests/ffi/regress_45189_test.dart",
"tests/ffi/regress_45198_test.dart",
"tests/ffi/regress_45507_test.dart",
"tests/ffi/regress_45988_test.dart",
"tests/ffi/regress_46004_test.dart",
"tests/ffi/regress_46127_test.dart",
"tests/ffi/regress_47594_test.dart",
"tests/ffi/regress_47673_test.dart",
"tests/ffi/regress_49402_test.dart",
"tests/ffi/regress_49684_test.dart",
"tests/ffi/regress_51315_test.dart",
"tests/ffi/regress_51321_test.dart",
"tests/ffi/regress_51504_test.dart",
"tests/ffi/regress_51538_2_test.dart",
"tests/ffi/regress_51538_3_test.dart",
"tests/ffi/regress_51538_test.dart",
"tests/ffi/regress_52298_test.dart",
"tests/ffi/regress_52399_test.dart",
"tests/ffi/regress_56412_2_test.dart",
"tests/ffi/regress_56412_test.dart",
"tests/ffi/regress_b_261224444_test.dart",
"tests/ffi/regress_flutter79441_test.dart",
"tests/ffi/regress_flutter97301_test.dart",
"tests/ffi/regress_jump_to_frame_test.dart",
"tests/ffi/sizeof_test.dart",
"tests/ffi/snapshot_test.dart",
"tests/ffi/stacktrace_regress_37910_test.dart",
"tests/ffi/structs_nested_test.dart",
"tests/ffi/structs_nnbd_workaround_test.dart",
"tests/ffi/structs_packed_test.dart",
"tests/ffi/structs_test.dart",
"tests/ffi/structs_typed_data_test.dart",
"tests/ffi/unaligned_test.dart",
"tests/ffi/variance_function_test.dart",
"tests/ffi/vmspecific_callback_unwind_error_through_handle_test.dart",
"tests/ffi/vmspecific_deprecated_funcs_test.dart",
"tests/ffi/vmspecific_dynamic_library_test.dart",
"tests/ffi/vmspecific_enable_ffi_test.dart",
"tests/ffi/vmspecific_ffi_native_handles_test.dart",
"tests/ffi/vmspecific_ffi_native_test.dart",
"tests/ffi/vmspecific_function_callbacks_exit_test.dart",
"tests/ffi/vmspecific_function_callbacks_test.dart",
"tests/ffi/vmspecific_function_gc_test.dart",
"tests/ffi/vmspecific_function_test.dart",
"tests/ffi/vmspecific_handle_dynamically_linked_test.dart",
"tests/ffi/vmspecific_handle_test.dart",
"tests/ffi/vmspecific_highmem_32bit_test.dart",
"tests/ffi/vmspecific_leaf_call_test.dart",
"tests/ffi/vmspecific_native_finalizer_2_test.dart",
"tests/ffi/vmspecific_native_finalizer_api_calls_test.dart",
"tests/ffi/vmspecific_native_finalizer_deeply_immutable_test.dart",
"tests/ffi/vmspecific_native_finalizer_isolate_groups_test.dart",
"tests/ffi/vmspecific_native_finalizer_isolates_test.dart",
"tests/ffi/vmspecific_native_finalizer_test.dart",
"tests/ffi/vmspecific_object_gc_test.dart",
"tests/ffi/vmspecific_pointer_load_il_test.dart",
"tests/ffi/vmspecific_regress_37100_test.dart",
"tests/ffi/vmspecific_regress_37511_callbacks_test.dart",
"tests/ffi/vmspecific_regress_37511_test.dart",
"tests/ffi/vmspecific_regress_37780_test.dart",
"tests/ffi/vmspecific_regress_51794_test.dart",
"tests/ffi/vmspecific_send_port_id_test.dart",
]
test_deps = []
test_resources = []
foreach(test_source, test_sources) {
label = string_replace(test_source, "/", "_")
aot_label = label + "_aot"
application_snapshot(label) {
dart_snapshot_kind = "kernel"
main_dart = test_source
training_args = [] # Not used
output = "$target_gen_dir/$test_source.dill"
}
aot_snapshot(aot_label) {
main_dart = test_source
output = "$target_gen_dir/$test_source.elf"
}
test_deps += [
":$aot_label",
":$label",
]
test_resources += [
{
path = rebase_path("$target_gen_dir/$test_source.dill")
dest = "data/$test_source"
},
{
path = rebase_path("$target_gen_dir/$test_source.elf")
dest = "data/$test_source.elf"
},
]
}
test_binaries = [
"dartvm",
"dartaotruntime",
"run_vm_tests",
]
foreach(binary, test_binaries) {
fuchsia_component("${binary}_test_component") {
testonly = true
manifest = "runtime/bin/${binary}_test_component.cml"
data_deps = [
"runtime/bin:${binary}",
"runtime/bin:ffi_test_dynamic_library",
"runtime/bin:ffi_test_functions",
]
library_files = [
"libffi_test_dynamic_library.so",
"libffi_test_functions.so",
]
resource_files = [
".dart_tool/package_config.json",
"tools/addlatexhash.dart",
]
resources = []
foreach(file, library_files) {
resources += [
{
path = root_out_dir + "/" + file
dest = "lib/" + file
},
]
}
foreach(file, resource_files) {
resources += [
{
path = file
dest = "data/" + file
},
]
}
deps = test_deps
resources += test_resources
}
}
fuchsia_package("fuchsia_test_package") {
testonly = true
if (is_debug) {
package_name = "dart_test_debug"
} else if (is_release) {
package_name = "dart_test_release"
} else if (is_product) {
package_name = "dart_test_product"
}
deps = []
foreach(binary, test_binaries) {
deps += [ ":${binary}_test_component" ]
}
}
}
if (is_linux) {
group("debian_package") {
public_deps = [ "tools/debian_package" ]
}
}