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

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

Issue 257633002: HashTable::New() handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« 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 25 matching lines...) Expand all
36 using namespace v8::internal; 36 using namespace v8::internal;
37 37
38 38
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 Heap* heap = isolate->heap();
47 Handle<Map> map = factory->NewMap(JS_WEAK_SET_TYPE, JSWeakSet::kSize); 46 Handle<Map> map = factory->NewMap(JS_WEAK_SET_TYPE, JSWeakSet::kSize);
48 Handle<JSObject> weakset_obj = factory->NewJSObjectFromMap(map); 47 Handle<JSObject> weakset_obj = factory->NewJSObjectFromMap(map);
49 Handle<JSWeakSet> weakset(JSWeakSet::cast(*weakset_obj)); 48 Handle<JSWeakSet> weakset(JSWeakSet::cast(*weakset_obj));
50 // Do not use handles for the hash table, it would make entries strong. 49 // Do not use handles for the hash table, it would make entries strong.
51 Object* table_obj = ObjectHashTable::Allocate(heap, 1)->ToObjectChecked(); 50 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 1);
52 ObjectHashTable* table = ObjectHashTable::cast(table_obj); 51 weakset->set_table(*table);
53 weakset->set_table(table);
54 weakset->set_next(Smi::FromInt(0)); 52 weakset->set_next(Smi::FromInt(0));
55 return weakset; 53 return weakset;
56 } 54 }
57 55
58 static void PutIntoWeakSet(Handle<JSWeakSet> weakset, 56 static void PutIntoWeakSet(Handle<JSWeakSet> weakset,
59 Handle<JSObject> key, 57 Handle<JSObject> key,
60 Handle<Object> value) { 58 Handle<Object> value) {
61 Handle<ObjectHashTable> table = ObjectHashTable::Put( 59 Handle<ObjectHashTable> table = ObjectHashTable::Put(
62 Handle<ObjectHashTable>(ObjectHashTable::cast(weakset->table())), 60 Handle<ObjectHashTable>(ObjectHashTable::cast(weakset->table())),
63 Handle<JSObject>(JSObject::cast(*key)), 61 Handle<JSObject>(JSObject::cast(*key)),
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 Handle<Smi>(Smi::FromInt(i), isolate)); 246 Handle<Smi>(Smi::FromInt(i), isolate));
249 } 247 }
250 248
251 // Force compacting garbage collection. The subsequent collections are used 249 // Force compacting garbage collection. The subsequent collections are used
252 // to verify that key references were actually updated. 250 // to verify that key references were actually updated.
253 CHECK(FLAG_always_compact); 251 CHECK(FLAG_always_compact);
254 heap->CollectAllGarbage(Heap::kNoGCFlags); 252 heap->CollectAllGarbage(Heap::kNoGCFlags);
255 heap->CollectAllGarbage(Heap::kNoGCFlags); 253 heap->CollectAllGarbage(Heap::kNoGCFlags);
256 heap->CollectAllGarbage(Heap::kNoGCFlags); 254 heap->CollectAllGarbage(Heap::kNoGCFlags);
257 } 255 }
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