Fixed issue 303 by not shortcutting cons-symbols and added

symbol table verification after mark-compact GCs.
Review URL: http://codereview.chromium.org/73029

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1698 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
kasperl@chromium.org 2009-04-14 09:58:42 +00:00
parent c77875113c
commit 850d5ed380
2 changed files with 17 additions and 5 deletions

View File

@ -813,12 +813,20 @@ void Heap::ScavengeObject(HeapObject** p, HeapObject* object) {
static inline bool IsShortcutCandidate(HeapObject* object, Map* map) {
// A ConsString object with Heap::empty_string() as the right side
// is a candidate for being shortcut by the scavenger.
// A ConsString with an empty string as the right side is a
// candidate for being shortcut by the scavenger unless it is a
// symbol. It's not common to have non-flat symbols, so we do not
// shortcut them thereby avoiding turning symbols into strings.
ASSERT(kNotStringTag != 0 && kSymbolTag != 0);
static const uint32_t kShortcutTypeMask =
kIsNotStringMask |
kIsSymbolMask |
kStringRepresentationMask;
ASSERT(object->map() == map);
if (map->instance_type() >= FIRST_NONSTRING_TYPE) return false;
return (StringShape(map).representation_tag() == kConsStringTag) &&
(ConsString::cast(object)->unchecked_second() == Heap::empty_string());
InstanceType type = map->instance_type();
if ((type & kShortcutTypeMask) != kConsStringTag) return false;
ASSERT(object->IsString() && !object->IsSymbol());
return ConsString::cast(object)->unchecked_second() == Heap::empty_string();
}

View File

@ -183,6 +183,10 @@ void MarkCompactCollector::Prepare(GCTracer* tracer) {
void MarkCompactCollector::Finish() {
#ifdef DEBUG
SymbolTable* symbol_table = SymbolTable::cast(Heap::symbol_table());
SymbolTableVerifier v;
symbol_table->IterateElements(&v);
ASSERT(state_ == SWEEP_SPACES || state_ == REBUILD_RSETS);
state_ = IDLE;
#endif