diff options
| author | 2015-03-13 11:45:07 +0000 | |
|---|---|---|
| committer | 2015-03-13 12:28:43 +0000 | |
| commit | 29ba1b068fc9f5a8011782c147b1f7732928aac7 (patch) | |
| tree | 5b61289b1e135cce6f01e8c9cbcaa747a39f196c | |
| parent | d9a59ca8f038a0f93a4e1504e0f7f8f388848719 (diff) | |
Fix the computation of the size of the stack maps region.
In art::StackMapStream::ComputeStackMapSize, compute the
size of a CodeInfo's stack maps region using the stack
mask size, not the maximum element of the stack mask.
Also, rename this method as
art::StackMapStream::ComputeStackMapsSize to make it clear
it that it covers all the stack maps of the CodeInfo item,
not just one stack map.
Change-Id: Icad21946dbca6e1ade2b82c9c2c535fdfed110a9
| -rw-r--r-- | compiler/optimizing/stack_map_stream.h | 16 | ||||
| -rw-r--r-- | runtime/stack_map.h | 9 |
2 files changed, 19 insertions, 6 deletions
diff --git a/compiler/optimizing/stack_map_stream.h b/compiler/optimizing/stack_map_stream.h index 76ddbf3204..8fb58d19a9 100644 --- a/compiler/optimizing/stack_map_stream.h +++ b/compiler/optimizing/stack_map_stream.h @@ -100,13 +100,17 @@ class StackMapStream : public ValueObject { size_t ComputeNeededSize() const { return CodeInfo::kFixedSize - + ComputeStackMapSize() + + ComputeStackMapsSize() + ComputeDexRegisterMapsSize() + ComputeInlineInfoSize(); } - size_t ComputeStackMapSize() const { - return stack_maps_.Size() * StackMap::ComputeAlignedStackMapSize(stack_mask_max_); + size_t ComputeStackMaskSize() const { + return StackMaskEncodingSize(stack_mask_max_); + } + + size_t ComputeStackMapsSize() const { + return stack_maps_.Size() * StackMap::ComputeAlignedStackMapSize(ComputeStackMaskSize()); } // Compute the size of the Dex register map of `entry`. @@ -141,7 +145,7 @@ class StackMapStream : public ValueObject { } size_t ComputeDexRegisterMapsStart() const { - return CodeInfo::kFixedSize + ComputeStackMapSize(); + return CodeInfo::kFixedSize + ComputeStackMapsSize(); } size_t ComputeInlineInfoStart() const { @@ -150,9 +154,10 @@ class StackMapStream : public ValueObject { void FillIn(MemoryRegion region) { CodeInfo code_info(region); + DCHECK_EQ(region.size(), ComputeNeededSize()); code_info.SetOverallSize(region.size()); - size_t stack_mask_size = StackMaskEncodingSize(stack_mask_max_); + size_t stack_mask_size = ComputeStackMaskSize(); uint8_t* memory_start = region.start(); MemoryRegion dex_register_maps_region = region.Subregion( @@ -165,6 +170,7 @@ class StackMapStream : public ValueObject { code_info.SetNumberOfStackMaps(stack_maps_.Size()); code_info.SetStackMaskSize(stack_mask_size); + DCHECK_EQ(code_info.StackMapsSize(), ComputeStackMapsSize()); uintptr_t next_dex_register_map_offset = 0; uintptr_t next_inline_info_offset = 0; diff --git a/runtime/stack_map.h b/runtime/stack_map.h index e88820fc79..3856da3189 100644 --- a/runtime/stack_map.h +++ b/runtime/stack_map.h @@ -606,10 +606,17 @@ class CodeInfo { region_.Store<uint32_t>(kNumberOfStackMapsOffset, number_of_stack_maps); } + // Get the size of one stack map of this CodeInfo object, in bytes. + // All stack maps of a CodeInfo have the same size. size_t StackMapSize() const { return StackMap::ComputeAlignedStackMapSize(GetStackMaskSize()); } + // Get the size all the stack maps of this CodeInfo object, in bytes. + size_t StackMapsSize() const { + return StackMapSize() * GetNumberOfStackMaps(); + } + uint32_t GetStackMapsOffset() const { return kFixedSize; } @@ -663,7 +670,7 @@ class CodeInfo { MemoryRegion GetStackMaps() const { return region_.size() == 0 ? MemoryRegion() - : region_.Subregion(kFixedSize, StackMapSize() * GetNumberOfStackMaps()); + : region_.Subregion(kFixedSize, StackMapsSize()); } // Compute the size of a Dex register map starting at offset `origin` in |