mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 12:47:14 +00:00
[vm] Avoid embedding sources in CFE compilations if we AppJit
Creation of AppJit snapshot will not include the source of [Script] objects (see `UntaggedScript::snapshot_to`). As a result there's no point in letting the CFE embed the sources into the kernel if we only use it to create an AppJit snapshot. This is also in line with build rules for our dart-sdk, where we do the kernel compilation separately, see utils/application_snapshot.gni: ``` template("application_snapshot") { ... # Build the kernel file using the prebuilt VM to speed up the # debug and simulator builds. prebuilt_dart_action(target_name + "_dill") { ... args = [ ... "--no-embed-sources", ... ] [[[ } ... } ``` TEST=ci Change-Id: I4e17e49dc21af6102d62c2278dbd6ebbe387f7e8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313560 Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com>
This commit is contained in:
parent
7f42498d66
commit
8d802dd78a
|
@ -82,6 +82,7 @@ CompilerOptions setupCompilerOptions(
|
|||
FileSystem fileSystem,
|
||||
Uri? platformKernelPath,
|
||||
bool enableAsserts,
|
||||
bool embedSources,
|
||||
bool nullSafety,
|
||||
List<String>? experimentalFlags,
|
||||
Uri? packagesUri,
|
||||
|
@ -104,6 +105,7 @@ CompilerOptions setupCompilerOptions(
|
|||
soundNullSafety: nullSafety, supportMirrors: enableMirrors))
|
||||
..packagesFileUri = packagesUri
|
||||
..sdkSummary = platformKernelPath
|
||||
..embedSourceText = embedSources
|
||||
..verbose = verbose
|
||||
..omitPlatform = false // so that compilation results can be rejected,
|
||||
// which potentially is only relevant for
|
||||
|
@ -156,6 +158,7 @@ abstract class Compiler {
|
|||
final FileSystem fileSystem;
|
||||
final Uri? platformKernelPath;
|
||||
final bool enableAsserts;
|
||||
final bool embedSources;
|
||||
final bool nullSafety;
|
||||
final List<String>? experimentalFlags;
|
||||
final String? packageConfig;
|
||||
|
@ -175,6 +178,7 @@ abstract class Compiler {
|
|||
|
||||
Compiler(this.isolateGroupId, this.fileSystem, this.platformKernelPath,
|
||||
{this.enableAsserts = false,
|
||||
this.embedSources = true,
|
||||
this.nullSafety = true,
|
||||
this.experimentalFlags = null,
|
||||
this.supportCodeCoverage = false,
|
||||
|
@ -200,6 +204,7 @@ abstract class Compiler {
|
|||
fileSystem,
|
||||
platformKernelPath,
|
||||
enableAsserts,
|
||||
embedSources,
|
||||
nullSafety,
|
||||
experimentalFlags,
|
||||
packagesUri,
|
||||
|
@ -385,6 +390,7 @@ class SingleShotCompilerWrapper extends Compiler {
|
|||
int isolateGroupId, FileSystem fileSystem, Uri platformKernelPath,
|
||||
{this.requireMain = false,
|
||||
bool enableAsserts = false,
|
||||
bool embedSources = true,
|
||||
bool nullSafety = true,
|
||||
List<String>? experimentalFlags,
|
||||
String? packageConfig,
|
||||
|
@ -393,6 +399,7 @@ class SingleShotCompilerWrapper extends Compiler {
|
|||
required bool enableMirrors})
|
||||
: super(isolateGroupId, fileSystem, platformKernelPath,
|
||||
enableAsserts: enableAsserts,
|
||||
embedSources: embedSources,
|
||||
nullSafety: nullSafety,
|
||||
experimentalFlags: experimentalFlags,
|
||||
packageConfig: packageConfig,
|
||||
|
@ -776,7 +783,7 @@ Future _processLoadRequest(request) async {
|
|||
final Uri? script =
|
||||
inputFileUri != null ? Uri.base.resolve(inputFileUri) : null;
|
||||
final bool incremental = request[4];
|
||||
final bool snapshot = request[5];
|
||||
final bool forAppJitSnapshot = request[5];
|
||||
final bool nullSafety = request[6];
|
||||
final List sourceFiles = request[8];
|
||||
final bool enableAsserts = request[9];
|
||||
|
@ -799,7 +806,7 @@ Future _processLoadRequest(request) async {
|
|||
computePlatformBinariesLocation().resolve('vm_platform_strong.dill');
|
||||
}
|
||||
|
||||
final String invocationModes = snapshot ? 'compile' : '';
|
||||
final String invocationModes = forAppJitSnapshot ? 'compile' : '';
|
||||
|
||||
Compiler? compiler;
|
||||
|
||||
|
@ -866,11 +873,13 @@ Future _processLoadRequest(request) async {
|
|||
enableMirrors: enableMirrors);
|
||||
fileSystem = compiler.fileSystem;
|
||||
} else {
|
||||
final embedSources = !forAppJitSnapshot;
|
||||
fileSystem = _buildFileSystem(
|
||||
sourceFiles, platformKernel, multirootFilepaths, multirootScheme);
|
||||
compiler = new SingleShotCompilerWrapper(
|
||||
isolateGroupId, fileSystem, platformKernelPath,
|
||||
requireMain: false,
|
||||
embedSources: embedSources,
|
||||
enableAsserts: enableAsserts,
|
||||
nullSafety: nullSafety,
|
||||
experimentalFlags: experimentalFlags,
|
||||
|
@ -1122,7 +1131,7 @@ Future trainInternal(String scriptUri, String? platformKernelPath) async {
|
|||
scriptUri,
|
||||
platformKernelPath,
|
||||
false /* incremental */,
|
||||
false /* snapshot */,
|
||||
false /* for_app_jit_snapshot */,
|
||||
true /* null safety */,
|
||||
1 /* isolateGroupId chosen randomly */,
|
||||
[] /* source files */,
|
||||
|
|
|
@ -188,15 +188,15 @@ const char* PathSanitizer::sanitized_uri() const {
|
|||
Dart_KernelCompilationResult DFE::CompileScript(const char* script_uri,
|
||||
bool incremental,
|
||||
const char* package_config,
|
||||
bool snapshot) {
|
||||
bool for_app_jit_snapshot) {
|
||||
// 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);
|
||||
const char* sanitized_uri = path_sanitizer.sanitized_uri();
|
||||
|
||||
return Dart_CompileToKernel(sanitized_uri, platform_strong_dill,
|
||||
platform_strong_dill_size, incremental, snapshot,
|
||||
package_config, verbosity());
|
||||
return Dart_CompileToKernel(
|
||||
sanitized_uri, platform_strong_dill, platform_strong_dill_size,
|
||||
incremental, for_app_jit_snapshot, package_config, verbosity());
|
||||
}
|
||||
|
||||
void DFE::CompileAndReadScript(const char* script_uri,
|
||||
|
@ -205,9 +205,10 @@ void DFE::CompileAndReadScript(const char* script_uri,
|
|||
char** error,
|
||||
int* exit_code,
|
||||
const char* package_config,
|
||||
bool snapshot) {
|
||||
Dart_KernelCompilationResult result = CompileScript(
|
||||
script_uri, use_incremental_compiler(), package_config, snapshot);
|
||||
bool for_app_jit_snapshot) {
|
||||
Dart_KernelCompilationResult result =
|
||||
CompileScript(script_uri, use_incremental_compiler(), package_config,
|
||||
for_app_jit_snapshot);
|
||||
switch (result.status) {
|
||||
case Dart_KernelCompilationStatus_Ok:
|
||||
*kernel_buffer = result.kernel;
|
||||
|
|
|
@ -297,10 +297,10 @@ 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 snapshot = Options::gen_snapshot_kind() == kAppJIT;
|
||||
const bool for_app_jit_snapshot = Options::gen_snapshot_kind() == kAppJIT;
|
||||
dfe.CompileAndReadScript(script_uri, &application_kernel_buffer,
|
||||
&application_kernel_buffer_size, error, exit_code,
|
||||
resolved_packages_config, snapshot);
|
||||
resolved_packages_config, for_app_jit_snapshot);
|
||||
if (application_kernel_buffer == nullptr) {
|
||||
Dart_ExitScope();
|
||||
Dart_ShutdownIsolate();
|
||||
|
|
|
@ -19,6 +19,7 @@ evaluate_*: SkipByDesign # No incremental compiler available.
|
|||
get_allocation_traces_test: SkipByDesign # Allocation traces aren't consistent when running from snapshot.
|
||||
get_instances_as_array_rpc_expression_evaluation_on_internal_test: SkipByDesign # No incremental compiler available.
|
||||
get_object_rpc_test: SkipByDesign # App-JIT snapshots don't contain script sources.
|
||||
get_source_report_const_coverage_test: SkipByDesign # AppJit doesn't include sources & therefore no coverage of sources.
|
||||
pause_on_exceptions_test: SkipByDesign # No incremental compiler available.
|
||||
rewind_optimized_out_test: SkipByDesign # No incremental compiler available.
|
||||
rewind_test: SkipByDesign # No incremental compiler available.
|
||||
|
|
|
@ -6170,7 +6170,7 @@ Dart_CompileToKernel(const char* script_uri,
|
|||
const uint8_t* platform_kernel,
|
||||
intptr_t platform_kernel_size,
|
||||
bool incremental_compile,
|
||||
bool snapshot_compile,
|
||||
bool for_app_jit_snapshot,
|
||||
const char* package_config,
|
||||
Dart_KernelCompilationVerbosityLevel verbosity) {
|
||||
API_TIMELINE_DURATION(Thread::Current());
|
||||
|
@ -6182,8 +6182,8 @@ Dart_CompileToKernel(const char* script_uri,
|
|||
#else
|
||||
result = KernelIsolate::CompileToKernel(
|
||||
script_uri, platform_kernel, platform_kernel_size, 0, nullptr,
|
||||
incremental_compile, snapshot_compile, package_config, nullptr, nullptr,
|
||||
verbosity);
|
||||
incremental_compile, for_app_jit_snapshot, package_config, nullptr,
|
||||
nullptr, verbosity);
|
||||
if (incremental_compile) {
|
||||
Dart_KernelCompilationResult ack_result =
|
||||
result.status == Dart_KernelCompilationStatus_Ok ?
|
||||
|
|
|
@ -768,7 +768,7 @@ class KernelCompilationRequest : public ValueObject {
|
|||
int source_files_count,
|
||||
Dart_SourceFile source_files[],
|
||||
bool incremental_compile,
|
||||
bool snapshot_compile,
|
||||
bool for_app_jit_snapshot,
|
||||
const char* package_config,
|
||||
const char* multiroot_filepaths,
|
||||
const char* multiroot_scheme,
|
||||
|
@ -826,7 +826,7 @@ class KernelCompilationRequest : public ValueObject {
|
|||
|
||||
Dart_CObject dart_snapshot;
|
||||
dart_snapshot.type = Dart_CObject_kBool;
|
||||
dart_snapshot.value.as_bool = snapshot_compile;
|
||||
dart_snapshot.value.as_bool = for_app_jit_snapshot;
|
||||
|
||||
// TODO(aam): Assert that isolate exists once we move CompileAndReadScript
|
||||
// compilation logic out of CreateIsolateAndSetupHelper and into
|
||||
|
@ -1103,7 +1103,7 @@ Dart_KernelCompilationResult KernelIsolate::CompileToKernel(
|
|||
int source_file_count,
|
||||
Dart_SourceFile source_files[],
|
||||
bool incremental_compile,
|
||||
bool snapshot_compile,
|
||||
bool for_app_jit_snapshot,
|
||||
const char* package_config,
|
||||
const char* multiroot_filepaths,
|
||||
const char* multiroot_scheme,
|
||||
|
@ -1130,7 +1130,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, snapshot_compile, package_config,
|
||||
incremental_compile, for_app_jit_snapshot, package_config,
|
||||
multiroot_filepaths, multiroot_scheme, experimental_flags_, nullptr,
|
||||
verbosity);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ class KernelIsolate : public AllStatic {
|
|||
int source_files_count = 0,
|
||||
Dart_SourceFile source_files[] = nullptr,
|
||||
bool incremental_compile = true,
|
||||
bool snapshot_compile = false,
|
||||
bool for_app_jit_snapshot = false,
|
||||
const char* package_config = nullptr,
|
||||
const char* multiroot_filepaths = nullptr,
|
||||
const char* multiroot_scheme = nullptr,
|
||||
|
|
Loading…
Reference in a new issue