From ac3ac681a1d1d5d5d4662b7e4d3cf8e0b4d53d27 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 20 Sep 2018 11:01:43 +0100 Subject: Pass JIT roots as a vector> to JIT cache. This avoids creating an object on the heap and thus prevents issues for the 904-object-allocation in the JIT-at-first-use configuration. Test: run_build_test_target.py -j48 art-jit-on-first-use (test 904 passes; test 1935 still failing). Bug: 116189667 Change-Id: I58c0c8cb2d78edc63dab7d72e69b882abbfb79fd --- compiler/optimizing/optimizing_compiler.cc | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'compiler/optimizing/optimizing_compiler.cc') diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 5f6f71ddc9..9ae025b3fe 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -1218,7 +1218,7 @@ bool OptimizingCompiler::JitCompile(Thread* self, const CompilerOptions& compiler_options = GetCompilerDriver()->GetCompilerOptions(); JniCompiledMethod jni_compiled_method = ArtQuickJniCompileMethod( compiler_options, access_flags, method_idx, *dex_file); - ScopedNullHandle> roots; + std::vector> roots; ArenaSet> cha_single_implementation_list( allocator.Adapter(kArenaAllocCHA)); ArenaStack arena_stack(runtime->GetJitArenaPool()); @@ -1320,19 +1320,6 @@ bool OptimizingCompiler::JitCompile(Thread* self, ScopedArenaVector stack_map = codegen->BuildStackMaps(code_item); size_t number_of_roots = codegen->GetNumberOfJitRoots(); - // We allocate an object array to ensure the JIT roots that we will collect in EmitJitRoots - // will be visible by the GC between EmitLiterals and CommitCode. Once CommitCode is - // executed, this array is not needed. - Handle> roots( - hs.NewHandle(mirror::ObjectArray::Alloc( - self, GetClassRoot>(), number_of_roots))); - if (roots == nullptr) { - // Out of memory, just clear the exception to avoid any Java exception uncaught problems. - MaybeRecordStat(compilation_stats_.get(), MethodCompilationStat::kJitOutOfMemoryForCommit); - DCHECK(self->IsExceptionPending()); - self->ClearException(); - return false; - } uint8_t* stack_map_data = nullptr; uint8_t* roots_data = nullptr; uint32_t data_size = code_cache->ReserveData(self, @@ -1346,7 +1333,14 @@ bool OptimizingCompiler::JitCompile(Thread* self, return false; } memcpy(stack_map_data, stack_map.data(), stack_map.size()); - codegen->EmitJitRoots(code_allocator.GetData(), roots, roots_data); + std::vector> roots; + codegen->EmitJitRoots(code_allocator.GetData(), roots_data, &roots); + // The root Handle<>s filled by the codegen reference entries in the VariableSizedHandleScope. + DCHECK(std::all_of(roots.begin(), + roots.end(), + [&handles](Handle root){ + return handles.Contains(root.GetReference()); + })); const void* code = code_cache->CommitCode( self, -- cgit v1.2.3-59-g8ed1b