Commit 1bb3976a authored by whesse@chromium.org's avatar whesse@chromium.org

Change RelocInfo to write 64-bit data field on x64 architecture.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2081 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2eebe599
......@@ -91,13 +91,13 @@ int Label::pos() const {
// bits, the lowest 7 bits written first.
//
// data-jump + pos: 00 1110 11,
// signed int, lowest byte written first
// signed intptr_t, lowest byte written first
//
// data-jump + st.pos: 01 1110 11,
// signed int, lowest byte written first
// signed intptr_t, lowest byte written first
//
// data-jump + comm.: 10 1110 11,
// signed int, lowest byte written first
// signed intptr_t, lowest byte written first
//
const int kMaxRelocModes = 14;
......@@ -159,7 +159,7 @@ void RelocInfoWriter::WriteTaggedPC(uint32_t pc_delta, int tag) {
}
void RelocInfoWriter::WriteTaggedData(int32_t data_delta, int tag) {
void RelocInfoWriter::WriteTaggedData(intptr_t data_delta, int tag) {
*--pos_ = data_delta << kPositionTypeTagBits | tag;
}
......@@ -179,11 +179,12 @@ void RelocInfoWriter::WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag) {
}
void RelocInfoWriter::WriteExtraTaggedData(int32_t data_delta, int top_tag) {
void RelocInfoWriter::WriteExtraTaggedData(intptr_t data_delta, int top_tag) {
WriteExtraTag(kDataJumpTag, top_tag);
for (int i = 0; i < kIntSize; i++) {
for (int i = 0; i < kIntptrSize; i++) {
*--pos_ = data_delta;
data_delta = ArithmeticShiftRight(data_delta, kBitsPerByte);
// Signed right shift is arithmetic shift. Tested in test-utils.cc.
data_delta = data_delta >> kBitsPerByte;
}
}
......@@ -206,11 +207,13 @@ void RelocInfoWriter::Write(const RelocInfo* rinfo) {
WriteTaggedPC(pc_delta, kCodeTargetTag);
} else if (RelocInfo::IsPosition(rmode)) {
// Use signed delta-encoding for data.
int32_t data_delta = rinfo->data() - last_data_;
intptr_t data_delta = rinfo->data() - last_data_;
int pos_type_tag = rmode == RelocInfo::POSITION ? kNonstatementPositionTag
: kStatementPositionTag;
// Check if data is small enough to fit in a tagged byte.
if (is_intn(data_delta, kSmallDataBits)) {
// We cannot use is_intn because data_delta is not an int32_t.
if (data_delta >= -(1 << (kSmallDataBits-1)) &&
data_delta < 1 << (kSmallDataBits-1)) {
WriteTaggedPC(pc_delta, kPositionTag);
WriteTaggedData(data_delta, pos_type_tag);
last_data_ = rinfo->data();
......@@ -264,9 +267,9 @@ inline void RelocIterator::AdvanceReadPC() {
void RelocIterator::AdvanceReadData() {
int32_t x = 0;
for (int i = 0; i < kIntSize; i++) {
x |= *--pos_ << i * kBitsPerByte;
intptr_t x = 0;
for (int i = 0; i < kIntptrSize; i++) {
x |= static_cast<intptr_t>(*--pos_) << i * kBitsPerByte;
}
rinfo_.data_ += x;
}
......@@ -295,7 +298,8 @@ inline int RelocIterator::GetPositionTypeTag() {
inline void RelocIterator::ReadTaggedData() {
int8_t signed_b = *pos_;
rinfo_.data_ += ArithmeticShiftRight(signed_b, kPositionTypeTagBits);
// Signed right shift is arithmetic shift. Tested in test-utils.cc.
rinfo_.data_ += signed_b >> kPositionTypeTagBits;
}
......
......@@ -272,8 +272,8 @@ class RelocInfoWriter BASE_EMBEDDED {
inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta);
inline void WriteTaggedPC(uint32_t pc_delta, int tag);
inline void WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag);
inline void WriteExtraTaggedData(int32_t data_delta, int top_tag);
inline void WriteTaggedData(int32_t data_delta, int tag);
inline void WriteExtraTaggedData(intptr_t data_delta, int top_tag);
inline void WriteTaggedData(intptr_t data_delta, int tag);
inline void WriteExtraTag(int extra_tag, int top_tag);
byte* pos_;
......
......@@ -111,11 +111,12 @@ const int kMinInt = -kMaxInt - 1;
const uint32_t kMaxUInt32 = 0xFFFFFFFFu;
const int kCharSize = sizeof(char); // NOLINT
const int kShortSize = sizeof(short); // NOLINT
const int kIntSize = sizeof(int); // NOLINT
const int kDoubleSize = sizeof(double); // NOLINT
const int kPointerSize = sizeof(void*); // NOLINT
const int kCharSize = sizeof(char); // NOLINT
const int kShortSize = sizeof(short); // NOLINT
const int kIntSize = sizeof(int); // NOLINT
const int kDoubleSize = sizeof(double); // NOLINT
const int kPointerSize = sizeof(void*); // NOLINT
const int kIntptrSize = sizeof(intptr_t); // NOLINT
#if V8_HOST_ARCH_64_BIT
const int kPointerSizeLog2 = 3;
......
......@@ -152,6 +152,13 @@ TEST(Utils1) {
CHECK_EQ(0, FastD2I(0.345));
CHECK_EQ(1, FastD2I(1.234));
CHECK_EQ(1000000, FastD2I(1000000.123));
// Check that >> is implemented as arithmetic shift right.
// If this is not true, then ArithmeticShiftRight() must be changed,
// There are also documented right shifts in assembler.cc of
// int8_t and intptr_t signed integers.
CHECK_EQ(-2, -8 >> 2);
CHECK_EQ(-2, static_cast<int8_t>(-8) >> 2);
CHECK_EQ(-2, static_cast<intptr_t>(-8) >> 2);
}
......@@ -177,32 +184,3 @@ TEST(SNPrintF) {
buffer.Dispose();
}
}
// Issue 358: When copying EmbeddedVector, Vector::start_ must point
// to the buffer in the copy, not in the source.
TEST(EmbeddedVectorCopy) {
EmbeddedVector<int, 1> src;
src[0] = 100;
EmbeddedVector<int, 1> dst = src;
CHECK_NE(src.start(), dst.start());
CHECK_EQ(src[0], dst[0]);
src[0] = 200;
CHECK_NE(src[0], dst[0]);
}
// Also Issue 358, assignment case.
TEST(EmbeddedVectorAssign) {
EmbeddedVector<int, 1> src;
src[0] = 100;
EmbeddedVector<int, 1> dst;
dst[0] = 200;
CHECK_NE(src.start(), dst.start());
CHECK_NE(src[0], dst[0]);
dst = src;
CHECK_NE(src.start(), dst.start());
CHECK_EQ(src[0], dst[0]);
src[0] = 200;
CHECK_NE(src[0], dst[0]);
}
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