summaryrefslogtreecommitdiffstats
path: root/compiler/compiled_method.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/compiled_method.cc')
-rw-r--r--compiler/compiled_method.cc75
1 files changed, 60 insertions, 15 deletions
diff --git a/compiler/compiled_method.cc b/compiler/compiled_method.cc
index 22be28c..1849e7e 100644
--- a/compiler/compiled_method.cc
+++ b/compiler/compiled_method.cc
@@ -20,16 +20,29 @@
namespace art {
CompiledCode::CompiledCode(CompilerDriver* compiler_driver, InstructionSet instruction_set,
- const ArrayRef<const uint8_t>& quick_code)
+ const ArrayRef<const uint8_t>& quick_code, bool owns_code_array)
: compiler_driver_(compiler_driver), instruction_set_(instruction_set),
- quick_code_(nullptr) {
+ owns_code_array_(owns_code_array), quick_code_(nullptr) {
SetCode(&quick_code);
}
void CompiledCode::SetCode(const ArrayRef<const uint8_t>* quick_code) {
if (quick_code != nullptr) {
CHECK(!quick_code->empty());
- quick_code_ = compiler_driver_->DeduplicateCode(*quick_code);
+ if (owns_code_array_) {
+ // If we are supposed to own the code, don't deduplicate it.
+ CHECK(quick_code_ == nullptr);
+ quick_code_ = new SwapVector<uint8_t>(quick_code->begin(), quick_code->end(),
+ compiler_driver_->GetSwapSpaceAllocator());
+ } else {
+ quick_code_ = compiler_driver_->DeduplicateCode(*quick_code);
+ }
+ }
+}
+
+CompiledCode::~CompiledCode() {
+ if (owns_code_array_) {
+ delete quick_code_;
}
}
@@ -46,11 +59,11 @@ bool CompiledCode::operator==(const CompiledCode& rhs) const {
return (rhs.quick_code_ == nullptr);
}
-uint32_t CompiledCode::AlignCode(uint32_t offset) const {
+size_t CompiledCode::AlignCode(size_t offset) const {
return AlignCode(offset, instruction_set_);
}
-uint32_t CompiledCode::AlignCode(uint32_t offset, InstructionSet instruction_set) {
+size_t CompiledCode::AlignCode(size_t offset, InstructionSet instruction_set) {
return RoundUp(offset, GetInstructionSetAlignment(instruction_set));
}
@@ -120,17 +133,39 @@ CompiledMethod::CompiledMethod(CompilerDriver* driver,
const ArrayRef<const uint8_t>& native_gc_map,
const ArrayRef<const uint8_t>& cfi_info,
const ArrayRef<LinkerPatch>& patches)
- : CompiledCode(driver, instruction_set, quick_code), frame_size_in_bytes_(frame_size_in_bytes),
- core_spill_mask_(core_spill_mask), fp_spill_mask_(fp_spill_mask),
- src_mapping_table_(src_mapping_table == nullptr ?
- driver->DeduplicateSrcMappingTable(ArrayRef<SrcMapElem>()) :
- driver->DeduplicateSrcMappingTable(ArrayRef<SrcMapElem>(src_mapping_table->Arrange()))),
- mapping_table_(mapping_table.data() == nullptr ?
- nullptr : driver->DeduplicateMappingTable(mapping_table)),
- vmap_table_(driver->DeduplicateVMapTable(vmap_table)),
- gc_map_(native_gc_map.data() == nullptr ? nullptr : driver->DeduplicateGCMap(native_gc_map)),
- cfi_info_(cfi_info.data() == nullptr ? nullptr : driver->DeduplicateCFIInfo(cfi_info)),
+ : CompiledCode(driver, instruction_set, quick_code, !driver->DedupeEnabled()),
+ owns_arrays_(!driver->DedupeEnabled()),
+ frame_size_in_bytes_(frame_size_in_bytes), core_spill_mask_(core_spill_mask),
+ fp_spill_mask_(fp_spill_mask),
patches_(patches.begin(), patches.end(), driver->GetSwapSpaceAllocator()) {
+ if (owns_arrays_) {
+ if (src_mapping_table == nullptr) {
+ src_mapping_table_ = new SwapSrcMap(driver->GetSwapSpaceAllocator());
+ } else {
+ src_mapping_table->Arrange();
+ src_mapping_table_ = new SwapSrcMap(src_mapping_table->begin(), src_mapping_table->end(),
+ driver->GetSwapSpaceAllocator());
+ }
+ mapping_table_ = mapping_table.empty() ?
+ nullptr : new SwapVector<uint8_t>(mapping_table.begin(), mapping_table.end(),
+ driver->GetSwapSpaceAllocator());
+ vmap_table_ = new SwapVector<uint8_t>(vmap_table.begin(), vmap_table.end(),
+ driver->GetSwapSpaceAllocator());
+ gc_map_ = native_gc_map.empty() ? nullptr :
+ new SwapVector<uint8_t>(native_gc_map.begin(), native_gc_map.end(),
+ driver->GetSwapSpaceAllocator());
+ cfi_info_ = cfi_info.empty() ? nullptr :
+ new SwapVector<uint8_t>(cfi_info.begin(), cfi_info.end(), driver->GetSwapSpaceAllocator());
+ } else {
+ src_mapping_table_ = src_mapping_table == nullptr ?
+ driver->DeduplicateSrcMappingTable(ArrayRef<SrcMapElem>()) :
+ driver->DeduplicateSrcMappingTable(ArrayRef<SrcMapElem>(src_mapping_table->Arrange()));
+ mapping_table_ = mapping_table.empty() ?
+ nullptr : driver->DeduplicateMappingTable(mapping_table);
+ vmap_table_ = driver->DeduplicateVMapTable(vmap_table);
+ gc_map_ = native_gc_map.empty() ? nullptr : driver->DeduplicateGCMap(native_gc_map);
+ cfi_info_ = cfi_info.empty() ? nullptr : driver->DeduplicateCFIInfo(cfi_info);
+ }
}
CompiledMethod* CompiledMethod::SwapAllocCompiledMethod(
@@ -194,4 +229,14 @@ void CompiledMethod::ReleaseSwapAllocatedCompiledMethod(CompilerDriver* driver,
alloc.deallocate(m, 1);
}
+CompiledMethod::~CompiledMethod() {
+ if (owns_arrays_) {
+ delete src_mapping_table_;
+ delete mapping_table_;
+ delete vmap_table_;
+ delete gc_map_;
+ delete cfi_info_;
+ }
+}
+
} // namespace art