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

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

Issue 686783003: Clear old backing store of WeakCollection on updates. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 6 years, 1 month 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 | « src/runtime/runtime-collections.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 4590 matching lines...) Expand 10 before | Expand all | Expand 10 after
4601 marking->Abort(); 4601 marking->Abort();
4602 marking->Start(); 4602 marking->Start();
4603 CHECK(marking->IsMarking()); 4603 CHECK(marking->IsMarking());
4604 4604
4605 // Now everything is set up for crashing in JSObject::MigrateFastToFast() 4605 // Now everything is set up for crashing in JSObject::MigrateFastToFast()
4606 // when it calls heap->AdjustLiveBytes(...). 4606 // when it calls heap->AdjustLiveBytes(...).
4607 JSObject::MigrateToMap(o, map2); 4607 JSObject::MigrateToMap(o, map2);
4608 } 4608 }
4609 4609
4610 4610
4611 TEST(Regress3631) {
4612 i::FLAG_expose_gc = true;
4613 CcTest::InitializeVM();
4614 v8::HandleScope scope(CcTest::isolate());
4615 Isolate* isolate = CcTest::i_isolate();
4616 Heap* heap = isolate->heap();
4617 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
4618 v8::Local<v8::Value> result = CompileRun(
4619 "var weak_map = new WeakMap();"
4620 "var future_keys = [];"
4621 "for (var i = 0; i < 50; i++) {"
4622 " var key = {'k' : i + 0.1};"
4623 " weak_map.set(key, 1);"
4624 " future_keys.push({'x' : i + 0.2});"
4625 "}"
4626 "weak_map");
4627 if (marking->IsStopped()) {
4628 marking->Start();
4629 }
4630 // Incrementally mark the backing store.
4631 Handle<JSObject> obj =
4632 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result));
4633 Handle<JSWeakCollection> weak_map(reinterpret_cast<JSWeakCollection*>(*obj));
4634 while (!Marking::IsBlack(
4635 Marking::MarkBitFrom(HeapObject::cast(weak_map->table()))) &&
4636 !marking->IsStopped()) {
4637 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
4638 }
4639 // Stash the backing store in a handle.
4640 Handle<Object> save(weak_map->table(), isolate);
4641 // The following line will update the backing store.
4642 CompileRun(
4643 "for (var i = 0; i < 50; i++) {"
4644 " weak_map.set(future_keys[i], i);"
4645 "}");
4646 heap->incremental_marking()->set_should_hurry(true);
4647 heap->CollectGarbage(OLD_POINTER_SPACE);
4648 }
4649
4650
4611 #ifdef DEBUG 4651 #ifdef DEBUG
4612 TEST(PathTracer) { 4652 TEST(PathTracer) {
4613 CcTest::InitializeVM(); 4653 CcTest::InitializeVM();
4614 v8::HandleScope scope(CcTest::isolate()); 4654 v8::HandleScope scope(CcTest::isolate());
4615 4655
4616 v8::Local<v8::Value> result = CompileRun("'abc'"); 4656 v8::Local<v8::Value> result = CompileRun("'abc'");
4617 Handle<Object> o = v8::Utils::OpenHandle(*result); 4657 Handle<Object> o = v8::Utils::OpenHandle(*result);
4618 CcTest::i_isolate()->heap()->TracePathToObject(*o); 4658 CcTest::i_isolate()->heap()->TracePathToObject(*o);
4619 } 4659 }
4620 #endif // DEBUG 4660 #endif // DEBUG
OLDNEW
« no previous file with comments | « src/runtime/runtime-collections.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698