Index: test/cctest/test-heap.cc |
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc |
index daf45ad13edb08e2350c6f6aee6fb6945b4c56e4..a1ca9666e14846d7df65cba41608667379cb5a77 100644 |
--- a/test/cctest/test-heap.cc |
+++ b/test/cctest/test-heap.cc |
@@ -1984,3 +1984,39 @@ TEST(PrintSharedFunctionInfo) { |
g->shared()->PrintLn(); |
} |
#endif // OBJECT_PRINT |
+ |
+ |
+TEST(Regress2211) { |
+ InitializeVM(); |
+ v8::HandleScope scope; |
+ |
+ v8::Handle<v8::String> value = v8_str("val string"); |
+ Smi* hash = Smi::FromInt(321); |
+ Heap* heap = Isolate::Current()->heap(); |
+ |
+ for (int i = 0; i < 2; i++) { |
+ // Store identity hash first and common hidden property second. |
+ v8::Handle<v8::Object> obj = v8::Object::New(); |
+ Handle<JSObject> internal_obj = v8::Utils::OpenHandle(*obj); |
+ CHECK(internal_obj->HasFastProperties()); |
+ |
+ // In the first iteration, set hidden value first and identity hash second. |
+ // In the second iteration, reverse the order. |
+ if (i == 0) obj->SetHiddenValue(v8_str("key string"), value); |
+ MaybeObject* maybe_obj = internal_obj->SetIdentityHash(hash, |
+ ALLOW_CREATION); |
+ CHECK(!maybe_obj->IsFailure()); |
+ if (i == 1) obj->SetHiddenValue(v8_str("key string"), value); |
+ |
+ // Check values. |
+ CHECK_EQ(hash, |
+ internal_obj->GetHiddenProperty(heap->identity_hash_symbol())); |
+ CHECK(value->Equals(obj->GetHiddenValue(v8_str("key string")))); |
+ |
+ // Check size. |
+ DescriptorArray* descriptors = internal_obj->map()->instance_descriptors(); |
+ ObjectHashTable* hashtable = ObjectHashTable::cast( |
+ internal_obj->FastPropertyAt(descriptors->GetFieldIndex(0))); |
+ CHECK_LE(hashtable->SizeFor(hashtable->length()), 52); |
+ } |
+} |