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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 CHECK_EQ(table->FindEntry(key), HashMap::kNotFound); | 92 CHECK_EQ(table->FindEntry(key), HashMap::kNotFound); |
93 CHECK_EQ(table->Lookup(key), CcTest::heap()->the_hole_value()); | 93 CHECK_EQ(table->Lookup(key), CcTest::heap()->the_hole_value()); |
94 CHECK(key->GetIdentityHash()->IsSmi()); | 94 CHECK(key->GetIdentityHash()->IsSmi()); |
95 } | 95 } |
96 | 96 |
97 // Keys that don't have an identity hash should not be found and also | 97 // Keys that don't have an identity hash should not be found and also |
98 // should not get an identity hash code generated. | 98 // should not get an identity hash code generated. |
99 for (int i = 0; i < 100; i++) { | 99 for (int i = 0; i < 100; i++) { |
100 Handle<JSReceiver> key = factory->NewJSArray(7); | 100 Handle<JSReceiver> key = factory->NewJSArray(7); |
101 CHECK_EQ(table->Lookup(key), CcTest::heap()->the_hole_value()); | 101 CHECK_EQ(table->Lookup(key), CcTest::heap()->the_hole_value()); |
102 CHECK_EQ(key->GetIdentityHash(), | 102 Object* identity_hash = key->GetIdentityHash(); |
103 CcTest::heap()->undefined_value()); | 103 CHECK_EQ(identity_hash, CcTest::heap()->undefined_value()); |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 | 107 |
108 TEST(HashMap) { | 108 TEST(HashMap) { |
109 LocalContext context; | 109 LocalContext context; |
110 v8::HandleScope scope(context->GetIsolate()); | 110 v8::HandleScope scope(context->GetIsolate()); |
111 Isolate* isolate = CcTest::i_isolate(); | 111 Isolate* isolate = CcTest::i_isolate(); |
112 TestHashMap(ObjectHashTable::New(isolate, 23)); | 112 TestHashMap(ObjectHashTable::New(isolate, 23)); |
113 TestHashMap(isolate->factory()->NewOrderedHashMap()); | 113 TestHashMap(isolate->factory()->NewOrderedHashMap()); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 LocalContext context; | 245 LocalContext context; |
246 v8::HandleScope scope(context->GetIsolate()); | 246 v8::HandleScope scope(context->GetIsolate()); |
247 Isolate* isolate = CcTest::i_isolate(); | 247 Isolate* isolate = CcTest::i_isolate(); |
248 TestHashMapCausesGC(ObjectHashTable::New(isolate, 1)); | 248 TestHashMapCausesGC(ObjectHashTable::New(isolate, 1)); |
249 TestHashMapCausesGC(isolate->factory()->NewOrderedHashMap()); | 249 TestHashMapCausesGC(isolate->factory()->NewOrderedHashMap()); |
250 } | 250 } |
251 #endif | 251 #endif |
252 | 252 |
253 | 253 |
254 } | 254 } |
OLD | NEW |