Reviewers: Mads Ager,

Message:
If you have a great idea on how to write a regression test case for this
issue, please let me know. It's somewhat difficult to write it because
it requires the TryFlatten call in SymbolKey::GetObject() to fail, and a
later flattening of the symbol to succeed.

Description:
Fix issue 303 by not shortcutting cons-symbols.

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

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

Affected files:
   M     src/heap.cc


Index: src/heap.cc
===================================================================
--- src/heap.cc (revision 1697)
+++ src/heap.cc (working copy)
@@ -813,12 +813,20 @@


  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();
  }





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

Reply via email to