[vm, fuchsia] Always look for VmexResource.

TEST=ci
Bug: https://dartbug.com/52579
Change-Id: I856fb8ae5a5bc282471c1ecf3774fc49f7c5b57a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491926
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
This commit is contained in:
Ryan Macnak
2026-03-31 19:59:09 -07:00
committed by Commit Queue
parent 6db8c35352
commit e7f818b866
13 changed files with 20 additions and 66 deletions
+2 -8
View File
@@ -446,10 +446,7 @@ template("build_gen_snapshot_dart_io") {
deps = [ "//third_party/zlib" ]
if (is_fuchsia) {
deps += [
"$fuchsia_sdk/fidl/fuchsia.io",
"$fuchsia_sdk/fidl/fuchsia.kernel",
]
deps += [ "$fuchsia_sdk/fidl/fuchsia.io" ]
public_deps = [ "$fuchsia_sdk/pkg/fdio" ]
}
@@ -567,10 +564,7 @@ template("dart_io") {
deps += [ "//third_party/boringssl" ]
if (is_fuchsia) {
deps += [
"$fuchsia_sdk/fidl/fuchsia.io",
"$fuchsia_sdk/fidl/fuchsia.kernel",
]
deps += [ "$fuchsia_sdk/fidl/fuchsia.io" ]
public_deps = [ "$fuchsia_sdk/pkg/fdio" ]
}
-3
View File
@@ -189,9 +189,6 @@ int RunAnalyzer(int argc, char** argv) {
init_params.file_write = DartUtils::WriteFile;
init_params.file_close = DartUtils::CloseFile;
init_params.entropy_source = DartUtils::EntropySource;
#if defined(DART_HOST_OS_FUCHSIA)
init_params.vmex_resource = Platform::GetVMEXResource();
#endif
error = Dart_Initialize(&init_params);
if (error != nullptr) {
-3
View File
@@ -1115,9 +1115,6 @@ void main(int argc, char** argv) {
init_params.file_close = DartUtils::CloseFile;
init_params.entropy_source = DartUtils::EntropySource;
init_params.start_kernel_isolate = false;
#if defined(DART_HOST_OS_FUCHSIA)
init_params.vmex_resource = ZX_HANDLE_INVALID;
#endif
error = Dart_Initialize(&init_params);
if (error != nullptr) {
-3
View File
@@ -918,9 +918,6 @@ int main(int argc, char** argv) {
init_params.file_close = DartUtils::CloseFile;
init_params.entropy_source = DartUtils::EntropySource;
init_params.start_kernel_isolate = false;
#if defined(DART_HOST_OS_FUCHSIA)
init_params.vmex_resource = Platform::GetVMEXResource();
#endif
std::unique_ptr<MappedMemory> mapped_vm_snapshot_data;
std::unique_ptr<MappedMemory> mapped_vm_snapshot_instructions;
-7
View File
@@ -1384,13 +1384,6 @@ void main(int argc, char** argv) {
dfe.UseDartFrontend() && dfe.CanUseDartFrontend();
#else
init_params.start_kernel_isolate = false;
#endif
#if defined(DART_HOST_OS_FUCHSIA)
#if defined(DART_PRECOMPILED_RUNTIME)
init_params.vmex_resource = ZX_HANDLE_INVALID;
#else
init_params.vmex_resource = Platform::GetVMEXResource();
#endif
#endif
error = Dart_Initialize(&init_params);
-4
View File
@@ -110,10 +110,6 @@ class Platform {
static void SetCoreDumpResourceLimit(int value);
#if defined(DART_HOST_OS_FUCHSIA)
static zx_handle_t GetVMEXResource();
#endif
private:
// The path to the executable.
static const char* executable_name_;
-15
View File
@@ -7,9 +7,6 @@
#include "bin/platform.h"
#include <fuchsia/kernel/cpp/fidl.h>
#include <lib/fdio/directory.h>
#include <lib/zx/resource.h>
#include <string.h>
#include <sys/utsname.h>
#include <unistd.h>
@@ -170,18 +167,6 @@ void Platform::SetCoreDumpResourceLimit(int value) {
// Not supported.
}
zx_handle_t Platform::GetVMEXResource() {
zx::resource vmex_resource;
fuchsia::kernel::VmexResourceSyncPtr vmex_resource_svc;
zx_status_t status = fdio_service_connect(
"/svc/fuchsia.kernel.VmexResource",
vmex_resource_svc.NewRequest().TakeChannel().release());
ASSERT(status == ZX_OK);
status = vmex_resource_svc->Get(&vmex_resource);
ASSERT(status == ZX_OK);
return vmex_resource.release();
}
} // namespace bin
} // namespace dart
-3
View File
@@ -443,9 +443,6 @@ static int Main(int argc, const char** argv) {
init_params.file_write = dart::bin::DartUtils::WriteFile;
init_params.file_close = dart::bin::DartUtils::CloseFile;
init_params.start_kernel_isolate = start_kernel_isolate;
#if defined(DART_HOST_OS_FUCHSIA)
init_params.vmex_resource = dart::bin::Platform::GetVMEXResource();
#endif
error = Dart::Init(&init_params);
if (error != nullptr) {
Syslog::PrintErr("Failed to initialize VM: %s\n", error);
+1 -10
View File
@@ -837,7 +837,7 @@ typedef Dart_Handle (*Dart_GetVMServiceAssetsArchive)(void);
* The current version of the Dart_InitializeFlags. Should be incremented every
* time Dart_InitializeFlags changes in a binary incompatible way.
*/
#define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x00000009)
#define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x0000000A)
/** Forward declaration */
struct Dart_CodeObserver;
@@ -942,15 +942,6 @@ typedef struct {
* as early as during the Dart_Initialize() call.
*/
Dart_CodeObserver* code_observer;
#if defined(__Fuchsia__)
/**
* The resource needed to use zx_vmo_replace_as_executable. Can be
* ZX_HANDLE_INVALID if the process has ambient-replace-as-executable or if
* executable memory is not needed (e.g., this is an AOT runtime).
*/
zx_handle_t vmex_resource;
#endif
} Dart_InitializeParams;
/**
+1
View File
@@ -84,6 +84,7 @@ library_for_all_configs("libdart_vm") {
if (is_fuchsia) {
extra_deps += [
"$fuchsia_sdk/fidl/fuchsia.intl",
"$fuchsia_sdk/fidl/fuchsia.kernel",
"$fuchsia_sdk/pkg/async",
"$fuchsia_sdk/pkg/async-default",
"$fuchsia_sdk/pkg/async-loop",
-4
View File
@@ -331,11 +331,7 @@ char* Dart::DartInit(const Dart_InitializeParams* params) {
NOT_IN_PRODUCT(CodeObservers::RegisterExternal(*params->code_observer));
}
start_time_micros_ = OS::GetCurrentMonotonicMicros();
#if defined(DART_HOST_OS_FUCHSIA)
VirtualMemory::Init(params->vmex_resource);
#else
VirtualMemory::Init();
#endif
#if defined(DART_PRECOMPILED_RUNTIME) && defined(DART_TARGET_OS_LINUX)
if (VirtualMemory::PageSize() > kElfPageSize) {
-4
View File
@@ -65,11 +65,7 @@ class VirtualMemory {
#endif
}
#if defined(DART_HOST_OS_FUCHSIA)
static void Init(zx_handle_t vmex_resource);
#else
static void Init();
#endif
static void Cleanup();
DART_FORCE_INLINE static bool ShouldDualMapExecutablePages() {
+16 -2
View File
@@ -7,6 +7,9 @@
#include "vm/virtual_memory.h"
#include <fuchsia/kernel/cpp/fidl.h>
#include <lib/fdio/directory.h>
#include <lib/zx/resource.h>
#include <zircon/process.h>
#include <zircon/status.h>
#include <zircon/syscalls.h>
@@ -51,7 +54,7 @@ intptr_t VirtualMemory::CalculatePageSize() {
return page_size;
}
void VirtualMemory::Init(zx_handle_t vmex_resource) {
void VirtualMemory::Init() {
if (FLAG_old_gen_heap_size < 0 || FLAG_old_gen_heap_size > kMaxAddrSpaceMB) {
OS::PrintErr(
"warning: value specified for --old_gen_heap_size %d is larger than"
@@ -89,7 +92,18 @@ void VirtualMemory::Init(zx_handle_t vmex_resource) {
#endif // defined(DART_COMPRESSED_POINTERS)
page_size_ = CalculatePageSize();
vmex_resource_ = vmex_resource;
// If VmexResource is unavailable or does not return a valid handle then
// this will be observed as failures from vmo_replace_as_executable below.
zx::resource vmex_resource;
fuchsia::kernel::VmexResourceSyncPtr vmex_resource_svc;
zx_status_t status = fdio_service_connect(
"/svc/fuchsia.kernel.VmexResource",
vmex_resource_svc.NewRequest().TakeChannel().release());
ASSERT(status == ZX_OK);
status = vmex_resource_svc->Get(&vmex_resource);
ASSERT(status == ZX_OK);
vmex_resource_ = vmex_resource.release();
}
void VirtualMemory::Cleanup() {