| 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 28 matching lines...) Expand all Loading... |
| 39 static Isolate* GetIsolateFrom(LocalContext* context) { | 39 static Isolate* GetIsolateFrom(LocalContext* context) { |
| 40 return reinterpret_cast<Isolate*>((*context)->GetIsolate()); | 40 return reinterpret_cast<Isolate*>((*context)->GetIsolate()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 | 43 |
| 44 static Handle<JSWeakSet> AllocateJSWeakSet(Isolate* isolate) { | 44 static Handle<JSWeakSet> AllocateJSWeakSet(Isolate* isolate) { |
| 45 Factory* factory = isolate->factory(); | 45 Factory* factory = isolate->factory(); |
| 46 Handle<Map> map = factory->NewMap(JS_WEAK_SET_TYPE, JSWeakSet::kSize); | 46 Handle<Map> map = factory->NewMap(JS_WEAK_SET_TYPE, JSWeakSet::kSize); |
| 47 Handle<JSObject> weakset_obj = factory->NewJSObjectFromMap(map); | 47 Handle<JSObject> weakset_obj = factory->NewJSObjectFromMap(map); |
| 48 Handle<JSWeakSet> weakset(JSWeakSet::cast(*weakset_obj)); | 48 Handle<JSWeakSet> weakset(JSWeakSet::cast(*weakset_obj)); |
| 49 // Do not use handles for the hash table, it would make entries strong. | 49 // Do not leak handles for the hash table, it would make entries strong. |
| 50 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 1); | 50 { |
| 51 weakset->set_table(*table); | 51 HandleScope scope(isolate); |
| 52 weakset->set_next(Smi::FromInt(0)); | 52 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 1); |
| 53 weakset->set_table(*table); |
| 54 } |
| 53 return weakset; | 55 return weakset; |
| 54 } | 56 } |
| 55 | 57 |
| 56 static void PutIntoWeakSet(Handle<JSWeakSet> weakset, | 58 static void PutIntoWeakSet(Handle<JSWeakSet> weakset, |
| 57 Handle<JSObject> key, | 59 Handle<JSObject> key, |
| 58 Handle<Object> value) { | 60 Handle<Object> value) { |
| 59 Handle<ObjectHashTable> table = ObjectHashTable::Put( | 61 Handle<ObjectHashTable> table = ObjectHashTable::Put( |
| 60 Handle<ObjectHashTable>(ObjectHashTable::cast(weakset->table())), | 62 Handle<ObjectHashTable>(ObjectHashTable::cast(weakset->table())), |
| 61 Handle<JSObject>(JSObject::cast(*key)), | 63 Handle<JSObject>(JSObject::cast(*key)), |
| 62 value); | 64 value); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 Handle<Smi>(Smi::FromInt(i), isolate)); | 248 Handle<Smi>(Smi::FromInt(i), isolate)); |
| 247 } | 249 } |
| 248 | 250 |
| 249 // Force compacting garbage collection. The subsequent collections are used | 251 // Force compacting garbage collection. The subsequent collections are used |
| 250 // to verify that key references were actually updated. | 252 // to verify that key references were actually updated. |
| 251 CHECK(FLAG_always_compact); | 253 CHECK(FLAG_always_compact); |
| 252 heap->CollectAllGarbage(Heap::kNoGCFlags); | 254 heap->CollectAllGarbage(Heap::kNoGCFlags); |
| 253 heap->CollectAllGarbage(Heap::kNoGCFlags); | 255 heap->CollectAllGarbage(Heap::kNoGCFlags); |
| 254 heap->CollectAllGarbage(Heap::kNoGCFlags); | 256 heap->CollectAllGarbage(Heap::kNoGCFlags); |
| 255 } | 257 } |
| OLD | NEW |