Support for saving Dart compilation trace on device. (flutter/engine#5443)
Support for saving Dart compilation trace on device.
This commit is contained in:
committed by
GitHub
parent
f2a864c5e4
commit
633a89dbb3
@@ -47,6 +47,7 @@ namespace blink {
|
||||
|
||||
#define BUILTIN_NATIVE_LIST(V) \
|
||||
V(Logger_PrintString, 1) \
|
||||
V(SaveCompilationTrace, 0) \
|
||||
V(ScheduleMicrotask, 1)
|
||||
|
||||
BUILTIN_NATIVE_LIST(DECLARE_FUNCTION);
|
||||
@@ -199,6 +200,24 @@ void Logger_PrintString(Dart_NativeArguments args) {
|
||||
}
|
||||
}
|
||||
|
||||
void SaveCompilationTrace(Dart_NativeArguments args) {
|
||||
uint8_t* buffer = nullptr;
|
||||
intptr_t length = 0;
|
||||
Dart_Handle result = Dart_SaveCompilationTrace(&buffer, &length);
|
||||
if (Dart_IsError(result)) {
|
||||
Dart_SetReturnValue(args, result);
|
||||
return;
|
||||
}
|
||||
|
||||
result = Dart_NewExternalTypedData(Dart_TypedData_kUint8, buffer, length);
|
||||
if (Dart_IsError(result)) {
|
||||
Dart_SetReturnValue(args, result);
|
||||
return;
|
||||
}
|
||||
|
||||
Dart_SetReturnValue(args, result);
|
||||
}
|
||||
|
||||
void ScheduleMicrotask(Dart_NativeArguments args) {
|
||||
Dart_Handle closure = Dart_GetNativeArgument(args, 0);
|
||||
UIDartState::Current()->ScheduleMicrotask(closure);
|
||||
|
||||
@@ -35,6 +35,17 @@ void _setupHooks() {
|
||||
}());
|
||||
}
|
||||
|
||||
void saveCompilationTrace(String filePath) {
|
||||
final result = _saveCompilationTrace();
|
||||
if (result is Error)
|
||||
throw result;
|
||||
|
||||
final file = new File(filePath);
|
||||
file.writeAsBytesSync(result);
|
||||
}
|
||||
|
||||
dynamic _saveCompilationTrace() native 'SaveCompilationTrace';
|
||||
|
||||
void _scheduleMicrotask(void callback()) native 'ScheduleMicrotask';
|
||||
|
||||
// Required for gen_snapshot to work correctly.
|
||||
|
||||
@@ -16,6 +16,7 @@ import 'dart:async';
|
||||
import 'dart:collection' as collection;
|
||||
import 'dart:convert';
|
||||
import 'dart:developer' as developer;
|
||||
import 'dart:io';
|
||||
import 'dart:math' as math;
|
||||
import 'dart:nativewrappers';
|
||||
import 'dart:typed_data';
|
||||
|
||||
Reference in New Issue
Block a user