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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // Perform two consecutive GCs because the first one will only clear | 117 // Perform two consecutive GCs because the first one will only clear |
118 // weak references whereas the second one will also clear weak maps. | 118 // weak references whereas the second one will also clear weak maps. |
119 heap->CollectAllGarbage(false); | 119 heap->CollectAllGarbage(false); |
120 CHECK_EQ(1, NumberOfWeakCalls); | 120 CHECK_EQ(1, NumberOfWeakCalls); |
121 CHECK_EQ(2, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); | 121 CHECK_EQ(2, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); |
122 CHECK_EQ( | 122 CHECK_EQ( |
123 0, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); | 123 0, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); |
124 heap->CollectAllGarbage(false); | 124 heap->CollectAllGarbage(false); |
125 CHECK_EQ(1, NumberOfWeakCalls); | 125 CHECK_EQ(1, NumberOfWeakCalls); |
126 CHECK_EQ(0, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); | 126 CHECK_EQ(0, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); |
127 CHECK_EQ(0, | 127 CHECK_EQ(2, |
128 ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); | 128 ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); |
129 } | 129 } |
130 | 130 |
131 | 131 |
132 TEST(Shrinking) { | 132 TEST(Shrinking) { |
133 LocalContext context; | 133 LocalContext context; |
134 Isolate* isolate = GetIsolateFrom(&context); | 134 Isolate* isolate = GetIsolateFrom(&context); |
135 Factory* factory = isolate->factory(); | 135 Factory* factory = isolate->factory(); |
136 Heap* heap = isolate->heap(); | 136 Heap* heap = isolate->heap(); |
137 HandleScope scope(isolate); | 137 HandleScope scope(isolate); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 { | 258 { |
259 HandleScope scope(isolate); | 259 HandleScope scope(isolate); |
260 AllocateJSWeakMap(isolate); | 260 AllocateJSWeakMap(isolate); |
261 SimulateIncrementalMarking(heap); | 261 SimulateIncrementalMarking(heap); |
262 } | 262 } |
263 // The weak map is marked black here but leaving the handle scope will make | 263 // The weak map is marked black here but leaving the handle scope will make |
264 // the object unreachable. Aborting incremental marking will clear all the | 264 // the object unreachable. Aborting incremental marking will clear all the |
265 // marking bits which makes the weak map garbage. | 265 // marking bits which makes the weak map garbage. |
266 heap->CollectAllGarbage(); | 266 heap->CollectAllGarbage(); |
267 } | 267 } |
OLD | NEW |