summaryrefslogtreecommitdiff
path: root/runtime/exception_test.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2015-10-27 18:51:20 +0000
committer Vladimir Marko <vmarko@google.com> 2015-10-27 18:52:35 +0000
commit562ff44698fc75f82e1f6cb0b71ce21df4328959 (patch)
treefd7b7b17bdc7c99c229a52c892c9d478de67172d /runtime/exception_test.cc
parent3aa2895fe9d2cb8c7fb04154463d296c5eab4fee (diff)
Revert "Remove DCHECK that does not work for gtests."
And fix the code alignment in gtests. This reverts commit 7d32dbc02beac2cb0217d52b61f2b3ef9974ffa6. Change-Id: I68813c36d1493f2746ceb129b30a649350d6bc13
Diffstat (limited to 'runtime/exception_test.cc')
-rw-r--r--runtime/exception_test.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/runtime/exception_test.cc b/runtime/exception_test.cc
index b1d4d35077..18ccd082ec 100644
--- a/runtime/exception_test.cc
+++ b/runtime/exception_test.cc
@@ -92,10 +92,25 @@ class ExceptionTest : public CommonRuntimeTest {
fake_header_code_and_maps_.insert(fake_header_code_and_maps_.end(),
fake_code_.begin(), fake_code_.end());
- // NOTE: Don't align the code (it will not be executed) but check that the Thumb2
- // adjustment will be a NOP, see EntryPointToCodePointer().
- CHECK_ALIGNED(mapping_table_offset, 2);
- const uint8_t* code_ptr = &fake_header_code_and_maps_[gc_map_offset];
+ // Align the code.
+ const size_t alignment = GetInstructionSetAlignment(kRuntimeISA);
+ fake_header_code_and_maps_.reserve(fake_header_code_and_maps_.size() + alignment);
+ const void* unaligned_code_ptr =
+ fake_header_code_and_maps_.data() + (fake_header_code_and_maps_.size() - code_size);
+ size_t offset = dchecked_integral_cast<size_t>(reinterpret_cast<uintptr_t>(unaligned_code_ptr));
+ size_t padding = RoundUp(offset, alignment) - offset;
+ // Make sure no resizing takes place.
+ CHECK_GE(fake_header_code_and_maps_.capacity(), fake_header_code_and_maps_.size() + padding);
+ fake_header_code_and_maps_.insert(fake_header_code_and_maps_.begin(), padding, 0);
+ const void* code_ptr = reinterpret_cast<const uint8_t*>(unaligned_code_ptr) + padding;
+ CHECK_EQ(code_ptr,
+ static_cast<const void*>(fake_header_code_and_maps_.data() +
+ (fake_header_code_and_maps_.size() - code_size)));
+
+ if (kRuntimeISA == kArm) {
+ // Check that the Thumb2 adjustment will be a NOP, see EntryPointToCodePointer().
+ CHECK_ALIGNED(mapping_table_offset, 2);
+ }
method_f_ = my_klass_->FindVirtualMethod("f", "()I", sizeof(void*));
ASSERT_TRUE(method_f_ != nullptr);