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

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

Issue 1999753002: [heap] Harden heap-related cctests (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix for win Created 4 years, 7 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-api.cc ('k') | test/cctest/test-serialize.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 17 matching lines...) Expand all
28 #include "src/v8.h" 28 #include "src/v8.h"
29 #include "test/cctest/cctest.h" 29 #include "test/cctest/cctest.h"
30 30
31 #include "src/api.h" 31 #include "src/api.h"
32 #include "src/debug/debug.h" 32 #include "src/debug/debug.h"
33 #include "src/execution.h" 33 #include "src/execution.h"
34 #include "src/factory.h" 34 #include "src/factory.h"
35 #include "src/global-handles.h" 35 #include "src/global-handles.h"
36 #include "src/macro-assembler.h" 36 #include "src/macro-assembler.h"
37 #include "src/objects.h" 37 #include "src/objects.h"
38 #include "test/cctest/heap/utils-inl.h" 38 #include "test/cctest/heap/heap-utils.h"
39 39
40 using namespace v8::internal; 40 using namespace v8::internal;
41 41
42 namespace { 42 namespace {
43 43
44 44
45 template<typename HashMap> 45 template<typename HashMap>
46 static void TestHashMap(Handle<HashMap> table) { 46 static void TestHashMap(Handle<HashMap> table) {
47 Isolate* isolate = CcTest::i_isolate(); 47 Isolate* isolate = CcTest::i_isolate();
48 Factory* factory = isolate->factory(); 48 Factory* factory = isolate->factory();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 #ifdef DEBUG 168 #ifdef DEBUG
169 template<class HashSet> 169 template<class HashSet>
170 static void TestHashSetCausesGC(Handle<HashSet> table) { 170 static void TestHashSetCausesGC(Handle<HashSet> table) {
171 Isolate* isolate = CcTest::i_isolate(); 171 Isolate* isolate = CcTest::i_isolate();
172 Factory* factory = isolate->factory(); 172 Factory* factory = isolate->factory();
173 173
174 Handle<JSObject> key = factory->NewJSArray(0); 174 Handle<JSObject> key = factory->NewJSArray(0);
175 175
176 // Simulate a full heap so that generating an identity hash code 176 // Simulate a full heap so that generating an identity hash code
177 // in subsequent calls will request GC. 177 // in subsequent calls will request GC.
178 SimulateFullSpace(CcTest::heap()->new_space()); 178 heap::SimulateFullSpace(CcTest::heap()->new_space());
179 SimulateFullSpace(CcTest::heap()->old_space()); 179 heap::SimulateFullSpace(CcTest::heap()->old_space());
180 180
181 // Calling Contains() should not cause GC ever. 181 // Calling Contains() should not cause GC ever.
182 int gc_count = isolate->heap()->gc_count(); 182 int gc_count = isolate->heap()->gc_count();
183 CHECK(!table->Contains(key)); 183 CHECK(!table->Contains(key));
184 CHECK(gc_count == isolate->heap()->gc_count()); 184 CHECK(gc_count == isolate->heap()->gc_count());
185 185
186 // Calling Remove() will not cause GC in this case. 186 // Calling Remove() will not cause GC in this case.
187 bool was_present = false; 187 bool was_present = false;
188 table = HashSet::Remove(table, key, &was_present); 188 table = HashSet::Remove(table, key, &was_present);
189 CHECK(!was_present); 189 CHECK(!was_present);
190 CHECK(gc_count == isolate->heap()->gc_count()); 190 CHECK(gc_count == isolate->heap()->gc_count());
191 191
192 // Calling Add() should cause GC. 192 // Calling Add() should cause GC.
193 table = HashSet::Add(table, key); 193 table = HashSet::Add(table, key);
194 CHECK(gc_count < isolate->heap()->gc_count()); 194 CHECK(gc_count < isolate->heap()->gc_count());
195 } 195 }
196 #endif 196 #endif
197 197
198 198
199 #ifdef DEBUG 199 #ifdef DEBUG
200 template<class HashMap> 200 template<class HashMap>
201 static void TestHashMapCausesGC(Handle<HashMap> table) { 201 static void TestHashMapCausesGC(Handle<HashMap> table) {
202 Isolate* isolate = CcTest::i_isolate(); 202 Isolate* isolate = CcTest::i_isolate();
203 Factory* factory = isolate->factory(); 203 Factory* factory = isolate->factory();
204 204
205 Handle<JSObject> key = factory->NewJSArray(0); 205 Handle<JSObject> key = factory->NewJSArray(0);
206 206
207 // Simulate a full heap so that generating an identity hash code 207 // Simulate a full heap so that generating an identity hash code
208 // in subsequent calls will request GC. 208 // in subsequent calls will request GC.
209 SimulateFullSpace(CcTest::heap()->new_space()); 209 heap::SimulateFullSpace(CcTest::heap()->new_space());
210 SimulateFullSpace(CcTest::heap()->old_space()); 210 heap::SimulateFullSpace(CcTest::heap()->old_space());
211 211
212 // Calling Lookup() should not cause GC ever. 212 // Calling Lookup() should not cause GC ever.
213 CHECK(table->Lookup(key)->IsTheHole()); 213 CHECK(table->Lookup(key)->IsTheHole());
214 214
215 // Calling Put() should request GC by returning a failure. 215 // Calling Put() should request GC by returning a failure.
216 int gc_count = isolate->heap()->gc_count(); 216 int gc_count = isolate->heap()->gc_count();
217 HashMap::Put(table, key, key); 217 HashMap::Put(table, key, key);
218 CHECK(gc_count < isolate->heap()->gc_count()); 218 CHECK(gc_count < isolate->heap()->gc_count());
219 } 219 }
220 220
(...skipping 15 matching lines...) Expand all
236 dict->SetRequiresCopyOnCapacityChange(); 236 dict->SetRequiresCopyOnCapacityChange();
237 Handle<Name> key = isolate->factory()->InternalizeString( 237 Handle<Name> key = isolate->factory()->InternalizeString(
238 v8::Utils::OpenHandle(*v8_str("key"))); 238 v8::Utils::OpenHandle(*v8_str("key")));
239 Handle<Object> value = handle(Smi::FromInt(0), isolate); 239 Handle<Object> value = handle(Smi::FromInt(0), isolate);
240 Handle<NameDictionary> new_dict = 240 Handle<NameDictionary> new_dict =
241 NameDictionary::Add(dict, key, value, PropertyDetails::Empty()); 241 NameDictionary::Add(dict, key, value, PropertyDetails::Empty());
242 CHECK_NE(*dict, *new_dict); 242 CHECK_NE(*dict, *new_dict);
243 } 243 }
244 244
245 } // namespace 245 } // namespace
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698