Reviewers: Mads Ager, agl,

Description:
Fix strict aliasing crash on x64.

Please review this at http://codereview.chromium.org/164498

Affected files:
   M SConstruct
   M src/handles-inl.h
   M src/handles.h


Index: SConstruct
diff --git a/SConstruct b/SConstruct
index  
c981ef91398778d152e9205948e0d76a28fbeda2..e36b42468f75bce8657b31dcc54b889e2ba27c69
  
100644
--- a/SConstruct
+++ b/SConstruct
@@ -166,7 +166,7 @@ LIBRARY_FLAGS = {
      },
      'arch:x64': {
        'CPPDEFINES':   ['V8_TARGET_ARCH_X64'],
-      'CCFLAGS':      ['-fno-strict-aliasing', '-m64'],
+      'CCFLAGS':      ['-m64'],
        'LINKFLAGS':    ['-m64'],
      },
      'prof:oprofile': {
Index: src/handles-inl.h
diff --git a/src/handles-inl.h b/src/handles-inl.h
index  
6013c5b51e697181f1bc81e9d6ebdfa10712b768..8478bb5cd949b0472c96643661066c4f45f595fd
  
100644
--- a/src/handles-inl.h
+++ b/src/handles-inl.h
@@ -39,7 +39,7 @@ namespace internal {
  template<class T>
  Handle<T>::Handle(T* obj) {
    ASSERT(!obj->IsFailure());
-  location_ = reinterpret_cast<T**>(HandleScope::CreateHandle(obj));
+  location_ = HandleScope::CreateHandle(obj);
  }


Index: src/handles.h
diff --git a/src/handles.h b/src/handles.h
index  
ba2694f509eec5800e60af14ae0f66cea4063d93..8c9cbebfd91f2af9987cb2890d073dda0c16c8f3
  
100644
--- a/src/handles.h
+++ b/src/handles.h
@@ -82,7 +82,7 @@ class Handle {
    }

    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 @@ class HandleScope {
    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
-~----------~----~----~----~------~----~------~--~---

Reply via email to