From: Roland Levillain Date: Tue, 23 Feb 2016 18:08:53 +0000 (+0000) Subject: Please Clang with respect to stack frame limits in dex2oat. X-Git-Tag: android-x86-7.1-r1~340^2~4^2^2~42^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5c7e2606d1246460a8a4b227d894110e89d0a842;p=android-x86%2Fart.git Please Clang with respect to stack frame limits in dex2oat. This change enables Clang to compile dex2oat on MIPS64 without complaining about stack frames larger than what `-Wframe-larger-than` allows. Bug: 27310199 Change-Id: I441a4be499959a089d3c2eae1135eb0273c1e80b --- diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index f7efdc5ba..1459c76a7 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -2550,16 +2550,20 @@ static int dex2oat(int argc, char** argv) { TimingLogger timings("compiler", false, false); - Dex2Oat dex2oat(&timings); + // Allocate `dex2oat` on the heap instead of on the stack, as Clang + // might produce a stack frame too large for this function or for + // functions inlining it (such as main), that would not fit the + // requirements of the `-Wframe-larger-than` option. + std::unique_ptr dex2oat = MakeUnique(&timings); // Parse arguments. Argument mistakes will lead to exit(EXIT_FAILURE) in UsageError. - dex2oat.ParseArgs(argc, argv); + dex2oat->ParseArgs(argc, argv); // Process profile information and assess if we need to do a profile guided compilation. // This operation involves I/O. - if (dex2oat.UseProfileGuidedCompilation()) { - if (dex2oat.LoadProfile()) { - if (!dex2oat.ShouldCompileBasedOnProfiles()) { + if (dex2oat->UseProfileGuidedCompilation()) { + if (dex2oat->LoadProfile()) { + if (!dex2oat->ShouldCompileBasedOnProfiles()) { LOG(INFO) << "Skipped compilation because of insignificant profile delta"; return EXIT_SUCCESS; } @@ -2570,7 +2574,7 @@ static int dex2oat(int argc, char** argv) { } // Check early that the result of compilation can be written - if (!dex2oat.OpenFile()) { + if (!dex2oat->OpenFile()) { return EXIT_FAILURE; } @@ -2580,25 +2584,25 @@ static int dex2oat(int argc, char** argv) { // 3) Compiling with --host // 4) Compiling on the host (not a target build) // Otherwise, print a stripped command line. - if (kIsDebugBuild || dex2oat.IsBootImage() || dex2oat.IsHost() || !kIsTargetBuild) { + if (kIsDebugBuild || dex2oat->IsBootImage() || dex2oat->IsHost() || !kIsTargetBuild) { LOG(INFO) << CommandLine(); } else { LOG(INFO) << StrippedCommandLine(); } - if (!dex2oat.Setup()) { - dex2oat.EraseOatFiles(); + if (!dex2oat->Setup()) { + dex2oat->EraseOatFiles(); return EXIT_FAILURE; } bool result; - if (dex2oat.IsImage()) { - result = CompileImage(dex2oat); + if (dex2oat->IsImage()) { + result = CompileImage(*dex2oat); } else { - result = CompileApp(dex2oat); + result = CompileApp(*dex2oat); } - dex2oat.Shutdown(); + dex2oat->Shutdown(); return result; } } // namespace art