summaryrefslogtreecommitdiff
path: root/dexlayout/dexlayout.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dexlayout/dexlayout.cc')
-rw-r--r--dexlayout/dexlayout.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc
index db227676c2..50dda88c55 100644
--- a/dexlayout/dexlayout.cc
+++ b/dexlayout/dexlayout.cc
@@ -1665,8 +1665,9 @@ int32_t DexLayout::LayoutCodeItems(const DexFile* dex_file,
enum CodeItemKind {
kMethodNotExecuted = 0,
- kMethodExecuted = 1,
- kSize = 2,
+ kMethodClinit = 1,
+ kMethodExecuted = 2,
+ kSize = 3,
};
static constexpr InvokeType invoke_types[] = {
@@ -1694,26 +1695,28 @@ int32_t DexLayout::LayoutCodeItems(const DexFile* dex_file,
continue;
}
// Separate executed methods (clinits and profiled methods) from unexecuted methods.
- // TODO: clinits are executed only once, consider separating them further.
const bool is_clinit = is_profile_class &&
(method->GetAccessFlags() & kAccConstructor) != 0 &&
(method->GetAccessFlags() & kAccStatic) != 0;
- const bool is_method_executed = is_clinit ||
+ const bool is_method_executed =
info_->IsStartupOrHotMethod(MethodReference(dex_file, method_id->GetIndex()));
- code_items[is_method_executed
- ? CodeItemKind::kMethodExecuted
- : CodeItemKind::kMethodNotExecuted]
- .insert(code_item);
+ CodeItemKind code_item_kind = CodeItemKind::kMethodNotExecuted;
+ if (is_clinit) {
+ code_item_kind = CodeItemKind::kMethodClinit;
+ } else if (is_method_executed) {
+ code_item_kind = CodeItemKind::kMethodExecuted;
+ }
+ code_items[code_item_kind].insert(code_item);
}
}
}
- // total_diff includes diffs generated by both executed and non-executed methods.
+ // Total_diff includes diffs generated by clinits, executed, and non-executed methods.
int32_t total_diff = 0;
// The relative placement has no effect on correctness; it is used to ensure
// the layout is deterministic
for (std::unordered_set<dex_ir::CodeItem*>& code_items_set : code_items) {
- // diff is reset for executed and non-executed methods.
+ // diff is reset for each class of code items.
int32_t diff = 0;
for (dex_ir::ClassData* data : new_class_data_order) {
data->SetOffset(data->GetOffset() + diff);