From f66291202b2830c03120b0a7ce8741622b3a8924 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 30 Jan 2015 16:05:55 -0800 Subject: [PATCH] Bug 1125202 - SpiderMonkey: Reduce usage of reinterpret_cast r=jandem --- js/src/jit/shared/Assembler-x86-shared.cpp | 2 +- js/src/jit/shared/BaseAssembler-x86-shared.h | 28 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/js/src/jit/shared/Assembler-x86-shared.cpp b/js/src/jit/shared/Assembler-x86-shared.cpp index 7f3f1bbe8d7..9908ed1084c 100644 --- a/js/src/jit/shared/Assembler-x86-shared.cpp +++ b/js/src/jit/shared/Assembler-x86-shared.cpp @@ -67,7 +67,7 @@ TraceDataRelocations(JSTracer *trc, uint8_t *buffer, CompactBufferReader &reader #endif // No barrier needed since these are constants. - gc::MarkGCThingUnbarriered(trc, reinterpret_cast(ptr), "ion-masm-ptr"); + gc::MarkGCThingUnbarriered(trc, ptr, "ion-masm-ptr"); } } diff --git a/js/src/jit/shared/BaseAssembler-x86-shared.h b/js/src/jit/shared/BaseAssembler-x86-shared.h index 000ec13870a..4bd4133f5a5 100644 --- a/js/src/jit/shared/BaseAssembler-x86-shared.h +++ b/js/src/jit/shared/BaseAssembler-x86-shared.h @@ -2146,7 +2146,7 @@ public: #ifdef JS_CODEGEN_X64 m_formatter.immediate64(reinterpret_cast(addr)); #else - m_formatter.immediate32(reinterpret_cast(addr)); + m_formatter.immediate32(reinterpret_cast(addr)); #endif } @@ -2279,7 +2279,7 @@ public: #ifdef JS_CODEGEN_X64 m_formatter.immediate64(reinterpret_cast(addr)); #else - m_formatter.immediate32(reinterpret_cast(addr)); + m_formatter.immediate32(reinterpret_cast(addr)); #endif } @@ -3897,7 +3897,7 @@ threeByteOpImmSimd("vblendps", VEX_PD, OP3_BLENDPS_VpsWpsIb, ESCAPE_BLENDPS, imm if (oom()) return false; - char* code = reinterpret_cast(m_formatter.data()); + const unsigned char* code = m_formatter.data(); int32_t offset = getInt32(code + from.m_offset); if (offset == -1) return false; @@ -3911,7 +3911,7 @@ threeByteOpImmSimd("vblendps", VEX_PD, OP3_BLENDPS_VpsWpsIb, ESCAPE_BLENDPS, imm if (oom()) return; - char* code = reinterpret_cast(m_formatter.data()); + unsigned char* code = m_formatter.data(); setInt32(code + from.m_offset, to.m_offset); } @@ -3926,13 +3926,13 @@ threeByteOpImmSimd("vblendps", VEX_PD, OP3_BLENDPS_VpsWpsIb, ESCAPE_BLENDPS, imm return; spew("##link ((%d)) jumps to ((%d))", from.m_offset, to.m_offset); - char* code = reinterpret_cast(m_formatter.data()); + unsigned char* code = m_formatter.data(); setRel32(code + from.m_offset, code + to.m_offset); } static bool canRelinkJump(void* from, void* to) { - intptr_t offset = reinterpret_cast(to) - reinterpret_cast(from); + intptr_t offset = static_cast(to) - static_cast(from); return (offset == static_cast(offset)); } @@ -3943,7 +3943,7 @@ threeByteOpImmSimd("vblendps", VEX_PD, OP3_BLENDPS_VpsWpsIb, ESCAPE_BLENDPS, imm static void setRel32(void* from, void* to) { - intptr_t offset = reinterpret_cast(to) - reinterpret_cast(from); + intptr_t offset = static_cast(to) - static_cast(from); MOZ_ASSERT(offset == static_cast(offset), "offset is too great for a 32-bit relocation"); if (offset != static_cast(offset)) @@ -3959,20 +3959,20 @@ threeByteOpImmSimd("vblendps", VEX_PD, OP3_BLENDPS_VpsWpsIb, ESCAPE_BLENDPS, imm return (char *)where + rel; } - static void *getPointer(void* where) + static void *getPointer(const void* where) { - return reinterpret_cast(where)[-1]; + return static_cast(where)[-1]; } static void **getPointerRef(void* where) { - return &reinterpret_cast(where)[-1]; + return &static_cast(where)[-1]; } static void setPointer(void* where, const void* value) { staticSpew("##setPtr ((where=%p)) ((value=%p))", where, value); - reinterpret_cast(where)[-1] = value; + static_cast(where)[-1] = value; } // Test whether the given address will fit in an address immediate field. @@ -3997,7 +3997,7 @@ threeByteOpImmSimd("vblendps", VEX_PD, OP3_BLENDPS_VpsWpsIb, ESCAPE_BLENDPS, imm static void setInt32(void* where, int32_t value) { - reinterpret_cast(where)[-1] = value; + static_cast(where)[-1] = value; } private: @@ -4617,9 +4617,9 @@ private: m_formatter.immediate8u(imm); } - static int32_t getInt32(void* where) + static int32_t getInt32(const void* where) { - return reinterpret_cast(where)[-1]; + return static_cast(where)[-1]; } class X86InstructionFormatter {