Reviewers: Erik Corry,

Description:
GcSafeCastToCode should not use Code::contains it is not evacuation safe.

[email protected]


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

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/frames.cc


Index: src/frames.cc
diff --git a/src/frames.cc b/src/frames.cc
index 4444aad486c893e0ef190c167da63768e4ab4783..21808570562c5244a4312f93dfd7f87e39e6ea67 100644
--- a/src/frames.cc
+++ b/src/frames.cc
@@ -1157,19 +1157,30 @@ JavaScriptFrame* StackFrameLocator::FindJavaScriptFrame(int n) { // -------------------------------------------------------------------------


-Code* InnerPointerToCodeCache::GcSafeCastToCode(HeapObject* object,
-                                                Address inner_pointer) {
-  Code* code = reinterpret_cast<Code*>(object);
-  ASSERT(code != NULL && code->contains(inner_pointer));
-  return code;
+static Map* GcSafeMapOfCodeSpaceObject(HeapObject* object) {
+  MapWord map_word = object->map_word();
+  return map_word.IsForwardingAddress() ?
+      map_word.ToForwardingAddress()->map() : map_word.ToMap();
 }


 static int GcSafeSizeOfCodeSpaceObject(HeapObject* object) {
-  MapWord map_word = object->map_word();
-  Map* map = map_word.IsForwardingAddress() ?
-      map_word.ToForwardingAddress()->map() : map_word.ToMap();
-  return object->SizeFromMap(map);
+  return object->SizeFromMap(GcSafeMapOfCodeSpaceObject(object));
+}
+
+
+Code* InnerPointerToCodeCache::GcSafeCastToCode(HeapObject* object,
+                                                Address inner_pointer) {
+  Code* code = reinterpret_cast<Code*>(object);
+#ifdef DEBUG
+  ASSERT(code != NULL);
+  Map* map = GcSafeMapOfCodeSpaceObject(code);
+  ASSERT(map == isolate_->heap()->code_map());
+  Address start = object->address();
+  Address end = object->address() + code->SizeFromMap(map);
+  ASSERT(start <= inner_pointer && inner_pointer < end);
+#endif
+  return code;
 }




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

Reply via email to