Fix verification of weak maps during initialization.

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
This commit is contained in:
mstarzinger@chromium.org 2011-10-04 15:54:57 +00:00
parent c034518442
commit 2fb58638a6
6 changed files with 6 additions and 8 deletions

View File

@ -498,7 +498,7 @@ void JSWeakMap::JSWeakMapVerify() {
CHECK(IsJSWeakMap());
JSObjectVerify();
VerifyHeapPointer(table());
ASSERT(table()->IsHashTable());
ASSERT(table()->IsHashTable() || table()->IsUndefined());
}

View 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)

View 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");

View 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: {

View 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)

View 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;