Revision: 2692 Author: [email protected] Date: Fri Aug 14 10:19:51 2009 Log: Fix strict aliasing crash on x64.
Review URL: http://codereview.chromium.org/164498 http://code.google.com/p/v8/source/detail?r=2692 Modified: /branches/bleeding_edge/SConstruct /branches/bleeding_edge/src/compilation-cache.cc /branches/bleeding_edge/src/handles-inl.h /branches/bleeding_edge/src/handles.h ======================================= --- /branches/bleeding_edge/SConstruct Fri Aug 14 04:24:32 2009 +++ /branches/bleeding_edge/SConstruct Fri Aug 14 10:19:51 2009 @@ -169,7 +169,7 @@ }, 'arch:x64': { 'CPPDEFINES': ['V8_TARGET_ARCH_X64'], - 'CCFLAGS': ['-fno-strict-aliasing', '-m64'], + 'CCFLAGS': ['-m64'], 'LINKFLAGS': ['-m64'], }, 'prof:oprofile': { ======================================= --- /branches/bleeding_edge/src/compilation-cache.cc Wed Jul 22 03:23:19 2009 +++ /branches/bleeding_edge/src/compilation-cache.cc Fri Aug 14 10:19:51 2009 @@ -290,7 +290,6 @@ HandleScope scope; ASSERT(boilerplate->IsBoilerplate()); Handle<CompilationCacheTable> table = GetTable(0); - // TODO(X64): -fstrict-aliasing causes a problem with table. Fix it. CALL_HEAP_FUNCTION_VOID(table->Put(*source, *boilerplate)); } ======================================= --- /branches/bleeding_edge/src/handles-inl.h Mon May 25 03:05:56 2009 +++ /branches/bleeding_edge/src/handles-inl.h Fri Aug 14 10:19:51 2009 @@ -39,7 +39,7 @@ template<class T> Handle<T>::Handle(T* obj) { ASSERT(!obj->IsFailure()); - location_ = reinterpret_cast<T**>(HandleScope::CreateHandle(obj)); + location_ = HandleScope::CreateHandle(obj); } ======================================= --- /branches/bleeding_edge/src/handles.h Thu Jul 30 02:13:48 2009 +++ /branches/bleeding_edge/src/handles.h Fri Aug 14 10:19:51 2009 @@ -82,7 +82,7 @@ } static Handle<T> null() { return Handle<T>(); } - bool is_null() {return location_ == NULL; } + bool is_null() { return location_ == NULL; } // Closes the given scope, but lets this handle escape. See // implementation in api.h. @@ -119,15 +119,18 @@ static int NumberOfHandles(); // Creates a new handle with the given value. - static inline Object** CreateHandle(Object* value) { - void** result = current_.next; - if (result == current_.limit) result = Extend(); + template <typename T> + static inline T** CreateHandle(T* value) { + void** cur = current_.next; + if (cur == current_.limit) cur = Extend(); // Update the current next field, set the value in the created // handle, and return the result. - ASSERT(result < current_.limit); - current_.next = result + 1; - *reinterpret_cast<Object**>(result) = value; - return reinterpret_cast<Object**>(result); + ASSERT(cur < current_.limit); + current_.next = cur + 1; + + T** result = reinterpret_cast<T**>(cur); + *result = value; + return result; } private: --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
