Revision: 9345
Author: [email protected]
Date: Tue Sep 20 06:36:52 2011
Log: GcSafeCastToCode should not use Code::contains it is not
evacuation safe.
[email protected]
Review URL: http://codereview.chromium.org/7980004
http://code.google.com/p/v8/source/detail?r=9345
Modified:
/branches/bleeding_edge/src/frames.cc
=======================================
--- /branches/bleeding_edge/src/frames.cc Tue Sep 20 03:08:39 2011
+++ /branches/bleeding_edge/src/frames.cc Tue Sep 20 06:36:52 2011
@@ -391,13 +391,18 @@
StackHandlerIterator it(this, top_handler());
return !it.done();
}
+
+
+#ifdef DEBUG
+static bool GcSafeCodeContains(HeapObject* object, Address addr);
+#endif
void StackFrame::IteratePc(ObjectVisitor* v,
Address* pc_address,
Code* holder) {
Address pc = *pc_address;
- ASSERT(holder->contains(pc));
+ ASSERT(GcSafeCodeContains(holder, pc));
unsigned pc_offset = static_cast<unsigned>(pc -
holder->instruction_start());
Object* code = holder;
v->VisitPointer(&code);
@@ -1157,19 +1162,34 @@
//
-------------------------------------------------------------------------
-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));
+}
+
+
+#ifdef DEBUG
+static bool GcSafeCodeContains(HeapObject* code, Address addr) {
+ Map* map = GcSafeMapOfCodeSpaceObject(code);
+ ASSERT(map == code->GetHeap()->code_map());
+ Address start = code->address();
+ Address end = code->address() + code->SizeFromMap(map);
+ return start <= addr && addr < end;
+}
+#endif
+
+
+Code* InnerPointerToCodeCache::GcSafeCastToCode(HeapObject* object,
+ Address inner_pointer) {
+ Code* code = reinterpret_cast<Code*>(object);
+ ASSERT(code != NULL && GcSafeCodeContains(code, inner_pointer));
+ return code;
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev