mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 15:01:30 +00:00
Don't include usage counters, etc in snapshots with code. If we already have code, eagerly recompiling in unlikely to have new type feedback.
Print snapshot sizes when generating an AOT snapshot from gen_snapshot (e.g., Flutter). Remove some unnecessary symbols. Use named constants for exit codes. Use Log::PrintErr instead of fprintf(stderr) so we see error messages in adb logcat. R=asiva@google.com Review URL: https://codereview.chromium.org/2517683002 .
This commit is contained in:
parent
f62713e97c
commit
5ee71cae9d
7 changed files with 27 additions and 34 deletions
|
@ -995,7 +995,7 @@ static Dart_QualifiedFunctionName* ParseEntryPointsManifestIfPresent() {
|
|||
if ((entries == NULL) && IsSnapshottingForPrecompilation()) {
|
||||
Log::PrintErr(
|
||||
"Could not find native embedder entry points during precompilation\n");
|
||||
exit(255);
|
||||
exit(kErrorExitCode);
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
@ -1081,7 +1081,7 @@ static void SetupForUriResolution() {
|
|||
Log::PrintErr("%s", Dart_GetError(result));
|
||||
Dart_ExitScope();
|
||||
Dart_ShutdownIsolate();
|
||||
exit(255);
|
||||
exit(kErrorExitCode);
|
||||
}
|
||||
// This is a generic dart snapshot which needs builtin library setup.
|
||||
Dart_Handle library =
|
||||
|
@ -1101,7 +1101,7 @@ static void SetupForGenericSnapshotCreation() {
|
|||
Log::PrintErr("Errors encountered while loading: %s\n", err_msg);
|
||||
Dart_ExitScope();
|
||||
Dart_ShutdownIsolate();
|
||||
exit(255);
|
||||
exit(kErrorExitCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1166,7 +1166,7 @@ int main(int argc, char** argv) {
|
|||
// Parse command line arguments.
|
||||
if (ParseArguments(argc, argv, &vm_options, &app_script_name) < 0) {
|
||||
PrintUsage();
|
||||
return 255;
|
||||
return kErrorExitCode;
|
||||
}
|
||||
|
||||
Thread::InitOnce();
|
||||
|
@ -1183,6 +1183,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
if (IsSnapshottingForPrecompilation()) {
|
||||
vm_options.AddArgument("--precompilation");
|
||||
vm_options.AddArgument("--print_snapshot_sizes");
|
||||
#if TARGET_ARCH_ARM
|
||||
// This is for the iPod Touch 5th Generation (and maybe other older devices)
|
||||
vm_options.AddArgument("--no-use_integer_division");
|
||||
|
@ -1213,7 +1214,7 @@ int main(int argc, char** argv) {
|
|||
if (error != NULL) {
|
||||
Log::PrintErr("VM initialization failed: %s\n", error);
|
||||
free(error);
|
||||
return 255;
|
||||
return kErrorExitCode;
|
||||
}
|
||||
|
||||
IsolateData* isolate_data = new IsolateData(NULL, commandline_package_root,
|
||||
|
@ -1223,7 +1224,7 @@ int main(int argc, char** argv) {
|
|||
if (isolate == NULL) {
|
||||
Log::PrintErr("Error: %s", error);
|
||||
free(error);
|
||||
exit(255);
|
||||
exit(kErrorExitCode);
|
||||
}
|
||||
|
||||
Dart_Handle result;
|
||||
|
@ -1276,9 +1277,9 @@ int main(int argc, char** argv) {
|
|||
NULL, isolate_data, &error)
|
||||
: Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error);
|
||||
if (isolate == NULL) {
|
||||
fprintf(stderr, "%s", error);
|
||||
Log::PrintErr("%s", error);
|
||||
free(error);
|
||||
exit(255);
|
||||
exit(kErrorExitCode);
|
||||
}
|
||||
Dart_EnterScope();
|
||||
result = Dart_SetEnvironmentCallback(EnvironmentCallback);
|
||||
|
|
|
@ -21,6 +21,7 @@ void Log::VPrint(const char* format, va_list args) {
|
|||
// (critical ones or not) if we print them to stdout/stderr.
|
||||
// We also log using android's logging system.
|
||||
vprintf(format, args);
|
||||
fflush(stdout);
|
||||
__android_log_vprint(ANDROID_LOG_INFO, "Dart", format, args);
|
||||
}
|
||||
|
||||
|
@ -29,6 +30,7 @@ void Log::VPrintErr(const char* format, va_list args) {
|
|||
// (critical ones or not) if we print them to stdout/stderr.
|
||||
// We also log using android's logging system.
|
||||
vfprintf(stderr, format, args);
|
||||
fflush(stderr);
|
||||
__android_log_vprint(ANDROID_LOG_ERROR, "Dart", format, args);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ void Log::VPrint(const char* format, va_list args) {
|
|||
|
||||
void Log::VPrintErr(const char* format, va_list args) {
|
||||
vfprintf(stderr, format, args);
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
} // namespace bin
|
||||
|
|
|
@ -133,7 +133,6 @@ static void ErrorExit(int exit_code, const char* format, ...) {
|
|||
va_start(arguments, format);
|
||||
Log::VPrintErr(format, arguments);
|
||||
va_end(arguments);
|
||||
fflush(stderr);
|
||||
|
||||
Dart_ExitScope();
|
||||
Dart_ShutdownIsolate();
|
||||
|
@ -1598,9 +1597,8 @@ bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) {
|
|||
// Load the embedder's portion of the VM service's Dart code so it will
|
||||
// be included in the app snapshot.
|
||||
if (!VmService::LoadForGenPrecompiled()) {
|
||||
fprintf(stderr, "VM service loading failed: %s\n",
|
||||
VmService::GetErrorMessage());
|
||||
fflush(stderr);
|
||||
Log::PrintErr("VM service loading failed: %s\n",
|
||||
VmService::GetErrorMessage());
|
||||
exit(kErrorExitCode);
|
||||
}
|
||||
}
|
||||
|
@ -1848,8 +1846,7 @@ void main(int argc, char** argv) {
|
|||
|
||||
if (!DartUtils::SetOriginalWorkingDirectory()) {
|
||||
OSError err;
|
||||
fprintf(stderr, "Error determining current directory: %s\n", err.message());
|
||||
fflush(stderr);
|
||||
Log::PrintErr("Error determining current directory: %s\n", err.message());
|
||||
Platform::Exit(kErrorExitCode);
|
||||
}
|
||||
|
||||
|
@ -1910,8 +1907,7 @@ void main(int argc, char** argv) {
|
|||
char* error = Dart_Initialize(&init_params);
|
||||
if (error != NULL) {
|
||||
EventHandler::Stop();
|
||||
fprintf(stderr, "VM initialization failed: %s\n", error);
|
||||
fflush(stderr);
|
||||
Log::PrintErr("VM initialization failed: %s\n", error);
|
||||
free(error);
|
||||
Platform::Exit(kErrorExitCode);
|
||||
}
|
||||
|
|
|
@ -563,7 +563,7 @@ class FunctionSerializationCluster : public SerializationCluster {
|
|||
s->Write<uint32_t>(func->ptr()->kind_tag_);
|
||||
if (kind == Snapshot::kAppNoJIT) {
|
||||
// Omit fields used to support de/reoptimization.
|
||||
} else {
|
||||
} else if (!Snapshot::IncludesCode(kind)) {
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
bool is_optimized = Code::IsOptimized(func->ptr()->code_);
|
||||
if (is_optimized) {
|
||||
|
@ -571,9 +571,6 @@ class FunctionSerializationCluster : public SerializationCluster {
|
|||
} else {
|
||||
s->Write<int32_t>(0);
|
||||
}
|
||||
s->Write<int8_t>(func->ptr()->deoptimization_counter_);
|
||||
s->Write<uint16_t>(func->ptr()->optimized_instruction_count_);
|
||||
s->Write<uint16_t>(func->ptr()->optimized_call_site_count_);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -643,10 +640,14 @@ class FunctionDeserializationCluster : public DeserializationCluster {
|
|||
// Omit fields used to support de/reoptimization.
|
||||
} else {
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
func->ptr()->usage_counter_ = d->Read<int32_t>();
|
||||
func->ptr()->deoptimization_counter_ = d->Read<int8_t>();
|
||||
func->ptr()->optimized_instruction_count_ = d->Read<uint16_t>();
|
||||
func->ptr()->optimized_call_site_count_ = d->Read<uint16_t>();
|
||||
if (Snapshot::IncludesCode(kind)) {
|
||||
func->ptr()->usage_counter_ = 0;
|
||||
} else {
|
||||
func->ptr()->usage_counter_ = d->Read<int32_t>();
|
||||
}
|
||||
func->ptr()->deoptimization_counter_ = 0;
|
||||
func->ptr()->optimized_instruction_count_ = 0;
|
||||
func->ptr()->optimized_call_site_count_ = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14305,9 +14305,7 @@ const char* Code::Name() const {
|
|||
Zone* zone = thread->zone();
|
||||
const char* name = StubCode::NameOfStub(UncheckedEntryPoint());
|
||||
ASSERT(name != NULL);
|
||||
char* stub_name =
|
||||
OS::SCreate(zone, "%s%s", Symbols::StubPrefix().ToCString(), name);
|
||||
return stub_name;
|
||||
return OS::SCreate(zone, "[Stub] %s", name);
|
||||
} else if (obj.IsClass()) {
|
||||
// Allocation stub.
|
||||
Thread* thread = Thread::Current();
|
||||
|
@ -14315,10 +14313,7 @@ const char* Code::Name() const {
|
|||
const Class& cls = Class::Cast(obj);
|
||||
String& cls_name = String::Handle(zone, cls.ScrubbedName());
|
||||
ASSERT(!cls_name.IsNull());
|
||||
char* stub_name =
|
||||
OS::SCreate(zone, "%s%s", Symbols::AllocationStubFor().ToCString(),
|
||||
cls_name.ToCString());
|
||||
return stub_name;
|
||||
return OS::SCreate(zone, "[Stub] Allocate %s", cls_name.ToCString());
|
||||
} else {
|
||||
ASSERT(obj.IsFunction());
|
||||
// Dart function.
|
||||
|
|
|
@ -367,11 +367,9 @@ class ObjectPointerVisitor;
|
|||
V(hashCode, "get:hashCode") \
|
||||
V(OptimizedOut, "<optimized out>") \
|
||||
V(NotInitialized, "<not initialized>") \
|
||||
V(AllocationStubFor, "[Stub] Allocate ") \
|
||||
V(TempParam, ":temp_param") \
|
||||
V(_UserTag, "_UserTag") \
|
||||
V(Default, "Default") \
|
||||
V(StubPrefix, "[Stub] ") \
|
||||
V(ClassID, "ClassID") \
|
||||
V(DartIsVM, "dart.isVM") \
|
||||
V(stack, ":stack") \
|
||||
|
|
Loading…
Reference in a new issue