From: lrn@chromium.org Date: Wed, 11 Aug 2010 10:52:34 +0000 (+0000) Subject: Allow compiling with strict aliasing enabled on GCC 4.4. X-Git-Tag: upstream/4.7.83~21381 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=abcf1012c602b727768adb603f79eec0db99d244;p=platform%2Fupstream%2Fv8.git Allow compiling with strict aliasing enabled on GCC 4.4. Patch by Jay Freeman. Fixes issue 463. Review URL: http://codereview.chromium.org/3117007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5237 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/SConstruct b/SConstruct index c7543d997..0abaeed77 100644 --- a/SConstruct +++ b/SConstruct @@ -58,7 +58,7 @@ else: # on linux we need these compiler flags to avoid crashes in the v8 test suite # and avoid dtoa.c strict aliasing issues if os.environ.get('GCC_VERSION') == '44': - GCC_EXTRA_CCFLAGS = ['-fno-tree-vrp', '-fno-strict-aliasing'] + GCC_EXTRA_CCFLAGS = ['-fno-tree-vrp'] GCC_DTOA_EXTRA_CCFLAGS = [] else: GCC_EXTRA_CCFLAGS = [] @@ -80,7 +80,6 @@ ANDROID_FLAGS = ['-march=armv7-a', '-frerun-cse-after-loop', '-frename-registers', '-fomit-frame-pointer', - '-fno-strict-aliasing', '-finline-limit=64', '-DCAN_USE_VFP_INSTRUCTIONS=1', '-DCAN_USE_ARMV7_INSTRUCTIONS=1', diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index ed61a1425..0d59505c0 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -56,7 +56,7 @@ class SourceCodeCache BASE_EMBEDDED { } void Iterate(ObjectVisitor* v) { - v->VisitPointer(BitCast(&cache_)); + v->VisitPointer(BitCast(&cache_)); } diff --git a/src/debug.cc b/src/debug.cc index 5d386cc04..dbf9df9fd 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -852,8 +852,8 @@ void Debug::PreemptionWhileInDebugger() { void Debug::Iterate(ObjectVisitor* v) { - v->VisitPointer(BitCast(&(debug_break_return_))); - v->VisitPointer(BitCast(&(debug_break_slot_))); + v->VisitPointer(BitCast(&(debug_break_return_))); + v->VisitPointer(BitCast(&(debug_break_slot_))); } diff --git a/src/factory.h b/src/factory.h index 22511121c..c014986f4 100644 --- a/src/factory.h +++ b/src/factory.h @@ -329,7 +329,7 @@ class Factory : public AllStatic { #define ROOT_ACCESSOR(type, name, camel_name) \ static inline Handle name() { \ - return Handle(BitCast( \ + return Handle(BitCast( \ &Heap::roots_[Heap::k##camel_name##RootIndex])); \ } ROOT_LIST(ROOT_ACCESSOR) @@ -337,7 +337,7 @@ class Factory : public AllStatic { #define SYMBOL_ACCESSOR(name, str) \ static inline Handle name() { \ - return Handle(BitCast( \ + return Handle(BitCast( \ &Heap::roots_[Heap::k##name##RootIndex])); \ } SYMBOL_LIST(SYMBOL_ACCESSOR) diff --git a/src/heap.cc b/src/heap.cc index bd4f0d979..dfc18cc74 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -4024,7 +4024,7 @@ void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) { v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]); v->Synchronize("strong_root_list"); - v->VisitPointer(BitCast(&hidden_symbol_)); + v->VisitPointer(BitCast(&hidden_symbol_)); v->Synchronize("symbol"); Bootstrapper::Iterate(v); diff --git a/src/mips/simulator-mips.cc b/src/mips/simulator-mips.cc index 886b9e4fa..57bed6a04 100644 --- a/src/mips/simulator-mips.cc +++ b/src/mips/simulator-mips.cc @@ -606,7 +606,7 @@ void Simulator::set_fpu_register(int fpureg, int32_t value) { void Simulator::set_fpu_register_double(int fpureg, double value) { ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters) && ((fpureg % 2) == 0)); - *v8i::BitCast(&FPUregisters_[fpureg]) = value; + *v8i::BitCast(&FPUregisters_[fpureg]) = value; } @@ -627,8 +627,7 @@ int32_t Simulator::get_fpu_register(int fpureg) const { double Simulator::get_fpu_register_double(int fpureg) const { ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters) && ((fpureg % 2) == 0)); - return *v8i::BitCast( - const_cast(&FPUregisters_[fpureg])); + return *v8i::BitCast(const_cast(&FPUregisters_[fpureg])); } // Raw access to the PC register. @@ -903,7 +902,7 @@ void Simulator::DecodeTypeRegister(Instruction* instr) { break; case MFHC1: fp_out = get_fpu_register_double(fs_reg); - alu_out = *v8i::BitCast(&fp_out); + alu_out = *v8i::BitCast(&fp_out); break; case MTC1: case MTHC1: diff --git a/src/top.cc b/src/top.cc index 2887b7664..1a4a9485d 100644 --- a/src/top.cc +++ b/src/top.cc @@ -107,16 +107,15 @@ void Top::IterateThread(ThreadVisitor* v, char* t) { void Top::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) { v->VisitPointer(&(thread->pending_exception_)); v->VisitPointer(&(thread->pending_message_obj_)); - v->VisitPointer( - BitCast(&(thread->pending_message_script_))); - v->VisitPointer(BitCast(&(thread->context_))); + v->VisitPointer(BitCast(&(thread->pending_message_script_))); + v->VisitPointer(BitCast(&(thread->context_))); v->VisitPointer(&(thread->scheduled_exception_)); for (v8::TryCatch* block = thread->TryCatchHandler(); block != NULL; block = TRY_CATCH_FROM_ADDRESS(block->next_)) { - v->VisitPointer(BitCast(&(block->exception_))); - v->VisitPointer(BitCast(&(block->message_))); + v->VisitPointer(BitCast(&(block->exception_))); + v->VisitPointer(BitCast(&(block->message_))); } // Iterate over pointers on native execution stack. diff --git a/src/utils.h b/src/utils.h index 236b85e64..d15319c7a 100644 --- a/src/utils.h +++ b/src/utils.h @@ -739,7 +739,11 @@ inline Dest BitCast(const Source& source) { return dest; } -} } // namespace v8::internal +template +inline Dest BitCast(Source* const & source) { + return BitCast(reinterpret_cast(source)); +} +} } // namespace v8::internal #endif // V8_UTILS_H_ diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc index d90655b09..9ad94ce0f 100644 --- a/src/x64/assembler-x64.cc +++ b/src/x64/assembler-x64.cc @@ -253,7 +253,7 @@ Operand::Operand(const Operand& operand, int32_t offset) { int32_t disp_value = 0; if (mode == 0x80 || is_baseless) { // Mode 2 or mode 0 with rbp/r13 as base: Word displacement. - disp_value = *reinterpret_cast(&operand.buf_[disp_offset]); + disp_value = *BitCast(&operand.buf_[disp_offset]); } else if (mode == 0x40) { // Mode 1: Byte displacement. disp_value = static_cast(operand.buf_[disp_offset]); diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp index 839ae0bb0..dbd94bf0b 100644 --- a/tools/gyp/v8.gyp +++ b/tools/gyp/v8.gyp @@ -108,8 +108,6 @@ 'conditions': [ [ 'gcc_version==44', { 'cflags': [ - # Avoid gcc 4.4 strict aliasing issues in dtoa.c - '-fno-strict-aliasing', # Avoid crashes with gcc 4.4 in the v8 test suite. '-fno-tree-vrp', ],