OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 Isolate* isolate = CcTest::i_isolate(); | 205 Isolate* isolate = CcTest::i_isolate(); |
206 v8::HandleScope scope(context->GetIsolate()); | 206 v8::HandleScope scope(context->GetIsolate()); |
207 // Test almost filled table. | 207 // Test almost filled table. |
208 { | 208 { |
209 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 100); | 209 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 100); |
210 ObjectHashTableTest* t = reinterpret_cast<ObjectHashTableTest*>(*table); | 210 ObjectHashTableTest* t = reinterpret_cast<ObjectHashTableTest*>(*table); |
211 int capacity = t->capacity(); | 211 int capacity = t->capacity(); |
212 for (int i = 0; i < capacity - 1; i++) { | 212 for (int i = 0; i < capacity - 1; i++) { |
213 t->insert(i, i * i, i); | 213 t->insert(i, i * i, i); |
214 } | 214 } |
215 t->Rehash(handle(Smi::kZero, isolate)); | 215 t->Rehash(handle(Smi::FromInt(0), isolate)); |
216 for (int i = 0; i < capacity - 1; i++) { | 216 for (int i = 0; i < capacity - 1; i++) { |
217 CHECK_EQ(i, t->lookup(i * i)); | 217 CHECK_EQ(i, t->lookup(i * i)); |
218 } | 218 } |
219 } | 219 } |
220 // Test half-filled table. | 220 // Test half-filled table. |
221 { | 221 { |
222 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 100); | 222 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 100); |
223 ObjectHashTableTest* t = reinterpret_cast<ObjectHashTableTest*>(*table); | 223 ObjectHashTableTest* t = reinterpret_cast<ObjectHashTableTest*>(*table); |
224 int capacity = t->capacity(); | 224 int capacity = t->capacity(); |
225 for (int i = 0; i < capacity / 2; i++) { | 225 for (int i = 0; i < capacity / 2; i++) { |
226 t->insert(i, i * i, i); | 226 t->insert(i, i * i, i); |
227 } | 227 } |
228 t->Rehash(handle(Smi::kZero, isolate)); | 228 t->Rehash(handle(Smi::FromInt(0), isolate)); |
229 for (int i = 0; i < capacity / 2; i++) { | 229 for (int i = 0; i < capacity / 2; i++) { |
230 CHECK_EQ(i, t->lookup(i * i)); | 230 CHECK_EQ(i, t->lookup(i * i)); |
231 } | 231 } |
232 } | 232 } |
233 } | 233 } |
234 | 234 |
235 | 235 |
236 #ifdef DEBUG | 236 #ifdef DEBUG |
237 template<class HashSet> | 237 template<class HashSet> |
238 static void TestHashSetCausesGC(Handle<HashSet> table) { | 238 static void TestHashSetCausesGC(Handle<HashSet> table) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 #endif | 297 #endif |
298 | 298 |
299 TEST(SetRequiresCopyOnCapacityChange) { | 299 TEST(SetRequiresCopyOnCapacityChange) { |
300 LocalContext context; | 300 LocalContext context; |
301 v8::HandleScope scope(context->GetIsolate()); | 301 v8::HandleScope scope(context->GetIsolate()); |
302 Isolate* isolate = CcTest::i_isolate(); | 302 Isolate* isolate = CcTest::i_isolate(); |
303 Handle<NameDictionary> dict = NameDictionary::New(isolate, 0, TENURED); | 303 Handle<NameDictionary> dict = NameDictionary::New(isolate, 0, TENURED); |
304 dict->SetRequiresCopyOnCapacityChange(); | 304 dict->SetRequiresCopyOnCapacityChange(); |
305 Handle<Name> key = isolate->factory()->InternalizeString( | 305 Handle<Name> key = isolate->factory()->InternalizeString( |
306 v8::Utils::OpenHandle(*v8_str("key"))); | 306 v8::Utils::OpenHandle(*v8_str("key"))); |
307 Handle<Object> value = handle(Smi::kZero, isolate); | 307 Handle<Object> value = handle(Smi::FromInt(0), isolate); |
308 Handle<NameDictionary> new_dict = | 308 Handle<NameDictionary> new_dict = |
309 NameDictionary::Add(dict, key, value, PropertyDetails::Empty()); | 309 NameDictionary::Add(dict, key, value, PropertyDetails::Empty()); |
310 CHECK_NE(*dict, *new_dict); | 310 CHECK_NE(*dict, *new_dict); |
311 } | 311 } |
312 | 312 |
313 } // namespace | 313 } // namespace |
OLD | NEW |