Chromium Code Reviews| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 key_obj->SetHiddenValue(v8_str("key 1"), v8_str("val 1")); | 168 key_obj->SetHiddenValue(v8_str("key 1"), v8_str("val 1")); |
| 169 key_obj->SetHiddenValue(v8_str("key 2"), v8_str("val 2")); | 169 key_obj->SetHiddenValue(v8_str("key 2"), v8_str("val 2")); |
| 170 key_obj->SetHiddenValue(v8_str("key 3"), v8_str("val 3")); | 170 key_obj->SetHiddenValue(v8_str("key 3"), v8_str("val 3")); |
| 171 | 171 |
| 172 // Simulate a full heap so that generating an identity hash code | 172 // Simulate a full heap so that generating an identity hash code |
| 173 // in subsequent calls will request GC. | 173 // in subsequent calls will request GC. |
| 174 SimulateFullSpace(CcTest::heap()->new_space()); | 174 SimulateFullSpace(CcTest::heap()->new_space()); |
| 175 SimulateFullSpace(CcTest::heap()->old_pointer_space()); | 175 SimulateFullSpace(CcTest::heap()->old_pointer_space()); |
| 176 | 176 |
| 177 // Calling Contains() should not cause GC ever. | 177 // Calling Contains() should not cause GC ever. |
| 178 CHECK(!table->Contains(*key)); | 178 int gc_count = isolate->heap()->gc_count(); |
|
rafaelw
2013/10/29 19:14:51
I just took a guess at how to address this test.
Michael Starzinger
2013/11/04 10:29:11
Yes, I think using the GC-count makes sense.
| |
| 179 CHECK(!ObjectHashSet::Contains(table, key)); | |
| 180 CHECK(gc_count == isolate->heap()->gc_count()); | |
| 179 | 181 |
| 180 // Calling Remove() should not cause GC ever. | 182 // Calling Remove() should not cause GC ever. |
|
rafaelw
2013/10/29 19:14:51
This comment doesn't seem true. I believe it's alw
Michael Starzinger
2013/11/04 10:29:11
You are right, the comment only holds for a HashSe
rafaelw
2013/11/04 15:12:01
Done.
| |
| 181 CHECK(!table->Remove(*key)->IsFailure()); | 183 table = ObjectHashSet::Remove(table, key); |
| 184 CHECK(gc_count == isolate->heap()->gc_count()); | |
| 182 | 185 |
| 183 // Calling Add() should request GC by returning a failure. | 186 // Calling Add() should cause GC. |
| 184 CHECK(table->Add(*key)->IsRetryAfterGC()); | 187 table = ObjectHashSet::Add(table, key); |
| 188 CHECK(gc_count < isolate->heap()->gc_count()); | |
| 185 } | 189 } |
| 186 #endif | 190 #endif |
| 187 | 191 |
| 188 | 192 |
| 189 #ifdef DEBUG | 193 #ifdef DEBUG |
| 190 TEST(ObjectHashTableCausesGC) { | 194 TEST(ObjectHashTableCausesGC) { |
| 191 i::FLAG_stress_compaction = false; | 195 i::FLAG_stress_compaction = false; |
| 192 LocalContext context; | 196 LocalContext context; |
| 193 Isolate* isolate = CcTest::i_isolate(); | 197 Isolate* isolate = CcTest::i_isolate(); |
| 194 Factory* factory = isolate->factory(); | 198 Factory* factory = isolate->factory(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 207 SimulateFullSpace(CcTest::heap()->new_space()); | 211 SimulateFullSpace(CcTest::heap()->new_space()); |
| 208 SimulateFullSpace(CcTest::heap()->old_pointer_space()); | 212 SimulateFullSpace(CcTest::heap()->old_pointer_space()); |
| 209 | 213 |
| 210 // Calling Lookup() should not cause GC ever. | 214 // Calling Lookup() should not cause GC ever. |
| 211 CHECK(table->Lookup(*key)->IsTheHole()); | 215 CHECK(table->Lookup(*key)->IsTheHole()); |
| 212 | 216 |
| 213 // Calling Put() should request GC by returning a failure. | 217 // Calling Put() should request GC by returning a failure. |
| 214 CHECK(table->Put(*key, *key)->IsRetryAfterGC()); | 218 CHECK(table->Put(*key, *key)->IsRetryAfterGC()); |
| 215 } | 219 } |
| 216 #endif | 220 #endif |
| OLD | NEW |