Skip to content

Commit edd64e6

Browse files
a-sivacommit-bot@chromium.org
authored andcommitted
Revert "[vm] AOT blobs snapshots are obsolete. Remove dead code."
This reverts commit bcc0900. Reason for revert: This CL is breaking the Fuchsia Flutter build see https://github.com/flutter/engine/pull/16604/checks?check_run_id=445155807 Original change's description: > [vm] AOT blobs snapshots are obsolete. Remove dead code. > > Change-Id: I35cf4befbe66b92197dcd659172f90be3de30f8e > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134840 > Commit-Queue: Samir Jindel <[email protected]> > Reviewed-by: Ryan Macnak <[email protected]> [email protected],[email protected] Change-Id: I9dd32a71bf43907f59ed766b98bf453bab99ea3c No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135881 Reviewed-by: Siva Annamalai <[email protected]> Commit-Queue: Siva Annamalai <[email protected]>
1 parent 8ac7f6b commit edd64e6

17 files changed

+315
-46
lines changed

pkg/smith/lib/configuration.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ class Configuration {
259259
isMinified: boolOption("minified"),
260260
useAnalyzerCfe: boolOption("use-cfe"),
261261
useAnalyzerFastaParser: boolOption("analyzer-use-fasta-parser"),
262+
useBlobs: boolOption("use-blobs"),
262263
useElf: boolOption("use-elf"),
263264
useHotReload: boolOption("hot-reload"),
264265
useHotReloadRollback: boolOption("hot-reload-rollback"),
@@ -329,6 +330,8 @@ class Configuration {
329330
final bool useAnalyzerCfe;
330331
final bool useAnalyzerFastaParser;
331332

333+
// TODO(rnystrom): What is this?
334+
final bool useBlobs;
332335
final bool useElf;
333336

334337
final bool useHotReload;
@@ -356,6 +359,7 @@ class Configuration {
356359
bool isMinified,
357360
bool useAnalyzerCfe,
358361
bool useAnalyzerFastaParser,
362+
bool useBlobs,
359363
bool useElf,
360364
bool useHotReload,
361365
bool useHotReloadRollback,
@@ -377,6 +381,7 @@ class Configuration {
377381
isMinified = isMinified ?? false,
378382
useAnalyzerCfe = useAnalyzerCfe ?? false,
379383
useAnalyzerFastaParser = useAnalyzerFastaParser ?? false,
384+
useBlobs = useBlobs ?? false,
380385
useElf = useElf ?? false,
381386
useHotReload = useHotReload ?? false,
382387
useHotReloadRollback = useHotReloadRollback ?? false,
@@ -407,6 +412,7 @@ class Configuration {
407412
isMinified == other.isMinified &&
408413
useAnalyzerCfe == other.useAnalyzerCfe &&
409414
useAnalyzerFastaParser == other.useAnalyzerFastaParser &&
415+
useBlobs == other.useBlobs &&
410416
useElf == other.useElf &&
411417
useHotReload == other.useHotReload &&
412418
useHotReloadRollback == other.useHotReloadRollback &&
@@ -456,6 +462,7 @@ class Configuration {
456462
isMinified,
457463
useAnalyzerCfe,
458464
useAnalyzerFastaParser,
465+
useBlobs,
459466
useElf,
460467
useHotReload,
461468
useHotReloadRollback,
@@ -496,6 +503,7 @@ class Configuration {
496503
if (isMinified) fields.add("minified");
497504
if (useAnalyzerCfe) fields.add("use-cfe");
498505
if (useAnalyzerFastaParser) fields.add("analyzer-use-fasta-parser");
506+
if (useBlobs) fields.add("use-blobs");
499507
if (useHotReload) fields.add("hot-reload");
500508
if (useHotReloadRollback) fields.add("hot-reload-rollback");
501509
if (useSdk) fields.add("use-sdk");
@@ -553,6 +561,7 @@ class Configuration {
553561
boolField("use-cfe", useAnalyzerCfe, other.useAnalyzerCfe);
554562
boolField("analyzer-use-fasta-parser", useAnalyzerFastaParser,
555563
other.useAnalyzerFastaParser);
564+
boolField("use-blobs", useBlobs, other.useBlobs);
556565
boolField("host-checked", isHostChecked, other.isHostChecked);
557566
boolField("hot-reload", useHotReload, other.useHotReload);
558567
boolField("hot-reload-rollback", useHotReloadRollback,

pkg/smith/test/configuration_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ void main() {
382382
isMinified: true,
383383
useAnalyzerCfe: true,
384384
useAnalyzerFastaParser: true,
385+
useBlobs: true,
385386
useElf: true,
386387
useHotReload: true,
387388
useHotReloadRollback: true,
@@ -411,6 +412,7 @@ architecture: ia32 x64
411412
minified: false true
412413
use-cfe: false true
413414
analyzer-use-fasta-parser: false true
415+
use-blobs: false true
414416
host-checked: false true
415417
hot-reload: false true
416418
hot-reload-rollback: false true

pkg/test_runner/lib/src/command.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ class AdbPrecompilationCommand extends Command implements AdbCommand {
547547
final String processTestFilename;
548548
final String precompiledTestDirectory;
549549
final List<String> arguments;
550+
final bool useBlobs;
550551
final bool useElf;
551552
final List<String> extraLibraries;
552553

@@ -555,6 +556,7 @@ class AdbPrecompilationCommand extends Command implements AdbCommand {
555556
this.processTestFilename,
556557
this.precompiledTestDirectory,
557558
this.arguments,
559+
this.useBlobs,
558560
this.useElf,
559561
this.extraLibraries,
560562
{int index = 0})
@@ -565,6 +567,7 @@ class AdbPrecompilationCommand extends Command implements AdbCommand {
565567
processTestFilename,
566568
precompiledTestDirectory,
567569
arguments,
570+
useBlobs,
568571
useElf,
569572
extraLibraries,
570573
index: index);
@@ -579,13 +582,15 @@ class AdbPrecompilationCommand extends Command implements AdbCommand {
579582
builder.add(buildPath);
580583
builder.add(precompiledTestDirectory);
581584
builder.add(arguments);
585+
builder.add(useBlobs);
582586
builder.add(useElf);
583587
extraLibraries.forEach(builder.add);
584588
}
585589

586590
bool _equal(AdbPrecompilationCommand other) =>
587591
super._equal(other) &&
588592
buildPath == other.buildPath &&
593+
useBlobs == other.useBlobs &&
589594
useElf == other.useElf &&
590595
arguments == other.arguments &&
591596
precompiledTestDirectory == other.precompiledTestDirectory &&

pkg/test_runner/lib/src/compiler_configuration.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration
626626
tempDir, arguments, environmentOverrides));
627627
}
628628

629-
if (!_configuration.useElf) {
629+
if (!_configuration.useBlobs && !_configuration.useElf) {
630630
commands.add(
631631
computeAssembleCommand(tempDir, arguments, environmentOverrides));
632632
if (!_configuration.keepGeneratedFiles) {
@@ -698,7 +698,10 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration
698698
}
699699

700700
var args = [
701-
if (_configuration.useElf) ...[
701+
if (_configuration.useBlobs) ...[
702+
"--snapshot-kind=app-aot-blobs",
703+
"--blobs_container_filename=$tempDir/out.aotsnapshot"
704+
] else if (_configuration.useElf) ...[
702705
"--snapshot-kind=app-aot-elf",
703706
"--elf=$tempDir/out.aotsnapshot"
704707
] else ...[

pkg/test_runner/lib/src/configuration.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class TestConfiguration {
115115
bool get isMinified => configuration.isMinified;
116116
bool get useAnalyzerCfe => configuration.useAnalyzerCfe;
117117
bool get useAnalyzerFastaParser => configuration.useAnalyzerFastaParser;
118+
bool get useBlobs => configuration.useBlobs;
118119
bool get useElf => configuration.useElf;
119120
bool get useSdk => configuration.useSdk;
120121
bool get enableAsserts => configuration.enableAsserts;

pkg/test_runner/lib/src/options.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ compiler.''',
816816
useAnalyzerCfe: data["use_cfe"] as bool,
817817
useAnalyzerFastaParser:
818818
data["analyzer_use_fasta_parser"] as bool,
819+
useBlobs: data["use_blobs"] as bool,
819820
useElf: data["use_elf"] as bool,
820821
useSdk: data["use_sdk"] as bool,
821822
useHotReload: data["hot_reload"] as bool,

pkg/test_runner/lib/src/runtime_configuration.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ abstract class RuntimeConfiguration {
4848
case Runtime.dartPrecompiled:
4949
if (configuration.system == System.android) {
5050
return DartPrecompiledAdbRuntimeConfiguration(
51+
useBlobs: configuration.useBlobs,
5152
useElf: configuration.useElf,
5253
);
5354
} else {
5455
return DartPrecompiledRuntimeConfiguration(
56+
useBlobs: configuration.useBlobs,
5557
useElf: configuration.useElf,
5658
);
5759
}
@@ -280,8 +282,11 @@ class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration {
280282
}
281283

282284
class DartPrecompiledRuntimeConfiguration extends DartVmRuntimeConfiguration {
285+
final bool useBlobs;
283286
final bool useElf;
284-
DartPrecompiledRuntimeConfiguration({bool useElf}) : useElf = useElf;
287+
DartPrecompiledRuntimeConfiguration({bool useBlobs, bool useElf})
288+
: useBlobs = useBlobs,
289+
useElf = useElf;
285290

286291
List<Command> computeRuntimeCommands(
287292
CommandArtifact artifact,
@@ -335,8 +340,11 @@ class DartPrecompiledAdbRuntimeConfiguration
335340
static const deviceDir = '/data/local/tmp/precompilation-testing';
336341
static const deviceTestDir = '/data/local/tmp/precompilation-testing/test';
337342

343+
final bool useBlobs;
338344
final bool useElf;
339-
DartPrecompiledAdbRuntimeConfiguration({bool useElf}) : useElf = useElf;
345+
DartPrecompiledAdbRuntimeConfiguration({bool useBlobs, bool useElf})
346+
: useBlobs = useBlobs,
347+
useElf = useElf;
340348

341349
List<Command> computeRuntimeCommands(
342350
CommandArtifact artifact,
@@ -353,7 +361,7 @@ class DartPrecompiledAdbRuntimeConfiguration
353361
var processTest = processTestBinaryFileName;
354362
return [
355363
AdbPrecompilationCommand(
356-
buildDir, processTest, script, arguments, useElf, extraLibs)
364+
buildDir, processTest, script, arguments, useBlobs, useElf, extraLibs)
357365
];
358366
}
359367
}

runtime/bin/gen_snapshot.cc

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ enum SnapshotKind {
8181
kCoreJIT,
8282
kApp,
8383
kAppJIT,
84+
kAppAOTBlobs,
8485
kAppAOTAssembly,
8586
kAppAOTElf,
8687
kVMAOTAssembly,
@@ -94,6 +95,7 @@ static const char* kSnapshotKindNames[] = {
9495
"core-jit",
9596
"app",
9697
"app-jit",
98+
"app-aot-blobs",
9799
"app-aot-assembly",
98100
"app-aot-elf",
99101
"vm-aot-assembly",
@@ -144,7 +146,8 @@ DEFINE_ENUM_OPTION(snapshot_kind, SnapshotKind, snapshot_kind);
144146
DEFINE_CB_OPTION(ProcessEnvironmentOption);
145147

146148
static bool IsSnapshottingForPrecompilation() {
147-
return (snapshot_kind == kAppAOTAssembly) || (snapshot_kind == kAppAOTElf) ||
149+
return (snapshot_kind == kAppAOTBlobs) ||
150+
(snapshot_kind == kAppAOTAssembly) || (snapshot_kind == kAppAOTElf) ||
148151
(snapshot_kind == kVMAOTAssembly);
149152
}
150153

@@ -283,6 +286,34 @@ static int ParseArguments(int argc,
283286
}
284287
break;
285288
}
289+
case kAppAOTBlobs: {
290+
if ((blobs_container_filename == NULL) &&
291+
((vm_snapshot_data_filename == NULL) ||
292+
(vm_snapshot_instructions_filename == NULL) ||
293+
(isolate_snapshot_data_filename == NULL) ||
294+
(isolate_snapshot_instructions_filename == NULL))) {
295+
Syslog::PrintErr(
296+
"Building an AOT snapshot as blobs requires specifying output "
297+
"file for --blobs_container_filename or "
298+
"files for --vm_snapshot_data, --vm_snapshot_instructions, "
299+
"--isolate_snapshot_data and --isolate_snapshot_instructions.\n\n");
300+
return -1;
301+
}
302+
if ((blobs_container_filename != NULL) &&
303+
((vm_snapshot_data_filename != NULL) ||
304+
(vm_snapshot_instructions_filename != NULL) ||
305+
(isolate_snapshot_data_filename != NULL) ||
306+
(isolate_snapshot_instructions_filename != NULL))) {
307+
Syslog::PrintErr(
308+
"Building an AOT snapshot as blobs requires specifying output "
309+
"file for --blobs_container_filename or "
310+
"files for --vm_snapshot_data, --vm_snapshot_instructions, "
311+
"--isolate_snapshot_data and --isolate_snapshot_instructions"
312+
" not both.\n\n");
313+
return -1;
314+
}
315+
break;
316+
}
286317
case kAppAOTElf: {
287318
if (elf_filename == NULL) {
288319
Syslog::PrintErr(
@@ -638,6 +669,54 @@ static void CreateAndWritePrecompiledSnapshot() {
638669
" To avoid this, use --strip to remove it and "
639670
"--save-debugging-info=<...> to save it to a separate file.\n");
640671
}
672+
} else if (snapshot_kind == kAppAOTBlobs) {
673+
Syslog::PrintErr(
674+
"WARNING: app-aot-blobs snapshots have been deprecated and support for "
675+
"generating them will be removed soon. Please use the app-aot-elf or "
676+
"app-aot-assembly snapshot kinds in conjunction with the portable ELF "
677+
"loader from //runtime/bin:elf_loader if necessary. See "
678+
"http://dartbug.com/38764 for more details.\n");
679+
680+
uint8_t* vm_snapshot_data_buffer = NULL;
681+
intptr_t vm_snapshot_data_size = 0;
682+
uint8_t* vm_snapshot_instructions_buffer = NULL;
683+
intptr_t vm_snapshot_instructions_size = 0;
684+
uint8_t* isolate_snapshot_data_buffer = NULL;
685+
intptr_t isolate_snapshot_data_size = 0;
686+
uint8_t* isolate_snapshot_instructions_buffer = NULL;
687+
intptr_t isolate_snapshot_instructions_size = 0;
688+
File* debug_file = nullptr;
689+
if (debugging_info_filename != nullptr) {
690+
debug_file = OpenFile(debugging_info_filename);
691+
}
692+
result = Dart_CreateAppAOTSnapshotAsBlobs(
693+
&vm_snapshot_data_buffer, &vm_snapshot_data_size,
694+
&vm_snapshot_instructions_buffer, &vm_snapshot_instructions_size,
695+
&isolate_snapshot_data_buffer, &isolate_snapshot_data_size,
696+
&isolate_snapshot_instructions_buffer,
697+
&isolate_snapshot_instructions_size, StreamingWriteCallback,
698+
debug_file);
699+
if (debug_file != nullptr) debug_file->Release();
700+
CHECK_RESULT(result);
701+
702+
if (blobs_container_filename != NULL) {
703+
Snapshot::WriteAppSnapshot(
704+
blobs_container_filename, vm_snapshot_data_buffer,
705+
vm_snapshot_data_size, vm_snapshot_instructions_buffer,
706+
vm_snapshot_instructions_size, isolate_snapshot_data_buffer,
707+
isolate_snapshot_data_size, isolate_snapshot_instructions_buffer,
708+
isolate_snapshot_instructions_size);
709+
} else {
710+
WriteFile(vm_snapshot_data_filename, vm_snapshot_data_buffer,
711+
vm_snapshot_data_size);
712+
WriteFile(vm_snapshot_instructions_filename,
713+
vm_snapshot_instructions_buffer, vm_snapshot_instructions_size);
714+
WriteFile(isolate_snapshot_data_filename, isolate_snapshot_data_buffer,
715+
isolate_snapshot_data_size);
716+
WriteFile(isolate_snapshot_instructions_filename,
717+
isolate_snapshot_instructions_buffer,
718+
isolate_snapshot_instructions_size);
719+
}
641720
} else {
642721
UNREACHABLE();
643722
}
@@ -747,6 +826,7 @@ static int CreateIsolateAndSnapshot(const CommandLineOptions& inputs) {
747826
CreateAndWriteAppJITSnapshot();
748827
break;
749828
case kAppAOTAssembly:
829+
case kAppAOTBlobs:
750830
case kAppAOTElf:
751831
CreateAndWritePrecompiledSnapshot();
752832
break;

runtime/bin/snapshot_utils.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,29 @@ void Snapshot::GenerateAppJIT(const char* snapshot_filename) {
509509
#endif
510510
}
511511

512+
void Snapshot::GenerateAppAOTAsBlobs(const char* snapshot_filename) {
513+
uint8_t* vm_data_buffer = NULL;
514+
intptr_t vm_data_size = 0;
515+
uint8_t* vm_instructions_buffer = NULL;
516+
intptr_t vm_instructions_size = 0;
517+
uint8_t* isolate_data_buffer = NULL;
518+
intptr_t isolate_data_size = 0;
519+
uint8_t* isolate_instructions_buffer = NULL;
520+
intptr_t isolate_instructions_size = 0;
521+
Dart_Handle result = Dart_CreateAppAOTSnapshotAsBlobs(
522+
&vm_data_buffer, &vm_data_size, &vm_instructions_buffer,
523+
&vm_instructions_size, &isolate_data_buffer, &isolate_data_size,
524+
&isolate_instructions_buffer, &isolate_instructions_size,
525+
/*callback=*/nullptr, /*debug_callback_info=*/nullptr);
526+
if (Dart_IsError(result)) {
527+
ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result));
528+
}
529+
WriteAppSnapshot(snapshot_filename, vm_data_buffer, vm_data_size,
530+
vm_instructions_buffer, vm_instructions_size,
531+
isolate_data_buffer, isolate_data_size,
532+
isolate_instructions_buffer, isolate_instructions_size);
533+
}
534+
512535
static void StreamingWriteCallback(void* callback_data,
513536
const uint8_t* buffer,
514537
intptr_t size) {

runtime/bin/snapshot_utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Snapshot {
3232
const char* script_name,
3333
const char* package_config);
3434
static void GenerateAppJIT(const char* snapshot_filename);
35+
static void GenerateAppAOTAsBlobs(const char* snapshot_filename);
3536
static void GenerateAppAOTAsAssembly(const char* snapshot_filename);
3637

3738
static AppSnapshot* TryReadAppendedAppSnapshotElf(const char* container_path);

runtime/include/dart_api.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,6 +3480,31 @@ DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle
34803480
Dart_CreateVMAOTSnapshotAsAssembly(Dart_StreamingWriteCallback callback,
34813481
void* callback_data);
34823482

3483+
/**
3484+
* Same as Dart_CreateAppAOTSnapshotAsAssembly, except all the pieces are
3485+
* provided directly as bytes that the embedder can load with mmap. The
3486+
* instructions pieces must be loaded with read and execute permissions; the
3487+
* other pieces may be loaded as read-only.
3488+
*
3489+
* This function has been DEPRECATED. Please use Dart_CreateAppAOTSnapshotAsELF
3490+
* or Dart_CreateAppAOTSnapshotAsAssembly instead. A portable ELF loader is
3491+
* available in the target //runtime/bin:elf_loader.
3492+
*
3493+
* If callback and debug_callback_data are provided, debug_callback_data will
3494+
* be used with the callback to provide separate debugging information.
3495+
*/
3496+
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle
3497+
Dart_CreateAppAOTSnapshotAsBlobs(uint8_t** vm_snapshot_data_buffer,
3498+
intptr_t* vm_snapshot_data_size,
3499+
uint8_t** vm_snapshot_instructions_buffer,
3500+
intptr_t* vm_snapshot_instructions_size,
3501+
uint8_t** isolate_snapshot_data_buffer,
3502+
intptr_t* isolate_snapshot_data_size,
3503+
uint8_t** isolate_snapshot_instructions_buffer,
3504+
intptr_t* isolate_snapshot_instructions_size,
3505+
Dart_StreamingWriteCallback callback,
3506+
void* debug_callback_data);
3507+
34833508
/**
34843509
* Sorts the class-ids in depth first traversal order of the inheritance
34853510
* tree. This is a costly operation, but it can make method dispatch

0 commit comments

Comments
 (0)