OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 | 2 |
3 #include <stdlib.h> | 3 #include <stdlib.h> |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "execution.h" | 7 #include "execution.h" |
8 #include "factory.h" | 8 #include "factory.h" |
9 #include "macro-assembler.h" | 9 #include "macro-assembler.h" |
10 #include "global-handles.h" | 10 #include "global-handles.h" |
(...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1959 } | 1959 } |
1960 CHECK(t->IsSlicedString()); | 1960 CHECK(t->IsSlicedString()); |
1961 CHECK(!HEAP->InNewSpace(*t)); | 1961 CHECK(!HEAP->InNewSpace(*t)); |
1962 *slice.location() = *t.location(); | 1962 *slice.location() = *t.location(); |
1963 } | 1963 } |
1964 | 1964 |
1965 CHECK(SlicedString::cast(*slice)->parent()->IsSeqAsciiString()); | 1965 CHECK(SlicedString::cast(*slice)->parent()->IsSeqAsciiString()); |
1966 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1966 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
1967 CHECK(SlicedString::cast(*slice)->parent()->IsSeqAsciiString()); | 1967 CHECK(SlicedString::cast(*slice)->parent()->IsSeqAsciiString()); |
1968 } | 1968 } |
| 1969 |
| 1970 |
| 1971 TEST(Regress2211) { |
| 1972 InitializeVM(); |
| 1973 v8::HandleScope scope; |
| 1974 |
| 1975 Handle<String> key = v8::Utils::OpenHandle(*v8::String::New("key")); |
| 1976 Handle<String> val = v8::Utils::OpenHandle(*v8::String::New("val")); |
| 1977 Smi* hash = Smi::FromInt(321); |
| 1978 Heap* heap = Isolate::Current()->heap(); |
| 1979 |
| 1980 // Store identity hash first and common hidden property second. |
| 1981 Handle<JSObject> object = v8::Utils::OpenHandle(*v8::Object::New()); |
| 1982 CHECK(object->HasFastProperties()); |
| 1983 |
| 1984 MaybeObject* maybe_obj = object->SetIdentityHash(hash, ALLOW_CREATION); |
| 1985 CHECK(!maybe_obj->IsFailure()); |
| 1986 |
| 1987 DescriptorArray* descriptors = object->map()->instance_descriptors(); |
| 1988 Object* inline_stored = object->FastPropertyAt(descriptors->GetFieldIndex(0)); |
| 1989 CHECK_EQ(hash, Smi::cast(inline_stored)); |
| 1990 CHECK_EQ(hash, object->GetHiddenProperty(heap->identity_hash_symbol())); |
| 1991 |
| 1992 JSObject::SetHiddenProperty(object, key, val); |
| 1993 CHECK_EQ(hash, object->GetHiddenProperty(heap->identity_hash_symbol())); |
| 1994 CHECK(val->Equals(String::cast(object->GetHiddenProperty(*key)))); |
| 1995 |
| 1996 ObjectHashTable* hashtable = ObjectHashTable::cast( |
| 1997 object->FastPropertyAt(descriptors->GetFieldIndex(0))); |
| 1998 CHECK_LE(hashtable->SizeFor(hashtable->length()), 52); // Reasonable size. |
| 1999 |
| 2000 // Store common hidden property first and identity hash second. |
| 2001 object = v8::Utils::OpenHandle(*v8::Object::New()); |
| 2002 CHECK(object->HasFastProperties()); |
| 2003 |
| 2004 JSObject::SetHiddenProperty(object, key, val); |
| 2005 maybe_obj = object->SetIdentityHash(hash, ALLOW_CREATION); |
| 2006 CHECK(!maybe_obj->IsFailure()); |
| 2007 |
| 2008 CHECK_EQ(hash, object->GetHiddenProperty(heap->identity_hash_symbol())); |
| 2009 CHECK(val->Equals(String::cast(object->GetHiddenProperty(*key)))); |
| 2010 |
| 2011 descriptors = object->map()->instance_descriptors(); |
| 2012 hashtable = ObjectHashTable::cast( |
| 2013 object->FastPropertyAt(descriptors->GetFieldIndex(0))); |
| 2014 CHECK_LE(hashtable->SizeFor(hashtable->length()), 52); // Reasonable size. |
| 2015 } |
OLD | NEW |