Commit 46cf1c0b authored by whesse@chromium.org's avatar whesse@chromium.org

Fix error in test-reloc-info/Positions. This error caused a failure on Windows 64-bit V8.

BUG=1267
TEST=test-reloc-info/Positions

Review URL: http://codereview.chromium.org/6719022

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7302 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 63867eea
// Copyright 2010 the V8 project authors. All rights reserved. // Copyright 2011 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
...@@ -42,24 +42,31 @@ static void WriteRinfo(RelocInfoWriter* writer, ...@@ -42,24 +42,31 @@ static void WriteRinfo(RelocInfoWriter* writer,
// Tests that writing both types of positions and then reading either // Tests that writing both types of positions and then reading either
// or both works as expected. // or both works as expected.
TEST(Positions) { TEST(Positions) {
const int instr_size = 10 << 10; const int code_size = 10 * KB;
const int reloc_size = 10 << 10; int relocation_info_size = 10 * KB;
const int buf_size = instr_size + reloc_size; const int buffer_size = code_size + relocation_info_size;
SmartPointer<byte> buf(new byte[buf_size]); SmartPointer<byte> buffer(new byte[buffer_size]);
byte* pc = *buf;
CodeDesc desc = { *buf, buf_size, instr_size, reloc_size, NULL };
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) { for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) {
RelocInfo::Mode mode = (i % 2 == 0) ? RelocInfo::Mode mode = (i % 2 == 0) ?
RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION; RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION;
WriteRinfo(&writer, pc, mode, pos); 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. // Read only (non-statement) positions.
{ {
RelocIterator it(desc, RelocInfo::ModeMask(RelocInfo::POSITION)); RelocIterator it(desc, RelocInfo::ModeMask(RelocInfo::POSITION));
pc = *buf; pc = *buffer;
for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) { for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) {
RelocInfo::Mode mode = (i % 2 == 0) ? RelocInfo::Mode mode = (i % 2 == 0) ?
RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION; RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION;
...@@ -76,7 +83,7 @@ TEST(Positions) { ...@@ -76,7 +83,7 @@ TEST(Positions) {
// Read only statement positions. // Read only statement positions.
{ {
RelocIterator it(desc, RelocInfo::ModeMask(RelocInfo::STATEMENT_POSITION)); 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) { for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) {
RelocInfo::Mode mode = (i % 2 == 0) ? RelocInfo::Mode mode = (i % 2 == 0) ?
RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION; RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION;
...@@ -93,7 +100,7 @@ TEST(Positions) { ...@@ -93,7 +100,7 @@ TEST(Positions) {
// Read both types of positions. // Read both types of positions.
{ {
RelocIterator it(desc, RelocInfo::kPositionMask); RelocIterator it(desc, RelocInfo::kPositionMask);
pc = *buf; pc = *buffer;
for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) { for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) {
RelocInfo::Mode mode = (i % 2 == 0) ? RelocInfo::Mode mode = (i % 2 == 0) ?
RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION; RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment