From 05a04b1023cb34009a98d19cfd56d4a0d621e37f Mon Sep 17 00:00:00 2001 From: "erik.corry@gmail.com" Date: Wed, 21 Jan 2009 08:20:40 +0000 Subject: [PATCH] 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 --- src/regexp-macro-assembler-irregexp-inl.h | 6 +-- src/regexp-macro-assembler-irregexp.cc | 4 +- src/utils.h | 49 ----------------------- 3 files changed, 5 insertions(+), 54 deletions(-) diff --git a/src/regexp-macro-assembler-irregexp-inl.h b/src/regexp-macro-assembler-irregexp-inl.h index f235dc0f29..24f32c5370 100644 --- a/src/regexp-macro-assembler-irregexp-inl.h +++ b/src/regexp-macro-assembler-irregexp-inl.h @@ -43,7 +43,7 @@ void RegExpMacroAssemblerIrregexp::Emit(uint32_t byte, if (pc_ + 3 >= buffer_.length()) { Expand(); } - Store32(buffer_.start() + pc_, word); + *reinterpret_cast(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(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(buffer_.start() + pc_) = word; pc_ += 4; } diff --git a/src/regexp-macro-assembler-irregexp.cc b/src/regexp-macro-assembler-irregexp.cc index d32a09d567..89d248230d 100644 --- a/src/regexp-macro-assembler-irregexp.cc +++ b/src/regexp-macro-assembler-irregexp.cc @@ -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(buffer_.start() + fixup); + *reinterpret_cast(buffer_.start() + fixup) = pc_; } } l->bind_to(pc_); diff --git a/src/utils.h b/src/utils.h index 98612468e9..58770b899e 100644 --- a/src/utils.h +++ b/src/utils.h @@ -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(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(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(ptr) = value; -#else - // Cast to avoid warning C4244 when compiling with Microsoft Visual C++. - ptr[1] = static_cast(value); - ptr[0] = value >> 8; -#endif -} - - -static inline void Store32(byte* ptr, uint32_t value) { -#ifdef CAN_READ_UNALIGNED - *reinterpret_cast(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_