/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License")
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef RUNTIME_OPTIONS_KEY
#error "Please #define RUNTIME_OPTIONS_KEY before #including this file"
#define RUNTIME_OPTIONS_KEY(...)  // Don't display errors in this file in IDEs.
#endif

// This file defines the list of keys for RuntimeOptions.
// These can be used with RuntimeOptions.Get/Set/etc, for example:
//         RuntimeOptions opt; bool* image_dex2oat_enabled = opt.Get(RuntimeOptions::ImageDex2Oat);
//
// Column Descriptions:
//                   <<Type>>             <<Key Name>>                  <<Default Value>>
//
// Default values are only used by Map::GetOrDefault(K<T>).
// If a default value is omitted here, T{} is used as the default value, which is
// almost-always the value of the type as if it was memset to all 0.
//
// Please keep the columns aligned if possible when adding new rows.
//

// Parse-able keys from the command line.
RUNTIME_OPTIONS_KEY (Unit,                Zygote)
RUNTIME_OPTIONS_KEY (Unit,                PrimaryZygote)
RUNTIME_OPTIONS_KEY (Unit,                Help)
RUNTIME_OPTIONS_KEY (Unit,                ShowVersion)
RUNTIME_OPTIONS_KEY (ParseStringList<':'>,BootClassPath)           // std::vector<std::string>
RUNTIME_OPTIONS_KEY (ParseStringList<':'>,BootClassPathLocations)  // std::vector<std::string>
RUNTIME_OPTIONS_KEY (std::string,         ClassPath)
RUNTIME_OPTIONS_KEY (ParseStringList<':'>,Image)
RUNTIME_OPTIONS_KEY (Unit,                CheckJni)
RUNTIME_OPTIONS_KEY (Unit,                JniOptsForceCopy)
RUNTIME_OPTIONS_KEY (std::string,         JdwpOptions,                    "suspend=n,server=y")
RUNTIME_OPTIONS_KEY (JdwpProvider,        JdwpProvider,                   JdwpProvider::kUnset)
RUNTIME_OPTIONS_KEY (MemoryKiB,           MemoryMaximumSize,              gc::Heap::kDefaultMaximumSize)  // -Xmx
RUNTIME_OPTIONS_KEY (MemoryKiB,           MemoryInitialSize,              gc::Heap::kDefaultInitialSize)  // -Xms
RUNTIME_OPTIONS_KEY (MemoryKiB,           HeapGrowthLimit)                // Default is 0 for unlimited
RUNTIME_OPTIONS_KEY (MemoryKiB,           HeapMinFree,                    gc::Heap::kDefaultMinFree)
RUNTIME_OPTIONS_KEY (MemoryKiB,           HeapMaxFree,                    gc::Heap::kDefaultMaxFree)
RUNTIME_OPTIONS_KEY (MemoryKiB,           NonMovingSpaceCapacity,         gc::Heap::kDefaultNonMovingSpaceCapacity)
RUNTIME_OPTIONS_KEY (MemoryKiB,           StopForNativeAllocs,            1 * GB)
RUNTIME_OPTIONS_KEY (double,              HeapTargetUtilization,          gc::Heap::kDefaultTargetUtilization)
RUNTIME_OPTIONS_KEY (double,              ForegroundHeapGrowthMultiplier, gc::Heap::kDefaultHeapGrowthMultiplier)
RUNTIME_OPTIONS_KEY (unsigned int,        ParallelGCThreads,              0u)
RUNTIME_OPTIONS_KEY (unsigned int,        ConcGCThreads)
RUNTIME_OPTIONS_KEY (unsigned int,        FinalizerTimeoutMs,             10000u)
RUNTIME_OPTIONS_KEY (Memory<1>,           StackSize)  // -Xss
RUNTIME_OPTIONS_KEY (unsigned int,        MaxSpinsBeforeThinLockInflation,Monitor::kDefaultMaxSpinsBeforeThinLockInflation)
RUNTIME_OPTIONS_KEY (MillisecondsToNanoseconds, \
                                          LongPauseLogThreshold,          gc::Heap::kDefaultLongPauseLogThreshold)
RUNTIME_OPTIONS_KEY (MillisecondsToNanoseconds, \
                                          LongGCLogThreshold,             gc::Heap::kDefaultLongGCLogThreshold)
RUNTIME_OPTIONS_KEY (MillisecondsToNanoseconds, \
                                          ThreadSuspendTimeout,           ThreadList::kDefaultThreadSuspendTimeout)
RUNTIME_OPTIONS_KEY (bool,                MonitorTimeoutEnable,           false)
RUNTIME_OPTIONS_KEY (int,                 MonitorTimeout,                 Monitor::kDefaultMonitorTimeoutMs)
RUNTIME_OPTIONS_KEY (Unit,                DumpGCPerformanceOnShutdown)
RUNTIME_OPTIONS_KEY (Unit,                DumpRegionInfoBeforeGC)
RUNTIME_OPTIONS_KEY (Unit,                DumpRegionInfoAfterGC)
RUNTIME_OPTIONS_KEY (Unit,                DumpJITInfoOnShutdown)
RUNTIME_OPTIONS_KEY (Unit,                IgnoreMaxFootprint)
RUNTIME_OPTIONS_KEY (bool,                AlwaysLogExplicitGcs,           true)
RUNTIME_OPTIONS_KEY (Unit,                LowMemoryMode)
RUNTIME_OPTIONS_KEY (bool,                UseTLAB,                        (kUseTlab || kUseReadBarrier))
RUNTIME_OPTIONS_KEY (bool,                EnableHSpaceCompactForOOM,      true)
RUNTIME_OPTIONS_KEY (bool,                UseJitCompilation,              true)
RUNTIME_OPTIONS_KEY (bool,                UseProfiledJitCompilation,      false)
RUNTIME_OPTIONS_KEY (bool,                DumpNativeStackOnSigQuit,       true)
RUNTIME_OPTIONS_KEY (bool,                MadviseRandomAccess,            false)
RUNTIME_OPTIONS_KEY (unsigned int,        MadviseWillNeedVdexFileSize,    0)
RUNTIME_OPTIONS_KEY (unsigned int,        MadviseWillNeedOdexFileSize,    0)
RUNTIME_OPTIONS_KEY (unsigned int,        MadviseWillNeedArtFileSize,     0)
RUNTIME_OPTIONS_KEY (JniIdType,           OpaqueJniIds,                   JniIdType::kDefault)  // -Xopaque-jni-ids:{true, false, swapable}
RUNTIME_OPTIONS_KEY (bool,                AutoPromoteOpaqueJniIds,        true)  // testing use only. -Xauto-promote-opaque-jni-ids:{true, false}
RUNTIME_OPTIONS_KEY (unsigned int,        JITCompileThreshold)
RUNTIME_OPTIONS_KEY (unsigned int,        JITWarmupThreshold)
RUNTIME_OPTIONS_KEY (unsigned int,        JITOsrThreshold)
RUNTIME_OPTIONS_KEY (unsigned int,        JITPriorityThreadWeight)
RUNTIME_OPTIONS_KEY (unsigned int,        JITInvokeTransitionWeight)
RUNTIME_OPTIONS_KEY (int,                 JITPoolThreadPthreadPriority,   jit::kJitPoolThreadPthreadDefaultPriority)
RUNTIME_OPTIONS_KEY (int,                 JITZygotePoolThreadPthreadPriority,   jit::kJitZygotePoolThreadPthreadDefaultPriority)
RUNTIME_OPTIONS_KEY (MemoryKiB,           JITCodeCacheInitialCapacity,    jit::JitCodeCache::kInitialCapacity)
RUNTIME_OPTIONS_KEY (MemoryKiB,           JITCodeCacheMaxCapacity,        jit::JitCodeCache::kMaxCapacity)
RUNTIME_OPTIONS_KEY (MillisecondsToNanoseconds, \
                                          HSpaceCompactForOOMMinIntervalsMs,\
                                                                          MsToNs(100 * 1000))  // 100s
RUNTIME_OPTIONS_KEY (std::vector<std::string>, \
                                          PropertiesList)  // -D<whatever> -D<whatever> ...
RUNTIME_OPTIONS_KEY (std::string,         JniTrace)
RUNTIME_OPTIONS_KEY (bool,                Relocate,                       kDefaultMustRelocate)
RUNTIME_OPTIONS_KEY (bool,                ImageDex2Oat,                   true)
RUNTIME_OPTIONS_KEY (bool,                Interpret,                      false) // -Xint
                                                        // Disable the compiler for CC (for now).
RUNTIME_OPTIONS_KEY (XGcOption,           GcOption)  // -Xgc:
RUNTIME_OPTIONS_KEY (gc::space::LargeObjectSpaceType, \
                                          LargeObjectSpace,               gc::Heap::kDefaultLargeObjectSpaceType)
RUNTIME_OPTIONS_KEY (Memory<1>,           LargeObjectThreshold,           gc::Heap::kDefaultLargeObjectThreshold)
RUNTIME_OPTIONS_KEY (BackgroundGcOption,  BackgroundGc)

RUNTIME_OPTIONS_KEY (Unit,                DisableExplicitGC)
RUNTIME_OPTIONS_KEY (Unit,                NoSigChain)
RUNTIME_OPTIONS_KEY (Unit,                ForceNativeBridge)
RUNTIME_OPTIONS_KEY (LogVerbosity,        Verbose)
RUNTIME_OPTIONS_KEY (unsigned int,        LockProfThreshold)
RUNTIME_OPTIONS_KEY (unsigned int,        StackDumpLockProfThreshold)
RUNTIME_OPTIONS_KEY (Unit,                MethodTrace)
RUNTIME_OPTIONS_KEY (std::string,         MethodTraceFile,                "/data/misc/trace/method-trace-file.bin")
RUNTIME_OPTIONS_KEY (unsigned int,        MethodTraceFileSize,            10 * MB)
RUNTIME_OPTIONS_KEY (Unit,                MethodTraceStreaming)
RUNTIME_OPTIONS_KEY (TraceClockSource,    ProfileClock,                   kDefaultTraceClockSource)  // -Xprofile:
RUNTIME_OPTIONS_KEY (ProfileSaverOptions, ProfileSaverOpts)  // -Xjitsaveprofilinginfo, -Xps-*
RUNTIME_OPTIONS_KEY (std::string,         Compiler)
RUNTIME_OPTIONS_KEY (std::vector<std::string>, \
                                          CompilerOptions)  // -Xcompiler-option ...
RUNTIME_OPTIONS_KEY (std::vector<std::string>, \
                                          ImageCompilerOptions)  // -Ximage-compiler-option ...
RUNTIME_OPTIONS_KEY (verifier::VerifyMode, \
                                          Verify,                         verifier::VerifyMode::kEnable)
RUNTIME_OPTIONS_KEY (unsigned int,        TargetSdkVersion, \
                                          static_cast<unsigned int>(SdkVersion::kUnset))
RUNTIME_OPTIONS_KEY (hiddenapi::EnforcementPolicy,
                                          HiddenApiPolicy,
                                          hiddenapi::EnforcementPolicy::kDisabled)
RUNTIME_OPTIONS_KEY (hiddenapi::EnforcementPolicy,
                                          CorePlatformApiPolicy,
                                          hiddenapi::EnforcementPolicy::kDisabled)
RUNTIME_OPTIONS_KEY (std::string,         NativeBridge)
RUNTIME_OPTIONS_KEY (unsigned int,        ZygoteMaxFailedBoots,           10)
RUNTIME_OPTIONS_KEY (std::string,         CpuAbiList)
RUNTIME_OPTIONS_KEY (std::string,         Fingerprint)
RUNTIME_OPTIONS_KEY (ExperimentalFlags,   Experimental,     ExperimentalFlags::kNone) // -Xexperimental:{...}
RUNTIME_OPTIONS_KEY (std::list<ti::AgentSpec>,         AgentLib)  // -agentlib:<libname>=<options>
RUNTIME_OPTIONS_KEY (std::list<ti::AgentSpec>,         AgentPath)  // -agentpath:<libname>=<options>
RUNTIME_OPTIONS_KEY (std::vector<Plugin>,            Plugins)  // -Xplugin:<library>

// Not parse-able from command line, but can be provided explicitly.
// (Do not add anything here that is defined in ParsedOptions::MakeParser)
RUNTIME_OPTIONS_KEY (std::vector<std::unique_ptr<const DexFile>>*, \
                                          BootClassPathDexList)
RUNTIME_OPTIONS_KEY (InstructionSet,      ImageInstructionSet,            kRuntimeISA)
RUNTIME_OPTIONS_KEY (CompilerCallbacks*,  CompilerCallbacksPtr)  // TODO: make unique_ptr
RUNTIME_OPTIONS_KEY (bool (*)(),          HookIsSensitiveThread)
RUNTIME_OPTIONS_KEY (int32_t (*)(FILE* stream, const char* format, va_list ap), \
                                          HookVfprintf,                   vfprintf)
// Use `art::FastExit` instead of `exit` so that we won't get DCHECK failures
// in global data destructors (see b/28106055).
RUNTIME_OPTIONS_KEY (void (*)(int32_t status), \
                                          HookExit,                       art::FastExit)
                                                                          // We don't call abort(3) by default; see
                                                                          // Runtime::Abort.
RUNTIME_OPTIONS_KEY (void (*)(),          HookAbort,                      nullptr)

RUNTIME_OPTIONS_KEY (bool,                SlowDebug,                      false)

RUNTIME_OPTIONS_KEY (unsigned int,        GlobalRefAllocStackTraceLimit,  0)  // 0 = off
RUNTIME_OPTIONS_KEY (Unit,                UseStderrLogger)

RUNTIME_OPTIONS_KEY (Unit,                OnlyUseSystemOatFiles)
RUNTIME_OPTIONS_KEY (unsigned int,        VerifierLoggingThreshold,       100)

RUNTIME_OPTIONS_KEY (bool,                FastClassNotFoundException,     true)
RUNTIME_OPTIONS_KEY (bool,                VerifierMissingKThrowFatal,     true)

// Whether to allow loading of the perfetto hprof plugin.
// Even with this option set, we will still only actually load the plugin
// if we are on a userdebug build or the app is debuggable or profileable.
//
// We do not want to enable this by default because PerfettoHprof does not
// work on host, and we do not want to enable it in tests.
//
// Switching this on adds ~500us to the startup on userdebug builds, or for
// profileable / debuggable apps.
//
// This is set to true in frameworks/base/core/jni/AndroidRuntime.cpp.
RUNTIME_OPTIONS_KEY (bool,                PerfettoHprof,                  false)

// This is to enable/disable Perfetto Java Heap Stack Profiling
RUNTIME_OPTIONS_KEY (bool,                PerfettoJavaHeapStackProf,      false)

// Metrics configuration settings
RUNTIME_OPTIONS_KEY (Unit,                WriteMetricsToLog)
RUNTIME_OPTIONS_KEY (bool,                WriteMetricsToStatsd,           true)
RUNTIME_OPTIONS_KEY (std::string,         WriteMetricsToFile)
RUNTIME_OPTIONS_KEY (Unit,                DisableFinalMetricsReport)
RUNTIME_OPTIONS_KEY (unsigned int,        MetricsReportingPeriod)

#undef RUNTIME_OPTIONS_KEY
