diff options
| author | 2014-03-12 22:20:00 +0000 | |
|---|---|---|
| committer | 2014-03-12 22:20:01 +0000 | |
| commit | e78a4234cd78210f738d0c8ff1452f4955b31a87 (patch) | |
| tree | 394cc0066c61c37f680d3622095fd10e542fca15 /compiler | |
| parent | 12bea5797758382ca0737c84ff6c941cd270d934 (diff) | |
| parent | 36fea8dd490ab6439f391b8cd7f366c59f026fd2 (diff) | |
Merge "Fixing structure of native frame for Generic JNI"
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/common_compiler_test.h | 9 | ||||
| -rw-r--r-- | compiler/oat_writer.cc | 29 |
2 files changed, 36 insertions, 2 deletions
diff --git a/compiler/common_compiler_test.h b/compiler/common_compiler_test.h index def7b681dc..d28b0fedac 100644 --- a/compiler/common_compiler_test.h +++ b/compiler/common_compiler_test.h @@ -219,8 +219,15 @@ class CommonCompilerTest : public CommonRuntimeTest { } else { const void* method_code = GetQuickGenericJniTrampoline(); mirror::ArtMethod* callee_save_method = runtime_->GetCalleeSaveMethod(Runtime::kRefsAndArgs); + + // Compute Sirt size, as Sirt goes into frame + MethodHelper mh(method); + uint32_t sirt_refs = mh.GetNumberOfReferenceArgsWithoutReceiver() + 1; + uint32_t sirt_size = StackIndirectReferenceTable::SizeOf(sirt_refs); + OatFile::OatMethod oat_method = CreateOatMethod(method_code, - callee_save_method->GetFrameSizeInBytes(), + callee_save_method->GetFrameSizeInBytes() + + sirt_size, callee_save_method->GetCoreSpillMask(), callee_save_method->GetFpSpillMask(), nullptr, diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc index ffd7b417e3..c5219a6f16 100644 --- a/compiler/oat_writer.cc +++ b/compiler/oat_writer.cc @@ -364,7 +364,7 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index, OatClass* oat_class = oat_classes_[oat_class_index]; CompiledMethod* compiled_method = oat_class->GetCompiledMethod(class_def_method_index); - if (compiled_method != NULL) { + if (compiled_method != nullptr) { const std::vector<uint8_t>* portable_code = compiled_method->GetPortableCode(); const std::vector<uint8_t>* quick_code = compiled_method->GetQuickCode(); if (portable_code != nullptr) { @@ -495,6 +495,33 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index, if (compiler_driver_->IsImage()) { + // Derive frame size and spill masks for native methods without code: + // These are generic JNI methods... + if (is_native && compiled_method == nullptr) { + // Compute Sirt size as putting _every_ reference into it, even null ones. + uint32_t s_len; + const char* shorty = dex_file.GetMethodShorty(dex_file.GetMethodId(method_idx), &s_len); + DCHECK(shorty != nullptr); + uint32_t refs = 1; // Native method always has "this" or class. + for (uint32_t i = 1; i < s_len; ++i) { + if (shorty[i] == 'L') { + refs++; + } + } + size_t sirt_size = StackIndirectReferenceTable::GetAlignedSirtSize(refs); + + // Get the generic spill masks and base frame size. + mirror::ArtMethod* callee_save_method = + Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs); + + frame_size_in_bytes = callee_save_method->GetFrameSizeInBytes() + sirt_size; + core_spill_mask = callee_save_method->GetCoreSpillMask(); + fp_spill_mask = callee_save_method->GetFpSpillMask(); + mapping_table_offset = 0; + vmap_table_offset = 0; + gc_map_offset = 0; + } + ClassLinker* linker = Runtime::Current()->GetClassLinker(); // Unchecked as we hold mutator_lock_ on entry. ScopedObjectAccessUnchecked soa(Thread::Current()); |