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

Side by Side Diff: test/cctest/test-mark-compact.cc

Issue 24065005: new gc callbacks with isolate parameters (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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-api.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // Now, as we don't have any handles to just allocated maps, we should 260 // Now, as we don't have any handles to just allocated maps, we should
261 // be able to trigger map compaction. 261 // be able to trigger map compaction.
262 // To give an additional chance to fail, try to force compaction which 262 // To give an additional chance to fail, try to force compaction which
263 // should be impossible right now. 263 // should be impossible right now.
264 HEAP->CollectAllGarbage(Heap::kForceCompactionMask); 264 HEAP->CollectAllGarbage(Heap::kForceCompactionMask);
265 // And now map pointers should be encodable again. 265 // And now map pointers should be encodable again.
266 CHECK(HEAP->map_space()->MapPointersEncodable()); 266 CHECK(HEAP->map_space()->MapPointersEncodable());
267 } 267 }
268 #endif 268 #endif
269 269
270 static int gc_starts = 0;
271 static int gc_ends = 0;
272
273 static void GCPrologueCallbackFunc() {
274 CHECK(gc_starts == gc_ends);
275 gc_starts++;
276 }
277
278
279 static void GCEpilogueCallbackFunc() {
280 CHECK(gc_starts == gc_ends + 1);
281 gc_ends++;
282 }
283
284
285 TEST(GCCallback) {
286 i::FLAG_stress_compaction = false;
287 CcTest::InitializeVM();
288
289 HEAP->SetGlobalGCPrologueCallback(&GCPrologueCallbackFunc);
290 HEAP->SetGlobalGCEpilogueCallback(&GCEpilogueCallbackFunc);
291
292 // Scavenge does not call GC callback functions.
293 HEAP->PerformScavenge();
294
295 CHECK_EQ(0, gc_starts);
296 CHECK_EQ(gc_ends, gc_starts);
297
298 HEAP->CollectGarbage(OLD_POINTER_SPACE);
299 CHECK_EQ(1, gc_starts);
300 CHECK_EQ(gc_ends, gc_starts);
301 }
302
303 270
304 static int NumberOfWeakCalls = 0; 271 static int NumberOfWeakCalls = 0;
305 static void WeakPointerCallback(v8::Isolate* isolate, 272 static void WeakPointerCallback(v8::Isolate* isolate,
306 v8::Persistent<v8::Value>* handle, 273 v8::Persistent<v8::Value>* handle,
307 void* id) { 274 void* id) {
308 ASSERT(id == reinterpret_cast<void*>(1234)); 275 ASSERT(id == reinterpret_cast<void*>(1234));
309 NumberOfWeakCalls++; 276 NumberOfWeakCalls++;
310 handle->Dispose(); 277 handle->Dispose();
311 } 278 }
312 279
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 549
583 550
584 TEST(RegressJoinThreadsOnIsolateDeinit) { 551 TEST(RegressJoinThreadsOnIsolateDeinit) {
585 intptr_t size_limit = ShortLivingIsolate() * 2; 552 intptr_t size_limit = ShortLivingIsolate() * 2;
586 for (int i = 0; i < 10; i++) { 553 for (int i = 0; i < 10; i++) {
587 CHECK_GT(size_limit, ShortLivingIsolate()); 554 CHECK_GT(size_limit, ShortLivingIsolate());
588 } 555 }
589 } 556 }
590 557
591 #endif // __linux__ and !USE_SIMULATOR 558 #endif // __linux__ and !USE_SIMULATOR
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698