mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:00:09 +00:00
[vm] Separate for-snapshot vs embed-sources bools when compiling to kernel
Fixes https://github.com/dart-lang/sdk/issues/53010 TEST=Fixes vm/dart/regress_48523_test Change-Id: I2066ffd250228c01bb7aa2de5d1d0362ba6f7071 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316581 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com>
This commit is contained in:
parent
79df0b2789
commit
23109940e0
|
@ -772,8 +772,7 @@ Future _processLoadRequest(request) async {
|
|||
}
|
||||
|
||||
final SendPort port = request[1];
|
||||
final int isolateGroupId = request[7];
|
||||
|
||||
final int isolateGroupId = request[8];
|
||||
if (tag == kListDependenciesTag) {
|
||||
await _processListDependenciesRequest(port, isolateGroupId);
|
||||
return;
|
||||
|
@ -783,17 +782,18 @@ Future _processLoadRequest(request) async {
|
|||
final Uri? script =
|
||||
inputFileUri != null ? Uri.base.resolve(inputFileUri) : null;
|
||||
final bool incremental = request[4];
|
||||
final bool forAppJitSnapshot = request[5];
|
||||
final bool nullSafety = request[6];
|
||||
final List sourceFiles = request[8];
|
||||
final bool enableAsserts = request[9];
|
||||
final bool forSnapshot = request[5];
|
||||
final bool embedSources = request[6];
|
||||
final bool nullSafety = request[7];
|
||||
final List sourceFiles = request[9];
|
||||
final bool enableAsserts = request[10];
|
||||
final List<String>? experimentalFlags =
|
||||
request[10] != null ? request[10].cast<String>() : null;
|
||||
final String? packageConfig = request[11];
|
||||
final String? multirootFilepaths = request[12];
|
||||
final String? multirootScheme = request[13];
|
||||
final String verbosityLevel = request[15];
|
||||
final bool enableMirrors = request[16];
|
||||
request[11] != null ? request[11].cast<String>() : null;
|
||||
final String? packageConfig = request[12];
|
||||
final String? multirootFilepaths = request[13];
|
||||
final String? multirootScheme = request[14];
|
||||
final String verbosityLevel = request[16];
|
||||
final bool enableMirrors = request[17];
|
||||
Uri platformKernelPath;
|
||||
List<int>? platformKernel = null;
|
||||
if (request[3] is String) {
|
||||
|
@ -806,7 +806,7 @@ Future _processLoadRequest(request) async {
|
|||
computePlatformBinariesLocation().resolve('vm_platform_strong.dill');
|
||||
}
|
||||
|
||||
final String invocationModes = forAppJitSnapshot ? 'compile' : '';
|
||||
final String invocationModes = forSnapshot ? 'compile' : '';
|
||||
|
||||
Compiler? compiler;
|
||||
|
||||
|
@ -873,7 +873,6 @@ Future _processLoadRequest(request) async {
|
|||
enableMirrors: enableMirrors);
|
||||
fileSystem = compiler.fileSystem;
|
||||
} else {
|
||||
final embedSources = !forAppJitSnapshot;
|
||||
fileSystem = _buildFileSystem(
|
||||
sourceFiles, platformKernel, multirootFilepaths, multirootScheme);
|
||||
compiler = new SingleShotCompilerWrapper(
|
||||
|
@ -1131,7 +1130,8 @@ Future trainInternal(String scriptUri, String? platformKernelPath) async {
|
|||
scriptUri,
|
||||
platformKernelPath,
|
||||
false /* incremental */,
|
||||
false /* for_app_jit_snapshot */,
|
||||
false /* for_snapshot */,
|
||||
true /* embed_sources */,
|
||||
true /* null safety */,
|
||||
1 /* isolateGroupId chosen randomly */,
|
||||
[] /* source files */,
|
||||
|
|
|
@ -116,18 +116,19 @@ Future<kernel_service.Status> singleShotCompile(
|
|||
/* [2] = String? = inputFileUri = */ entryFile,
|
||||
/* [3] = various = platformKernel = */ null,
|
||||
/* [4] = bool = incremental = */ false,
|
||||
/* [5] = bool = snapshot = */ false,
|
||||
/* [6] = bool = nullSafety = */ true,
|
||||
/* [7] = int = isolateGroupId = */ 42,
|
||||
/* [8] = List = sourceFiles = */ sourceFiles,
|
||||
/* [9] = bool = enableAsserts = */ true,
|
||||
/* [10] = List<String>? = experimentalFlags = */ [],
|
||||
/* [11] = String? = packageConfig = */ packageConfig,
|
||||
/* [12] = String? = multirootFilepaths = */ null,
|
||||
/* [13] = String? = multirootScheme = */ null,
|
||||
/* [14] = String? = workingDirectory = */ null,
|
||||
/* [15] = String = verbosityLevel = */ Verbosity.all.name,
|
||||
/* [16] = bool = enableMirrors = */ false,
|
||||
/* [5] = bool = for_snapshot = */ false,
|
||||
/* [6] = bool = embed_sources = */ true,
|
||||
/* [7] = bool = nullSafety = */ true,
|
||||
/* [8] = int = isolateGroupId = */ 42,
|
||||
/* [9] = List = sourceFiles = */ sourceFiles,
|
||||
/* [10] = bool = enableAsserts = */ true,
|
||||
/* [11] = List<String>? = experimentalFlags = */ [],
|
||||
/* [12] = String? = packageConfig = */ packageConfig,
|
||||
/* [13] = String? = multirootFilepaths = */ null,
|
||||
/* [14] = String? = multirootScheme = */ null,
|
||||
/* [15] = String? = workingDirectory = */ null,
|
||||
/* [16] = String = verbosityLevel = */ Verbosity.all.name,
|
||||
/* [17] = bool = enableMirrors = */ false,
|
||||
]);
|
||||
|
||||
// Wait for kernel-service response.
|
||||
|
|
|
@ -188,7 +188,8 @@ const char* PathSanitizer::sanitized_uri() const {
|
|||
Dart_KernelCompilationResult DFE::CompileScript(const char* script_uri,
|
||||
bool incremental,
|
||||
const char* package_config,
|
||||
bool for_app_jit_snapshot) {
|
||||
bool for_snapshot,
|
||||
bool embed_sources) {
|
||||
// TODO(aam): When Frontend is ready, VM should be passing vm_outline.dill
|
||||
// instead of vm_platform.dill to Frontend for compilation.
|
||||
PathSanitizer path_sanitizer(script_uri);
|
||||
|
@ -196,7 +197,7 @@ Dart_KernelCompilationResult DFE::CompileScript(const char* script_uri,
|
|||
|
||||
return Dart_CompileToKernel(
|
||||
sanitized_uri, platform_strong_dill, platform_strong_dill_size,
|
||||
incremental, for_app_jit_snapshot, package_config, verbosity());
|
||||
incremental, for_snapshot, embed_sources, package_config, verbosity());
|
||||
}
|
||||
|
||||
void DFE::CompileAndReadScript(const char* script_uri,
|
||||
|
@ -205,10 +206,11 @@ void DFE::CompileAndReadScript(const char* script_uri,
|
|||
char** error,
|
||||
int* exit_code,
|
||||
const char* package_config,
|
||||
bool for_app_jit_snapshot) {
|
||||
bool for_snapshot,
|
||||
bool embed_sources) {
|
||||
Dart_KernelCompilationResult result =
|
||||
CompileScript(script_uri, use_incremental_compiler(), package_config,
|
||||
for_app_jit_snapshot);
|
||||
for_snapshot, embed_sources);
|
||||
switch (result.status) {
|
||||
case Dart_KernelCompilationStatus_Ok:
|
||||
*kernel_buffer = result.kernel;
|
||||
|
|
|
@ -72,7 +72,8 @@ class DFE {
|
|||
Dart_KernelCompilationResult CompileScript(const char* script_uri,
|
||||
bool incremental,
|
||||
const char* package_config,
|
||||
bool snapshot);
|
||||
bool for_snapshot,
|
||||
bool embedd_sources);
|
||||
|
||||
// Compiles specified script and reads the resulting kernel file.
|
||||
// If the compilation is successful, returns a valid in memory kernel
|
||||
|
@ -87,7 +88,8 @@ class DFE {
|
|||
char** error,
|
||||
int* exit_code,
|
||||
const char* package_config,
|
||||
bool snapshot);
|
||||
bool for_snapshot,
|
||||
bool embed_sources);
|
||||
|
||||
// Reads the script kernel file if specified 'script_uri' is a kernel file.
|
||||
// Returns an in memory kernel representation of the specified script is a
|
||||
|
|
|
@ -107,7 +107,8 @@ Dart_Handle Loader::LibraryTagHandler(Dart_LibraryTag tag,
|
|||
uint8_t* kernel_buffer = nullptr;
|
||||
intptr_t kernel_buffer_size = -1;
|
||||
dfe.CompileAndReadScript(url_string, &kernel_buffer, &kernel_buffer_size,
|
||||
&error, &exit_code, nullptr, false);
|
||||
&error, &exit_code, nullptr,
|
||||
/*for_snapshot=*/false, /*embed_sources=*/true);
|
||||
if (exit_code == 0) {
|
||||
return Dart_LoadLibrary(
|
||||
WrapMallocedKernelBuffer(kernel_buffer, kernel_buffer_size));
|
||||
|
|
|
@ -297,10 +297,14 @@ static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate,
|
|||
// duplicate null-safety info messages from the frontend when generating
|
||||
// a kernel snapshot (this flag is instead set in
|
||||
// Snapshot::GenerateKernel()).
|
||||
const bool for_app_jit_snapshot = Options::gen_snapshot_kind() == kAppJIT;
|
||||
const bool for_snapshot = Options::gen_snapshot_kind() == kAppJIT;
|
||||
// If we compile for AppJIT the sources will not be included across app-jit
|
||||
// snapshotting, so there's no reason CFE should embed them in the kernel.
|
||||
const bool embed_sources = Options::gen_snapshot_kind() != kAppJIT;
|
||||
dfe.CompileAndReadScript(script_uri, &application_kernel_buffer,
|
||||
&application_kernel_buffer_size, error, exit_code,
|
||||
resolved_packages_config, for_app_jit_snapshot);
|
||||
resolved_packages_config, for_snapshot,
|
||||
embed_sources);
|
||||
if (application_kernel_buffer == nullptr) {
|
||||
Dart_ExitScope();
|
||||
Dart_ShutdownIsolate();
|
||||
|
|
|
@ -729,8 +729,9 @@ void Snapshot::GenerateKernel(const char* snapshot_filename,
|
|||
WriteSnapshotFile(snapshot_filename, kernel_buffer, kernel_buffer_size);
|
||||
free(kernel_buffer);
|
||||
} else {
|
||||
Dart_KernelCompilationResult result = dfe.CompileScript(
|
||||
script_name, /*incremental*/ false, package_config, /*snapshot=*/true);
|
||||
Dart_KernelCompilationResult result =
|
||||
dfe.CompileScript(script_name, /*incremental*/ false, package_config,
|
||||
/*snapshot=*/true, /*embedd_sources=*/true);
|
||||
if (result.status != Dart_KernelCompilationStatus_Ok) {
|
||||
Syslog::PrintErr("%s\n", result.error);
|
||||
Platform::Exit(kCompilationErrorExitCode);
|
||||
|
|
|
@ -3788,6 +3788,9 @@ DART_EXPORT Dart_Port Dart_KernelPort(void);
|
|||
* This is used by the frontend to determine if compilation related information
|
||||
* should be printed to console (e.g., null safety mode).
|
||||
*
|
||||
* \param embed_sources Set to `true` when sources should be embedded in the
|
||||
* kernel file.
|
||||
*
|
||||
* \param verbosity Specifies the logging behavior of the kernel compilation
|
||||
* service.
|
||||
*
|
||||
|
@ -3809,6 +3812,7 @@ Dart_CompileToKernel(const char* script_uri,
|
|||
const intptr_t platform_kernel_size,
|
||||
bool incremental_compile,
|
||||
bool snapshot_compile,
|
||||
bool embed_sources,
|
||||
const char* package_config,
|
||||
Dart_KernelCompilationVerbosityLevel verbosity);
|
||||
|
||||
|
|
|
@ -6137,7 +6137,8 @@ Dart_CompileToKernel(const char* script_uri,
|
|||
const uint8_t* platform_kernel,
|
||||
intptr_t platform_kernel_size,
|
||||
bool incremental_compile,
|
||||
bool for_app_jit_snapshot,
|
||||
bool for_snapshot,
|
||||
bool embed_sources,
|
||||
const char* package_config,
|
||||
Dart_KernelCompilationVerbosityLevel verbosity) {
|
||||
API_TIMELINE_DURATION(Thread::Current());
|
||||
|
@ -6149,7 +6150,7 @@ Dart_CompileToKernel(const char* script_uri,
|
|||
#else
|
||||
result = KernelIsolate::CompileToKernel(
|
||||
script_uri, platform_kernel, platform_kernel_size, 0, nullptr,
|
||||
incremental_compile, for_app_jit_snapshot, package_config, nullptr,
|
||||
incremental_compile, for_snapshot, embed_sources, package_config, nullptr,
|
||||
nullptr, verbosity);
|
||||
if (incremental_compile) {
|
||||
Dart_KernelCompilationResult ack_result =
|
||||
|
|
|
@ -1161,6 +1161,7 @@ char* IsolateGroupReloadContext::CompileToKernel(bool force_reload,
|
|||
root_lib_url, nullptr, 0, modified_scripts_count, modified_scripts,
|
||||
/*incremental_compile=*/true,
|
||||
/*snapshot_compile=*/false,
|
||||
/*embed_sources=*/true,
|
||||
/*package_config=*/nullptr,
|
||||
/*multiroot_filepaths=*/nullptr,
|
||||
/*multiroot_scheme=*/nullptr);
|
||||
|
|
|
@ -768,7 +768,8 @@ class KernelCompilationRequest : public ValueObject {
|
|||
int source_files_count,
|
||||
Dart_SourceFile source_files[],
|
||||
bool incremental_compile,
|
||||
bool for_app_jit_snapshot,
|
||||
bool for_snapshot,
|
||||
bool embed_sources,
|
||||
const char* package_config,
|
||||
const char* multiroot_filepaths,
|
||||
const char* multiroot_scheme,
|
||||
|
@ -826,7 +827,11 @@ class KernelCompilationRequest : public ValueObject {
|
|||
|
||||
Dart_CObject dart_snapshot;
|
||||
dart_snapshot.type = Dart_CObject_kBool;
|
||||
dart_snapshot.value.as_bool = for_app_jit_snapshot;
|
||||
dart_snapshot.value.as_bool = for_snapshot;
|
||||
|
||||
Dart_CObject dart_embed_sources;
|
||||
dart_embed_sources.type = Dart_CObject_kBool;
|
||||
dart_embed_sources.value.as_bool = embed_sources;
|
||||
|
||||
// TODO(aam): Assert that isolate exists once we move CompileAndReadScript
|
||||
// compilation logic out of CreateIsolateAndSetupHelper and into
|
||||
|
@ -934,6 +939,7 @@ class KernelCompilationRequest : public ValueObject {
|
|||
&dart_platform_kernel,
|
||||
&dart_incremental,
|
||||
&dart_snapshot,
|
||||
&dart_embed_sources,
|
||||
&null_safety,
|
||||
&isolate_id,
|
||||
&files,
|
||||
|
@ -1103,7 +1109,8 @@ Dart_KernelCompilationResult KernelIsolate::CompileToKernel(
|
|||
int source_file_count,
|
||||
Dart_SourceFile source_files[],
|
||||
bool incremental_compile,
|
||||
bool for_app_jit_snapshot,
|
||||
bool for_snapshot,
|
||||
bool embed_sources,
|
||||
const char* package_config,
|
||||
const char* multiroot_filepaths,
|
||||
const char* multiroot_scheme,
|
||||
|
@ -1130,7 +1137,7 @@ Dart_KernelCompilationResult KernelIsolate::CompileToKernel(
|
|||
return request.SendAndWaitForResponse(
|
||||
kCompileTag, kernel_port, script_uri, platform_kernel,
|
||||
platform_kernel_size, source_file_count, source_files,
|
||||
incremental_compile, for_app_jit_snapshot, package_config,
|
||||
incremental_compile, for_snapshot, embed_sources, package_config,
|
||||
multiroot_filepaths, multiroot_scheme, experimental_flags_, nullptr,
|
||||
verbosity);
|
||||
}
|
||||
|
@ -1147,7 +1154,7 @@ Dart_KernelCompilationResult KernelIsolate::ListDependencies() {
|
|||
KernelCompilationRequest request;
|
||||
return request.SendAndWaitForResponse(
|
||||
kListDependenciesTag, kernel_port, nullptr, nullptr, 0, 0, nullptr, false,
|
||||
false, nullptr, nullptr, nullptr, experimental_flags_, nullptr,
|
||||
false, false, nullptr, nullptr, nullptr, experimental_flags_, nullptr,
|
||||
Dart_KernelCompilationVerbosityLevel_Error);
|
||||
}
|
||||
|
||||
|
@ -1165,7 +1172,7 @@ Dart_KernelCompilationResult KernelIsolate::AcceptCompilation() {
|
|||
KernelCompilationRequest request;
|
||||
return request.SendAndWaitForResponse(
|
||||
kAcceptTag, kernel_port, nullptr, nullptr, 0, 0, nullptr, true, false,
|
||||
nullptr, nullptr, nullptr, experimental_flags_, nullptr,
|
||||
false, nullptr, nullptr, nullptr, experimental_flags_, nullptr,
|
||||
Dart_KernelCompilationVerbosityLevel_Error);
|
||||
}
|
||||
|
||||
|
@ -1183,7 +1190,7 @@ Dart_KernelCompilationResult KernelIsolate::RejectCompilation() {
|
|||
KernelCompilationRequest request;
|
||||
return request.SendAndWaitForResponse(
|
||||
kRejectTag, kernel_port, nullptr, nullptr, 0, 0, nullptr, true, false,
|
||||
nullptr, nullptr, nullptr, experimental_flags_, nullptr,
|
||||
false, nullptr, nullptr, nullptr, experimental_flags_, nullptr,
|
||||
Dart_KernelCompilationVerbosityLevel_Error);
|
||||
}
|
||||
|
||||
|
@ -1234,8 +1241,8 @@ Dart_KernelCompilationResult KernelIsolate::UpdateInMemorySources(
|
|||
KernelCompilationRequest request;
|
||||
return request.SendAndWaitForResponse(
|
||||
kUpdateSourcesTag, kernel_port, nullptr, nullptr, 0, source_files_count,
|
||||
source_files, true, false, nullptr, nullptr, nullptr, experimental_flags_,
|
||||
nullptr, Dart_KernelCompilationVerbosityLevel_Error);
|
||||
source_files, true, false, false, nullptr, nullptr, nullptr,
|
||||
experimental_flags_, nullptr, Dart_KernelCompilationVerbosityLevel_Error);
|
||||
}
|
||||
|
||||
void KernelIsolate::NotifyAboutIsolateGroupShutdown(
|
||||
|
|
|
@ -63,7 +63,8 @@ class KernelIsolate : public AllStatic {
|
|||
int source_files_count = 0,
|
||||
Dart_SourceFile source_files[] = nullptr,
|
||||
bool incremental_compile = true,
|
||||
bool for_app_jit_snapshot = false,
|
||||
bool for_snapshot = false,
|
||||
bool embed_sources = true,
|
||||
const char* package_config = nullptr,
|
||||
const char* multiroot_filepaths = nullptr,
|
||||
const char* multiroot_scheme = nullptr,
|
||||
|
|
|
@ -332,8 +332,8 @@ char* TestCase::CompileTestScriptWithDFE(const char* url,
|
|||
Zone* zone = Thread::Current()->zone();
|
||||
Dart_KernelCompilationResult result = KernelIsolate::CompileToKernel(
|
||||
url, platform_strong_dill, platform_strong_dill_size, sourcefiles_count,
|
||||
sourcefiles, incrementally, false, nullptr, multiroot_filepaths,
|
||||
multiroot_scheme);
|
||||
sourcefiles, incrementally, /*for_snapshot=*/false,
|
||||
/*embed_sources=*/true, nullptr, multiroot_filepaths, multiroot_scheme);
|
||||
if (result.status == Dart_KernelCompilationStatus_Ok) {
|
||||
if (KernelIsolate::AcceptCompilation().status !=
|
||||
Dart_KernelCompilationStatus_Ok) {
|
||||
|
|
Loading…
Reference in a new issue