Revision: 7067
Author: [email protected]
Date: Sat Mar  5 06:27:59 2011
Log: [Isolates] Add debugging code to ensure consistent Isolate class layout.

Review URL: http://codereview.chromium.org/6628036
http://code.google.com/p/v8/source/detail?r=7067

Modified:
 /branches/experimental/isolates/src/isolate.cc
 /branches/experimental/isolates/src/isolate.h

=======================================
--- /branches/experimental/isolates/src/isolate.cc      Thu Mar  3 00:38:10 2011
+++ /branches/experimental/isolates/src/isolate.cc      Sat Mar  5 06:27:59 2011
@@ -800,5 +800,14 @@
 void Isolate::ResetEagerOptimizingData() {
   compilation_cache_->ResetEagerOptimizingData();
 }
+
+
+#ifdef DEBUG
+#define ISOLATE_FIELD_OFFSET(type, name, ignored)                       \
+const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
+ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
+ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
+#undef ISOLATE_FIELD_OFFSET
+#endif

 } }  // namespace v8::internal
=======================================
--- /branches/experimental/isolates/src/isolate.h       Fri Mar  4 13:26:57 2011
+++ /branches/experimental/isolates/src/isolate.h       Sat Mar  5 06:27:59 2011
@@ -669,14 +669,23 @@
   static const int kBMMaxShift = 250;        // See StringSearchBase.

   // Accessors.
-#define GLOBAL_ACCESSOR(type, name, initialvalue) \ - type name() const { return name##_; } \
-  void set_##name(type value) { name##_ = value; }
+#define GLOBAL_ACCESSOR(type, name, initialvalue)                       \
+  inline type name() const {                                            \
+    ASSERT(OFFSET_OF(Isolate, name##_) == name##_debug_offset_);        \
+    return name##_;                                                     \
+  }                                                                     \
+  inline void set_##name(type value) {                                  \
+    ASSERT(OFFSET_OF(Isolate, name##_) == name##_debug_offset_);        \
+    name##_ = value;                                                    \
+  }
   ISOLATE_INIT_LIST(GLOBAL_ACCESSOR)
 #undef GLOBAL_ACCESSOR

-#define GLOBAL_ARRAY_ACCESSOR(type, name, length) \
-  type* name() { return &(name##_[0]); }
+#define GLOBAL_ARRAY_ACCESSOR(type, name, length)                       \
+  inline type* name() {                                                 \
+    ASSERT(OFFSET_OF(Isolate, name##_) == name##_debug_offset_);        \
+    return &(name##_)[0];                                               \
+  }
   ISOLATE_INIT_ARRAY_LIST(GLOBAL_ARRAY_ACCESSOR)
 #undef GLOBAL_ARRAY_ACCESSOR

@@ -1090,6 +1099,17 @@
   ISOLATE_INIT_ARRAY_LIST(GLOBAL_ARRAY_BACKING_STORE)
 #undef GLOBAL_ARRAY_BACKING_STORE

+#ifdef DEBUG
+  // This class is huge and has a number of fields controlled by
+  // preprocessor defines. Make sure the offsets of these fields agree
+  // between compilation units.
+#define ISOLATE_FIELD_OFFSET(type, name, ignored) \
+  static const intptr_t name##_debug_offset_;
+  ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
+  ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
+#undef ISOLATE_FIELD_OFFSET
+#endif
+
   friend class ExecutionAccess;
   friend class IsolateInitializer;
   friend class v8::Isolate;

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to