diff options
author | 2015-12-08 08:22:45 -0800 | |
---|---|---|
committer | 2015-12-08 08:22:45 -0800 | |
commit | 0b81f1715d6af9f98f982d6511e48973aa5a836a (patch) | |
tree | 06924f7e4b7f14db21fe41ec03a6b95eec29efeb /runtime/runtime.cc | |
parent | 641c83a8645ef9fd99dca06ec30bae8449b959c7 (diff) | |
parent | 2433d4e17c3006b8262a0d9421e201fc84777208 (diff) |
Merge "Allow initializing runtime with parsed options." am: e0d25b156e
am: 2433d4e17c
* commit '2433d4e17c3006b8262a0d9421e201fc84777208':
Allow initializing runtime with parsed options.
Diffstat (limited to 'runtime/runtime.cc')
-rw-r--r-- | runtime/runtime.cc | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc index fe8eb0d78d..dedc110b00 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -434,14 +434,25 @@ void Runtime::SweepSystemWeaks(IsMarkedVisitor* visitor) { GetLambdaBoxTable()->SweepWeakBoxedLambdas(visitor); } -bool Runtime::Create(const RuntimeOptions& options, bool ignore_unrecognized) { +bool Runtime::ParseOptions(const RuntimeOptions& raw_options, + bool ignore_unrecognized, + RuntimeArgumentMap* runtime_options) { + InitLogging(/* argv */ nullptr); // Calls Locks::Init() as a side effect. + bool parsed = ParsedOptions::Parse(raw_options, ignore_unrecognized, runtime_options); + if (!parsed) { + LOG(ERROR) << "Failed to parse options"; + return false; + } + return true; +} + +bool Runtime::Create(RuntimeArgumentMap&& runtime_options) { // TODO: acquire a static mutex on Runtime to avoid racing. if (Runtime::instance_ != nullptr) { return false; } - InitLogging(nullptr); // Calls Locks::Init() as a side effect. instance_ = new Runtime; - if (!instance_->Init(options, ignore_unrecognized)) { + if (!instance_->Init(std::move(runtime_options))) { // TODO: Currently deleting the instance will abort the runtime on destruction. Now This will // leak memory, instead. Fix the destructor. b/19100793. // delete instance_; @@ -451,6 +462,12 @@ bool Runtime::Create(const RuntimeOptions& options, bool ignore_unrecognized) { return true; } +bool Runtime::Create(const RuntimeOptions& raw_options, bool ignore_unrecognized) { + RuntimeArgumentMap runtime_options; + return ParseOptions(raw_options, ignore_unrecognized, &runtime_options) && + Create(std::move(runtime_options)); +} + static jobject CreateSystemClassLoader(Runtime* runtime) { if (runtime->IsAotCompiler() && !runtime->GetCompilerCallbacks()->IsBootImage()) { return nullptr; @@ -829,21 +846,14 @@ void Runtime::SetSentinel(mirror::Object* sentinel) { sentinel_ = GcRoot<mirror::Object>(sentinel); } -bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized) { +bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) { + RuntimeArgumentMap runtime_options(std::move(runtime_options_in)); ATRACE_BEGIN("Runtime::Init"); CHECK_EQ(sysconf(_SC_PAGE_SIZE), kPageSize); MemMap::Init(); using Opt = RuntimeArgumentMap; - RuntimeArgumentMap runtime_options; - std::unique_ptr<ParsedOptions> parsed_options( - ParsedOptions::Create(raw_options, ignore_unrecognized, &runtime_options)); - if (parsed_options.get() == nullptr) { - LOG(ERROR) << "Failed to parse options"; - ATRACE_END(); - return false; - } VLOG(startup) << "Runtime::Init -verbose:startup enabled"; QuasiAtomic::Startup(); |