summaryrefslogtreecommitdiff
path: root/compiler/compiled_method.h
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2016-02-05 09:57:59 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-02-05 09:57:59 +0000
commitf1ea14af52b64adb45ba57ce8c525511c208d0e2 (patch)
tree731cf133fa4f9012d142b7d9d288542009ca6613 /compiler/compiled_method.h
parent586996afc905518ed926e4680aab67bedabec9b7 (diff)
parent34ed3afc41820c72a3c0ab9770be66b6668aa029 (diff)
Merge "ART: Avoid uninitialized padding in LinkerPatch."
Diffstat (limited to 'compiler/compiled_method.h')
-rw-r--r--compiler/compiled_method.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/compiled_method.h b/compiler/compiled_method.h
index 7a93613481..58876200ca 100644
--- a/compiler/compiled_method.h
+++ b/compiler/compiled_method.h
@@ -283,11 +283,13 @@ class LinkerPatch {
static_assert(sizeof(element_offset_) == sizeof(cmp1_), "needed by relational operators");
};
union {
- uint32_t cmp2_; // Used for relational operators.
+ // Note: To avoid uninitialized padding on 64-bit systems, we use `size_t` for `cmp2_`.
+ // This allows a hashing function to treat an array of linker patches as raw memory.
+ size_t cmp2_; // Used for relational operators.
// Literal offset of the insn loading PC (same as literal_offset if it's the same insn,
// may be different if the PC-relative addressing needs multiple insns).
uint32_t pc_insn_offset_;
- static_assert(sizeof(pc_insn_offset_) == sizeof(cmp2_), "needed by relational operators");
+ static_assert(sizeof(pc_insn_offset_) <= sizeof(cmp2_), "needed by relational operators");
};
friend bool operator==(const LinkerPatch& lhs, const LinkerPatch& rhs);