Chromium Code Reviews| Index: test/cctest/test-reloc-info.cc |
| diff --git a/test/cctest/test-reloc-info.cc b/test/cctest/test-reloc-info.cc |
| index 2b9beac12bc8d8ce53e71111702219275e7da0c8..0d6ad67d6a1337bb529a28e7a6e5cd8f62c18081 100644 |
| --- a/test/cctest/test-reloc-info.cc |
| +++ b/test/cctest/test-reloc-info.cc |
| @@ -42,24 +42,31 @@ static void WriteRinfo(RelocInfoWriter* writer, |
| // Tests that writing both types of positions and then reading either |
| // or both works as expected. |
| TEST(Positions) { |
| - const int instr_size = 10 << 10; |
| - const int reloc_size = 10 << 10; |
| - const int buf_size = instr_size + reloc_size; |
| - SmartPointer<byte> buf(new byte[buf_size]); |
| - byte* pc = *buf; |
| - CodeDesc desc = { *buf, buf_size, instr_size, reloc_size, NULL }; |
| + const int code_size = 10 << 10; |
|
Lasse Reichstein
2011/03/22 11:42:44
Odd way to write a constant. Why not just 10 * KB,
|
| + int relocation_info_size = 10 << 10; |
| + const int buffer_size = code_size + relocation_info_size; |
| + SmartPointer<byte> buffer(new byte[buffer_size]); |
| - RelocInfoWriter writer(*buf + buf_size, pc); |
| + byte* pc = *buffer; |
| + byte* buffer_end = *buffer + buffer_size; |
| + |
| + RelocInfoWriter writer(buffer_end, pc); |
| + byte* relocation_info_end = buffer_end - relocation_info_size; |
| for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) { |
| RelocInfo::Mode mode = (i % 2 == 0) ? |
| RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION; |
| WriteRinfo(&writer, pc, mode, pos); |
| + CHECK(writer.pos() - RelocInfoWriter::kMaxSize >= relocation_info_end); |
| } |
| + relocation_info_size = static_cast<int>(buffer_end - writer.pos()); |
| + CodeDesc desc = { *buffer, buffer_size, code_size, |
| + relocation_info_size, NULL }; |
| + |
| // Read only (non-statement) positions. |
| { |
| RelocIterator it(desc, RelocInfo::ModeMask(RelocInfo::POSITION)); |
| - pc = *buf; |
| + pc = *buffer; |
| for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) { |
| RelocInfo::Mode mode = (i % 2 == 0) ? |
| RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION; |
| @@ -76,7 +83,7 @@ TEST(Positions) { |
| // Read only statement positions. |
| { |
| RelocIterator it(desc, RelocInfo::ModeMask(RelocInfo::STATEMENT_POSITION)); |
| - pc = *buf; |
| + pc = *buffer; |
| for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) { |
| RelocInfo::Mode mode = (i % 2 == 0) ? |
| RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION; |
| @@ -93,7 +100,7 @@ TEST(Positions) { |
| // Read both types of positions. |
| { |
| RelocIterator it(desc, RelocInfo::kPositionMask); |
| - pc = *buf; |
| + pc = *buffer; |
| for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) { |
| RelocInfo::Mode mode = (i % 2 == 0) ? |
| RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION; |