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

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

Issue 947683002: Reimplement Maps and Sets in JS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Merged to master Created 5 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
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-ordered-hash-table.cc » ('j') | 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 CHECK_EQ(identity_hash, CcTest::heap()->undefined_value()); 103 CHECK_EQ(identity_hash, CcTest::heap()->undefined_value());
104 } 104 }
105 } 105 }
106 106
107 107
108 TEST(HashMap) { 108 TEST(HashMap) {
109 LocalContext context; 109 LocalContext context;
110 v8::HandleScope scope(context->GetIsolate()); 110 v8::HandleScope scope(context->GetIsolate());
111 Isolate* isolate = CcTest::i_isolate(); 111 Isolate* isolate = CcTest::i_isolate();
112 TestHashMap(ObjectHashTable::New(isolate, 23)); 112 TestHashMap(ObjectHashTable::New(isolate, 23));
113 TestHashMap(isolate->factory()->NewOrderedHashMap());
114 } 113 }
115 114
116 115
117 class ObjectHashTableTest: public ObjectHashTable { 116 class ObjectHashTableTest: public ObjectHashTable {
118 public: 117 public:
119 void insert(int entry, int key, int value) { 118 void insert(int entry, int key, int value) {
120 set(EntryToIndex(entry), Smi::FromInt(key)); 119 set(EntryToIndex(entry), Smi::FromInt(key));
121 set(EntryToIndex(entry) + 1, Smi::FromInt(value)); 120 set(EntryToIndex(entry) + 1, Smi::FromInt(value));
122 } 121 }
123 122
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // Calling Remove() will not cause GC in this case. 191 // Calling Remove() will not cause GC in this case.
193 bool was_present = false; 192 bool was_present = false;
194 table = HashSet::Remove(table, key, &was_present); 193 table = HashSet::Remove(table, key, &was_present);
195 CHECK(!was_present); 194 CHECK(!was_present);
196 CHECK(gc_count == isolate->heap()->gc_count()); 195 CHECK(gc_count == isolate->heap()->gc_count());
197 196
198 // Calling Add() should cause GC. 197 // Calling Add() should cause GC.
199 table = HashSet::Add(table, key); 198 table = HashSet::Add(table, key);
200 CHECK(gc_count < isolate->heap()->gc_count()); 199 CHECK(gc_count < isolate->heap()->gc_count());
201 } 200 }
202
203
204 TEST(ObjectHashSetCausesGC) {
205 i::FLAG_stress_compaction = false;
206 LocalContext context;
207 v8::HandleScope scope(context->GetIsolate());
208 Isolate* isolate = CcTest::i_isolate();
209 TestHashSetCausesGC(isolate->factory()->NewOrderedHashSet());
210 }
211 #endif 201 #endif
212 202
213 203
214 #ifdef DEBUG 204 #ifdef DEBUG
215 template<class HashMap> 205 template<class HashMap>
216 static void TestHashMapCausesGC(Handle<HashMap> table) { 206 static void TestHashMapCausesGC(Handle<HashMap> table) {
217 Isolate* isolate = CcTest::i_isolate(); 207 Isolate* isolate = CcTest::i_isolate();
218 Factory* factory = isolate->factory(); 208 Factory* factory = isolate->factory();
219 209
220 Handle<JSObject> key = factory->NewJSArray(0); 210 Handle<JSObject> key = factory->NewJSArray(0);
(...skipping 18 matching lines...) Expand all
239 CHECK(gc_count < isolate->heap()->gc_count()); 229 CHECK(gc_count < isolate->heap()->gc_count());
240 } 230 }
241 231
242 232
243 TEST(ObjectHashTableCausesGC) { 233 TEST(ObjectHashTableCausesGC) {
244 i::FLAG_stress_compaction = false; 234 i::FLAG_stress_compaction = false;
245 LocalContext context; 235 LocalContext context;
246 v8::HandleScope scope(context->GetIsolate()); 236 v8::HandleScope scope(context->GetIsolate());
247 Isolate* isolate = CcTest::i_isolate(); 237 Isolate* isolate = CcTest::i_isolate();
248 TestHashMapCausesGC(ObjectHashTable::New(isolate, 1)); 238 TestHashMapCausesGC(ObjectHashTable::New(isolate, 1));
249 TestHashMapCausesGC(isolate->factory()->NewOrderedHashMap());
250 } 239 }
251 #endif 240 #endif
252 241
253
254 } 242 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-ordered-hash-table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698