1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2011 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker *
4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker *
8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker *
10*795d594fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker */
16*795d594fSAndroid Build Coastguard Worker
17*795d594fSAndroid Build Coastguard Worker #include "parsed_options.h"
18*795d594fSAndroid Build Coastguard Worker
19*795d594fSAndroid Build Coastguard Worker #include <memory>
20*795d594fSAndroid Build Coastguard Worker #include <sstream>
21*795d594fSAndroid Build Coastguard Worker
22*795d594fSAndroid Build Coastguard Worker #include <android-base/logging.h>
23*795d594fSAndroid Build Coastguard Worker #include <android-base/strings.h>
24*795d594fSAndroid Build Coastguard Worker
25*795d594fSAndroid Build Coastguard Worker #include "base/file_utils.h"
26*795d594fSAndroid Build Coastguard Worker #include "base/flags.h"
27*795d594fSAndroid Build Coastguard Worker #include "base/indenter.h"
28*795d594fSAndroid Build Coastguard Worker #include "base/macros.h"
29*795d594fSAndroid Build Coastguard Worker #include "base/utils.h"
30*795d594fSAndroid Build Coastguard Worker #include "debugger.h"
31*795d594fSAndroid Build Coastguard Worker #include "gc/heap.h"
32*795d594fSAndroid Build Coastguard Worker #include "jni_id_type.h"
33*795d594fSAndroid Build Coastguard Worker #include "monitor.h"
34*795d594fSAndroid Build Coastguard Worker #include "runtime.h"
35*795d594fSAndroid Build Coastguard Worker #include "ti/agent.h"
36*795d594fSAndroid Build Coastguard Worker #include "trace.h"
37*795d594fSAndroid Build Coastguard Worker
38*795d594fSAndroid Build Coastguard Worker #include "cmdline_parser.h"
39*795d594fSAndroid Build Coastguard Worker #include "runtime_options.h"
40*795d594fSAndroid Build Coastguard Worker
41*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN {
42*795d594fSAndroid Build Coastguard Worker
43*795d594fSAndroid Build Coastguard Worker using MemoryKiB = Memory<1024>;
44*795d594fSAndroid Build Coastguard Worker
ParsedOptions()45*795d594fSAndroid Build Coastguard Worker ParsedOptions::ParsedOptions()
46*795d594fSAndroid Build Coastguard Worker : hook_is_sensitive_thread_(nullptr),
47*795d594fSAndroid Build Coastguard Worker hook_vfprintf_(vfprintf),
48*795d594fSAndroid Build Coastguard Worker hook_exit_(exit),
49*795d594fSAndroid Build Coastguard Worker hook_abort_(nullptr) { // We don't call abort(3) by default; see
50*795d594fSAndroid Build Coastguard Worker // Runtime::Abort
51*795d594fSAndroid Build Coastguard Worker }
52*795d594fSAndroid Build Coastguard Worker
Parse(const RuntimeOptions & options,bool ignore_unrecognized,RuntimeArgumentMap * runtime_options)53*795d594fSAndroid Build Coastguard Worker bool ParsedOptions::Parse(const RuntimeOptions& options,
54*795d594fSAndroid Build Coastguard Worker bool ignore_unrecognized,
55*795d594fSAndroid Build Coastguard Worker RuntimeArgumentMap* runtime_options) {
56*795d594fSAndroid Build Coastguard Worker CHECK(runtime_options != nullptr);
57*795d594fSAndroid Build Coastguard Worker
58*795d594fSAndroid Build Coastguard Worker ParsedOptions parser;
59*795d594fSAndroid Build Coastguard Worker return parser.DoParse(options, ignore_unrecognized, runtime_options);
60*795d594fSAndroid Build Coastguard Worker }
61*795d594fSAndroid Build Coastguard Worker
62*795d594fSAndroid Build Coastguard Worker using RuntimeParser = CmdlineParser<RuntimeArgumentMap, RuntimeArgumentMap::Key>;
63*795d594fSAndroid Build Coastguard Worker using HiddenapiPolicyValueMap =
64*795d594fSAndroid Build Coastguard Worker std::initializer_list<std::pair<const char*, hiddenapi::EnforcementPolicy>>;
65*795d594fSAndroid Build Coastguard Worker
66*795d594fSAndroid Build Coastguard Worker // Yes, the stack frame is huge. But we get called super early on (and just once)
67*795d594fSAndroid Build Coastguard Worker // to pass the command line arguments, so we'll probably be ok.
68*795d594fSAndroid Build Coastguard Worker // Ideas to avoid suppressing this diagnostic are welcome!
69*795d594fSAndroid Build Coastguard Worker #pragma GCC diagnostic push
70*795d594fSAndroid Build Coastguard Worker #pragma GCC diagnostic ignored "-Wframe-larger-than="
71*795d594fSAndroid Build Coastguard Worker
MakeParser(bool ignore_unrecognized)72*795d594fSAndroid Build Coastguard Worker std::unique_ptr<RuntimeParser> ParsedOptions::MakeParser(bool ignore_unrecognized) {
73*795d594fSAndroid Build Coastguard Worker using M = RuntimeArgumentMap;
74*795d594fSAndroid Build Coastguard Worker
75*795d594fSAndroid Build Coastguard Worker std::unique_ptr<RuntimeParser::Builder> parser_builder =
76*795d594fSAndroid Build Coastguard Worker std::make_unique<RuntimeParser::Builder>();
77*795d594fSAndroid Build Coastguard Worker
78*795d594fSAndroid Build Coastguard Worker HiddenapiPolicyValueMap hiddenapi_policy_valuemap =
79*795d594fSAndroid Build Coastguard Worker {{"disabled", hiddenapi::EnforcementPolicy::kDisabled},
80*795d594fSAndroid Build Coastguard Worker {"just-warn", hiddenapi::EnforcementPolicy::kJustWarn},
81*795d594fSAndroid Build Coastguard Worker {"enabled", hiddenapi::EnforcementPolicy::kEnabled}};
82*795d594fSAndroid Build Coastguard Worker DCHECK_EQ(hiddenapi_policy_valuemap.size(),
83*795d594fSAndroid Build Coastguard Worker static_cast<size_t>(hiddenapi::EnforcementPolicy::kMax) + 1);
84*795d594fSAndroid Build Coastguard Worker
85*795d594fSAndroid Build Coastguard Worker // clang-format off
86*795d594fSAndroid Build Coastguard Worker parser_builder->
87*795d594fSAndroid Build Coastguard Worker SetCategory("standard")
88*795d594fSAndroid Build Coastguard Worker .Define({"-classpath _", "-cp _"})
89*795d594fSAndroid Build Coastguard Worker .WithHelp("The classpath, separated by ':'")
90*795d594fSAndroid Build Coastguard Worker .WithType<std::string>()
91*795d594fSAndroid Build Coastguard Worker .IntoKey(M::ClassPath)
92*795d594fSAndroid Build Coastguard Worker .Define("-D_")
93*795d594fSAndroid Build Coastguard Worker .WithType<std::vector<std::string>>().AppendValues()
94*795d594fSAndroid Build Coastguard Worker .IntoKey(M::PropertiesList)
95*795d594fSAndroid Build Coastguard Worker .Define("-verbose:_")
96*795d594fSAndroid Build Coastguard Worker .WithHelp("Switches for advanced logging. Multiple categories can be enabled separated by ','. Eg: -verbose:class,deopt")
97*795d594fSAndroid Build Coastguard Worker .WithType<LogVerbosity>()
98*795d594fSAndroid Build Coastguard Worker .IntoKey(M::Verbose)
99*795d594fSAndroid Build Coastguard Worker .Define({"-help", "-h"})
100*795d594fSAndroid Build Coastguard Worker .WithHelp("Print this help text.")
101*795d594fSAndroid Build Coastguard Worker .IntoKey(M::Help)
102*795d594fSAndroid Build Coastguard Worker .Define("-showversion")
103*795d594fSAndroid Build Coastguard Worker .IntoKey(M::ShowVersion)
104*795d594fSAndroid Build Coastguard Worker // TODO Re-enable -agentlib: once I have a good way to transform the values.
105*795d594fSAndroid Build Coastguard Worker // .Define("-agentlib:_")
106*795d594fSAndroid Build Coastguard Worker // .WithType<std::vector<ti::Agent>>().AppendValues()
107*795d594fSAndroid Build Coastguard Worker // .IntoKey(M::AgentLib)
108*795d594fSAndroid Build Coastguard Worker .Define("-agentpath:_")
109*795d594fSAndroid Build Coastguard Worker .WithHelp("Load native agents.")
110*795d594fSAndroid Build Coastguard Worker .WithType<std::list<ti::AgentSpec>>().AppendValues()
111*795d594fSAndroid Build Coastguard Worker .IntoKey(M::AgentPath)
112*795d594fSAndroid Build Coastguard Worker .SetCategory("extended")
113*795d594fSAndroid Build Coastguard Worker .Define("-Xbootclasspath:_")
114*795d594fSAndroid Build Coastguard Worker .WithType<ParseStringList<':'>>() // std::vector<std::string>, split by :
115*795d594fSAndroid Build Coastguard Worker .IntoKey(M::BootClassPath)
116*795d594fSAndroid Build Coastguard Worker .Define("-Xbootclasspathfds:_")
117*795d594fSAndroid Build Coastguard Worker .WithType<ParseIntList<':'>>()
118*795d594fSAndroid Build Coastguard Worker .IntoKey(M::BootClassPathFds)
119*795d594fSAndroid Build Coastguard Worker .Define("-Xbootclasspathimagefds:_")
120*795d594fSAndroid Build Coastguard Worker .WithType<ParseIntList<':'>>()
121*795d594fSAndroid Build Coastguard Worker .IntoKey(M::BootClassPathImageFds)
122*795d594fSAndroid Build Coastguard Worker .Define("-Xbootclasspathvdexfds:_")
123*795d594fSAndroid Build Coastguard Worker .WithType<ParseIntList<':'>>()
124*795d594fSAndroid Build Coastguard Worker .IntoKey(M::BootClassPathVdexFds)
125*795d594fSAndroid Build Coastguard Worker .Define("-Xbootclasspathoatfds:_")
126*795d594fSAndroid Build Coastguard Worker .WithType<ParseIntList<':'>>()
127*795d594fSAndroid Build Coastguard Worker .IntoKey(M::BootClassPathOatFds)
128*795d594fSAndroid Build Coastguard Worker .Define("-Xcheck:jni")
129*795d594fSAndroid Build Coastguard Worker .IntoKey(M::CheckJni)
130*795d594fSAndroid Build Coastguard Worker .Define("-Xms_")
131*795d594fSAndroid Build Coastguard Worker .WithType<MemoryKiB>()
132*795d594fSAndroid Build Coastguard Worker .IntoKey(M::MemoryInitialSize)
133*795d594fSAndroid Build Coastguard Worker .Define("-Xmx_")
134*795d594fSAndroid Build Coastguard Worker .WithType<MemoryKiB>()
135*795d594fSAndroid Build Coastguard Worker .IntoKey(M::MemoryMaximumSize)
136*795d594fSAndroid Build Coastguard Worker .Define("-Xss_")
137*795d594fSAndroid Build Coastguard Worker .WithType<Memory<1>>()
138*795d594fSAndroid Build Coastguard Worker .IntoKey(M::StackSize)
139*795d594fSAndroid Build Coastguard Worker .Define("-Xint")
140*795d594fSAndroid Build Coastguard Worker .WithValue(true)
141*795d594fSAndroid Build Coastguard Worker .IntoKey(M::Interpret)
142*795d594fSAndroid Build Coastguard Worker .SetCategory("Dalvik")
143*795d594fSAndroid Build Coastguard Worker .Define("-Xzygote")
144*795d594fSAndroid Build Coastguard Worker .WithHelp("Start as zygote")
145*795d594fSAndroid Build Coastguard Worker .IntoKey(M::Zygote)
146*795d594fSAndroid Build Coastguard Worker .Define("-Xjnitrace:_")
147*795d594fSAndroid Build Coastguard Worker .WithType<std::string>()
148*795d594fSAndroid Build Coastguard Worker .IntoKey(M::JniTrace)
149*795d594fSAndroid Build Coastguard Worker .Define("-Xgc:_")
150*795d594fSAndroid Build Coastguard Worker .WithType<XGcOption>()
151*795d594fSAndroid Build Coastguard Worker .IntoKey(M::GcOption)
152*795d594fSAndroid Build Coastguard Worker .Define("-XX:HeapGrowthLimit=_")
153*795d594fSAndroid Build Coastguard Worker .WithType<MemoryKiB>()
154*795d594fSAndroid Build Coastguard Worker .IntoKey(M::HeapGrowthLimit)
155*795d594fSAndroid Build Coastguard Worker .Define("-XX:HeapMinFree=_")
156*795d594fSAndroid Build Coastguard Worker .WithType<MemoryKiB>()
157*795d594fSAndroid Build Coastguard Worker .IntoKey(M::HeapMinFree)
158*795d594fSAndroid Build Coastguard Worker .Define("-XX:HeapMaxFree=_")
159*795d594fSAndroid Build Coastguard Worker .WithType<MemoryKiB>()
160*795d594fSAndroid Build Coastguard Worker .IntoKey(M::HeapMaxFree)
161*795d594fSAndroid Build Coastguard Worker .Define("-XX:NonMovingSpaceCapacity=_")
162*795d594fSAndroid Build Coastguard Worker .WithType<MemoryKiB>()
163*795d594fSAndroid Build Coastguard Worker .IntoKey(M::NonMovingSpaceCapacity)
164*795d594fSAndroid Build Coastguard Worker .Define("-XX:HeapTargetUtilization=_")
165*795d594fSAndroid Build Coastguard Worker .WithType<double>().WithRange(0.1, 0.9)
166*795d594fSAndroid Build Coastguard Worker .IntoKey(M::HeapTargetUtilization)
167*795d594fSAndroid Build Coastguard Worker .Define("-XX:ForegroundHeapGrowthMultiplier=_")
168*795d594fSAndroid Build Coastguard Worker .WithType<double>().WithRange(0.1, 5.0)
169*795d594fSAndroid Build Coastguard Worker .IntoKey(M::ForegroundHeapGrowthMultiplier)
170*795d594fSAndroid Build Coastguard Worker .Define("-XX:LowMemoryMode")
171*795d594fSAndroid Build Coastguard Worker .IntoKey(M::LowMemoryMode)
172*795d594fSAndroid Build Coastguard Worker .Define("-Xjitthreshold:_")
173*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
174*795d594fSAndroid Build Coastguard Worker .IntoKey(M::JITOptimizeThreshold)
175*795d594fSAndroid Build Coastguard Worker .SetCategory("ART")
176*795d594fSAndroid Build Coastguard Worker .Define("-Ximage:_")
177*795d594fSAndroid Build Coastguard Worker .WithType<ParseStringList<':'>>()
178*795d594fSAndroid Build Coastguard Worker .IntoKey(M::Image)
179*795d594fSAndroid Build Coastguard Worker .Define("-Xforcejitzygote")
180*795d594fSAndroid Build Coastguard Worker .IntoKey(M::ForceJitZygote)
181*795d594fSAndroid Build Coastguard Worker .Define("-Xallowinmemorycompilation")
182*795d594fSAndroid Build Coastguard Worker .WithHelp("Allows compiling the boot classpath in memory when the given boot image is"
183*795d594fSAndroid Build Coastguard Worker "unusable. This option is set by default for Zygote.")
184*795d594fSAndroid Build Coastguard Worker .IntoKey(M::AllowInMemoryCompilation)
185*795d594fSAndroid Build Coastguard Worker .Define("-Xprimaryzygote")
186*795d594fSAndroid Build Coastguard Worker .IntoKey(M::PrimaryZygote)
187*795d594fSAndroid Build Coastguard Worker .Define("-Xbootclasspath-locations:_")
188*795d594fSAndroid Build Coastguard Worker .WithType<ParseStringList<':'>>() // std::vector<std::string>, split by :
189*795d594fSAndroid Build Coastguard Worker .IntoKey(M::BootClassPathLocations)
190*795d594fSAndroid Build Coastguard Worker .Define("-Xjniopts:forcecopy")
191*795d594fSAndroid Build Coastguard Worker .IntoKey(M::JniOptsForceCopy)
192*795d594fSAndroid Build Coastguard Worker .Define("-XjdwpProvider:_")
193*795d594fSAndroid Build Coastguard Worker .WithType<JdwpProvider>()
194*795d594fSAndroid Build Coastguard Worker .IntoKey(M::JdwpProvider)
195*795d594fSAndroid Build Coastguard Worker .Define("-XjdwpOptions:_")
196*795d594fSAndroid Build Coastguard Worker .WithMetavar("OPTION[,OPTION...]")
197*795d594fSAndroid Build Coastguard Worker .WithHelp("JDWP options. Eg suspend=n,server=y.")
198*795d594fSAndroid Build Coastguard Worker .WithType<std::string>()
199*795d594fSAndroid Build Coastguard Worker .IntoKey(M::JdwpOptions)
200*795d594fSAndroid Build Coastguard Worker .Define("-XX:StopForNativeAllocs=_")
201*795d594fSAndroid Build Coastguard Worker .WithType<MemoryKiB>()
202*795d594fSAndroid Build Coastguard Worker .IntoKey(M::StopForNativeAllocs)
203*795d594fSAndroid Build Coastguard Worker .Define("-XX:ParallelGCThreads=_")
204*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
205*795d594fSAndroid Build Coastguard Worker .IntoKey(M::ParallelGCThreads)
206*795d594fSAndroid Build Coastguard Worker .Define("-XX:ConcGCThreads=_")
207*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
208*795d594fSAndroid Build Coastguard Worker .IntoKey(M::ConcGCThreads)
209*795d594fSAndroid Build Coastguard Worker .Define("-XX:FinalizerTimeoutMs=_")
210*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
211*795d594fSAndroid Build Coastguard Worker .IntoKey(M::FinalizerTimeoutMs)
212*795d594fSAndroid Build Coastguard Worker .Define("-XX:MaxSpinsBeforeThinLockInflation=_")
213*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
214*795d594fSAndroid Build Coastguard Worker .IntoKey(M::MaxSpinsBeforeThinLockInflation)
215*795d594fSAndroid Build Coastguard Worker .Define("-XX:LongPauseLogThreshold=_") // in ms
216*795d594fSAndroid Build Coastguard Worker .WithType<MillisecondsToNanoseconds>() // store as ns
217*795d594fSAndroid Build Coastguard Worker .IntoKey(M::LongPauseLogThreshold)
218*795d594fSAndroid Build Coastguard Worker .Define("-XX:LongGCLogThreshold=_") // in ms
219*795d594fSAndroid Build Coastguard Worker .WithType<MillisecondsToNanoseconds>() // store as ns
220*795d594fSAndroid Build Coastguard Worker .IntoKey(M::LongGCLogThreshold)
221*795d594fSAndroid Build Coastguard Worker .Define("-XX:DumpGCPerformanceOnShutdown")
222*795d594fSAndroid Build Coastguard Worker .IntoKey(M::DumpGCPerformanceOnShutdown)
223*795d594fSAndroid Build Coastguard Worker .Define("-XX:DumpRegionInfoBeforeGC")
224*795d594fSAndroid Build Coastguard Worker .IntoKey(M::DumpRegionInfoBeforeGC)
225*795d594fSAndroid Build Coastguard Worker .Define("-XX:DumpRegionInfoAfterGC")
226*795d594fSAndroid Build Coastguard Worker .IntoKey(M::DumpRegionInfoAfterGC)
227*795d594fSAndroid Build Coastguard Worker .Define("-XX:DumpJITInfoOnShutdown")
228*795d594fSAndroid Build Coastguard Worker .IntoKey(M::DumpJITInfoOnShutdown)
229*795d594fSAndroid Build Coastguard Worker .Define("-XX:IgnoreMaxFootprint")
230*795d594fSAndroid Build Coastguard Worker .IntoKey(M::IgnoreMaxFootprint)
231*795d594fSAndroid Build Coastguard Worker .Define("-XX:AlwaysLogExplicitGcs:_")
232*795d594fSAndroid Build Coastguard Worker .WithHelp("Allows one to control the logging of explicit GCs. Defaults to 'true'")
233*795d594fSAndroid Build Coastguard Worker .WithType<bool>()
234*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"false", false}, {"true", true}})
235*795d594fSAndroid Build Coastguard Worker .IntoKey(M::AlwaysLogExplicitGcs)
236*795d594fSAndroid Build Coastguard Worker .Define("-XX:UseTLAB")
237*795d594fSAndroid Build Coastguard Worker .WithValue(true)
238*795d594fSAndroid Build Coastguard Worker .IntoKey(M::UseTLAB)
239*795d594fSAndroid Build Coastguard Worker .Define({"-XX:EnableHSpaceCompactForOOM", "-XX:DisableHSpaceCompactForOOM"})
240*795d594fSAndroid Build Coastguard Worker .WithValues({true, false})
241*795d594fSAndroid Build Coastguard Worker .IntoKey(M::EnableHSpaceCompactForOOM)
242*795d594fSAndroid Build Coastguard Worker .Define("-XX:DumpNativeStackOnSigQuit:_")
243*795d594fSAndroid Build Coastguard Worker .WithType<bool>()
244*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"false", false}, {"true", true}})
245*795d594fSAndroid Build Coastguard Worker .IntoKey(M::DumpNativeStackOnSigQuit)
246*795d594fSAndroid Build Coastguard Worker .Define("-XX:MadviseRandomAccess:_")
247*795d594fSAndroid Build Coastguard Worker .WithHelp("Deprecated option")
248*795d594fSAndroid Build Coastguard Worker .WithType<bool>()
249*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"false", false}, {"true", true}})
250*795d594fSAndroid Build Coastguard Worker .IntoKey(M::MadviseRandomAccess)
251*795d594fSAndroid Build Coastguard Worker .Define("-XMadviseWillNeedVdexFileSize:_")
252*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
253*795d594fSAndroid Build Coastguard Worker .IntoKey(M::MadviseWillNeedVdexFileSize)
254*795d594fSAndroid Build Coastguard Worker .Define("-XMadviseWillNeedOdexFileSize:_")
255*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
256*795d594fSAndroid Build Coastguard Worker .IntoKey(M::MadviseWillNeedOdexFileSize)
257*795d594fSAndroid Build Coastguard Worker .Define("-XMadviseWillNeedArtFileSize:_")
258*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
259*795d594fSAndroid Build Coastguard Worker .IntoKey(M::MadviseWillNeedArtFileSize)
260*795d594fSAndroid Build Coastguard Worker .Define("-Xusejit:_")
261*795d594fSAndroid Build Coastguard Worker .WithType<bool>()
262*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"false", false}, {"true", true}})
263*795d594fSAndroid Build Coastguard Worker .IntoKey(M::UseJitCompilation)
264*795d594fSAndroid Build Coastguard Worker .Define("-Xuseprofiledjit:_")
265*795d594fSAndroid Build Coastguard Worker .WithType<bool>()
266*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"false", false}, {"true", true}})
267*795d594fSAndroid Build Coastguard Worker .IntoKey(M::UseProfiledJitCompilation)
268*795d594fSAndroid Build Coastguard Worker .Define("-Xjitinitialsize:_")
269*795d594fSAndroid Build Coastguard Worker .WithType<MemoryKiB>()
270*795d594fSAndroid Build Coastguard Worker .IntoKey(M::JITCodeCacheInitialCapacity)
271*795d594fSAndroid Build Coastguard Worker .Define("-Xjitmaxsize:_")
272*795d594fSAndroid Build Coastguard Worker .WithType<MemoryKiB>()
273*795d594fSAndroid Build Coastguard Worker .IntoKey(M::JITCodeCacheMaxCapacity)
274*795d594fSAndroid Build Coastguard Worker .Define("-Xjitwarmupthreshold:_")
275*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
276*795d594fSAndroid Build Coastguard Worker .IntoKey(M::JITWarmupThreshold)
277*795d594fSAndroid Build Coastguard Worker .Define("-Xjitprithreadweight:_")
278*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
279*795d594fSAndroid Build Coastguard Worker .IntoKey(M::JITPriorityThreadWeight)
280*795d594fSAndroid Build Coastguard Worker .Define("-Xjittransitionweight:_")
281*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
282*795d594fSAndroid Build Coastguard Worker .IntoKey(M::JITInvokeTransitionWeight)
283*795d594fSAndroid Build Coastguard Worker .Define("-Xjitpthreadpriority:_")
284*795d594fSAndroid Build Coastguard Worker .WithType<int>()
285*795d594fSAndroid Build Coastguard Worker .IntoKey(M::JITPoolThreadPthreadPriority)
286*795d594fSAndroid Build Coastguard Worker .Define("-Xjitzygotepthreadpriority:_")
287*795d594fSAndroid Build Coastguard Worker .WithType<int>()
288*795d594fSAndroid Build Coastguard Worker .IntoKey(M::JITZygotePoolThreadPthreadPriority)
289*795d594fSAndroid Build Coastguard Worker .Define("-Xjitsaveprofilinginfo")
290*795d594fSAndroid Build Coastguard Worker .WithType<ProfileSaverOptions>()
291*795d594fSAndroid Build Coastguard Worker .AppendValues()
292*795d594fSAndroid Build Coastguard Worker .IntoKey(M::ProfileSaverOpts)
293*795d594fSAndroid Build Coastguard Worker // .Define("-Xps-_") // profile saver options -Xps-<key>:<value>
294*795d594fSAndroid Build Coastguard Worker // .WithType<ProfileSaverOptions>()
295*795d594fSAndroid Build Coastguard Worker // .AppendValues()
296*795d594fSAndroid Build Coastguard Worker // .IntoKey(M::ProfileSaverOpts) // NOTE: Appends into same key as -Xjitsaveprofilinginfo
297*795d594fSAndroid Build Coastguard Worker // profile saver options -Xps-<key>:<value> but are split-out for better help messages.
298*795d594fSAndroid Build Coastguard Worker // The order of these is important. We want the wildcard one to be the
299*795d594fSAndroid Build Coastguard Worker // only one actually matched so it needs to be first.
300*795d594fSAndroid Build Coastguard Worker // TODO This should be redone.
301*795d594fSAndroid Build Coastguard Worker .Define({"-Xps-_",
302*795d594fSAndroid Build Coastguard Worker "-Xps-min-save-period-ms:_",
303*795d594fSAndroid Build Coastguard Worker "-Xps-min-first-save-ms:_",
304*795d594fSAndroid Build Coastguard Worker "-Xps-save-resolved-classes-delayed-ms:_",
305*795d594fSAndroid Build Coastguard Worker "-Xps-hot-startup-method-samples:_",
306*795d594fSAndroid Build Coastguard Worker "-Xps-min-methods-to-save:_",
307*795d594fSAndroid Build Coastguard Worker "-Xps-min-classes-to-save:_",
308*795d594fSAndroid Build Coastguard Worker "-Xps-min-notification-before-wake:_",
309*795d594fSAndroid Build Coastguard Worker "-Xps-max-notification-before-wake:_",
310*795d594fSAndroid Build Coastguard Worker "-Xps-inline-cache-threshold:_",
311*795d594fSAndroid Build Coastguard Worker "-Xps-profile-path:_"})
312*795d594fSAndroid Build Coastguard Worker .WithHelp("profile-saver options -Xps-<key>:<value>")
313*795d594fSAndroid Build Coastguard Worker .WithType<ProfileSaverOptions>()
314*795d594fSAndroid Build Coastguard Worker .AppendValues()
315*795d594fSAndroid Build Coastguard Worker .IntoKey(M::ProfileSaverOpts) // NOTE: Appends into same key as -Xjitsaveprofilinginfo
316*795d594fSAndroid Build Coastguard Worker .Define("-XX:HspaceCompactForOOMMinIntervalMs=_") // in ms
317*795d594fSAndroid Build Coastguard Worker .WithType<MillisecondsToNanoseconds>() // store as ns
318*795d594fSAndroid Build Coastguard Worker .IntoKey(M::HSpaceCompactForOOMMinIntervalsMs)
319*795d594fSAndroid Build Coastguard Worker .Define({"-Xrelocate", "-Xnorelocate"})
320*795d594fSAndroid Build Coastguard Worker .WithValues({true, false})
321*795d594fSAndroid Build Coastguard Worker .IntoKey(M::Relocate)
322*795d594fSAndroid Build Coastguard Worker .Define({"-Ximage-dex2oat", "-Xnoimage-dex2oat"})
323*795d594fSAndroid Build Coastguard Worker .WithValues({true, false})
324*795d594fSAndroid Build Coastguard Worker .IntoKey(M::ImageDex2Oat)
325*795d594fSAndroid Build Coastguard Worker .Define("-XX:LargeObjectSpace=_")
326*795d594fSAndroid Build Coastguard Worker .WithType<gc::space::LargeObjectSpaceType>()
327*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"disabled", gc::space::LargeObjectSpaceType::kDisabled},
328*795d594fSAndroid Build Coastguard Worker {"freelist", gc::space::LargeObjectSpaceType::kFreeList},
329*795d594fSAndroid Build Coastguard Worker {"map", gc::space::LargeObjectSpaceType::kMap}})
330*795d594fSAndroid Build Coastguard Worker .IntoKey(M::LargeObjectSpace)
331*795d594fSAndroid Build Coastguard Worker .Define("-XX:LargeObjectThreshold=_")
332*795d594fSAndroid Build Coastguard Worker .WithType<Memory<1>>()
333*795d594fSAndroid Build Coastguard Worker .IntoKey(M::LargeObjectThreshold)
334*795d594fSAndroid Build Coastguard Worker .Define("-XX:BackgroundGC=_")
335*795d594fSAndroid Build Coastguard Worker .WithType<BackgroundGcOption>()
336*795d594fSAndroid Build Coastguard Worker .IntoKey(M::BackgroundGc)
337*795d594fSAndroid Build Coastguard Worker .Define("-XX:+DisableExplicitGC")
338*795d594fSAndroid Build Coastguard Worker .IntoKey(M::DisableExplicitGC)
339*795d594fSAndroid Build Coastguard Worker .Define("-XX:+DisableEagerlyReleaseExplicitGC")
340*795d594fSAndroid Build Coastguard Worker .IntoKey(M::DisableEagerlyReleaseExplicitGC)
341*795d594fSAndroid Build Coastguard Worker .Define("-Xlockprofthreshold:_")
342*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
343*795d594fSAndroid Build Coastguard Worker .IntoKey(M::LockProfThreshold)
344*795d594fSAndroid Build Coastguard Worker .Define("-Xstackdumplockprofthreshold:_")
345*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
346*795d594fSAndroid Build Coastguard Worker .IntoKey(M::StackDumpLockProfThreshold)
347*795d594fSAndroid Build Coastguard Worker .Define("-Xmethod-trace")
348*795d594fSAndroid Build Coastguard Worker .IntoKey(M::MethodTrace)
349*795d594fSAndroid Build Coastguard Worker .Define("-Xmethod-trace-file:_")
350*795d594fSAndroid Build Coastguard Worker .WithType<std::string>()
351*795d594fSAndroid Build Coastguard Worker .IntoKey(M::MethodTraceFile)
352*795d594fSAndroid Build Coastguard Worker .Define("-Xmethod-trace-file-size:_")
353*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
354*795d594fSAndroid Build Coastguard Worker .IntoKey(M::MethodTraceFileSize)
355*795d594fSAndroid Build Coastguard Worker .Define("-Xmethod-trace-stream")
356*795d594fSAndroid Build Coastguard Worker .IntoKey(M::MethodTraceStreaming)
357*795d594fSAndroid Build Coastguard Worker .Define("-Xmethod-trace-clock:_")
358*795d594fSAndroid Build Coastguard Worker .WithType<TraceClockSource>()
359*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"threadcpuclock", TraceClockSource::kThreadCpu},
360*795d594fSAndroid Build Coastguard Worker {"wallclock", TraceClockSource::kWall},
361*795d594fSAndroid Build Coastguard Worker {"dualclock", TraceClockSource::kDual}})
362*795d594fSAndroid Build Coastguard Worker .IntoKey(M::MethodTraceClock)
363*795d594fSAndroid Build Coastguard Worker .Define("-Xcompiler:_")
364*795d594fSAndroid Build Coastguard Worker .WithType<std::string>()
365*795d594fSAndroid Build Coastguard Worker .IntoKey(M::Compiler)
366*795d594fSAndroid Build Coastguard Worker .Define("-Xcompiler-option _")
367*795d594fSAndroid Build Coastguard Worker .WithType<std::vector<std::string>>()
368*795d594fSAndroid Build Coastguard Worker .AppendValues()
369*795d594fSAndroid Build Coastguard Worker .IntoKey(M::CompilerOptions)
370*795d594fSAndroid Build Coastguard Worker .Define("-Ximage-compiler-option _")
371*795d594fSAndroid Build Coastguard Worker .WithType<std::vector<std::string>>()
372*795d594fSAndroid Build Coastguard Worker .AppendValues()
373*795d594fSAndroid Build Coastguard Worker .IntoKey(M::ImageCompilerOptions)
374*795d594fSAndroid Build Coastguard Worker .Define("-Xverify:_")
375*795d594fSAndroid Build Coastguard Worker .WithType<verifier::VerifyMode>()
376*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"none", verifier::VerifyMode::kNone},
377*795d594fSAndroid Build Coastguard Worker {"remote", verifier::VerifyMode::kEnable},
378*795d594fSAndroid Build Coastguard Worker {"all", verifier::VerifyMode::kEnable},
379*795d594fSAndroid Build Coastguard Worker {"softfail", verifier::VerifyMode::kSoftFail}})
380*795d594fSAndroid Build Coastguard Worker .IntoKey(M::Verify)
381*795d594fSAndroid Build Coastguard Worker .Define("-XX:NativeBridge=_")
382*795d594fSAndroid Build Coastguard Worker .WithType<std::string>()
383*795d594fSAndroid Build Coastguard Worker .IntoKey(M::NativeBridge)
384*795d594fSAndroid Build Coastguard Worker .Define("-Xzygote-max-boot-retry=_")
385*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
386*795d594fSAndroid Build Coastguard Worker .IntoKey(M::ZygoteMaxFailedBoots)
387*795d594fSAndroid Build Coastguard Worker .Define("-Xno-sig-chain")
388*795d594fSAndroid Build Coastguard Worker .IntoKey(M::NoSigChain)
389*795d594fSAndroid Build Coastguard Worker .Define("--cpu-abilist=_")
390*795d594fSAndroid Build Coastguard Worker .WithType<std::string>()
391*795d594fSAndroid Build Coastguard Worker .IntoKey(M::CpuAbiList)
392*795d594fSAndroid Build Coastguard Worker .Define("-Xfingerprint:_")
393*795d594fSAndroid Build Coastguard Worker .WithType<std::string>()
394*795d594fSAndroid Build Coastguard Worker .IntoKey(M::Fingerprint)
395*795d594fSAndroid Build Coastguard Worker .Define("-Xexperimental:_")
396*795d594fSAndroid Build Coastguard Worker .WithType<ExperimentalFlags>()
397*795d594fSAndroid Build Coastguard Worker .AppendValues()
398*795d594fSAndroid Build Coastguard Worker .IntoKey(M::Experimental)
399*795d594fSAndroid Build Coastguard Worker .Define("-Xforce-nb-testing")
400*795d594fSAndroid Build Coastguard Worker .IntoKey(M::ForceNativeBridge)
401*795d594fSAndroid Build Coastguard Worker .Define("-Xplugin:_")
402*795d594fSAndroid Build Coastguard Worker .WithHelp("Load and initialize the specified art-plugin.")
403*795d594fSAndroid Build Coastguard Worker .WithType<std::vector<Plugin>>().AppendValues()
404*795d594fSAndroid Build Coastguard Worker .IntoKey(M::Plugins)
405*795d594fSAndroid Build Coastguard Worker .Define("-XX:ThreadSuspendTimeout=_") // in ms
406*795d594fSAndroid Build Coastguard Worker .WithType<MillisecondsToNanoseconds>() // store as ns
407*795d594fSAndroid Build Coastguard Worker .IntoKey(M::ThreadSuspendTimeout)
408*795d594fSAndroid Build Coastguard Worker .Define("-XX:MonitorTimeoutEnable=_")
409*795d594fSAndroid Build Coastguard Worker .WithType<bool>()
410*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"false", false}, {"true", true}})
411*795d594fSAndroid Build Coastguard Worker .IntoKey(M::MonitorTimeoutEnable)
412*795d594fSAndroid Build Coastguard Worker .Define("-XX:MonitorTimeout=_") // in ms
413*795d594fSAndroid Build Coastguard Worker .WithType<int>()
414*795d594fSAndroid Build Coastguard Worker .IntoKey(M::MonitorTimeout)
415*795d594fSAndroid Build Coastguard Worker .Define("-XX:GlobalRefAllocStackTraceLimit=_") // Number of free slots to enable tracing.
416*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
417*795d594fSAndroid Build Coastguard Worker .IntoKey(M::GlobalRefAllocStackTraceLimit)
418*795d594fSAndroid Build Coastguard Worker .Define("-XX:SlowDebug=_")
419*795d594fSAndroid Build Coastguard Worker .WithType<bool>()
420*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"false", false}, {"true", true}})
421*795d594fSAndroid Build Coastguard Worker .IntoKey(M::SlowDebug)
422*795d594fSAndroid Build Coastguard Worker .Define("-Xtarget-sdk-version:_")
423*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
424*795d594fSAndroid Build Coastguard Worker .IntoKey(M::TargetSdkVersion)
425*795d594fSAndroid Build Coastguard Worker .Define("-Xhidden-api-policy:_")
426*795d594fSAndroid Build Coastguard Worker .WithType<hiddenapi::EnforcementPolicy>()
427*795d594fSAndroid Build Coastguard Worker .WithValueMap(hiddenapi_policy_valuemap)
428*795d594fSAndroid Build Coastguard Worker .IntoKey(M::HiddenApiPolicy)
429*795d594fSAndroid Build Coastguard Worker .Define("-Xcore-platform-api-policy:_")
430*795d594fSAndroid Build Coastguard Worker .WithType<hiddenapi::EnforcementPolicy>()
431*795d594fSAndroid Build Coastguard Worker .WithValueMap(hiddenapi_policy_valuemap)
432*795d594fSAndroid Build Coastguard Worker .IntoKey(M::CorePlatformApiPolicy)
433*795d594fSAndroid Build Coastguard Worker .Define("-Xuse-stderr-logger")
434*795d594fSAndroid Build Coastguard Worker .IntoKey(M::UseStderrLogger)
435*795d594fSAndroid Build Coastguard Worker .Define("-Xonly-use-system-oat-files")
436*795d594fSAndroid Build Coastguard Worker .IntoKey(M::OnlyUseTrustedOatFiles)
437*795d594fSAndroid Build Coastguard Worker .Define("-Xdeny-art-apex-data-files")
438*795d594fSAndroid Build Coastguard Worker .IntoKey(M::DenyArtApexDataFiles)
439*795d594fSAndroid Build Coastguard Worker .Define("-Xverifier-logging-threshold=_")
440*795d594fSAndroid Build Coastguard Worker .WithType<unsigned int>()
441*795d594fSAndroid Build Coastguard Worker .IntoKey(M::VerifierLoggingThreshold)
442*795d594fSAndroid Build Coastguard Worker .Define("-XX:FastClassNotFoundException=_")
443*795d594fSAndroid Build Coastguard Worker .WithType<bool>()
444*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"false", false}, {"true", true}})
445*795d594fSAndroid Build Coastguard Worker .IntoKey(M::FastClassNotFoundException)
446*795d594fSAndroid Build Coastguard Worker .Define("-Xopaque-jni-ids:_")
447*795d594fSAndroid Build Coastguard Worker .WithHelp("Control the representation of jmethodID and jfieldID values")
448*795d594fSAndroid Build Coastguard Worker .WithType<JniIdType>()
449*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"true", JniIdType::kIndices},
450*795d594fSAndroid Build Coastguard Worker {"false", JniIdType::kPointer},
451*795d594fSAndroid Build Coastguard Worker {"swapable", JniIdType::kSwapablePointer},
452*795d594fSAndroid Build Coastguard Worker {"pointer", JniIdType::kPointer},
453*795d594fSAndroid Build Coastguard Worker {"indices", JniIdType::kIndices},
454*795d594fSAndroid Build Coastguard Worker {"default", JniIdType::kDefault}})
455*795d594fSAndroid Build Coastguard Worker .IntoKey(M::OpaqueJniIds)
456*795d594fSAndroid Build Coastguard Worker .Define("-Xauto-promote-opaque-jni-ids:_")
457*795d594fSAndroid Build Coastguard Worker .WithType<bool>()
458*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"true", true}, {"false", false}})
459*795d594fSAndroid Build Coastguard Worker .IntoKey(M::AutoPromoteOpaqueJniIds)
460*795d594fSAndroid Build Coastguard Worker .Define("-XX:VerifierMissingKThrowFatal=_")
461*795d594fSAndroid Build Coastguard Worker .WithType<bool>()
462*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"false", false}, {"true", true}})
463*795d594fSAndroid Build Coastguard Worker .IntoKey(M::VerifierMissingKThrowFatal)
464*795d594fSAndroid Build Coastguard Worker .Define("-XX:ForceJavaZygoteForkLoop=_")
465*795d594fSAndroid Build Coastguard Worker .WithType<bool>()
466*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"false", false}, {"true", true}})
467*795d594fSAndroid Build Coastguard Worker .IntoKey(M::ForceJavaZygoteForkLoop)
468*795d594fSAndroid Build Coastguard Worker .Define("-XX:PerfettoHprof=_")
469*795d594fSAndroid Build Coastguard Worker .WithType<bool>()
470*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"false", false}, {"true", true}})
471*795d594fSAndroid Build Coastguard Worker .IntoKey(M::PerfettoHprof)
472*795d594fSAndroid Build Coastguard Worker .Define("-XX:PerfettoJavaHeapStackProf=_")
473*795d594fSAndroid Build Coastguard Worker .WithType<bool>()
474*795d594fSAndroid Build Coastguard Worker .WithValueMap({{"false", false}, {"true", true}})
475*795d594fSAndroid Build Coastguard Worker .IntoKey(M::PerfettoJavaHeapStackProf);
476*795d594fSAndroid Build Coastguard Worker // clang-format on
477*795d594fSAndroid Build Coastguard Worker
478*795d594fSAndroid Build Coastguard Worker FlagBase::AddFlagsToCmdlineParser(parser_builder.get());
479*795d594fSAndroid Build Coastguard Worker
480*795d594fSAndroid Build Coastguard Worker parser_builder
481*795d594fSAndroid Build Coastguard Worker ->Ignore({"-ea",
482*795d594fSAndroid Build Coastguard Worker "-da",
483*795d594fSAndroid Build Coastguard Worker "-enableassertions",
484*795d594fSAndroid Build Coastguard Worker "-disableassertions",
485*795d594fSAndroid Build Coastguard Worker "--runtime-arg",
486*795d594fSAndroid Build Coastguard Worker "-esa",
487*795d594fSAndroid Build Coastguard Worker "-dsa",
488*795d594fSAndroid Build Coastguard Worker "-enablesystemassertions",
489*795d594fSAndroid Build Coastguard Worker "-disablesystemassertions",
490*795d594fSAndroid Build Coastguard Worker "-Xrs",
491*795d594fSAndroid Build Coastguard Worker "-Xint:_",
492*795d594fSAndroid Build Coastguard Worker "-Xdexopt:_",
493*795d594fSAndroid Build Coastguard Worker "-Xnoquithandler",
494*795d594fSAndroid Build Coastguard Worker "-Xjnigreflimit:_",
495*795d594fSAndroid Build Coastguard Worker "-Xgenregmap",
496*795d594fSAndroid Build Coastguard Worker "-Xnogenregmap",
497*795d594fSAndroid Build Coastguard Worker "-Xverifyopt:_",
498*795d594fSAndroid Build Coastguard Worker "-Xcheckdexsum",
499*795d594fSAndroid Build Coastguard Worker "-Xincludeselectedop",
500*795d594fSAndroid Build Coastguard Worker "-Xjitop:_",
501*795d594fSAndroid Build Coastguard Worker "-Xincludeselectedmethod",
502*795d594fSAndroid Build Coastguard Worker "-Xjitblocking",
503*795d594fSAndroid Build Coastguard Worker "-Xjitmethod:_",
504*795d594fSAndroid Build Coastguard Worker "-Xjitclass:_",
505*795d594fSAndroid Build Coastguard Worker "-Xjitoffset:_",
506*795d594fSAndroid Build Coastguard Worker "-Xjitosrthreshold:_",
507*795d594fSAndroid Build Coastguard Worker "-Xjitconfig:_",
508*795d594fSAndroid Build Coastguard Worker "-Xjitcheckcg",
509*795d594fSAndroid Build Coastguard Worker "-Xjitverbose",
510*795d594fSAndroid Build Coastguard Worker "-Xjitprofile",
511*795d594fSAndroid Build Coastguard Worker "-Xjitdisableopt",
512*795d594fSAndroid Build Coastguard Worker "-Xjitsuspendpoll",
513*795d594fSAndroid Build Coastguard Worker "-XX:mainThreadStackSize=_",
514*795d594fSAndroid Build Coastguard Worker "-Xprofile:_"})
515*795d594fSAndroid Build Coastguard Worker .IgnoreUnrecognized(ignore_unrecognized)
516*795d594fSAndroid Build Coastguard Worker .OrderCategories({"standard", "extended", "Dalvik", "ART"});
517*795d594fSAndroid Build Coastguard Worker
518*795d594fSAndroid Build Coastguard Worker // TODO: Move Usage information into this DSL.
519*795d594fSAndroid Build Coastguard Worker
520*795d594fSAndroid Build Coastguard Worker return std::make_unique<RuntimeParser>(parser_builder->Build());
521*795d594fSAndroid Build Coastguard Worker }
522*795d594fSAndroid Build Coastguard Worker
523*795d594fSAndroid Build Coastguard Worker #pragma GCC diagnostic pop
524*795d594fSAndroid Build Coastguard Worker
525*795d594fSAndroid Build Coastguard Worker // Remove all the special options that have something in the void* part of the option.
526*795d594fSAndroid Build Coastguard Worker // If runtime_options is not null, put the options in there.
527*795d594fSAndroid Build Coastguard Worker // As a side-effect, populate the hooks from options.
ProcessSpecialOptions(const RuntimeOptions & options,RuntimeArgumentMap * runtime_options,std::vector<std::string> * out_options)528*795d594fSAndroid Build Coastguard Worker bool ParsedOptions::ProcessSpecialOptions(const RuntimeOptions& options,
529*795d594fSAndroid Build Coastguard Worker RuntimeArgumentMap* runtime_options,
530*795d594fSAndroid Build Coastguard Worker std::vector<std::string>* out_options) {
531*795d594fSAndroid Build Coastguard Worker using M = RuntimeArgumentMap;
532*795d594fSAndroid Build Coastguard Worker
533*795d594fSAndroid Build Coastguard Worker // TODO: Move the below loop into JNI
534*795d594fSAndroid Build Coastguard Worker // Handle special options that set up hooks
535*795d594fSAndroid Build Coastguard Worker for (size_t i = 0; i < options.size(); ++i) {
536*795d594fSAndroid Build Coastguard Worker const std::string option(options[i].first);
537*795d594fSAndroid Build Coastguard Worker // TODO: support -Djava.class.path
538*795d594fSAndroid Build Coastguard Worker if (option == "bootclasspath") {
539*795d594fSAndroid Build Coastguard Worker auto boot_class_path = static_cast<std::vector<std::unique_ptr<const DexFile>>*>(
540*795d594fSAndroid Build Coastguard Worker const_cast<void*>(options[i].second));
541*795d594fSAndroid Build Coastguard Worker
542*795d594fSAndroid Build Coastguard Worker if (runtime_options != nullptr) {
543*795d594fSAndroid Build Coastguard Worker runtime_options->Set(M::BootClassPathDexList, boot_class_path);
544*795d594fSAndroid Build Coastguard Worker }
545*795d594fSAndroid Build Coastguard Worker } else if (option == "compilercallbacks") {
546*795d594fSAndroid Build Coastguard Worker CompilerCallbacks* compiler_callbacks =
547*795d594fSAndroid Build Coastguard Worker reinterpret_cast<CompilerCallbacks*>(const_cast<void*>(options[i].second));
548*795d594fSAndroid Build Coastguard Worker if (runtime_options != nullptr) {
549*795d594fSAndroid Build Coastguard Worker runtime_options->Set(M::CompilerCallbacksPtr, compiler_callbacks);
550*795d594fSAndroid Build Coastguard Worker }
551*795d594fSAndroid Build Coastguard Worker } else if (option == "imageinstructionset") {
552*795d594fSAndroid Build Coastguard Worker const char* isa_str = reinterpret_cast<const char*>(options[i].second);
553*795d594fSAndroid Build Coastguard Worker auto&& image_isa = GetInstructionSetFromString(isa_str);
554*795d594fSAndroid Build Coastguard Worker if (image_isa == InstructionSet::kNone) {
555*795d594fSAndroid Build Coastguard Worker Usage("%s is not a valid instruction set.", isa_str);
556*795d594fSAndroid Build Coastguard Worker return false;
557*795d594fSAndroid Build Coastguard Worker }
558*795d594fSAndroid Build Coastguard Worker if (runtime_options != nullptr) {
559*795d594fSAndroid Build Coastguard Worker runtime_options->Set(M::ImageInstructionSet, image_isa);
560*795d594fSAndroid Build Coastguard Worker }
561*795d594fSAndroid Build Coastguard Worker } else if (option == "sensitiveThread") {
562*795d594fSAndroid Build Coastguard Worker const void* hook = options[i].second;
563*795d594fSAndroid Build Coastguard Worker bool (*hook_is_sensitive_thread)() = reinterpret_cast<bool (*)()>(const_cast<void*>(hook));
564*795d594fSAndroid Build Coastguard Worker
565*795d594fSAndroid Build Coastguard Worker if (runtime_options != nullptr) {
566*795d594fSAndroid Build Coastguard Worker runtime_options->Set(M::HookIsSensitiveThread, hook_is_sensitive_thread);
567*795d594fSAndroid Build Coastguard Worker }
568*795d594fSAndroid Build Coastguard Worker } else if (option == "vfprintf") {
569*795d594fSAndroid Build Coastguard Worker const void* hook = options[i].second;
570*795d594fSAndroid Build Coastguard Worker if (hook == nullptr) {
571*795d594fSAndroid Build Coastguard Worker Usage("vfprintf argument was nullptr");
572*795d594fSAndroid Build Coastguard Worker return false;
573*795d594fSAndroid Build Coastguard Worker }
574*795d594fSAndroid Build Coastguard Worker int (*hook_vfprintf)(FILE *, const char*, va_list) =
575*795d594fSAndroid Build Coastguard Worker reinterpret_cast<int (*)(FILE *, const char*, va_list)>(const_cast<void*>(hook));
576*795d594fSAndroid Build Coastguard Worker
577*795d594fSAndroid Build Coastguard Worker if (runtime_options != nullptr) {
578*795d594fSAndroid Build Coastguard Worker runtime_options->Set(M::HookVfprintf, hook_vfprintf);
579*795d594fSAndroid Build Coastguard Worker }
580*795d594fSAndroid Build Coastguard Worker hook_vfprintf_ = hook_vfprintf;
581*795d594fSAndroid Build Coastguard Worker } else if (option == "exit") {
582*795d594fSAndroid Build Coastguard Worker const void* hook = options[i].second;
583*795d594fSAndroid Build Coastguard Worker if (hook == nullptr) {
584*795d594fSAndroid Build Coastguard Worker Usage("exit argument was nullptr");
585*795d594fSAndroid Build Coastguard Worker return false;
586*795d594fSAndroid Build Coastguard Worker }
587*795d594fSAndroid Build Coastguard Worker void(*hook_exit)(jint) = reinterpret_cast<void(*)(jint)>(const_cast<void*>(hook));
588*795d594fSAndroid Build Coastguard Worker if (runtime_options != nullptr) {
589*795d594fSAndroid Build Coastguard Worker runtime_options->Set(M::HookExit, hook_exit);
590*795d594fSAndroid Build Coastguard Worker }
591*795d594fSAndroid Build Coastguard Worker hook_exit_ = hook_exit;
592*795d594fSAndroid Build Coastguard Worker } else if (option == "abort") {
593*795d594fSAndroid Build Coastguard Worker const void* hook = options[i].second;
594*795d594fSAndroid Build Coastguard Worker if (hook == nullptr) {
595*795d594fSAndroid Build Coastguard Worker Usage("abort was nullptr\n");
596*795d594fSAndroid Build Coastguard Worker return false;
597*795d594fSAndroid Build Coastguard Worker }
598*795d594fSAndroid Build Coastguard Worker void(*hook_abort)() = reinterpret_cast<void(*)()>(const_cast<void*>(hook));
599*795d594fSAndroid Build Coastguard Worker if (runtime_options != nullptr) {
600*795d594fSAndroid Build Coastguard Worker runtime_options->Set(M::HookAbort, hook_abort);
601*795d594fSAndroid Build Coastguard Worker }
602*795d594fSAndroid Build Coastguard Worker hook_abort_ = hook_abort;
603*795d594fSAndroid Build Coastguard Worker } else {
604*795d594fSAndroid Build Coastguard Worker // It is a regular option, that doesn't have a known 'second' value.
605*795d594fSAndroid Build Coastguard Worker // Push it on to the regular options which will be parsed by our parser.
606*795d594fSAndroid Build Coastguard Worker if (out_options != nullptr) {
607*795d594fSAndroid Build Coastguard Worker out_options->push_back(option);
608*795d594fSAndroid Build Coastguard Worker }
609*795d594fSAndroid Build Coastguard Worker }
610*795d594fSAndroid Build Coastguard Worker }
611*795d594fSAndroid Build Coastguard Worker
612*795d594fSAndroid Build Coastguard Worker return true;
613*795d594fSAndroid Build Coastguard Worker }
614*795d594fSAndroid Build Coastguard Worker
615*795d594fSAndroid Build Coastguard Worker // Intended for local changes only.
MaybeOverrideVerbosity()616*795d594fSAndroid Build Coastguard Worker static void MaybeOverrideVerbosity() {
617*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.class_linker = true; // TODO: don't check this in!
618*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.collector = true; // TODO: don't check this in!
619*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.compiler = true; // TODO: don't check this in!
620*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.deopt = true; // TODO: don't check this in!
621*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.gc = true; // TODO: don't check this in!
622*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.heap = true; // TODO: don't check this in!
623*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.image = true; // TODO: don't check this in!
624*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.interpreter = true; // TODO: don't check this in!
625*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.jdwp = true; // TODO: don't check this in!
626*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.jit = true; // TODO: don't check this in!
627*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.jni = true; // TODO: don't check this in!
628*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.monitor = true; // TODO: don't check this in!
629*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.oat = true; // TODO: don't check this in!
630*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.profiler = true; // TODO: don't check this in!
631*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.signals = true; // TODO: don't check this in!
632*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.simulator = true; // TODO: don't check this in!
633*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.startup = true; // TODO: don't check this in!
634*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.third_party_jni = true; // TODO: don't check this in!
635*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.threads = true; // TODO: don't check this in!
636*795d594fSAndroid Build Coastguard Worker // gLogVerbosity.verifier = true; // TODO: don't check this in!
637*795d594fSAndroid Build Coastguard Worker }
638*795d594fSAndroid Build Coastguard Worker
DoParse(const RuntimeOptions & options,bool ignore_unrecognized,RuntimeArgumentMap * runtime_options)639*795d594fSAndroid Build Coastguard Worker bool ParsedOptions::DoParse(const RuntimeOptions& options,
640*795d594fSAndroid Build Coastguard Worker bool ignore_unrecognized,
641*795d594fSAndroid Build Coastguard Worker RuntimeArgumentMap* runtime_options) {
642*795d594fSAndroid Build Coastguard Worker for (size_t i = 0; i < options.size(); ++i) {
643*795d594fSAndroid Build Coastguard Worker if (true && options[0].first == "-Xzygote") {
644*795d594fSAndroid Build Coastguard Worker LOG(INFO) << "option[" << i << "]=" << options[i].first;
645*795d594fSAndroid Build Coastguard Worker }
646*795d594fSAndroid Build Coastguard Worker }
647*795d594fSAndroid Build Coastguard Worker
648*795d594fSAndroid Build Coastguard Worker auto parser = MakeParser(ignore_unrecognized);
649*795d594fSAndroid Build Coastguard Worker
650*795d594fSAndroid Build Coastguard Worker // Convert to a simple string list (without the magic pointer options)
651*795d594fSAndroid Build Coastguard Worker std::vector<std::string> argv_list;
652*795d594fSAndroid Build Coastguard Worker if (!ProcessSpecialOptions(options, nullptr, &argv_list)) {
653*795d594fSAndroid Build Coastguard Worker return false;
654*795d594fSAndroid Build Coastguard Worker }
655*795d594fSAndroid Build Coastguard Worker
656*795d594fSAndroid Build Coastguard Worker CmdlineResult parse_result = parser->Parse(argv_list);
657*795d594fSAndroid Build Coastguard Worker
658*795d594fSAndroid Build Coastguard Worker // Handle parse errors by displaying the usage and potentially exiting.
659*795d594fSAndroid Build Coastguard Worker if (parse_result.IsError()) {
660*795d594fSAndroid Build Coastguard Worker if (parse_result.GetStatus() == CmdlineResult::kUsage) {
661*795d594fSAndroid Build Coastguard Worker UsageMessage(stdout, "%s\n", parse_result.GetMessage().c_str());
662*795d594fSAndroid Build Coastguard Worker Exit(0);
663*795d594fSAndroid Build Coastguard Worker } else if (parse_result.GetStatus() == CmdlineResult::kUnknown && !ignore_unrecognized) {
664*795d594fSAndroid Build Coastguard Worker Usage("%s\n", parse_result.GetMessage().c_str());
665*795d594fSAndroid Build Coastguard Worker return false;
666*795d594fSAndroid Build Coastguard Worker } else {
667*795d594fSAndroid Build Coastguard Worker Usage("%s\n", parse_result.GetMessage().c_str());
668*795d594fSAndroid Build Coastguard Worker Exit(0);
669*795d594fSAndroid Build Coastguard Worker }
670*795d594fSAndroid Build Coastguard Worker
671*795d594fSAndroid Build Coastguard Worker UNREACHABLE();
672*795d594fSAndroid Build Coastguard Worker }
673*795d594fSAndroid Build Coastguard Worker
674*795d594fSAndroid Build Coastguard Worker using M = RuntimeArgumentMap;
675*795d594fSAndroid Build Coastguard Worker RuntimeArgumentMap args = parser->ReleaseArgumentsMap();
676*795d594fSAndroid Build Coastguard Worker bool use_default_bootclasspath = true;
677*795d594fSAndroid Build Coastguard Worker
678*795d594fSAndroid Build Coastguard Worker // -help, -showversion, etc.
679*795d594fSAndroid Build Coastguard Worker if (args.Exists(M::Help)) {
680*795d594fSAndroid Build Coastguard Worker Usage(nullptr);
681*795d594fSAndroid Build Coastguard Worker return false;
682*795d594fSAndroid Build Coastguard Worker } else if (args.Exists(M::ShowVersion)) {
683*795d594fSAndroid Build Coastguard Worker UsageMessage(stdout,
684*795d594fSAndroid Build Coastguard Worker "ART version %s %s\n",
685*795d594fSAndroid Build Coastguard Worker Runtime::GetVersion(),
686*795d594fSAndroid Build Coastguard Worker GetInstructionSetString(kRuntimeISA));
687*795d594fSAndroid Build Coastguard Worker Exit(0);
688*795d594fSAndroid Build Coastguard Worker } else if (args.Exists(M::BootClassPath)) {
689*795d594fSAndroid Build Coastguard Worker LOG(INFO) << "setting boot class path to " << args.Get(M::BootClassPath)->Join();
690*795d594fSAndroid Build Coastguard Worker use_default_bootclasspath = false;
691*795d594fSAndroid Build Coastguard Worker }
692*795d594fSAndroid Build Coastguard Worker
693*795d594fSAndroid Build Coastguard Worker if (args.GetOrDefault(M::Interpret)) {
694*795d594fSAndroid Build Coastguard Worker if (args.Exists(M::UseJitCompilation) && *args.Get(M::UseJitCompilation)) {
695*795d594fSAndroid Build Coastguard Worker Usage("-Xusejit:true and -Xint cannot be specified together\n");
696*795d594fSAndroid Build Coastguard Worker Exit(0);
697*795d594fSAndroid Build Coastguard Worker }
698*795d594fSAndroid Build Coastguard Worker args.Set(M::UseJitCompilation, false);
699*795d594fSAndroid Build Coastguard Worker }
700*795d594fSAndroid Build Coastguard Worker
701*795d594fSAndroid Build Coastguard Worker // Set a default boot class path if we didn't get an explicit one via command line.
702*795d594fSAndroid Build Coastguard Worker const char* env_bcp = getenv("BOOTCLASSPATH");
703*795d594fSAndroid Build Coastguard Worker if (env_bcp != nullptr) {
704*795d594fSAndroid Build Coastguard Worker args.SetIfMissing(M::BootClassPath, ParseStringList<':'>::Split(env_bcp));
705*795d594fSAndroid Build Coastguard Worker }
706*795d594fSAndroid Build Coastguard Worker
707*795d594fSAndroid Build Coastguard Worker // Set a default class path if we didn't get an explicit one via command line.
708*795d594fSAndroid Build Coastguard Worker if (getenv("CLASSPATH") != nullptr) {
709*795d594fSAndroid Build Coastguard Worker args.SetIfMissing(M::ClassPath, std::string(getenv("CLASSPATH")));
710*795d594fSAndroid Build Coastguard Worker }
711*795d594fSAndroid Build Coastguard Worker
712*795d594fSAndroid Build Coastguard Worker // Default to number of processors minus one since the main GC thread also does work.
713*795d594fSAndroid Build Coastguard Worker args.SetIfMissing(M::ParallelGCThreads, gc::Heap::kDefaultEnableParallelGC ?
714*795d594fSAndroid Build Coastguard Worker static_cast<unsigned int>(sysconf(_SC_NPROCESSORS_CONF) - 1u) : 0u);
715*795d594fSAndroid Build Coastguard Worker
716*795d594fSAndroid Build Coastguard Worker // -verbose:
717*795d594fSAndroid Build Coastguard Worker {
718*795d594fSAndroid Build Coastguard Worker LogVerbosity *log_verbosity = args.Get(M::Verbose);
719*795d594fSAndroid Build Coastguard Worker if (log_verbosity != nullptr) {
720*795d594fSAndroid Build Coastguard Worker gLogVerbosity = *log_verbosity;
721*795d594fSAndroid Build Coastguard Worker }
722*795d594fSAndroid Build Coastguard Worker }
723*795d594fSAndroid Build Coastguard Worker
724*795d594fSAndroid Build Coastguard Worker MaybeOverrideVerbosity();
725*795d594fSAndroid Build Coastguard Worker
726*795d594fSAndroid Build Coastguard Worker SetRuntimeDebugFlagsEnabled(args.GetOrDefault(M::SlowDebug));
727*795d594fSAndroid Build Coastguard Worker
728*795d594fSAndroid Build Coastguard Worker if (!ProcessSpecialOptions(options, &args, nullptr)) {
729*795d594fSAndroid Build Coastguard Worker return false;
730*795d594fSAndroid Build Coastguard Worker }
731*795d594fSAndroid Build Coastguard Worker
732*795d594fSAndroid Build Coastguard Worker {
733*795d594fSAndroid Build Coastguard Worker // If not set, background collector type defaults to homogeneous compaction.
734*795d594fSAndroid Build Coastguard Worker // If not low memory mode, semispace otherwise.
735*795d594fSAndroid Build Coastguard Worker
736*795d594fSAndroid Build Coastguard Worker gc::CollectorType background_collector_type_ = args.GetOrDefault(M::BackgroundGc);
737*795d594fSAndroid Build Coastguard Worker bool low_memory_mode_ = args.Exists(M::LowMemoryMode);
738*795d594fSAndroid Build Coastguard Worker
739*795d594fSAndroid Build Coastguard Worker if (background_collector_type_ == gc::kCollectorTypeNone) {
740*795d594fSAndroid Build Coastguard Worker background_collector_type_ = low_memory_mode_ ?
741*795d594fSAndroid Build Coastguard Worker gc::kCollectorTypeSS : gc::kCollectorTypeHomogeneousSpaceCompact;
742*795d594fSAndroid Build Coastguard Worker }
743*795d594fSAndroid Build Coastguard Worker
744*795d594fSAndroid Build Coastguard Worker args.Set(M::BackgroundGc, BackgroundGcOption { background_collector_type_ });
745*795d594fSAndroid Build Coastguard Worker }
746*795d594fSAndroid Build Coastguard Worker
747*795d594fSAndroid Build Coastguard Worker const ParseStringList<':'>* boot_class_path_locations = args.Get(M::BootClassPathLocations);
748*795d594fSAndroid Build Coastguard Worker if (boot_class_path_locations != nullptr && boot_class_path_locations->Size() != 0u) {
749*795d594fSAndroid Build Coastguard Worker const ParseStringList<':'>* boot_class_path = args.Get(M::BootClassPath);
750*795d594fSAndroid Build Coastguard Worker if (boot_class_path == nullptr ||
751*795d594fSAndroid Build Coastguard Worker boot_class_path_locations->Size() != boot_class_path->Size()) {
752*795d594fSAndroid Build Coastguard Worker Usage("The number of boot class path files does not match"
753*795d594fSAndroid Build Coastguard Worker " the number of boot class path locations given\n"
754*795d594fSAndroid Build Coastguard Worker " boot class path files (%zu): %s\n"
755*795d594fSAndroid Build Coastguard Worker " boot class path locations (%zu): %s\n",
756*795d594fSAndroid Build Coastguard Worker (boot_class_path != nullptr) ? boot_class_path->Size() : 0u,
757*795d594fSAndroid Build Coastguard Worker (boot_class_path != nullptr) ? boot_class_path->Join().c_str() : "<nil>",
758*795d594fSAndroid Build Coastguard Worker boot_class_path_locations->Size(),
759*795d594fSAndroid Build Coastguard Worker boot_class_path_locations->Join().c_str());
760*795d594fSAndroid Build Coastguard Worker return false;
761*795d594fSAndroid Build Coastguard Worker }
762*795d594fSAndroid Build Coastguard Worker }
763*795d594fSAndroid Build Coastguard Worker
764*795d594fSAndroid Build Coastguard Worker if (args.Exists(M::ForceJitZygote)) {
765*795d594fSAndroid Build Coastguard Worker if (args.Exists(M::Image)) {
766*795d594fSAndroid Build Coastguard Worker Usage("-Ximage and -Xforcejitzygote cannot be specified together\n");
767*795d594fSAndroid Build Coastguard Worker Exit(0);
768*795d594fSAndroid Build Coastguard Worker }
769*795d594fSAndroid Build Coastguard Worker // If `boot.art` exists in the ART APEX, it will be used. Otherwise, Everything will be JITed.
770*795d594fSAndroid Build Coastguard Worker args.Set(M::Image, ParseStringList<':'>::Split(GetJitZygoteBootImageLocation()));
771*795d594fSAndroid Build Coastguard Worker }
772*795d594fSAndroid Build Coastguard Worker
773*795d594fSAndroid Build Coastguard Worker if (args.Exists(M::Zygote)) {
774*795d594fSAndroid Build Coastguard Worker args.Set(M::AllowInMemoryCompilation, Unit());
775*795d594fSAndroid Build Coastguard Worker }
776*795d594fSAndroid Build Coastguard Worker
777*795d594fSAndroid Build Coastguard Worker if (!args.Exists(M::CompilerCallbacksPtr) && !args.Exists(M::Image) &&
778*795d594fSAndroid Build Coastguard Worker use_default_bootclasspath) {
779*795d594fSAndroid Build Coastguard Worker const bool deny_art_apex_data_files = args.Exists(M::DenyArtApexDataFiles);
780*795d594fSAndroid Build Coastguard Worker std::string image_locations =
781*795d594fSAndroid Build Coastguard Worker GetDefaultBootImageLocation(GetAndroidRoot(), deny_art_apex_data_files);
782*795d594fSAndroid Build Coastguard Worker args.Set(M::Image, ParseStringList<':'>::Split(image_locations));
783*795d594fSAndroid Build Coastguard Worker }
784*795d594fSAndroid Build Coastguard Worker
785*795d594fSAndroid Build Coastguard Worker // 0 means no growth limit, and growth limit should be always <= heap size
786*795d594fSAndroid Build Coastguard Worker if (args.GetOrDefault(M::HeapGrowthLimit) <= 0u ||
787*795d594fSAndroid Build Coastguard Worker args.GetOrDefault(M::HeapGrowthLimit) > args.GetOrDefault(M::MemoryMaximumSize)) {
788*795d594fSAndroid Build Coastguard Worker args.Set(M::HeapGrowthLimit, args.GetOrDefault(M::MemoryMaximumSize));
789*795d594fSAndroid Build Coastguard Worker }
790*795d594fSAndroid Build Coastguard Worker
791*795d594fSAndroid Build Coastguard Worker // Increase log thresholds for GC stress mode to avoid excessive log spam.
792*795d594fSAndroid Build Coastguard Worker if (args.GetOrDefault(M::GcOption).gcstress_) {
793*795d594fSAndroid Build Coastguard Worker args.SetIfMissing(M::AlwaysLogExplicitGcs, false);
794*795d594fSAndroid Build Coastguard Worker args.SetIfMissing(M::LongPauseLogThreshold, gc::Heap::kDefaultLongPauseLogThresholdGcStress);
795*795d594fSAndroid Build Coastguard Worker args.SetIfMissing(M::LongGCLogThreshold, gc::Heap::kDefaultLongGCLogThresholdGcStress);
796*795d594fSAndroid Build Coastguard Worker }
797*795d594fSAndroid Build Coastguard Worker
798*795d594fSAndroid Build Coastguard Worker *runtime_options = std::move(args);
799*795d594fSAndroid Build Coastguard Worker return true;
800*795d594fSAndroid Build Coastguard Worker }
801*795d594fSAndroid Build Coastguard Worker
Exit(int status)802*795d594fSAndroid Build Coastguard Worker void ParsedOptions::Exit(int status) {
803*795d594fSAndroid Build Coastguard Worker hook_exit_(status);
804*795d594fSAndroid Build Coastguard Worker }
805*795d594fSAndroid Build Coastguard Worker
Abort()806*795d594fSAndroid Build Coastguard Worker void ParsedOptions::Abort() {
807*795d594fSAndroid Build Coastguard Worker hook_abort_();
808*795d594fSAndroid Build Coastguard Worker }
809*795d594fSAndroid Build Coastguard Worker
UsageMessageV(FILE * stream,const char * fmt,va_list ap)810*795d594fSAndroid Build Coastguard Worker void ParsedOptions::UsageMessageV(FILE* stream, const char* fmt, va_list ap) {
811*795d594fSAndroid Build Coastguard Worker hook_vfprintf_(stream, fmt, ap);
812*795d594fSAndroid Build Coastguard Worker }
813*795d594fSAndroid Build Coastguard Worker
UsageMessage(FILE * stream,const char * fmt,...)814*795d594fSAndroid Build Coastguard Worker void ParsedOptions::UsageMessage(FILE* stream, const char* fmt, ...) {
815*795d594fSAndroid Build Coastguard Worker va_list ap;
816*795d594fSAndroid Build Coastguard Worker va_start(ap, fmt);
817*795d594fSAndroid Build Coastguard Worker UsageMessageV(stream, fmt, ap);
818*795d594fSAndroid Build Coastguard Worker va_end(ap);
819*795d594fSAndroid Build Coastguard Worker }
820*795d594fSAndroid Build Coastguard Worker
Usage(const char * fmt,...)821*795d594fSAndroid Build Coastguard Worker void ParsedOptions::Usage(const char* fmt, ...) {
822*795d594fSAndroid Build Coastguard Worker bool error = (fmt != nullptr);
823*795d594fSAndroid Build Coastguard Worker FILE* stream = error ? stderr : stdout;
824*795d594fSAndroid Build Coastguard Worker
825*795d594fSAndroid Build Coastguard Worker if (fmt != nullptr) {
826*795d594fSAndroid Build Coastguard Worker va_list ap;
827*795d594fSAndroid Build Coastguard Worker va_start(ap, fmt);
828*795d594fSAndroid Build Coastguard Worker UsageMessageV(stream, fmt, ap);
829*795d594fSAndroid Build Coastguard Worker va_end(ap);
830*795d594fSAndroid Build Coastguard Worker }
831*795d594fSAndroid Build Coastguard Worker
832*795d594fSAndroid Build Coastguard Worker const char* program = "dalvikvm";
833*795d594fSAndroid Build Coastguard Worker UsageMessage(stream, "%s: [options] class [argument ...]\n", program);
834*795d594fSAndroid Build Coastguard Worker UsageMessage(stream, "\n");
835*795d594fSAndroid Build Coastguard Worker
836*795d594fSAndroid Build Coastguard Worker std::stringstream oss;
837*795d594fSAndroid Build Coastguard Worker VariableIndentationOutputStream vios(&oss);
838*795d594fSAndroid Build Coastguard Worker auto parser = MakeParser(false);
839*795d594fSAndroid Build Coastguard Worker parser->DumpHelp(vios);
840*795d594fSAndroid Build Coastguard Worker UsageMessage(stream, oss.str().c_str());
841*795d594fSAndroid Build Coastguard Worker Exit((error) ? 1 : 0);
842*795d594fSAndroid Build Coastguard Worker }
843*795d594fSAndroid Build Coastguard Worker
844*795d594fSAndroid Build Coastguard Worker } // namespace art
845