diff --git a/build/toolchain/mac/BUILD.gn b/build/toolchain/mac/BUILD.gn index 9138af109b8..dff4b054e85 100644 --- a/build/toolchain/mac/BUILD.gn +++ b/build/toolchain/mac/BUILD.gn @@ -66,7 +66,7 @@ template("mac_toolchain") { sysroot_flags = "-isysroot $sysroot $version_flags" } - strip = !is_debug + strip = !is_debug && !use_ios_simulator toolchain_flags = "" if (invoker.toolchain_cpu == "i386") { diff --git a/sky/build/PackagerInvoke b/sky/build/PackagerInvoke index d37237b6a40..947730ac037 100755 --- a/sky/build/PackagerInvoke +++ b/sky/build/PackagerInvoke @@ -50,6 +50,14 @@ PackageProject() { # Remove old build artifacts RunCommand rm -f ${derived_dir}/app.flx + local src_dir=${SOURCE_ROOT}/FlutterResources + AssertExists $src_dir + + local precompilation_flag="" + if [ $CURRENT_ARCH != "x86_64" ]; then + precompilation_flag="--precompiled" + fi + # Generate the new FLX file. The pub command must be run from the directory # containing the pubspec RunCommand pushd ${project_path} @@ -59,7 +67,8 @@ PackageProject() { --main ${dart_main} \ --output-file ${derived_dir}/app.flx \ --package-root ${package_root} \ - --precompiled + --compiler ${src_dir}/ScriptSnapshotter \ + ${precompilation_flag} \ if [[ $? -ne 0 ]]; then EchoError "Failed to package $1 ..." diff --git a/sky/build/SnapshotterInvoke b/sky/build/SnapshotterInvoke index caa3b9e6e00..e429985227c 100755 --- a/sky/build/SnapshotterInvoke +++ b/sky/build/SnapshotterInvoke @@ -59,6 +59,13 @@ GenerateBinaryInclude() { } SnapshotProject() { + if [ $CURRENT_ARCH == "x86_64" ]; then + echo "Script snapshots are used on the simulator as the fully JIT enabled" + echo "Dart VM is available. There is no need to incur the cost of" + echo "precompilation. The packager has already done the heavy lifting." + return 0 + fi + # Check that the caller has provided a project path if [[ -z "$1" ]]; then EchoError "The path to the dart project must be specified" diff --git a/sky/build/sdk_xcode_harness/FlutterApplication.xcodeproj/project.pbxproj b/sky/build/sdk_xcode_harness/FlutterApplication.xcodeproj/project.pbxproj index 55d0d78b28d..4151190fc1f 100644 --- a/sky/build/sdk_xcode_harness/FlutterApplication.xcodeproj/project.pbxproj +++ b/sky/build/sdk_xcode_harness/FlutterApplication.xcodeproj/project.pbxproj @@ -13,10 +13,11 @@ 9E07CFB51BE82D2600BCD8DE /* FlutterApplication.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E07CF861BE7F4D200BCD8DE /* FlutterApplication.framework */; }; 9E07CFB61BE82D2600BCD8DE /* FlutterApplication.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9E07CF861BE7F4D200BCD8DE /* FlutterApplication.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 9E07CFBA1BE82DFF00BCD8DE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E07CF9D1BE8280A00BCD8DE /* main.m */; }; - 9E07CFE81BEAA35200BCD8DE /* InstructionsSnapshot.S in Sources */ = {isa = PBXBuildFile; fileRef = 9E07CFE51BEAA35200BCD8DE /* InstructionsSnapshot.S */; }; - 9E07CFE91BEAA35200BCD8DE /* kDartIsolateSnapshotBuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 9E07CFE61BEAA35200BCD8DE /* kDartIsolateSnapshotBuffer.c */; }; - 9E07CFEA1BEAA35200BCD8DE /* kDartVmIsolateSnapshotBuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 9E07CFE71BEAA35200BCD8DE /* kDartVmIsolateSnapshotBuffer.c */; }; 9E07CFF41BEAB58200BCD8DE /* app.flx in Resources */ = {isa = PBXBuildFile; fileRef = 9E07CFF31BEAB58200BCD8DE /* app.flx */; }; + 9E0FB06C1C1A3F5600DDAEFA /* FlutterApplication.c in Sources */ = {isa = PBXBuildFile; fileRef = 9E0FB0681C1A3F5600DDAEFA /* FlutterApplication.c */; }; + 9E0FB06D1C1A3F5600DDAEFA /* InstructionsSnapshotSource.S in Sources */ = {isa = PBXBuildFile; fileRef = 9E0FB0691C1A3F5600DDAEFA /* InstructionsSnapshotSource.S */; }; + 9E0FB06E1C1A3F5600DDAEFA /* kDartIsolateSnapshotBufferSource.c in Sources */ = {isa = PBXBuildFile; fileRef = 9E0FB06A1C1A3F5600DDAEFA /* kDartIsolateSnapshotBufferSource.c */; }; + 9E0FB06F1C1A3F5600DDAEFA /* kDartVmIsolateSnapshotBufferSource.c in Sources */ = {isa = PBXBuildFile; fileRef = 9E0FB06B1C1A3F5600DDAEFA /* kDartVmIsolateSnapshotBufferSource.c */; }; 9E29675A1C03C1D200546454 /* FlutterRunner in Resources */ = {isa = PBXBuildFile; fileRef = 9E2967581C03C18700546454 /* FlutterRunner */; }; 9E29675B1C03C1D200546454 /* icudtl.dat in Resources */ = {isa = PBXBuildFile; fileRef = 9E2967591C03C18700546454 /* icudtl.dat */; }; /* End PBXBuildFile section */ @@ -68,6 +69,10 @@ 9E07CFE61BEAA35200BCD8DE /* kDartIsolateSnapshotBuffer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = kDartIsolateSnapshotBuffer.c; path = Generated/kDartIsolateSnapshotBuffer.c; sourceTree = ""; }; 9E07CFE71BEAA35200BCD8DE /* kDartVmIsolateSnapshotBuffer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = kDartVmIsolateSnapshotBuffer.c; path = Generated/kDartVmIsolateSnapshotBuffer.c; sourceTree = ""; }; 9E07CFF31BEAB58200BCD8DE /* app.flx */ = {isa = PBXFileReference; lastKnownFileType = file; name = app.flx; path = Generated/app.flx; sourceTree = ""; }; + 9E0FB0681C1A3F5600DDAEFA /* FlutterApplication.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = FlutterApplication.c; sourceTree = ""; }; + 9E0FB0691C1A3F5600DDAEFA /* InstructionsSnapshotSource.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = InstructionsSnapshotSource.S; sourceTree = ""; }; + 9E0FB06A1C1A3F5600DDAEFA /* kDartIsolateSnapshotBufferSource.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = kDartIsolateSnapshotBufferSource.c; sourceTree = ""; }; + 9E0FB06B1C1A3F5600DDAEFA /* kDartVmIsolateSnapshotBufferSource.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = kDartVmIsolateSnapshotBufferSource.c; sourceTree = ""; }; 9E2967531C03C17300546454 /* EmbedderEntryPoints */ = {isa = PBXFileReference; lastKnownFileType = text; name = EmbedderEntryPoints; path = FlutterResources/EmbedderEntryPoints; sourceTree = SOURCE_ROOT; }; 9E2967541C03C17300546454 /* PackagerInvoke */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; name = PackagerInvoke; path = FlutterResources/PackagerInvoke; sourceTree = SOURCE_ROOT; }; 9E2967551C03C17300546454 /* Runner.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Runner.xcconfig; path = FlutterResources/Runner.xcconfig; sourceTree = SOURCE_ROOT; }; @@ -120,6 +125,10 @@ children = ( 9E07CFD61BE997D800BCD8DE /* Generated */, 9E07CF891BE7F4D200BCD8DE /* FlutterApplication.h */, + 9E0FB0681C1A3F5600DDAEFA /* FlutterApplication.c */, + 9E0FB0691C1A3F5600DDAEFA /* InstructionsSnapshotSource.S */, + 9E0FB06A1C1A3F5600DDAEFA /* kDartIsolateSnapshotBufferSource.c */, + 9E0FB06B1C1A3F5600DDAEFA /* kDartVmIsolateSnapshotBufferSource.c */, 9E07CF8B1BE7F4D200BCD8DE /* Info.plist */, ); path = FlutterApplication; @@ -189,7 +198,7 @@ buildConfigurationList = 9E07CF8E1BE7F4D200BCD8DE /* Build configuration list for PBXNativeTarget "FlutterApplication" */; buildPhases = ( 9EBB2F351BF675C200177634 /* Ensure `pub get` */, - 9E07CFF21BEAB2E800BCD8DE /* Run FLX Packager */, + 9E07CFF21BEAB2E800BCD8DE /* Run FLX Packager + Optional Script Snapshotter */, 9E07CFCD1BE98FCD00BCD8DE /* Generate Precompiled Snapshot */, 9E07CF811BE7F4D200BCD8DE /* Sources */, 9E07CF821BE7F4D200BCD8DE /* Frameworks */, @@ -304,7 +313,7 @@ shellScript = "${SOURCE_ROOT}/FlutterResources/SnapshotterInvoke ${FLUTTER_APPLICATION_PATH}"; showEnvVarsInLog = 0; }; - 9E07CFF21BEAB2E800BCD8DE /* Run FLX Packager */ = { + 9E07CFF21BEAB2E800BCD8DE /* Run FLX Packager + Optional Script Snapshotter */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -313,7 +322,7 @@ "$(FLUTTER_APPLICATION_PATH)/flutter.yaml", "$(SRCROOT)/FlutterResources/PackagerInvoke", ); - name = "Run FLX Packager"; + name = "Run FLX Packager + Optional Script Snapshotter"; outputPaths = ( "${SRCROOT}/FlutterApplication/Generated/app.flx", ); @@ -344,9 +353,10 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 9E07CFEA1BEAA35200BCD8DE /* kDartVmIsolateSnapshotBuffer.c in Sources */, - 9E07CFE91BEAA35200BCD8DE /* kDartIsolateSnapshotBuffer.c in Sources */, - 9E07CFE81BEAA35200BCD8DE /* InstructionsSnapshot.S in Sources */, + 9E0FB06D1C1A3F5600DDAEFA /* InstructionsSnapshotSource.S in Sources */, + 9E0FB06E1C1A3F5600DDAEFA /* kDartIsolateSnapshotBufferSource.c in Sources */, + 9E0FB06F1C1A3F5600DDAEFA /* kDartVmIsolateSnapshotBufferSource.c in Sources */, + 9E0FB06C1C1A3F5600DDAEFA /* FlutterApplication.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -421,6 +431,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; VALID_ARCHS = "$(FLUTTER_TARGET_ARCH)"; @@ -464,6 +475,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; + ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; diff --git a/sky/build/sdk_xcode_harness/FlutterApplication/FlutterApplication.c b/sky/build/sdk_xcode_harness/FlutterApplication/FlutterApplication.c new file mode 100644 index 00000000000..86d6254e78c --- /dev/null +++ b/sky/build/sdk_xcode_harness/FlutterApplication/FlutterApplication.c @@ -0,0 +1,5 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const char IntentionallyEmpty = '\0'; diff --git a/sky/build/sdk_xcode_harness/FlutterApplication/InstructionsSnapshotSource.S b/sky/build/sdk_xcode_harness/FlutterApplication/InstructionsSnapshotSource.S new file mode 100644 index 00000000000..3490b95eb17 --- /dev/null +++ b/sky/build/sdk_xcode_harness/FlutterApplication/InstructionsSnapshotSource.S @@ -0,0 +1,4 @@ + +#if __arm__ || __aarch64__ +#include "Generated/InstructionsSnapshot.S" +#endif diff --git a/sky/build/sdk_xcode_harness/FlutterApplication/kDartIsolateSnapshotBufferSource.c b/sky/build/sdk_xcode_harness/FlutterApplication/kDartIsolateSnapshotBufferSource.c new file mode 100644 index 00000000000..168cae5b203 --- /dev/null +++ b/sky/build/sdk_xcode_harness/FlutterApplication/kDartIsolateSnapshotBufferSource.c @@ -0,0 +1,7 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#if __arm__ || __aarch64__ +#include "Generated/kDartIsolateSnapshotBuffer.c" +#endif diff --git a/sky/build/sdk_xcode_harness/FlutterApplication/kDartVmIsolateSnapshotBufferSource.c b/sky/build/sdk_xcode_harness/FlutterApplication/kDartVmIsolateSnapshotBufferSource.c new file mode 100644 index 00000000000..e2c75c5cc0e --- /dev/null +++ b/sky/build/sdk_xcode_harness/FlutterApplication/kDartVmIsolateSnapshotBufferSource.c @@ -0,0 +1,7 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#if __arm__ || __aarch64__ +#include "Generated/kDartVmIsolateSnapshotBuffer.c" +#endif diff --git a/sky/build/sky_precompilation_sdk.gni b/sky/build/sky_precompilation_sdk.gni index 1cf15545104..1a3c5525b85 100644 --- a/sky/build/sky_precompilation_sdk.gni +++ b/sky/build/sky_precompilation_sdk.gni @@ -26,6 +26,20 @@ template("sky_precompilation_sdk") { deps = [ snapshotter_target ] } + script_snapshotter_copy_gen_target_name = + target_name + "_copy_script_snapshotter" + copy(script_snapshotter_copy_gen_target_name) { + script_snapshotter_target = "//sky/tools/sky_snapshot($dart_host_toolchain)" + script_snapshotter_directory = + get_label_info(script_snapshotter_target, "root_out_dir") + script_snapshotter_name = get_label_info(script_snapshotter_target, "name") + + sources = [ "$script_snapshotter_directory/$script_snapshotter_name" ] + outputs = [ "$sdk_dir/$resources_dir/ScriptSnapshotter" ] + + deps = [ script_snapshotter_target ] + } + copy("embedder_entry_points") { sources = [ "//sky/engine/bindings/dart_vm_entry_points.txt" ] outputs = [ "$sdk_dir/$resources_dir/EmbedderEntryPoints" ] @@ -85,6 +99,7 @@ template("sky_precompilation_sdk") { group(target_name) { deps = [ ":$snapshotter_copy_gen_target_name", + ":$script_snapshotter_copy_gen_target_name", ":embedder_entry_points", ":$copy_runner_gen_target_name", ":$copy_data_gen_target_name", diff --git a/sky/engine/bindings/BUILD.gn b/sky/engine/bindings/BUILD.gn index 70de601eda7..99b51958d05 100644 --- a/sky/engine/bindings/BUILD.gn +++ b/sky/engine/bindings/BUILD.gn @@ -43,10 +43,11 @@ source_set("bindings") { ":generated_bindings", ] - # On iOS, precompiled snapshots contain the instruction buffer. Generation - # of the same requires all application specific script code to be specified - # up front. In such cases, there can be no updater or generic snapshotter - if (!is_ios) { + # On iOS (device), precompiled snapshots contain the instruction buffer. + # Generation of the same requires all application specific script code to be + # specified up front. In such cases, there can be no updater or generic + # snapshotter. + if (!is_ios || use_ios_simulator) { deps += [ ":snapshot_cc", ] diff --git a/sky/shell/platform/ios/sky_surface.mm b/sky/shell/platform/ios/sky_surface.mm index 6d64e9cf5f9..7845ed97040 100644 --- a/sky/shell/platform/ios/sky_surface.mm +++ b/sky/shell/platform/ios/sky_surface.mm @@ -199,7 +199,12 @@ static std::string TracesBasePath() { _sky_engine->SetServices(services.Pass()); mojo::String bundle_path([self flxBundlePath]); + +#if TARGET_IPHONE_SIMULATOR + _sky_engine->RunFromBundle(bundle_path); +#else _sky_engine->RunFromPrecompiledSnapshot(bundle_path); +#endif } - (void)notifySurfaceDestruction {