Bug 1004028 - Enable assertion type validation on MSVC. r=Waldo,terrence
authorJan de Mooij <jdemooij@mozilla.com>
Sat, 24 Jan 2015 14:40:27 +0100
changeset 254319 88849e352ddcbca353ecf9ecc0c5222db5f56018
parent 254288 e4cea48ed2f5a3c23272d2693be6197c9480d750
child 254320 13f7779c31edff977a51176027472d2428b4704c
push id721
push userjlund@mozilla.com
push dateTue, 21 Apr 2015 23:03:33 +0000
treeherdermozilla-release@d27c9211ebb3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo, terrence
bugs1004028
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1004028 - Enable assertion type validation on MSVC. r=Waldo,terrence
js/src/jsgc.h
js/src/jsobj.h
mfbt/Assertions.h
--- a/js/src/jsgc.h
+++ b/js/src/jsgc.h
@@ -1147,17 +1147,19 @@ class RelocationOverlay
 
     Cell *forwardingAddress() const {
         MOZ_ASSERT(isForwarded());
         return newLocation_;
     }
 
     void forwardTo(Cell *cell) {
         MOZ_ASSERT(!isForwarded());
-        MOZ_ASSERT(JSObject::offsetOfShape() == offsetof(RelocationOverlay, newLocation_));
+        static_assert(offsetof(JSObject, shape_) == offsetof(RelocationOverlay, newLocation_),
+                      "forwarding pointer and shape should be at same location, "
+                      "so that obj->zone() works on forwarded objects");
         newLocation_ = cell;
         magic_ = Relocated;
         next_ = nullptr;
     }
 
     RelocationOverlay *next() const {
         return next_;
     }
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -34,16 +34,20 @@ namespace js {
 
 class AutoPropDescVector;
 class GCMarker;
 struct NativeIterator;
 class Nursery;
 class ObjectElements;
 struct StackShape;
 
+namespace gc {
+class RelocationOverlay;
+}
+
 inline JSObject *
 CastAsObject(PropertyOp op)
 {
     return JS_FUNC_TO_DATA_PTR(JSObject *, op);
 }
 
 inline JSObject *
 CastAsObject(StrictPropertyOp op)
@@ -112,16 +116,17 @@ class JSObject : public js::gc::Cell
      */
     js::HeapPtrTypeObject type_;
 
   private:
     friend class js::Shape;
     friend class js::GCMarker;
     friend class js::NewObjectCache;
     friend class js::Nursery;
+    friend class js::gc::RelocationOverlay;
     friend bool js::PreventExtensions(JSContext *cx, JS::HandleObject obj, bool *succeeded);
     friend bool js::SetImmutablePrototype(js::ExclusiveContext *cx, JS::HandleObject obj,
                                           bool *succeeded);
 
     /* Make the type object to use for LAZY_TYPE objects. */
     static js::types::TypeObject *makeLazyType(JSContext *cx, js::HandleObject obj);
 
   public:
--- a/mfbt/Assertions.h
+++ b/mfbt/Assertions.h
@@ -297,24 +297,16 @@ MOZ_ReportCrash(const char* aStr, const 
  */
 
 /*
  * Implement MOZ_VALIDATE_ASSERT_CONDITION_TYPE, which is used to guard against
  * accidentally passing something unintended in lieu of an assertion condition.
  */
 
 #ifdef __cplusplus
-#  if defined(__clang__) || defined(__GNUC__)
-#    define MOZ_SUPPORT_ASSERT_CONDITION_TYPE_VALIDATION
-#  elif defined(_MSC_VER)
-//   Disabled for now because of insufficient decltype support. Bug 1004028.
-#  endif
-#endif
-
-#ifdef MOZ_SUPPORT_ASSERT_CONDITION_TYPE_VALIDATION
 #  include "mozilla/TypeTraits.h"
 namespace mozilla {
 namespace detail {
 
 template<typename T>
 struct IsFunction
 {
   static const bool value = false;