Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: test/cctest/test-weaksets.cc

Issue 891473005: Add WeakKeyMap to v8.h (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Renamed WeakKeyMap to NativeWeakMap as suggested in review comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-weakmaps.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 HandleScope scope(isolate); 51 HandleScope scope(isolate);
52 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 1); 52 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 1);
53 weakset->set_table(*table); 53 weakset->set_table(*table);
54 } 54 }
55 return weakset; 55 return weakset;
56 } 56 }
57 57
58 static void PutIntoWeakSet(Handle<JSWeakSet> weakset, 58 static void PutIntoWeakSet(Handle<JSWeakSet> weakset,
59 Handle<JSObject> key, 59 Handle<JSObject> key,
60 Handle<Object> value) { 60 Handle<Object> value) {
61 Handle<ObjectHashTable> table = ObjectHashTable::Put( 61 Runtime::WeakCollectionSet(weakset, key, value);
62 Handle<ObjectHashTable>(ObjectHashTable::cast(weakset->table())),
63 Handle<JSObject>(JSObject::cast(*key)),
64 value);
65 weakset->set_table(*table);
66 } 62 }
67 63
68 static int NumberOfWeakCalls = 0; 64 static int NumberOfWeakCalls = 0;
69 static void WeakPointerCallback( 65 static void WeakPointerCallback(
70 const v8::WeakCallbackData<v8::Value, void>& data) { 66 const v8::WeakCallbackData<v8::Value, void>& data) {
71 std::pair<v8::Persistent<v8::Value>*, int>* p = 67 std::pair<v8::Persistent<v8::Value>*, int>* p =
72 reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>( 68 reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>(
73 data.GetParameter()); 69 data.GetParameter());
74 DCHECK_EQ(1234, p->second); 70 DCHECK_EQ(1234, p->second);
75 NumberOfWeakCalls++; 71 NumberOfWeakCalls++;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 Handle<Smi>(Smi::FromInt(i), isolate)); 244 Handle<Smi>(Smi::FromInt(i), isolate));
249 } 245 }
250 246
251 // Force compacting garbage collection. The subsequent collections are used 247 // Force compacting garbage collection. The subsequent collections are used
252 // to verify that key references were actually updated. 248 // to verify that key references were actually updated.
253 CHECK(FLAG_always_compact); 249 CHECK(FLAG_always_compact);
254 heap->CollectAllGarbage(Heap::kNoGCFlags); 250 heap->CollectAllGarbage(Heap::kNoGCFlags);
255 heap->CollectAllGarbage(Heap::kNoGCFlags); 251 heap->CollectAllGarbage(Heap::kNoGCFlags);
256 heap->CollectAllGarbage(Heap::kNoGCFlags); 252 heap->CollectAllGarbage(Heap::kNoGCFlags);
257 } 253 }
OLDNEW
« no previous file with comments | « test/cctest/test-weakmaps.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698