Fix endianism issues in regexp interpreter.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1115 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
erik.corry@gmail.com 2009-01-21 08:20:40 +00:00
parent bfbda9c871
commit 05a04b1023
3 changed files with 5 additions and 54 deletions

View File

@ -43,7 +43,7 @@ void RegExpMacroAssemblerIrregexp::Emit(uint32_t byte,
if (pc_ + 3 >= buffer_.length()) {
Expand();
}
Store32(buffer_.start() + pc_, word);
*reinterpret_cast<uint32_t*>(buffer_.start() + pc_) = word;
pc_ += 4;
}
@ -53,7 +53,7 @@ void RegExpMacroAssemblerIrregexp::Emit16(uint32_t word) {
if (pc_ + 1 >= buffer_.length()) {
Expand();
}
Store16(buffer_.start() + pc_, word);
*reinterpret_cast<uint16_t*>(buffer_.start() + pc_) = word;
pc_ += 2;
}
@ -63,7 +63,7 @@ void RegExpMacroAssemblerIrregexp::Emit32(uint32_t word) {
if (pc_ + 3 >= buffer_.length()) {
Expand();
}
Store32(buffer_.start() + pc_, word);
*reinterpret_cast<uint32_t*>(buffer_.start() + pc_) = word;
pc_ += 4;
}

View File

@ -60,8 +60,8 @@ void RegExpMacroAssemblerIrregexp::Bind(Label* l) {
int pos = l->pos();
while (pos != 0) {
int fixup = pos;
pos = Load32(buffer_.start() + fixup);
Store32(buffer_.start() + fixup, pc_);
pos = *reinterpret_cast<int32_t*>(buffer_.start() + fixup);
*reinterpret_cast<uint32_t*>(buffer_.start() + fixup) = pc_;
}
}
l->bind_to(pc_);

View File

@ -527,55 +527,6 @@ static inline void CopyChars(sinkchar* dest, const sourcechar* src, int chars) {
}
static inline int Load16(const byte* ptr) {
#ifdef CAN_READ_UNALIGNED
return *reinterpret_cast<const uint16_t*>(ptr);
#else
uint32_t word;
word = ptr[1];
word |= ptr[0] << 8;
return word;
#endif
}
static inline int Load32(const byte* ptr) {
#ifdef CAN_READ_UNALIGNED
return *reinterpret_cast<const uint32_t*>(ptr);
#else
uint32_t word;
word = ptr[3];
word |= ptr[2] << 8;
word |= ptr[1] << 16;
word |= ptr[0] << 24;
return word;
#endif
}
static inline void Store16(byte* ptr, uint16_t value) {
#ifdef CAN_READ_UNALIGNED
*reinterpret_cast<uint16_t*>(ptr) = value;
#else
// Cast to avoid warning C4244 when compiling with Microsoft Visual C++.
ptr[1] = static_cast<byte>(value);
ptr[0] = value >> 8;
#endif
}
static inline void Store32(byte* ptr, uint32_t value) {
#ifdef CAN_READ_UNALIGNED
*reinterpret_cast<uint32_t*>(ptr) = value;
#else
ptr[3] = value;
ptr[2] = value >> 8;
ptr[1] = value >> 16;
ptr[0] = value >> 24;
#endif
}
} } // namespace v8::internal
#endif // V8_UTILS_H_