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

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

Issue 1026113004: Reload length of retained_maps array after GC. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove unused var Created 5 years, 9 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
« src/objects.cc ('K') | « src/objects.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 5078 matching lines...) Expand 10 before | Expand all | Expand 10 after
5089 CHECK(!weak_prototype->cleared()); 5089 CHECK(!weak_prototype->cleared());
5090 // Change the map of a.x and make the previous map garbage collectable. 5090 // Change the map of a.x and make the previous map garbage collectable.
5091 CompileRun("a.x.__proto__ = {};"); 5091 CompileRun("a.x.__proto__ = {};");
5092 for (int i = 0; i < 4; i++) { 5092 for (int i = 0; i < 4; i++) {
5093 heap->CollectAllGarbage(Heap::kNoGCFlags); 5093 heap->CollectAllGarbage(Heap::kNoGCFlags);
5094 } 5094 }
5095 CHECK(weak_prototype->cleared()); 5095 CHECK(weak_prototype->cleared());
5096 } 5096 }
5097 5097
5098 5098
5099 void CheckMapRetainingFor(int n) { 5099 Handle<WeakCell> AddRetainedMap(Isolate* isolate, Heap* heap) {
5100 FLAG_retain_maps_for_n_gc = n;
5101 Isolate* isolate = CcTest::i_isolate();
5102 Heap* heap = isolate->heap();
5103 Handle<WeakCell> weak_cell;
5104 {
5105 HandleScope inner_scope(isolate); 5100 HandleScope inner_scope(isolate);
5106 Handle<Map> map = Map::Create(isolate, 1); 5101 Handle<Map> map = Map::Create(isolate, 1);
5107 v8::Local<v8::Value> result = 5102 v8::Local<v8::Value> result =
5108 CompileRun("(function () { return {x : 10}; })();"); 5103 CompileRun("(function () { return {x : 10}; })();");
5109 Handle<JSObject> proto = 5104 Handle<JSObject> proto =
5110 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); 5105 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result));
5111 map->set_prototype(*proto); 5106 map->set_prototype(*proto);
5112 heap->AddRetainedMap(map); 5107 heap->AddRetainedMap(map);
5113 weak_cell = inner_scope.CloseAndEscape(Map::WeakCellForMap(map)); 5108 return inner_scope.CloseAndEscape(Map::WeakCellForMap(map));
5114 } 5109 }
5110
5111
5112 void CheckMapRetainingFor(int n) {
5113 FLAG_retain_maps_for_n_gc = n;
5114 Isolate* isolate = CcTest::i_isolate();
5115 Heap* heap = isolate->heap();
5116 Handle<WeakCell> weak_cell = AddRetainedMap(isolate, heap);
5115 CHECK(!weak_cell->cleared()); 5117 CHECK(!weak_cell->cleared());
5116 for (int i = 0; i < n; i++) { 5118 for (int i = 0; i < n; i++) {
5117 heap->CollectGarbage(OLD_POINTER_SPACE); 5119 heap->CollectGarbage(OLD_POINTER_SPACE);
5118 } 5120 }
5119 CHECK(!weak_cell->cleared()); 5121 CHECK(!weak_cell->cleared());
5120 heap->CollectGarbage(OLD_POINTER_SPACE); 5122 heap->CollectGarbage(OLD_POINTER_SPACE);
5121 CHECK(weak_cell->cleared()); 5123 CHECK(weak_cell->cleared());
5122 } 5124 }
5123 5125
5124 5126
5125 TEST(MapRetaining) { 5127 TEST(MapRetaining) {
5126 CcTest::InitializeVM(); 5128 CcTest::InitializeVM();
5127 v8::HandleScope scope(CcTest::isolate()); 5129 v8::HandleScope scope(CcTest::isolate());
5128 CheckMapRetainingFor(FLAG_retain_maps_for_n_gc); 5130 CheckMapRetainingFor(FLAG_retain_maps_for_n_gc);
5129 CheckMapRetainingFor(0); 5131 CheckMapRetainingFor(0);
5130 CheckMapRetainingFor(1); 5132 CheckMapRetainingFor(1);
5131 CheckMapRetainingFor(7); 5133 CheckMapRetainingFor(7);
5132 } 5134 }
5133 5135
5134 5136
5137 TEST(RegressArrayListGC) {
5138 FLAG_retain_maps_for_n_gc = 1;
5139 FLAG_incremental_marking = 0;
5140 FLAG_gc_global = true;
5141 CcTest::InitializeVM();
5142 v8::HandleScope scope(CcTest::isolate());
5143 Isolate* isolate = CcTest::i_isolate();
5144 Heap* heap = isolate->heap();
5145 AddRetainedMap(isolate, heap);
5146 Handle<Map> map = Map::Create(isolate, 1);
5147 heap->CollectGarbage(OLD_POINTER_SPACE);
5148 // Force GC in old space on next addition of retained map.
5149 Map::WeakCellForMap(map);
5150 SimulateFullSpace(CcTest::heap()->new_space());
5151 for (int i = 0; i < 10; i++) {
5152 heap->AddRetainedMap(map);
5153 }
5154 heap->CollectGarbage(OLD_POINTER_SPACE);
5155 }
5156
5157
5135 #ifdef DEBUG 5158 #ifdef DEBUG
5136 TEST(PathTracer) { 5159 TEST(PathTracer) {
5137 CcTest::InitializeVM(); 5160 CcTest::InitializeVM();
5138 v8::HandleScope scope(CcTest::isolate()); 5161 v8::HandleScope scope(CcTest::isolate());
5139 5162
5140 v8::Local<v8::Value> result = CompileRun("'abc'"); 5163 v8::Local<v8::Value> result = CompileRun("'abc'");
5141 Handle<Object> o = v8::Utils::OpenHandle(*result); 5164 Handle<Object> o = v8::Utils::OpenHandle(*result);
5142 CcTest::i_isolate()->heap()->TracePathToObject(*o); 5165 CcTest::i_isolate()->heap()->TracePathToObject(*o);
5143 } 5166 }
5144 #endif // DEBUG 5167 #endif // DEBUG
5145 5168
5146 5169
5147 TEST(WritableVsImmortalRoots) { 5170 TEST(WritableVsImmortalRoots) {
5148 for (int i = 0; i < Heap::kStrongRootListLength; ++i) { 5171 for (int i = 0; i < Heap::kStrongRootListLength; ++i) {
5149 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); 5172 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i);
5150 bool writable = Heap::RootCanBeWrittenAfterInitialization(root_index); 5173 bool writable = Heap::RootCanBeWrittenAfterInitialization(root_index);
5151 bool immortal = Heap::RootIsImmortalImmovable(root_index); 5174 bool immortal = Heap::RootIsImmortalImmovable(root_index);
5152 // A root value can be writable, immortal, or neither, but not both. 5175 // A root value can be writable, immortal, or neither, but not both.
5153 CHECK(!immortal || !writable); 5176 CHECK(!immortal || !writable);
5154 } 5177 }
5155 } 5178 }
OLDNEW
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698