// 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;
}
-void RelocInfoWriter::WriteTaggedData(int32_t data_delta, int tag) {
+void RelocInfoWriter::WriteTaggedData(intptr_t data_delta, int tag) {
*--pos_ = data_delta << kPositionTypeTagBits | 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;
}
}
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();
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;
}
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;
}
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_;
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;
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);
}
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]);
-}