| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 55 } |
| 56 return weakset; | 56 return weakset; |
| 57 } | 57 } |
| 58 | 58 |
| 59 static int NumberOfWeakCalls = 0; | 59 static int NumberOfWeakCalls = 0; |
| 60 static void WeakPointerCallback( | 60 static void WeakPointerCallback( |
| 61 const v8::WeakCallbackData<v8::Value, void>& data) { | 61 const v8::WeakCallbackData<v8::Value, void>& data) { |
| 62 std::pair<v8::Persistent<v8::Value>*, int>* p = | 62 std::pair<v8::Persistent<v8::Value>*, int>* p = |
| 63 reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>( | 63 reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>( |
| 64 data.GetParameter()); | 64 data.GetParameter()); |
| 65 DCHECK_EQ(1234, p->second); | 65 CHECK_EQ(1234, p->second); |
| 66 NumberOfWeakCalls++; | 66 NumberOfWeakCalls++; |
| 67 p->first->Reset(); | 67 p->first->Reset(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 | 70 |
| 71 TEST(WeakSet_Weakness) { | 71 TEST(WeakSet_Weakness) { |
| 72 FLAG_incremental_marking = false; | 72 FLAG_incremental_marking = false; |
| 73 LocalContext context; | 73 LocalContext context; |
| 74 Isolate* isolate = GetIsolateFrom(&context); | 74 Isolate* isolate = GetIsolateFrom(&context); |
| 75 Factory* factory = isolate->factory(); | 75 Factory* factory = isolate->factory(); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 JSWeakCollection::Set(weakset, keys[i], smi, hash); | 242 JSWeakCollection::Set(weakset, keys[i], smi, hash); |
| 243 } | 243 } |
| 244 | 244 |
| 245 // Force compacting garbage collection. The subsequent collections are used | 245 // Force compacting garbage collection. The subsequent collections are used |
| 246 // to verify that key references were actually updated. | 246 // to verify that key references were actually updated. |
| 247 CHECK(FLAG_always_compact); | 247 CHECK(FLAG_always_compact); |
| 248 heap->CollectAllGarbage(); | 248 heap->CollectAllGarbage(); |
| 249 heap->CollectAllGarbage(); | 249 heap->CollectAllGarbage(); |
| 250 heap->CollectAllGarbage(); | 250 heap->CollectAllGarbage(); |
| 251 } | 251 } |
| OLD | NEW |