summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2014-03-20 15:08:57 +0000
committer Vladimir Marko <vmarko@google.com> 2014-03-20 16:51:33 +0000
commit31806a3e1e55cb68ea03b1b3b8edd8441c090d82 (patch)
treed6bb32838d7d821f1b24e7fdce2b64dfa8c031d2
parentafb21d16bd2267f7f34e63a5b5105f7572455d22 (diff)
Make all gc maps with 0 entries identical.
Change-Id: Ie4fee22ffed07d23d103f52e4ab39ef083678d85
-rw-r--r--compiler/gc_map_builder.h21
1 files changed, 9 insertions, 12 deletions
diff --git a/compiler/gc_map_builder.h b/compiler/gc_map_builder.h
index 5a7a9e00fd..bc8ad41608 100644
--- a/compiler/gc_map_builder.h
+++ b/compiler/gc_map_builder.h
@@ -20,22 +20,19 @@
#include <vector>
#include "gc_map.h"
+#include "utils.h"
namespace art {
class GcMapBuilder {
public:
- GcMapBuilder(std::vector<uint8_t>* table,
- size_t entries, uint32_t max_native_offset,
- size_t references_width) : entries_(entries),
- references_width_(references_width), in_use_(entries),
- table_(table) {
- // Compute width in bytes needed to hold max_native_offset.
- native_offset_width_ = 0;
- while (max_native_offset != 0) {
- native_offset_width_++;
- max_native_offset >>= 8;
- }
+ GcMapBuilder(std::vector<uint8_t>* table, size_t entries, uint32_t max_native_offset,
+ size_t references_width)
+ : entries_(entries), references_width_(entries != 0u ? references_width : 0u),
+ native_offset_width_(entries != 0 && max_native_offset != 0
+ ? sizeof(max_native_offset) - CLZ(max_native_offset) / 8u
+ : 0u),
+ in_use_(entries), table_(table) {
// Resize table and set up header.
table->resize((EntryWidth() * entries) + sizeof(uint32_t));
CHECK_LT(native_offset_width_, 1U << 3);
@@ -94,7 +91,7 @@ class GcMapBuilder {
// Number of bytes used to encode the reference bitmap.
const size_t references_width_;
// Number of bytes used to encode a native offset.
- size_t native_offset_width_;
+ const size_t native_offset_width_;
// Entries that are in use.
std::vector<bool> in_use_;
// The table we're building.