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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 Isolate* isolate = CcTest::i_isolate(); | 133 Isolate* isolate = CcTest::i_isolate(); |
134 v8::HandleScope scope(context->GetIsolate()); | 134 v8::HandleScope scope(context->GetIsolate()); |
135 // Test almost filled table. | 135 // Test almost filled table. |
136 { | 136 { |
137 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 100); | 137 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 100); |
138 ObjectHashTableTest* t = reinterpret_cast<ObjectHashTableTest*>(*table); | 138 ObjectHashTableTest* t = reinterpret_cast<ObjectHashTableTest*>(*table); |
139 int capacity = t->capacity(); | 139 int capacity = t->capacity(); |
140 for (int i = 0; i < capacity - 1; i++) { | 140 for (int i = 0; i < capacity - 1; i++) { |
141 t->insert(i, i * i, i); | 141 t->insert(i, i * i, i); |
142 } | 142 } |
143 t->Rehash(Smi::FromInt(0)); | 143 t->Rehash(handle(Smi::FromInt(0), isolate)); |
144 for (int i = 0; i < capacity - 1; i++) { | 144 for (int i = 0; i < capacity - 1; i++) { |
145 CHECK_EQ(i, t->lookup(i * i)); | 145 CHECK_EQ(i, t->lookup(i * i)); |
146 } | 146 } |
147 } | 147 } |
148 // Test half-filled table. | 148 // Test half-filled table. |
149 { | 149 { |
150 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 100); | 150 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 100); |
151 ObjectHashTableTest* t = reinterpret_cast<ObjectHashTableTest*>(*table); | 151 ObjectHashTableTest* t = reinterpret_cast<ObjectHashTableTest*>(*table); |
152 int capacity = t->capacity(); | 152 int capacity = t->capacity(); |
153 for (int i = 0; i < capacity / 2; i++) { | 153 for (int i = 0; i < capacity / 2; i++) { |
154 t->insert(i, i * i, i); | 154 t->insert(i, i * i, i); |
155 } | 155 } |
156 t->Rehash(Smi::FromInt(0)); | 156 t->Rehash(handle(Smi::FromInt(0), isolate)); |
157 for (int i = 0; i < capacity / 2; i++) { | 157 for (int i = 0; i < capacity / 2; i++) { |
158 CHECK_EQ(i, t->lookup(i * i)); | 158 CHECK_EQ(i, t->lookup(i * i)); |
159 } | 159 } |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 | 163 |
164 #ifdef DEBUG | 164 #ifdef DEBUG |
165 template<class HashSet> | 165 template<class HashSet> |
166 static void TestHashSetCausesGC(Handle<HashSet> table) { | 166 static void TestHashSetCausesGC(Handle<HashSet> table) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 LocalContext context; | 239 LocalContext context; |
240 v8::HandleScope scope(context->GetIsolate()); | 240 v8::HandleScope scope(context->GetIsolate()); |
241 Isolate* isolate = CcTest::i_isolate(); | 241 Isolate* isolate = CcTest::i_isolate(); |
242 TestHashMapCausesGC(ObjectHashTable::New(isolate, 1)); | 242 TestHashMapCausesGC(ObjectHashTable::New(isolate, 1)); |
243 TestHashMapCausesGC(isolate->factory()->NewOrderedHashMap()); | 243 TestHashMapCausesGC(isolate->factory()->NewOrderedHashMap()); |
244 } | 244 } |
245 #endif | 245 #endif |
246 | 246 |
247 | 247 |
248 } | 248 } |
OLD | NEW |