Skip to content

Commit

Permalink
Revert "[vm] Expose Dart_{CurrentIsolate,ExitIsolate,EnterIsolate}"
Browse files Browse the repository at this point in the history
This reverts commit a251281.

Reason for revert: FFI tests fail to link on Windows, fail to load on product-mode Android

Original change's description:
> [vm] Expose Dart_{CurrentIsolate,ExitIsolate,EnterIsolate}
>
> For applications that want to have arbitrary number of isolates call
> into native code that may be blocking, we expose the API functions that
> allows those native threads to exit an isolate before running
> long/blocking code.
>
> Without the ability to exit/re-enter isolate, one may experience
> deadlocks as we have a fixed limit on the number of concurrently
> executing isolates atm.
>
> In the longer term we may find a way to do this automatically
> with low overhead, see [0]. But since those API functions are quite
> stable and we already expose e.g. `Dart_{Enter,Exit}Scope`, I don't
> see a reason not to expose `Dart_{Enter,Exit}Isolate`.
>
> [0] Issue #51261
>
> Issue #51254
>
> TEST=ffi{,_2}/dl_api_exit_enter_isolate_test
>
> Change-Id: I91c772ca962fddb87919663fea07939a498fa205
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292722
> Commit-Queue: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

Change-Id: I05ad5b9ce24754a68693160e470f8eb71a812c75
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294860
Auto-Submit: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
  • Loading branch information
rmacnak-google authored and Commit Queue committed Apr 12, 2023
1 parent 7bac8ed commit 783d0ef
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 97 deletions.
34 changes: 10 additions & 24 deletions runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#include <iostream>
#include <limits>

#include "bin/lockers.h"

// TODO(dartbug.com/40579): This requires static linking to either link
// dart.exe or dart_precompiled_runtime.exe on Windows.
// The sample currently fails on Windows in AOT mode.
Expand Down Expand Up @@ -422,6 +420,16 @@ DART_EXPORT intptr_t InitDartApiDL(void* data) {
//
// sample_async_callback.dart

void Fatal(char const* file, int line, char const* error) {
printf("FATAL %s:%i\n", file, line);
printf("%s\n", error);
Dart_DumpNativeStackTrace(nullptr);
Dart_PrepareToAbort();
abort();
}

#define FATAL(error) Fatal(__FILE__, __LINE__, error)

DART_EXPORT void SleepOnAnyOS(intptr_t seconds) {
#if defined(DART_HOST_OS_WINDOWS)
Sleep(1000 * seconds);
Expand Down Expand Up @@ -1274,28 +1282,6 @@ DART_EXPORT void SetFfiNativeResolverForTest(Dart_Handle url) {
ENSURE(!Dart_IsError(result));
}

DART_EXPORT void WaitUntilNThreadsEnterBarrier(intptr_t num_threads) {
Dart_Isolate isolate = Dart_CurrentIsolate_DL();
Dart_ExitIsolate_DL();
{
ENSURE(Dart_CurrentIsolate_DL() == nullptr);

// Guaranteed to be initialized exactly once (no race between multiple
// threads).
static dart::bin::Monitor monitor;
static intptr_t thread_count = 0;

dart::bin::MonitorLocker ml(&monitor);
++thread_count;
while (thread_count < num_threads) {
ml.Wait();
}
if (thread_count != num_threads) UNREACHABLE();
ml.NotifyAll();
}
Dart_EnterIsolate_DL(isolate);
}

////////////////////////////////////////////////////////////////////////////////
// Helper for the regression test for b/216834909
////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 0 additions & 4 deletions runtime/include/dart_api_dl.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ typedef void (*Dart_NativeMessageHandler_DL)(Dart_Port_DL dest_port_id,
F(Dart_UpdateFinalizableExternalSize, void, \
(Dart_FinalizableHandle object, Dart_Handle strong_ref_to_object, \
intptr_t external_allocation_size)) \
/* Isolates */ \
F(Dart_CurrentIsolate, Dart_Isolate, (void)) \
F(Dart_ExitIsolate, void, (void)) \
F(Dart_EnterIsolate, void, (Dart_Isolate)) \
/* Dart_Port */ \
F(Dart_Post, bool, (Dart_Port_DL port_id, Dart_Handle object)) \
F(Dart_NewSendPort, Dart_Handle, (Dart_Port_DL port_id)) \
Expand Down
2 changes: 1 addition & 1 deletion runtime/include/dart_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
// On backwards compatible changes the minor version is increased.
// The versioning covers the symbols exposed in dart_api_dl.h
#define DART_API_DL_MAJOR_VERSION 2
#define DART_API_DL_MINOR_VERSION 3
#define DART_API_DL_MINOR_VERSION 2

#endif /* RUNTIME_INCLUDE_DART_VERSION_H_ */ /* NOLINT */
33 changes: 0 additions & 33 deletions tests/ffi/dl_api_exit_enter_isolate_test.dart

This file was deleted.

35 changes: 0 additions & 35 deletions tests/ffi_2/dl_api_exit_enter_isolate_test.dart

This file was deleted.

0 comments on commit 783d0ef

Please sign in to comment.