Fix verification of weak maps during initialization.
authormstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 4 Oct 2011 15:54:57 +0000 (15:54 +0000)
committermstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 4 Oct 2011 15:54:57 +0000 (15:54 +0000)
R=rossberg@chromium.org

Review URL: http://codereview.chromium.org/8135003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9517 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/objects-debug.cc
src/objects-inl.h
src/objects-printer.cc
src/objects.cc
src/objects.h
src/runtime.cc

index 567a2787093705e62b6d5166a1b624376c351789..6d2cf5f72c042dc9ba16f82799c65bf51e261f57 100644 (file)
@@ -498,7 +498,7 @@ void JSWeakMap::JSWeakMapVerify() {
   CHECK(IsJSWeakMap());
   JSObjectVerify();
   VerifyHeapPointer(table());
-  ASSERT(table()->IsHashTable());
+  ASSERT(table()->IsHashTable() || table()->IsUndefined());
 }
 
 
index cd78471ce73718ddc8920ac8f40c532b8cc146ba..11b73d383582c1ebe525f94986df05495135ec20 100644 (file)
@@ -3887,7 +3887,7 @@ void JSProxy::InitializeBody(int object_size, Object* value) {
 }
 
 
-ACCESSORS(JSWeakMap, table, ObjectHashTable, kTableOffset)
+ACCESSORS(JSWeakMap, table, Object, kTableOffset)
 ACCESSORS_GCSAFE(JSWeakMap, next, Object, kNextOffset)
 
 
index aac79a65a86a6f9a410ea52754d44ef4e1f893e4..fc7573241afd97aaaca147bdfe6feaf04324ecb2 100644 (file)
@@ -708,7 +708,6 @@ void JSFunctionProxy::JSFunctionProxyPrint(FILE* out) {
 void JSWeakMap::JSWeakMapPrint(FILE* out) {
   HeapObject::PrintHeader(out, "JSWeakMap");
   PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map()));
-  PrintF(out, " - number of elements = %d\n", table()->NumberOfElements());
   PrintF(out, " - table = ");
   table()->ShortPrint(out);
   PrintF(out, "\n");
index 9e62e3fe0d212c88959986c9fb262836b6ec1161..105dfd101edcf5033a603870a0c16319d2b8f1c2 100644 (file)
@@ -1002,8 +1002,7 @@ void JSObject::JSObjectShortPrint(StringStream* accumulator) {
       break;
     }
     case JS_WEAK_MAP_TYPE: {
-      int elements = JSWeakMap::cast(this)->table()->NumberOfElements();
-      accumulator->Add("<JS WeakMap[%d]>", elements);
+      accumulator->Add("<JS WeakMap>");
       break;
     }
     case JS_REGEXP_TYPE: {
index 7b522e04a33b98ebc6a574b43fa02ea692a63ba0..74fb01257954d77788f4e3cfa2bf16d478b0f1fa 100644 (file)
@@ -6897,7 +6897,7 @@ class JSFunctionProxy: public JSProxy {
 class JSWeakMap: public JSObject {
  public:
   // [table]: the backing hash table mapping keys to values.
-  DECL_ACCESSORS(table, ObjectHashTable)
+  DECL_ACCESSORS(table, Object)
 
   // [next]: linked list of encountered weak maps during GC.
   DECL_ACCESSORS(next, Object)
index 89abf38414b3f0ae559e9f112f2cbef51e87eb3e..0e1ae4484948d806817af5b66ba71ae65f0f5802 100644 (file)
@@ -716,7 +716,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) {
   ASSERT(args.length() == 2);
   CONVERT_ARG_CHECKED(JSWeakMap, weakmap, 0);
   CONVERT_ARG_CHECKED(JSReceiver, key, 1);
-  return weakmap->table()->Lookup(*key);
+  return ObjectHashTable::cast(weakmap->table())->Lookup(*key);
 }
 
 
@@ -726,7 +726,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) {
   CONVERT_ARG_CHECKED(JSWeakMap, weakmap, 0);
   CONVERT_ARG_CHECKED(JSReceiver, key, 1);
   Handle<Object> value(args[2]);
-  Handle<ObjectHashTable> table(weakmap->table());
+  Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table()));
   Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value);
   weakmap->set_table(*new_table);
   return *value;