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

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

Issue 1082973003: Force full GC whenever CollectAllGarbage is meant to trigger a full GC. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/test-weaksets.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 v8::HandleScope s2(context->GetIsolate()); 121 v8::HandleScope s2(context->GetIsolate());
122 v8::Handle<v8::ArrayBuffer> ab2 = 122 v8::Handle<v8::ArrayBuffer> ab2 =
123 v8::ArrayBuffer::New(context->GetIsolate(), 128); 123 v8::ArrayBuffer::New(context->GetIsolate(), 128);
124 124
125 Handle<JSArrayBuffer> iab1 = v8::Utils::OpenHandle(*ab1); 125 Handle<JSArrayBuffer> iab1 = v8::Utils::OpenHandle(*ab1);
126 Handle<JSArrayBuffer> iab2 = v8::Utils::OpenHandle(*ab2); 126 Handle<JSArrayBuffer> iab2 = v8::Utils::OpenHandle(*ab2);
127 CHECK_EQ(2, CountArrayBuffersInWeakList(isolate->heap()) - start); 127 CHECK_EQ(2, CountArrayBuffersInWeakList(isolate->heap()) - start);
128 CHECK(HasArrayBufferInWeakList(isolate->heap(), *iab1)); 128 CHECK(HasArrayBufferInWeakList(isolate->heap(), *iab1));
129 CHECK(HasArrayBufferInWeakList(isolate->heap(), *iab2)); 129 CHECK(HasArrayBufferInWeakList(isolate->heap(), *iab2));
130 } 130 }
131 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 131 isolate->heap()->CollectAllGarbage();
132 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start); 132 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start);
133 { 133 {
134 HandleScope scope2(isolate); 134 HandleScope scope2(isolate);
135 Handle<JSArrayBuffer> iab1 = v8::Utils::OpenHandle(*ab1); 135 Handle<JSArrayBuffer> iab1 = v8::Utils::OpenHandle(*ab1);
136 136
137 CHECK(HasArrayBufferInWeakList(isolate->heap(), *iab1)); 137 CHECK(HasArrayBufferInWeakList(isolate->heap(), *iab1));
138 } 138 }
139 } 139 }
140 140
141 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 141 isolate->heap()->CollectAllGarbage();
142 CHECK_EQ(start, CountArrayBuffersInWeakList(isolate->heap())); 142 CHECK_EQ(start, CountArrayBuffersInWeakList(isolate->heap()));
143 } 143 }
144 144
145 145
146 TEST(WeakArrayBuffersFromScript) { 146 TEST(WeakArrayBuffersFromScript) {
147 v8::V8::Initialize(); 147 v8::V8::Initialize();
148 LocalContext context; 148 LocalContext context;
149 Isolate* isolate = GetIsolateFrom(&context); 149 Isolate* isolate = GetIsolateFrom(&context);
150 int start = CountArrayBuffersInWeakList(isolate->heap()); 150 int start = CountArrayBuffersInWeakList(isolate->heap());
151 151
(...skipping 21 matching lines...) Expand all
173 *v8::Utils::OpenHandle(*ab1))); 173 *v8::Utils::OpenHandle(*ab1)));
174 CHECK(HasArrayBufferInWeakList(isolate->heap(), 174 CHECK(HasArrayBufferInWeakList(isolate->heap(),
175 *v8::Utils::OpenHandle(*ab2))); 175 *v8::Utils::OpenHandle(*ab2)));
176 CHECK(HasArrayBufferInWeakList(isolate->heap(), 176 CHECK(HasArrayBufferInWeakList(isolate->heap(),
177 *v8::Utils::OpenHandle(*ab3))); 177 *v8::Utils::OpenHandle(*ab3)));
178 } 178 }
179 179
180 i::ScopedVector<char> source(1024); 180 i::ScopedVector<char> source(1024);
181 i::SNPrintF(source, "ab%d = null;", i); 181 i::SNPrintF(source, "ab%d = null;", i);
182 CompileRun(source.start()); 182 CompileRun(source.start());
183 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 183 isolate->heap()->CollectAllGarbage();
184 184
185 CHECK_EQ(2, CountArrayBuffersInWeakList(isolate->heap()) - start); 185 CHECK_EQ(2, CountArrayBuffersInWeakList(isolate->heap()) - start);
186 186
187 { 187 {
188 v8::HandleScope s2(context->GetIsolate()); 188 v8::HandleScope s2(context->GetIsolate());
189 for (int j = 1; j <= 3; j++) { 189 for (int j = 1; j <= 3; j++) {
190 if (j == i) continue; 190 if (j == i) continue;
191 i::SNPrintF(source, "ab%d", j); 191 i::SNPrintF(source, "ab%d", j);
192 v8::Handle<v8::ArrayBuffer> ab = 192 v8::Handle<v8::ArrayBuffer> ab =
193 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun(source.start())); 193 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun(source.start()));
194 CHECK(HasArrayBufferInWeakList(isolate->heap(), 194 CHECK(HasArrayBufferInWeakList(isolate->heap(),
195 *v8::Utils::OpenHandle(*ab))); 195 *v8::Utils::OpenHandle(*ab)));
196 } 196 }
197 } 197 }
198 198
199 CompileRun("ab1 = null; ab2 = null; ab3 = null;"); 199 CompileRun("ab1 = null; ab2 = null; ab3 = null;");
200 } 200 }
201 201
202 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 202 isolate->heap()->CollectAllGarbage();
203 CHECK_EQ(start, CountArrayBuffersInWeakList(isolate->heap())); 203 CHECK_EQ(start, CountArrayBuffersInWeakList(isolate->heap()));
204 } 204 }
205 } 205 }
206 206
207 template <typename View> 207 template <typename View>
208 void TestViewFromApi() { 208 void TestViewFromApi() {
209 v8::V8::Initialize(); 209 v8::V8::Initialize();
210 LocalContext context; 210 LocalContext context;
211 Isolate* isolate = GetIsolateFrom(&context); 211 Isolate* isolate = GetIsolateFrom(&context);
212 212
213 v8::HandleScope s1(context->GetIsolate()); 213 v8::HandleScope s1(context->GetIsolate());
214 v8::Handle<v8::ArrayBuffer> ab = 214 v8::Handle<v8::ArrayBuffer> ab =
215 v8::ArrayBuffer::New(context->GetIsolate(), 2048); 215 v8::ArrayBuffer::New(context->GetIsolate(), 2048);
216 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); 216 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
217 { 217 {
218 v8::HandleScope s2(context->GetIsolate()); 218 v8::HandleScope s2(context->GetIsolate());
219 v8::Handle<View> ta1 = View::New(ab, 0, 256); 219 v8::Handle<View> ta1 = View::New(ab, 0, 256);
220 { 220 {
221 v8::HandleScope s3(context->GetIsolate()); 221 v8::HandleScope s3(context->GetIsolate());
222 v8::Handle<View> ta2 = View::New(ab, 0, 128); 222 v8::Handle<View> ta2 = View::New(ab, 0, 128);
223 223
224 Handle<JSArrayBufferView> ita1 = v8::Utils::OpenHandle(*ta1); 224 Handle<JSArrayBufferView> ita1 = v8::Utils::OpenHandle(*ta1);
225 Handle<JSArrayBufferView> ita2 = v8::Utils::OpenHandle(*ta2); 225 Handle<JSArrayBufferView> ita2 = v8::Utils::OpenHandle(*ta2);
226 CHECK_EQ(2, CountViews(isolate->heap(), *iab)); 226 CHECK_EQ(2, CountViews(isolate->heap(), *iab));
227 CHECK(HasViewInWeakList(isolate->heap(), *iab, *ita1)); 227 CHECK(HasViewInWeakList(isolate->heap(), *iab, *ita1));
228 CHECK(HasViewInWeakList(isolate->heap(), *iab, *ita2)); 228 CHECK(HasViewInWeakList(isolate->heap(), *iab, *ita2));
229 } 229 }
230 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 230 isolate->heap()->CollectAllGarbage();
231 CHECK_EQ(1, CountViews(isolate->heap(), *iab)); 231 CHECK_EQ(1, CountViews(isolate->heap(), *iab));
232 Handle<JSArrayBufferView> ita1 = v8::Utils::OpenHandle(*ta1); 232 Handle<JSArrayBufferView> ita1 = v8::Utils::OpenHandle(*ta1);
233 CHECK(HasViewInWeakList(isolate->heap(), *iab, *ita1)); 233 CHECK(HasViewInWeakList(isolate->heap(), *iab, *ita1));
234 } 234 }
235 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 235 isolate->heap()->CollectAllGarbage();
236 236
237 CHECK_EQ(0, CountViews(isolate->heap(), *iab)); 237 CHECK_EQ(0, CountViews(isolate->heap(), *iab));
238 } 238 }
239 239
240 240
241 TEST(Uint8ArrayFromApi) { 241 TEST(Uint8ArrayFromApi) {
242 TestViewFromApi<v8::Uint8Array>(); 242 TestViewFromApi<v8::Uint8Array>();
243 } 243 }
244 244
245 245
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 CHECK(HasViewInWeakList(isolate->heap(), *iab, 326 CHECK(HasViewInWeakList(isolate->heap(), *iab,
327 *v8::Utils::OpenHandle(*ta1))); 327 *v8::Utils::OpenHandle(*ta1)));
328 CHECK(HasViewInWeakList(isolate->heap(), *iab, 328 CHECK(HasViewInWeakList(isolate->heap(), *iab,
329 *v8::Utils::OpenHandle(*ta2))); 329 *v8::Utils::OpenHandle(*ta2)));
330 CHECK(HasViewInWeakList(isolate->heap(), *iab, 330 CHECK(HasViewInWeakList(isolate->heap(), *iab,
331 *v8::Utils::OpenHandle(*ta3))); 331 *v8::Utils::OpenHandle(*ta3)));
332 } 332 }
333 333
334 i::SNPrintF(source, "ta%d = null;", i); 334 i::SNPrintF(source, "ta%d = null;", i);
335 CompileRun(source.start()); 335 CompileRun(source.start());
336 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 336 isolate->heap()->CollectAllGarbage();
337 337
338 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start); 338 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start);
339 339
340 { 340 {
341 v8::HandleScope s2(context->GetIsolate()); 341 v8::HandleScope s2(context->GetIsolate());
342 v8::Handle<v8::ArrayBuffer> ab = 342 v8::Handle<v8::ArrayBuffer> ab =
343 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab")); 343 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab"));
344 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); 344 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
345 CHECK_EQ(2, CountViews(isolate->heap(), *iab)); 345 CHECK_EQ(2, CountViews(isolate->heap(), *iab));
346 for (int j = 1; j <= 3; j++) { 346 for (int j = 1; j <= 3; j++) {
347 if (j == i) continue; 347 if (j == i) continue;
348 i::SNPrintF(source, "ta%d", j); 348 i::SNPrintF(source, "ta%d", j);
349 v8::Handle<TypedArray> ta = 349 v8::Handle<TypedArray> ta =
350 v8::Handle<TypedArray>::Cast(CompileRun(source.start())); 350 v8::Handle<TypedArray>::Cast(CompileRun(source.start()));
351 CHECK(HasViewInWeakList(isolate->heap(), *iab, 351 CHECK(HasViewInWeakList(isolate->heap(), *iab,
352 *v8::Utils::OpenHandle(*ta))); 352 *v8::Utils::OpenHandle(*ta)));
353 } 353 }
354 } 354 }
355 355
356 CompileRun("ta1 = null; ta2 = null; ta3 = null;"); 356 CompileRun("ta1 = null; ta2 = null; ta3 = null;");
357 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 357 isolate->heap()->CollectAllGarbage();
358 358
359 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start); 359 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start);
360 360
361 { 361 {
362 v8::HandleScope s3(context->GetIsolate()); 362 v8::HandleScope s3(context->GetIsolate());
363 v8::Handle<v8::ArrayBuffer> ab = 363 v8::Handle<v8::ArrayBuffer> ab =
364 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab")); 364 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab"));
365 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); 365 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
366 CHECK_EQ(0, CountViews(isolate->heap(), *iab)); 366 CHECK_EQ(0, CountViews(isolate->heap(), *iab));
367 } 367 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 410
411 411
412 TEST(Uint8ClampedArrayFromScript) { 412 TEST(Uint8ClampedArrayFromScript) {
413 TestTypedArrayFromScript<v8::Uint8ClampedArray>("Uint8ClampedArray"); 413 TestTypedArrayFromScript<v8::Uint8ClampedArray>("Uint8ClampedArray");
414 } 414 }
415 415
416 416
417 TEST(DataViewFromScript) { 417 TEST(DataViewFromScript) {
418 TestTypedArrayFromScript<v8::DataView>("DataView"); 418 TestTypedArrayFromScript<v8::DataView>("DataView");
419 } 419 }
OLDNEW
« no previous file with comments | « test/cctest/test-weaksets.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698