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

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

Issue 640303006: Weak Cells (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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
« src/objects-inl.h ('K') | « src/serialize.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 4223 matching lines...) Expand 10 before | Expand all | Expand 10 after
4234 " var proto = {'name' : 'weak'};" 4234 " var proto = {'name' : 'weak'};"
4235 " var obj = Object.create(proto);" 4235 " var obj = Object.create(proto);"
4236 " compareNilIC(obj);" 4236 " compareNilIC(obj);"
4237 " compareNilIC(obj);" 4237 " compareNilIC(obj);"
4238 " compareNilIC(obj);" 4238 " compareNilIC(obj);"
4239 " return proto;" 4239 " return proto;"
4240 " })();"); 4240 " })();");
4241 } 4241 }
4242 4242
4243 4243
4244 TEST(WeakCell) {
4245 CcTest::InitializeVM();
4246 Isolate* isolate = CcTest::i_isolate();
4247 v8::internal::Heap* heap = CcTest::heap();
4248 v8::internal::Factory* factory = isolate->factory();
4249
4250 HandleScope outer_scope(isolate);
4251 Handle<WeakCell> weak_cell;
4252 {
4253 HandleScope inner_scope(isolate);
4254 Handle<HeapObject> value = factory->NewFixedArray(1, NOT_TENURED);
4255 weak_cell = inner_scope.CloseAndEscape(factory->NewWeakCell(value));
4256 }
4257 CHECK(weak_cell->value()->IsFixedArray());
4258 heap->CollectGarbage(NEW_SPACE);
4259 CHECK(weak_cell->value()->IsFixedArray());
4260 heap->CollectGarbage(NEW_SPACE);
4261 CHECK(weak_cell->value()->IsFixedArray());
4262 heap->CollectAllAvailableGarbage();
Erik Corry 2014/10/13 15:56:17 The tests should also test that the weak cell is u
ulan 2014/10/14 10:17:22 Done.
4263 CHECK(weak_cell->value()->IsUndefined());
4264 }
4265
4266
4267 TEST(WeakCellsWithIncrementalMarking) {
4268 CcTest::InitializeVM();
4269 Isolate* isolate = CcTest::i_isolate();
4270 v8::internal::Heap* heap = CcTest::heap();
4271 v8::internal::Factory* factory = isolate->factory();
4272
4273 const int N = 16;
4274 HandleScope outer_scope(isolate);
4275 Handle<FixedArray> survivor = factory->NewFixedArray(1, NOT_TENURED);
4276 Handle<WeakCell> weak_cells[N];
4277
4278 for (int i = 0; i < N; i++) {
4279 HandleScope inner_scope(isolate);
4280 Handle<HeapObject> value =
4281 i == 0 ? survivor : factory->NewFixedArray(1, NOT_TENURED);
4282 Handle<WeakCell> weak_cell = factory->NewWeakCell(value);
4283 CHECK(weak_cell->value()->IsFixedArray());
4284 IncrementalMarking* marking = heap->incremental_marking();
4285 if (marking->IsStopped()) marking->Start();
4286 marking->Step(128, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
4287 heap->CollectGarbage(NEW_SPACE);
4288 CHECK(weak_cell->value()->IsFixedArray());
4289 weak_cells[i] = inner_scope.CloseAndEscape(weak_cell);
4290 }
4291 heap->CollectAllGarbage(Heap::kNoGCFlags);
4292 CHECK_EQ(*survivor, weak_cells[0]->value());
4293 for (int i = 1; i < N; i++) {
4294 CHECK(weak_cells[i]->value()->IsUndefined());
4295 }
4296 }
4297
4298
4244 #ifdef DEBUG 4299 #ifdef DEBUG
4245 TEST(AddInstructionChangesNewSpacePromotion) { 4300 TEST(AddInstructionChangesNewSpacePromotion) {
4246 i::FLAG_allow_natives_syntax = true; 4301 i::FLAG_allow_natives_syntax = true;
4247 i::FLAG_expose_gc = true; 4302 i::FLAG_expose_gc = true;
4248 i::FLAG_stress_compaction = true; 4303 i::FLAG_stress_compaction = true;
4249 i::FLAG_gc_interval = 1000; 4304 i::FLAG_gc_interval = 1000;
4250 CcTest::InitializeVM(); 4305 CcTest::InitializeVM();
4251 if (!i::FLAG_allocation_site_pretenuring) return; 4306 if (!i::FLAG_allocation_site_pretenuring) return;
4252 v8::HandleScope scope(CcTest::isolate()); 4307 v8::HandleScope scope(CcTest::isolate());
4253 Isolate* isolate = CcTest::i_isolate(); 4308 Isolate* isolate = CcTest::i_isolate();
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
4505 #ifdef DEBUG 4560 #ifdef DEBUG
4506 TEST(PathTracer) { 4561 TEST(PathTracer) {
4507 CcTest::InitializeVM(); 4562 CcTest::InitializeVM();
4508 v8::HandleScope scope(CcTest::isolate()); 4563 v8::HandleScope scope(CcTest::isolate());
4509 4564
4510 v8::Local<v8::Value> result = CompileRun("'abc'"); 4565 v8::Local<v8::Value> result = CompileRun("'abc'");
4511 Handle<Object> o = v8::Utils::OpenHandle(*result); 4566 Handle<Object> o = v8::Utils::OpenHandle(*result);
4512 CcTest::i_isolate()->heap()->TracePathToObject(*o); 4567 CcTest::i_isolate()->heap()->TracePathToObject(*o);
4513 } 4568 }
4514 #endif // DEBUG 4569 #endif // DEBUG
OLDNEW
« src/objects-inl.h ('K') | « src/serialize.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698