Skip to content

Commit

Permalink
[vm/shared] Add 'dart:concurrent' core library.
Browse files Browse the repository at this point in the history
This brings Mutex and ConditionVariable classes to guard access to shared variables.

TEST=shared_test, shared_primitives_test
BUG=dart-lang#55991
CoreLibraryReviewExempt: dart:concurrent library is experimental, restricted to main/dev channels, vm-only at this point.
Change-Id: I64ca7a0434cbe0079976133ccbf9de2dd4c0d7b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372181
Commit-Queue: Alexander Aprelev <[email protected]>
Reviewed-by: Slava Egorov <[email protected]>
  • Loading branch information
aam authored and Commit Queue committed Jul 10, 2024
1 parent 98ebbcd commit d2bc055
Show file tree
Hide file tree
Showing 60 changed files with 1,276 additions and 563 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ library from "org-dartlang-test:///main.dart" as main {
static method foo() → dynamic {}
}

And 18 platform libraries:
And 19 platform libraries:
- dart:_http
- dart:_builtin
- dart:vmservice_io
- dart:async
- dart:cli
- dart:collection
- dart:concurrent
- dart:convert
- dart:core
- dart:developer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ library from "org-dartlang-test:///main.dart" as main {
static method foo() → dynamic {}
}

And 18 platform libraries:
And 19 platform libraries:
- dart:_http
- dart:_builtin
- dart:vmservice_io
- dart:async
- dart:cli
- dart:collection
- dart:concurrent
- dart:convert
- dart:core
- dart:developer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ library from "org-dartlang-test:///main.dart" as main {
}
}

And 17 platform libraries:
And 18 platform libraries:
- dart:_builtin
- dart:_internal
- dart:_vmservice
- dart:async
- dart:cli
- dart:collection
- dart:concurrent
- dart:convert
- dart:core
- dart:developer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ library from "org-dartlang-test:///main.dart" as main {
return 42;
}

And 18 platform libraries:
And 19 platform libraries:
- dart:_http
- dart:_builtin
- dart:vmservice_io
- dart:async
- dart:cli
- dart:collection
- dart:concurrent
- dart:convert
- dart:core
- dart:developer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ library from "org-dartlang-test:///main.dart" as main {
return 42;
}

And 18 platform libraries:
And 19 platform libraries:
- dart:_http
- dart:_builtin
- dart:vmservice_io
- dart:async
- dart:cli
- dart:collection
- dart:concurrent
- dart:convert
- dart:core
- dart:developer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ library from "org-dartlang-test:///main.dart" as main {
}
}

And 18 platform libraries:
And 19 platform libraries:
- dart:_http
- dart:_builtin
- dart:vmservice_io
- dart:async
- dart:cli
- dart:collection
- dart:concurrent
- dart:convert
- dart:core
- dart:developer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ library from "org-dartlang-test:///main.dart" as main {
}
}

And 18 platform libraries:
And 19 platform libraries:
- dart:_http
- dart:_builtin
- dart:vmservice_io
- dart:async
- dart:cli
- dart:collection
- dart:concurrent
- dart:convert
- dart:core
- dart:developer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ library from "org-dartlang-test:///main.dart" as main {
}
}

And 18 platform libraries:
And 19 platform libraries:
- dart:_http
- dart:_builtin
- dart:vmservice_io
- dart:async
- dart:cli
- dart:collection
- dart:concurrent
- dart:convert
- dart:core
- dart:developer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ library from "org-dartlang-test:///main.dart" as main {
}
}

And 18 platform libraries:
And 19 platform libraries:
- dart:_http
- dart:_builtin
- dart:vmservice_io
- dart:async
- dart:cli
- dart:collection
- dart:concurrent
- dart:convert
- dart:core
- dart:developer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ library from "org-dartlang-test:///main.dart" as main {
}
}

And 18 platform libraries:
And 19 platform libraries:
- dart:_http
- dart:_builtin
- dart:vmservice_io
- dart:async
- dart:cli
- dart:collection
- dart:concurrent
- dart:convert
- dart:core
- dart:developer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ constants {
#C1 = 0
}

And 18 platform libraries:
And 19 platform libraries:
- dart:_http
- dart:_builtin
- dart:vmservice_io
- dart:async
- dart:cli
- dart:collection
- dart:concurrent
- dart:convert
- dart:core
- dart:developer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ constants {
#C1 = 0
}

And 18 platform libraries:
And 19 platform libraries:
- dart:_http
- dart:_builtin
- dart:vmservice_io
- dart:async
- dart:cli
- dart:collection
- dart:concurrent
- dart:convert
- dart:core
- dart:developer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ constants {
#C1 = 0
}

And 18 platform libraries:
And 19 platform libraries:
- dart:_http
- dart:_builtin
- dart:vmservice_io
- dart:async
- dart:cli
- dart:collection
- dart:concurrent
- dart:convert
- dart:core
- dart:developer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//
// sdk/lib/collection/collection.dart: Error: Loaded library is compiled with sound null safety and cannot be used in compilation for unsound null safety.
//
// sdk/lib/concurrent/concurrent.dart: Error: Loaded library is compiled with sound null safety and cannot be used in compilation for unsound null safety.
//
// sdk/lib/convert/convert.dart: Error: Loaded library is compiled with sound null safety and cannot be used in compilation for unsound null safety.
//
// sdk/lib/developer/developer.dart: Error: Loaded library is compiled with sound null safety and cannot be used in compilation for unsound null safety.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//
// sdk/lib/collection/collection.dart: Error: Loaded library is compiled with sound null safety and cannot be used in compilation for unsound null safety.
//
// sdk/lib/concurrent/concurrent.dart: Error: Loaded library is compiled with sound null safety and cannot be used in compilation for unsound null safety.
//
// sdk/lib/convert/convert.dart: Error: Loaded library is compiled with sound null safety and cannot be used in compilation for unsound null safety.
//
// sdk/lib/developer/developer.dart: Error: Loaded library is compiled with sound null safety and cannot be used in compilation for unsound null safety.
Expand Down
1 change: 1 addition & 0 deletions pkg/vm/lib/modular/target/flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class FlutterTarget extends VmTarget {
List<String> get extraRequiredLibraries => const <String>[
'dart:async',
'dart:collection',
'dart:concurrent',
'dart:convert',
'dart:developer',
'dart:ffi',
Expand Down
1 change: 1 addition & 0 deletions pkg/vm/lib/modular/target/vm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class VmTarget extends Target {
List<String> get extraRequiredLibraries => const <String>[
'dart:async',
'dart:collection',
'dart:concurrent',
'dart:convert',
'dart:developer',
'dart:ffi',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ LoadingUnit(id=1, parent=0,
dart:ffi
dart:developer
dart:convert
dart:concurrent
dart:collection
dart:async
#pkg/vm/testcases/transformations/deferred_loading/c.dart
Expand Down
41 changes: 41 additions & 0 deletions runtime/bin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import("../vm/vm_sources.gni")
import("builtin_impl_sources.gni")
import("builtin_sources.gni")
import("cli_sources.gni")
import("concurrent_impl_sources.gni")
import("io_impl_sources.gni")
import("io_sources.gni")
import("native_assets_impl_sources.gni")
Expand Down Expand Up @@ -138,6 +139,39 @@ build_native_assets_api("native_assets_api_product") {
]
}

template("build_concurrent_api") {
extra_configs = []
if (defined(invoker.extra_configs)) {
extra_configs += invoker.extra_configs
}
source_set(target_name) {
configs += [ "..:dart_config" ] + extra_configs
deps = []
include_dirs = [ ".." ]
sources = concurrent_api_sources
sources += [
"concurrent_natives.cc",
"concurrent_natives.h",
]
}
}

build_concurrent_api("concurrent_api") {
extra_configs = [
"..:dart_maybe_product_config",
"..:dart_os_config",
"..:dart_arch_config",
]
}

build_concurrent_api("concurrent_api_product") {
extra_configs = [
"..:dart_product_config",
"..:dart_os_config",
"..:dart_arch_config",
]
}

static_library("crashpad") {
configs += [
"..:dart_arch_config",
Expand Down Expand Up @@ -827,6 +861,12 @@ template("dart_executable") {
deps += [ ":standalone_dart_io" ]
}

if (use_product_mode) {
deps += [ ":concurrent_api_product" ]
} else {
deps += [ ":concurrent_api" ]
}

configs += [ ":export_api_symbols" ]

ldflags = extra_ldflags
Expand Down Expand Up @@ -1072,6 +1112,7 @@ executable("run_vm_tests") {
}

deps = [
":concurrent_api",
":crashpad",
":dart_kernel_platform_cc",
":dart_snapshot_cc",
Expand Down
1 change: 1 addition & 0 deletions runtime/bin/builtin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Builtin::builtin_lib_props Builtin::builtin_libraries_[] = {
{DartUtils::kIOLibURL, true},
{DartUtils::kHttpLibURL, false},
{DartUtils::kCLILibURL, true},
{DartUtils::kConcurrentLibURL, true},

// End marker.
{nullptr, false}};
Expand Down
3 changes: 2 additions & 1 deletion runtime/bin/builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ namespace bin {
class Builtin {
public:
// Note: Changes to this enum should be accompanied with changes to
// the builtin_libraries_ array in builtin.cc and builtin_nolib.cc.
// the builtin_libraries_ array in builtin.cc.
enum BuiltinLibraryId {
kInvalidLibrary = -1,
kBuiltinLibrary = 0,
kIOLibrary,
kHttpLibrary,
kCLILibrary,
kConcurrentLibrary,
};

// Setup native resolver method built in library specified in 'id'.
Expand Down
8 changes: 7 additions & 1 deletion runtime/bin/builtin_natives.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "platform/assert.h"

#include "bin/builtin.h"
#include "bin/concurrent_natives.h"
#include "bin/dartutils.h"
#include "bin/file.h"
#include "bin/io_natives.h"
Expand All @@ -24,7 +25,8 @@ namespace bin {
// Lists the native functions implementing basic functionality in
// standalone dart, such as printing, file I/O, and platform information.
// Advanced I/O classes like sockets and process management are implemented
// using functions listed in io_natives.cc.
// using functions listed in io_natives.cc and synchronization primitives -
// in concurrent_natives.cc.
#define BUILTIN_NATIVE_LIST(V) V(Builtin_PrintString, 1)

BUILTIN_NATIVE_LIST(DECLARE_FUNCTION);
Expand Down Expand Up @@ -63,6 +65,10 @@ Dart_NativeFunction Builtin::NativeLookup(Dart_Handle name,
}
Dart_NativeFunction result =
IONativeLookup(name, argument_count, auto_setup_scope);
if (result != nullptr) {
return result;
}
result = ConcurrentNativeLookup(name, argument_count, auto_setup_scope);
if (result == nullptr) {
result = Builtin_DummyNative;
}
Expand Down
Loading

0 comments on commit d2bc055

Please sign in to comment.