Commit 903599a2 authored by deanm@chromium.org's avatar deanm@chromium.org

Fix strict aliasing crash on x64.

Review URL: http://codereview.chromium.org/164498


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2692 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 166cf2e4
...@@ -169,7 +169,7 @@ LIBRARY_FLAGS = { ...@@ -169,7 +169,7 @@ LIBRARY_FLAGS = {
}, },
'arch:x64': { 'arch:x64': {
'CPPDEFINES': ['V8_TARGET_ARCH_X64'], 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
'CCFLAGS': ['-fno-strict-aliasing', '-m64'], 'CCFLAGS': ['-m64'],
'LINKFLAGS': ['-m64'], 'LINKFLAGS': ['-m64'],
}, },
'prof:oprofile': { 'prof:oprofile': {
......
...@@ -290,7 +290,6 @@ void CompilationCacheScript::Put(Handle<String> source, ...@@ -290,7 +290,6 @@ void CompilationCacheScript::Put(Handle<String> source,
HandleScope scope; HandleScope scope;
ASSERT(boilerplate->IsBoilerplate()); ASSERT(boilerplate->IsBoilerplate());
Handle<CompilationCacheTable> table = GetTable(0); Handle<CompilationCacheTable> table = GetTable(0);
// TODO(X64): -fstrict-aliasing causes a problem with table. Fix it.
CALL_HEAP_FUNCTION_VOID(table->Put(*source, *boilerplate)); CALL_HEAP_FUNCTION_VOID(table->Put(*source, *boilerplate));
} }
......
...@@ -39,7 +39,7 @@ namespace internal { ...@@ -39,7 +39,7 @@ namespace internal {
template<class T> template<class T>
Handle<T>::Handle(T* obj) { Handle<T>::Handle(T* obj) {
ASSERT(!obj->IsFailure()); ASSERT(!obj->IsFailure());
location_ = reinterpret_cast<T**>(HandleScope::CreateHandle(obj)); location_ = HandleScope::CreateHandle(obj);
} }
......
...@@ -82,7 +82,7 @@ class Handle { ...@@ -82,7 +82,7 @@ class Handle {
} }
static Handle<T> null() { return Handle<T>(); } 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 // Closes the given scope, but lets this handle escape. See
// implementation in api.h. // implementation in api.h.
...@@ -119,15 +119,18 @@ class HandleScope { ...@@ -119,15 +119,18 @@ class HandleScope {
static int NumberOfHandles(); static int NumberOfHandles();
// Creates a new handle with the given value. // Creates a new handle with the given value.
static inline Object** CreateHandle(Object* value) { template <typename T>
void** result = current_.next; static inline T** CreateHandle(T* value) {
if (result == current_.limit) result = Extend(); void** cur = current_.next;
if (cur == current_.limit) cur = Extend();
// Update the current next field, set the value in the created // Update the current next field, set the value in the created
// handle, and return the result. // handle, and return the result.
ASSERT(result < current_.limit); ASSERT(cur < current_.limit);
current_.next = result + 1; current_.next = cur + 1;
*reinterpret_cast<Object**>(result) = value;
return reinterpret_cast<Object**>(result); T** result = reinterpret_cast<T**>(cur);
*result = value;
return result;
} }
private: private:
......
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