From e859296b71def257f021ff8bd225e82209558cea Mon Sep 17 00:00:00 2001 From: Stanislav Baranov Date: Thu, 20 Dec 2018 11:48:59 -0800 Subject: [PATCH] Document native functions for compilation trace (#7256) --- lib/ui/natives.dart | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/lib/ui/natives.dart b/lib/ui/natives.dart index 4375c3eea3e..7f349c6a8ed 100644 --- a/lib/ui/natives.dart +++ b/lib/ui/natives.dart @@ -36,22 +36,33 @@ void _setupHooks() { }()); } -void saveCompilationTrace(String filePath) { - final dynamic result = _saveCompilationTrace(); - if (result is Error) - throw result; - - final File file = new File(filePath); - file.writeAsBytesSync(result); -} - -List dumpCompilationTrace() { +/// Returns runtime Dart compilation trace as a UTF-8 encoded memory buffer. +/// +/// The buffer contains a list of symbols compiled by the Dart JIT at runtime up to the point +/// when this function was called. This list can be saved to a text file and passed to tools +/// such as `flutter build` or Dart `gen_snapshot` in order to precompile this code offline. +/// +/// The list has one symbol per line of the following format: `,,\n`. +/// Here are some examples: +/// +/// ``` +/// dart:core,Duration,get:inMilliseconds +/// package:flutter/src/widgets/binding.dart,::,runApp +/// file:///.../my_app.dart,::,main +/// ``` +/// +/// This function is only effective in debug and dynamic modes, and will throw in AOT mode. +List saveCompilationTrace() { final dynamic result = _saveCompilationTrace(); if (result is Error) throw result; return result; } +// TODO(sbaranov): This function will go away in subsequent PR, once the framework has caught up. +@Deprecated('Use saveCompilationTrace() instead.') +List dumpCompilationTrace() => saveCompilationTrace(); + dynamic _saveCompilationTrace() native 'SaveCompilationTrace'; void _scheduleMicrotask(void callback()) native 'ScheduleMicrotask';