Commit abcf1012 authored by lrn@chromium.org's avatar lrn@chromium.org

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
parent 5e28c3e6
...@@ -58,7 +58,7 @@ else: ...@@ -58,7 +58,7 @@ else:
# on linux we need these compiler flags to avoid crashes in the v8 test suite # on linux we need these compiler flags to avoid crashes in the v8 test suite
# and avoid dtoa.c strict aliasing issues # and avoid dtoa.c strict aliasing issues
if os.environ.get('GCC_VERSION') == '44': 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 = [] GCC_DTOA_EXTRA_CCFLAGS = []
else: else:
GCC_EXTRA_CCFLAGS = [] GCC_EXTRA_CCFLAGS = []
...@@ -80,7 +80,6 @@ ANDROID_FLAGS = ['-march=armv7-a', ...@@ -80,7 +80,6 @@ ANDROID_FLAGS = ['-march=armv7-a',
'-frerun-cse-after-loop', '-frerun-cse-after-loop',
'-frename-registers', '-frename-registers',
'-fomit-frame-pointer', '-fomit-frame-pointer',
'-fno-strict-aliasing',
'-finline-limit=64', '-finline-limit=64',
'-DCAN_USE_VFP_INSTRUCTIONS=1', '-DCAN_USE_VFP_INSTRUCTIONS=1',
'-DCAN_USE_ARMV7_INSTRUCTIONS=1', '-DCAN_USE_ARMV7_INSTRUCTIONS=1',
......
...@@ -56,7 +56,7 @@ class SourceCodeCache BASE_EMBEDDED { ...@@ -56,7 +56,7 @@ class SourceCodeCache BASE_EMBEDDED {
} }
void Iterate(ObjectVisitor* v) { void Iterate(ObjectVisitor* v) {
v->VisitPointer(BitCast<Object**, FixedArray**>(&cache_)); v->VisitPointer(BitCast<Object**>(&cache_));
} }
......
...@@ -852,8 +852,8 @@ void Debug::PreemptionWhileInDebugger() { ...@@ -852,8 +852,8 @@ void Debug::PreemptionWhileInDebugger() {
void Debug::Iterate(ObjectVisitor* v) { void Debug::Iterate(ObjectVisitor* v) {
v->VisitPointer(BitCast<Object**, Code**>(&(debug_break_return_))); v->VisitPointer(BitCast<Object**>(&(debug_break_return_)));
v->VisitPointer(BitCast<Object**, Code**>(&(debug_break_slot_))); v->VisitPointer(BitCast<Object**>(&(debug_break_slot_)));
} }
......
...@@ -329,7 +329,7 @@ class Factory : public AllStatic { ...@@ -329,7 +329,7 @@ class Factory : public AllStatic {
#define ROOT_ACCESSOR(type, name, camel_name) \ #define ROOT_ACCESSOR(type, name, camel_name) \
static inline Handle<type> name() { \ static inline Handle<type> name() { \
return Handle<type>(BitCast<type**, Object**>( \ return Handle<type>(BitCast<type**>( \
&Heap::roots_[Heap::k##camel_name##RootIndex])); \ &Heap::roots_[Heap::k##camel_name##RootIndex])); \
} }
ROOT_LIST(ROOT_ACCESSOR) ROOT_LIST(ROOT_ACCESSOR)
...@@ -337,7 +337,7 @@ class Factory : public AllStatic { ...@@ -337,7 +337,7 @@ class Factory : public AllStatic {
#define SYMBOL_ACCESSOR(name, str) \ #define SYMBOL_ACCESSOR(name, str) \
static inline Handle<String> name() { \ static inline Handle<String> name() { \
return Handle<String>(BitCast<String**, Object**>( \ return Handle<String>(BitCast<String**>( \
&Heap::roots_[Heap::k##name##RootIndex])); \ &Heap::roots_[Heap::k##name##RootIndex])); \
} }
SYMBOL_LIST(SYMBOL_ACCESSOR) SYMBOL_LIST(SYMBOL_ACCESSOR)
......
...@@ -4024,7 +4024,7 @@ void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) { ...@@ -4024,7 +4024,7 @@ void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) {
v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]); v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]);
v->Synchronize("strong_root_list"); v->Synchronize("strong_root_list");
v->VisitPointer(BitCast<Object**, String**>(&hidden_symbol_)); v->VisitPointer(BitCast<Object**>(&hidden_symbol_));
v->Synchronize("symbol"); v->Synchronize("symbol");
Bootstrapper::Iterate(v); Bootstrapper::Iterate(v);
......
...@@ -606,7 +606,7 @@ void Simulator::set_fpu_register(int fpureg, int32_t value) { ...@@ -606,7 +606,7 @@ void Simulator::set_fpu_register(int fpureg, int32_t value) {
void Simulator::set_fpu_register_double(int fpureg, double value) { void Simulator::set_fpu_register_double(int fpureg, double value) {
ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters) && ((fpureg % 2) == 0)); ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters) && ((fpureg % 2) == 0));
*v8i::BitCast<double*, int32_t*>(&FPUregisters_[fpureg]) = value; *v8i::BitCast<double*>(&FPUregisters_[fpureg]) = value;
} }
...@@ -627,8 +627,7 @@ int32_t Simulator::get_fpu_register(int fpureg) const { ...@@ -627,8 +627,7 @@ int32_t Simulator::get_fpu_register(int fpureg) const {
double Simulator::get_fpu_register_double(int fpureg) const { double Simulator::get_fpu_register_double(int fpureg) const {
ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters) && ((fpureg % 2) == 0)); ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters) && ((fpureg % 2) == 0));
return *v8i::BitCast<double*, int32_t*>( return *v8i::BitCast<double*>(const_cast<int32_t*>(&FPUregisters_[fpureg]));
const_cast<int32_t*>(&FPUregisters_[fpureg]));
} }
// Raw access to the PC register. // Raw access to the PC register.
...@@ -903,7 +902,7 @@ void Simulator::DecodeTypeRegister(Instruction* instr) { ...@@ -903,7 +902,7 @@ void Simulator::DecodeTypeRegister(Instruction* instr) {
break; break;
case MFHC1: case MFHC1:
fp_out = get_fpu_register_double(fs_reg); fp_out = get_fpu_register_double(fs_reg);
alu_out = *v8i::BitCast<int32_t*, double*>(&fp_out); alu_out = *v8i::BitCast<int32_t*>(&fp_out);
break; break;
case MTC1: case MTC1:
case MTHC1: case MTHC1:
......
...@@ -107,16 +107,15 @@ void Top::IterateThread(ThreadVisitor* v, char* t) { ...@@ -107,16 +107,15 @@ void Top::IterateThread(ThreadVisitor* v, char* t) {
void Top::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) { void Top::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) {
v->VisitPointer(&(thread->pending_exception_)); v->VisitPointer(&(thread->pending_exception_));
v->VisitPointer(&(thread->pending_message_obj_)); v->VisitPointer(&(thread->pending_message_obj_));
v->VisitPointer( v->VisitPointer(BitCast<Object**>(&(thread->pending_message_script_)));
BitCast<Object**, Script**>(&(thread->pending_message_script_))); v->VisitPointer(BitCast<Object**>(&(thread->context_)));
v->VisitPointer(BitCast<Object**, Context**>(&(thread->context_)));
v->VisitPointer(&(thread->scheduled_exception_)); v->VisitPointer(&(thread->scheduled_exception_));
for (v8::TryCatch* block = thread->TryCatchHandler(); for (v8::TryCatch* block = thread->TryCatchHandler();
block != NULL; block != NULL;
block = TRY_CATCH_FROM_ADDRESS(block->next_)) { block = TRY_CATCH_FROM_ADDRESS(block->next_)) {
v->VisitPointer(BitCast<Object**, void**>(&(block->exception_))); v->VisitPointer(BitCast<Object**>(&(block->exception_)));
v->VisitPointer(BitCast<Object**, void**>(&(block->message_))); v->VisitPointer(BitCast<Object**>(&(block->message_)));
} }
// Iterate over pointers on native execution stack. // Iterate over pointers on native execution stack.
......
...@@ -739,7 +739,11 @@ inline Dest BitCast(const Source& source) { ...@@ -739,7 +739,11 @@ inline Dest BitCast(const Source& source) {
return dest; return dest;
} }
} } // namespace v8::internal template <class Dest, class Source>
inline Dest BitCast(Source* const & source) {
return BitCast<Dest>(reinterpret_cast<uintptr_t>(source));
}
} } // namespace v8::internal
#endif // V8_UTILS_H_ #endif // V8_UTILS_H_
...@@ -253,7 +253,7 @@ Operand::Operand(const Operand& operand, int32_t offset) { ...@@ -253,7 +253,7 @@ Operand::Operand(const Operand& operand, int32_t offset) {
int32_t disp_value = 0; int32_t disp_value = 0;
if (mode == 0x80 || is_baseless) { if (mode == 0x80 || is_baseless) {
// Mode 2 or mode 0 with rbp/r13 as base: Word displacement. // Mode 2 or mode 0 with rbp/r13 as base: Word displacement.
disp_value = *reinterpret_cast<const int32_t*>(&operand.buf_[disp_offset]); disp_value = *BitCast<const int32_t*>(&operand.buf_[disp_offset]);
} else if (mode == 0x40) { } else if (mode == 0x40) {
// Mode 1: Byte displacement. // Mode 1: Byte displacement.
disp_value = static_cast<signed char>(operand.buf_[disp_offset]); disp_value = static_cast<signed char>(operand.buf_[disp_offset]);
......
...@@ -108,8 +108,6 @@ ...@@ -108,8 +108,6 @@
'conditions': [ 'conditions': [
[ 'gcc_version==44', { [ 'gcc_version==44', {
'cflags': [ '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. # Avoid crashes with gcc 4.4 in the v8 test suite.
'-fno-tree-vrp', '-fno-tree-vrp',
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment