| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 CcTest::heap()->CollectGarbage(NEW_SPACE); | 57 CcTest::heap()->CollectGarbage(NEW_SPACE); |
| 58 CHECK_EQ(table->NumberOfElements(), 1); | 58 CHECK_EQ(table->NumberOfElements(), 1); |
| 59 CHECK_EQ(table->Lookup(a), *b); | 59 CHECK_EQ(table->Lookup(a), *b); |
| 60 CHECK_EQ(table->Lookup(b), CcTest::heap()->the_hole_value()); | 60 CHECK_EQ(table->Lookup(b), CcTest::heap()->the_hole_value()); |
| 61 | 61 |
| 62 // Keys that are overwritten should not change number of elements. | 62 // Keys that are overwritten should not change number of elements. |
| 63 table = HashMap::Put(table, a, factory->NewJSArray(13)); | 63 table = HashMap::Put(table, a, factory->NewJSArray(13)); |
| 64 CHECK_EQ(table->NumberOfElements(), 1); | 64 CHECK_EQ(table->NumberOfElements(), 1); |
| 65 CHECK_NE(table->Lookup(a), *b); | 65 CHECK_NE(table->Lookup(a), *b); |
| 66 | 66 |
| 67 // Keys mapped to the hole should be removed permanently. | 67 table = HashMap::Remove(table, a); |
| 68 table = HashMap::Put(table, a, factory->the_hole_value()); | |
| 69 CHECK_EQ(table->NumberOfElements(), 0); | 68 CHECK_EQ(table->NumberOfElements(), 0); |
| 70 CHECK_EQ(table->Lookup(a), CcTest::heap()->the_hole_value()); | 69 CHECK_EQ(table->Lookup(a), CcTest::heap()->the_hole_value()); |
| 71 | 70 |
| 72 // Keys should map back to their respective values and also should get | 71 // Keys should map back to their respective values and also should get |
| 73 // an identity hash code generated. | 72 // an identity hash code generated. |
| 74 for (int i = 0; i < 100; i++) { | 73 for (int i = 0; i < 100; i++) { |
| 75 Handle<JSReceiver> key = factory->NewJSArray(7); | 74 Handle<JSReceiver> key = factory->NewJSArray(7); |
| 76 Handle<JSObject> value = factory->NewJSArray(11); | 75 Handle<JSObject> value = factory->NewJSArray(11); |
| 77 table = HashMap::Put(table, key, value); | 76 table = HashMap::Put(table, key, value); |
| 78 CHECK_EQ(table->NumberOfElements(), i + 1); | 77 CHECK_EQ(table->NumberOfElements(), i + 1); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 LocalContext context; | 241 LocalContext context; |
| 243 v8::HandleScope scope(context->GetIsolate()); | 242 v8::HandleScope scope(context->GetIsolate()); |
| 244 Isolate* isolate = CcTest::i_isolate(); | 243 Isolate* isolate = CcTest::i_isolate(); |
| 245 TestHashMapCausesGC(ObjectHashTable::New(isolate, 1)); | 244 TestHashMapCausesGC(ObjectHashTable::New(isolate, 1)); |
| 246 TestHashMapCausesGC(isolate->factory()->NewOrderedHashMap()); | 245 TestHashMapCausesGC(isolate->factory()->NewOrderedHashMap()); |
| 247 } | 246 } |
| 248 #endif | 247 #endif |
| 249 | 248 |
| 250 | 249 |
| 251 } | 250 } |
| OLD | NEW |