mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:39:49 +00:00
Cleanup options for use of application snapshots
- unified kAppAfterRun and kAppJITAfterRun to kAppJIT - adjusted the test configuration to make dart2app and dart2appjit to mean the same - delete GenerateFullSnapshot function as it is not used anymore R=rmacnak@google.com Review URL: https://codereview.chromium.org/2429023002 .
This commit is contained in:
parent
b85f900cb7
commit
af4d246ef1
|
@ -44,14 +44,12 @@ extern const uint8_t* isolate_snapshot_buffer;
|
|||
|
||||
/**
|
||||
* Global state used to control and store generation of application snapshots
|
||||
* (script/full).
|
||||
* A full application snapshot can be generated and run using the following
|
||||
* commands
|
||||
* - Generating a full application snapshot :
|
||||
* dart_bootstrap --full-snapshot-after-run=<filename> --package-root=<dirs>
|
||||
* <script_uri> [<script_options>]
|
||||
* - Running the full application snapshot generated above :
|
||||
* dart --run-full-snapshot=<filename> <script_uri> [<script_options>]
|
||||
* An application snapshot can be generated and run using the following
|
||||
* command
|
||||
* dart --snapshot-kind=app-jit --snapshot=<app_snapshot_filename>
|
||||
* <script_uri> [<script_options>]
|
||||
* To Run the application snapshot generated above, use :
|
||||
* dart <app_snapshot_filename> [<script_options>]
|
||||
*/
|
||||
static bool run_app_snapshot = false;
|
||||
static const char* snapshot_filename = NULL;
|
||||
|
@ -59,8 +57,7 @@ enum SnapshotKind {
|
|||
kNone,
|
||||
kScript,
|
||||
kAppAOT,
|
||||
kAppJITAfterRun,
|
||||
kAppAfterRun,
|
||||
kAppJIT,
|
||||
};
|
||||
static SnapshotKind gen_snapshot_kind = kNone;
|
||||
|
||||
|
@ -360,15 +357,12 @@ static bool ProcessSnapshotKindOption(const char* kind,
|
|||
} else if (strcmp(kind, "app-aot") == 0) {
|
||||
gen_snapshot_kind = kAppAOT;
|
||||
return true;
|
||||
} else if (strcmp(kind, "app-jit-after-run") == 0) {
|
||||
gen_snapshot_kind = kAppJITAfterRun;
|
||||
return true;
|
||||
} else if (strcmp(kind, "app-after-run") == 0) {
|
||||
gen_snapshot_kind = kAppAfterRun;
|
||||
} else if (strcmp(kind, "app-jit") == 0) {
|
||||
gen_snapshot_kind = kAppJIT;
|
||||
return true;
|
||||
}
|
||||
Log::PrintErr("Unrecognized snapshot kind: '%s'\nValid kinds are: "
|
||||
"script, app-aot, app-jit-after-run, app-after-run\n", kind);
|
||||
"script, app-aot, app-jit\n", kind);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -804,8 +798,7 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
|||
IsolateData* isolate_data = new IsolateData(script_uri,
|
||||
package_root,
|
||||
packages_config);
|
||||
if ((gen_snapshot_kind == kAppAfterRun) ||
|
||||
(gen_snapshot_kind == kAppJITAfterRun)) {
|
||||
if (gen_snapshot_kind == kAppJIT) {
|
||||
isolate_data->set_exit_hook(SnapshotOnExitHook);
|
||||
}
|
||||
Dart_Isolate isolate = Dart_CreateIsolate(script_uri,
|
||||
|
@ -1159,27 +1152,16 @@ static bool FileModifiedCallback(const char* url, int64_t since) {
|
|||
}
|
||||
|
||||
|
||||
static void WriteSnapshotFile(const char* snapshot_directory,
|
||||
const char* filename,
|
||||
static void WriteSnapshotFile(const char* filename,
|
||||
bool write_magic_number,
|
||||
const uint8_t* buffer,
|
||||
const intptr_t size) {
|
||||
char* concat = NULL;
|
||||
const char* qualified_filename;
|
||||
if ((snapshot_directory != NULL) && (strlen(snapshot_directory) > 0)) {
|
||||
intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, filename);
|
||||
concat = new char[len + 1];
|
||||
snprintf(concat, len + 1, "%s/%s", snapshot_directory, filename);
|
||||
qualified_filename = concat;
|
||||
} else {
|
||||
qualified_filename = filename;
|
||||
}
|
||||
|
||||
File* file = File::Open(qualified_filename, File::kWriteTruncate);
|
||||
File* file = File::Open(filename, File::kWriteTruncate);
|
||||
if (file == NULL) {
|
||||
ErrorExit(kErrorExitCode,
|
||||
"Unable to open file %s for writing snapshot\n",
|
||||
qualified_filename);
|
||||
filename);
|
||||
}
|
||||
|
||||
if (write_magic_number) {
|
||||
|
@ -1190,7 +1172,7 @@ static void WriteSnapshotFile(const char* snapshot_directory,
|
|||
if (!file->WriteFully(buffer, size)) {
|
||||
ErrorExit(kErrorExitCode,
|
||||
"Unable to write file %s for writing snapshot\n",
|
||||
qualified_filename);
|
||||
filename);
|
||||
}
|
||||
file->Release();
|
||||
if (concat != NULL) {
|
||||
|
@ -1410,7 +1392,7 @@ static void GenerateScriptSnapshot() {
|
|||
ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result));
|
||||
}
|
||||
|
||||
WriteSnapshotFile(NULL, snapshot_filename, true, buffer, size);
|
||||
WriteSnapshotFile(snapshot_filename, true, buffer, size);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1455,7 +1437,7 @@ static void GeneratePrecompiledSnapshot() {
|
|||
rodata_blob_buffer,
|
||||
rodata_blob_size);
|
||||
} else {
|
||||
WriteSnapshotFile(NULL, snapshot_filename,
|
||||
WriteSnapshotFile(snapshot_filename,
|
||||
false,
|
||||
assembly_buffer,
|
||||
assembly_size);
|
||||
|
@ -1496,9 +1478,16 @@ static void GeneratePrecompiledJITSnapshot() {
|
|||
}
|
||||
|
||||
|
||||
static void GenerateFullSnapshot() {
|
||||
// Create a full snapshot of the script.
|
||||
static void GenerateAppSnapshot() {
|
||||
Dart_Handle result;
|
||||
#if defined(TARGET_ARCH_X64)
|
||||
result = Dart_PrecompileJIT();
|
||||
if (Dart_IsError(result)) {
|
||||
ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result));
|
||||
}
|
||||
GeneratePrecompiledJITSnapshot();
|
||||
#else
|
||||
// Create an application snapshot of the script.
|
||||
uint8_t* vm_isolate_buffer = NULL;
|
||||
intptr_t vm_isolate_size = 0;
|
||||
uint8_t* isolate_buffer = NULL;
|
||||
|
@ -1518,9 +1507,11 @@ static void GenerateFullSnapshot() {
|
|||
isolate_buffer,
|
||||
isolate_size,
|
||||
NULL, 0, NULL, 0);
|
||||
#endif // defined(TARGET_ARCH_X64)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define CHECK_RESULT(result) \
|
||||
if (Dart_IsError(result)) { \
|
||||
if (Dart_IsVMRestartRequest(result)) { \
|
||||
|
@ -1536,12 +1527,7 @@ static void GenerateFullSnapshot() {
|
|||
|
||||
static void SnapshotOnExitHook(int64_t exit_code) {
|
||||
if (exit_code == 0) {
|
||||
if (gen_snapshot_kind == kAppAfterRun) {
|
||||
GenerateFullSnapshot();
|
||||
} else {
|
||||
Dart_PrecompileJIT();
|
||||
GeneratePrecompiledJITSnapshot();
|
||||
}
|
||||
GenerateAppSnapshot();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1599,9 +1585,8 @@ bool RunMainIsolate(const char* script_name,
|
|||
result = Dart_LibraryImportLibrary(
|
||||
isolate_data->builtin_lib(), root_lib, Dart_Null());
|
||||
if (is_noopt ||
|
||||
(gen_snapshot_kind == kAppAfterRun) ||
|
||||
(gen_snapshot_kind == kAppAOT) ||
|
||||
(gen_snapshot_kind == kAppJITAfterRun)) {
|
||||
(gen_snapshot_kind == kAppJIT)) {
|
||||
// Load the embedder's portion of the VM service's Dart code so it will
|
||||
// be included in the app snapshot.
|
||||
if (!VmService::LoadForGenPrecompiled()) {
|
||||
|
@ -1703,17 +1688,10 @@ bool RunMainIsolate(const char* script_name,
|
|||
// Keep handling messages until the last active receive port is closed.
|
||||
result = Dart_RunLoop();
|
||||
// Generate an app snapshot after execution if specified.
|
||||
if ((gen_snapshot_kind == kAppAfterRun) ||
|
||||
(gen_snapshot_kind == kAppJITAfterRun)) {
|
||||
if ((gen_snapshot_kind == kAppJIT)) {
|
||||
if (!Dart_IsCompilationError(result) &&
|
||||
!Dart_IsVMRestartRequest(result)) {
|
||||
if (gen_snapshot_kind == kAppAfterRun) {
|
||||
GenerateFullSnapshot();
|
||||
} else {
|
||||
Dart_Handle prepare_result = Dart_PrecompileJIT();
|
||||
CHECK_RESULT(prepare_result);
|
||||
GeneratePrecompiledJITSnapshot();
|
||||
}
|
||||
GenerateAppSnapshot();
|
||||
}
|
||||
}
|
||||
CHECK_RESULT(result);
|
||||
|
@ -1891,7 +1869,7 @@ void main(int argc, char** argv) {
|
|||
}
|
||||
#endif
|
||||
|
||||
if (gen_snapshot_kind == kAppJITAfterRun) {
|
||||
if (gen_snapshot_kind == kAppJIT) {
|
||||
vm_options.AddArgument("--fields_may_be_reset");
|
||||
}
|
||||
if ((gen_snapshot_kind == kAppAOT) || is_noopt) {
|
||||
|
|
|
@ -80,7 +80,7 @@ LibTest/math/log_A01_t01: PASS, FAIL, OK # Issue 26261
|
|||
[ $runtime == dartium || $compiler == dart2js ]
|
||||
LibTest/async/Future/Future.delayed_A01_t02: Pass, Fail # Issue 15524
|
||||
|
||||
[ ($compiler == none || $compiler == precompiler || $compiler == dart2appjit) && ($runtime == vm || $runtime == drt || $runtime == dartium || $runtime == dart_precompiled || $runtime == dart_app) ]
|
||||
[ ($compiler == none || $compiler == precompiler || $compiler == dart2app || $compiler == dart2appjit) && ($runtime == vm || $runtime == drt || $runtime == dartium || $runtime == dart_precompiled || $runtime == dart_app) ]
|
||||
# Optional trailing commas for argument and parameter lists added to language.
|
||||
# https://github.com/dart-lang/co19/issues/68
|
||||
Language/Expressions/Function_Invocation/Actual_Argument_List_Evaluation/syntax_t05: Fail, OK
|
||||
|
|
|
@ -164,7 +164,7 @@ Language/Expressions/Property_Extraction/Super_Closurization: CompileTimeError #
|
|||
Language/Metadata/*: SkipByDesign # Uses dart:mirrors
|
||||
Language/Expressions/Null/instance_of_class_null_t01: Skip # Uses dart:mirrors
|
||||
|
||||
[ $noopt || $compiler == precompiler || $compiler == dart2appjit || $mode == product ]
|
||||
[ $noopt || $compiler == precompiler || $compiler == dart2app || $compiler == dart2appjit || $mode == product ]
|
||||
Language/Libraries_and_Scripts/Imports/deferred_import_t01: Skip # Eager loading
|
||||
Language/Libraries_and_Scripts/Imports/deferred_import_t02: Skip # Eager loading
|
||||
Language/Libraries_and_Scripts/Imports/invalid_uri_deferred_t01: Skip # Eager loading
|
||||
|
@ -179,7 +179,7 @@ LibTest/collection/ListMixin/ListMixin_class_A01_t02: Pass, Timeout
|
|||
LibTest/core/Map/Map_class_A01_t04: Pass, Timeout
|
||||
LibTest/core/Uri/encodeQueryComponent_A01_t02: Pass, Timeout
|
||||
|
||||
[ $noopt || $compiler == precompiler || $compiler == dart2appjit ]
|
||||
[ $noopt || $compiler == precompiler || $compiler == dart2app || $compiler == dart2appjit ]
|
||||
Language/Mixins/Mixin_Application/error_t01: Pass
|
||||
Language/Mixins/Mixin_Application/error_t02: Pass
|
||||
Language/Mixins/declaring_constructor_t01: Pass
|
||||
|
|
|
@ -229,7 +229,7 @@ assert_test: Pass, RuntimeError
|
|||
map_insert_remove_oom_test: Skip # Heap limit too low. Increasing iteration count to make a higher limit a meaningful test makes it too slow for simarm[64] bots.
|
||||
io/web_socket_test: Pass, RuntimeError # Issue 24674
|
||||
|
||||
[ $noopt || $compiler == precompiler || $compiler == dart2appjit ]
|
||||
[ $noopt || $compiler == precompiler || $compiler == dart2app || $compiler == dart2appjit ]
|
||||
io/test_extension_test: Skip # Platform.executable
|
||||
io/test_extension_fail_test: Skip # Platform.executable
|
||||
io/platform_test: Skip # Platform.executable
|
||||
|
|
|
@ -78,11 +78,9 @@ abstract class CompilerConfiguration {
|
|||
useFastStartup: useFastStartup,
|
||||
extraDart2jsOptions:
|
||||
TestUtils.getExtraOptions(configuration, 'dart2js_options'));
|
||||
case 'dart2appjit':
|
||||
case 'dart2app':
|
||||
return new Dart2AppSnapshotCompilerConfiguration(
|
||||
isDebug: isDebug, isChecked: isChecked);
|
||||
case 'dart2appjit':
|
||||
return new Dart2AppJitSnapshotCompilerConfiguration(
|
||||
isDebug: isDebug, isChecked: isChecked, useBlobs: useBlobs);
|
||||
case 'precompiler':
|
||||
return new PrecompilerCompilerConfiguration(
|
||||
|
@ -502,8 +500,9 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration {
|
|||
}
|
||||
|
||||
class Dart2AppSnapshotCompilerConfiguration extends CompilerConfiguration {
|
||||
Dart2AppSnapshotCompilerConfiguration({bool isDebug, bool isChecked})
|
||||
: super._subclass(isDebug: isDebug, isChecked: isChecked);
|
||||
final bool useBlobs;
|
||||
Dart2AppSnapshotCompilerConfiguration({bool isDebug, bool isChecked, bool useBlobs})
|
||||
: super._subclass(isDebug: isDebug, isChecked: isChecked), this.useBlobs = useBlobs;
|
||||
|
||||
int computeTimeoutMultiplier() {
|
||||
int multiplier = 2;
|
||||
|
@ -530,10 +529,13 @@ class Dart2AppSnapshotCompilerConfiguration extends CompilerConfiguration {
|
|||
CommandBuilder commandBuilder,
|
||||
List arguments,
|
||||
Map<String, String> environmentOverrides) {
|
||||
var exec = "$buildDir/dart_bootstrap";
|
||||
var exec = "$buildDir/dart";
|
||||
var args = new List();
|
||||
args.add("--snapshot=$tempDir/out.jitsnapshot");
|
||||
args.add("--snapshot-kind=app-after-run");
|
||||
args.add("--snapshot-kind=app-jit");
|
||||
if (useBlobs) {
|
||||
args.add("--use-blobs");
|
||||
}
|
||||
args.addAll(arguments);
|
||||
|
||||
return commandBuilder.getCompilationCommand(
|
||||
|
@ -579,37 +581,6 @@ class Dart2AppSnapshotCompilerConfiguration extends CompilerConfiguration {
|
|||
}
|
||||
}
|
||||
|
||||
class Dart2AppJitSnapshotCompilerConfiguration extends Dart2AppSnapshotCompilerConfiguration {
|
||||
final bool useBlobs;
|
||||
Dart2AppJitSnapshotCompilerConfiguration({bool isDebug, bool isChecked, bool useBlobs})
|
||||
: super(isDebug: isDebug, isChecked: isChecked), this.useBlobs = useBlobs;
|
||||
|
||||
CompilationCommand computeCompilationCommand(
|
||||
String tempDir,
|
||||
String buildDir,
|
||||
CommandBuilder commandBuilder,
|
||||
List arguments,
|
||||
Map<String, String> environmentOverrides) {
|
||||
var exec = "$buildDir/dart";
|
||||
var args = new List();
|
||||
args.add("--snapshot=$tempDir/out.jitsnapshot");
|
||||
args.add("--snapshot-kind=app-jit-after-run");
|
||||
if (useBlobs) {
|
||||
args.add("--use-blobs");
|
||||
}
|
||||
args.addAll(arguments);
|
||||
|
||||
return commandBuilder.getCompilationCommand(
|
||||
'dart2snapshot',
|
||||
tempDir,
|
||||
!useSdk,
|
||||
bootstrapDependencies(buildDir),
|
||||
exec,
|
||||
args,
|
||||
environmentOverrides);
|
||||
}
|
||||
}
|
||||
|
||||
class AnalyzerCompilerConfiguration extends CompilerConfiguration {
|
||||
AnalyzerCompilerConfiguration(
|
||||
{bool isDebug, bool isChecked, bool isStrong, bool isHostChecked, bool
|
||||
|
|
|
@ -73,8 +73,9 @@ class TestOptionsParser {
|
|||
dart2analyzer: Perform static analysis on Dart code by running the analyzer
|
||||
(only valid with the following runtimes: none)
|
||||
|
||||
dart2app: Compile the Dart code into an app snapshot before running the test
|
||||
(only valid with the following runtimes: dart_app)''',
|
||||
dart2app:
|
||||
dart2appjit: Compile the Dart code into an app snapshot before running test
|
||||
(only valid with dart_app runtime)''',
|
||||
['-c', '--compiler'],
|
||||
['none', 'precompiler', 'dart2js', 'dart2analyzer', 'dart2app', 'dart2appjit'],
|
||||
'none'),
|
||||
|
@ -670,8 +671,6 @@ Note: currently only implemented for dart2js.''',
|
|||
validRuntimes = const ['none'];
|
||||
break;
|
||||
case 'dart2app':
|
||||
validRuntimes = const ['dart_app'];
|
||||
break;
|
||||
case 'dart2appjit':
|
||||
validRuntimes = const ['dart_app'];
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue