diff options
Diffstat (limited to 'compiler/common_compiler_test.cc')
-rw-r--r-- | compiler/common_compiler_test.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc index d7f6a2274f..392a0d1001 100644 --- a/compiler/common_compiler_test.cc +++ b/compiler/common_compiler_test.cc @@ -303,6 +303,23 @@ void CommonCompilerTestImpl::CompileMethod(ArtMethod* method) { } } +std::vector<uint8_t> CommonCompilerTestImpl::JniCompileCode(ArtMethod* method) { + CHECK(method->IsNative()); + Thread* self = Thread::Current(); + StackHandleScope<1> hs(self); + const DexFile& dex_file = *method->GetDexFile(); + Handle<mirror::DexCache> dex_cache = + hs.NewHandle(GetClassLinker()->FindDexCache(self, dex_file)); + OneCompiledMethodStorage storage; + std::unique_ptr<Compiler> compiler(Compiler::Create(*compiler_options_, &storage)); + compiler->JniCompile(method->GetAccessFlags(), + method->GetDexMethodIndex(), + dex_file, + dex_cache); + ArrayRef<const uint8_t> code = storage.GetCode(); + return std::vector<uint8_t>(code.begin(), code.end()); +} + void CommonCompilerTestImpl::ClearBootImageOption() { compiler_options_->image_type_ = CompilerOptions::ImageType::kNone; } |