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

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

Issue 424693006: Regression test for chromium:388880 added. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments addressed Created 6 years, 4 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 | « no previous file | 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 4423 matching lines...) Expand 10 before | Expand all | Expand 10 after
4434 FixedArray::kHeaderSize; 4434 FixedArray::kHeaderSize;
4435 Handle<FixedArray> second = 4435 Handle<FixedArray> second =
4436 isolate->factory()->NewFixedArray(length, NOT_TENURED); 4436 isolate->factory()->NewFixedArray(length, NOT_TENURED);
4437 CHECK(heap->InNewSpace(*second)); 4437 CHECK(heap->InNewSpace(*second));
4438 4438
4439 // This scavenge will corrupt memory if the promotion queue is not evacuated. 4439 // This scavenge will corrupt memory if the promotion queue is not evacuated.
4440 heap->CollectGarbage(NEW_SPACE); 4440 heap->CollectGarbage(NEW_SPACE);
4441 } 4441 }
4442 4442
4443 4443
4444 TEST(Regress388880) {
4445 i::FLAG_expose_gc = true;
4446 CcTest::InitializeVM();
4447 v8::HandleScope scope(CcTest::isolate());
4448 Isolate* isolate = CcTest::i_isolate();
4449 Factory* factory = isolate->factory();
4450 Heap* heap = isolate->heap();
4451
4452 Handle<Map> map1 = Map::Create(isolate->object_function(), 1);
4453 Handle<Map> map2 =
4454 Map::CopyWithField(map1, factory->NewStringFromStaticAscii("foo"),
4455 HeapType::Any(isolate), NONE, Representation::Tagged(),
4456 OMIT_TRANSITION).ToHandleChecked();
4457
4458 int desired_offset = Page::kPageSize - map1->instance_size();
4459
4460 // Allocate fixed array in old pointer space so, that object allocated
4461 // afterwards would end at the end of the page.
4462 {
4463 SimulateFullSpace(heap->old_pointer_space());
4464 int padding_size = desired_offset - Page::kObjectStartOffset;
4465 int padding_array_length =
4466 (padding_size - FixedArray::kHeaderSize) / kPointerSize;
4467
4468 Handle<FixedArray> temp2 =
4469 factory->NewFixedArray(padding_array_length, TENURED);
4470 Page* page = Page::FromAddress(temp2->address());
4471 CHECK_EQ(Page::kObjectStartOffset, page->Offset(temp2->address()));
4472 }
4473
4474 Handle<JSObject> o = factory->NewJSObjectFromMap(map1, TENURED, false);
4475 o->set_properties(*factory->empty_fixed_array());
4476
4477 // Ensure that the object allocated where we need it.
4478 Page* page = Page::FromAddress(o->address());
4479 CHECK_EQ(desired_offset, page->Offset(o->address()));
4480
4481 // Now we have an object right at the end of the page.
4482
4483 // Enable incremental marking to trigger actions in Heap::AdjustLiveBytes()
4484 // that would cause crash.
4485 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
4486 marking->Abort();
4487 marking->Start();
4488 CHECK(marking->IsMarking());
4489
4490 // Now everything is set up for crashing in JSObject::MigrateFastToFast()
4491 // when it calls heap->AdjustLiveBytes(...).
4492 JSObject::MigrateToMap(o, map2);
4493 }
4494
4495
4444 #ifdef DEBUG 4496 #ifdef DEBUG
4445 TEST(PathTracer) { 4497 TEST(PathTracer) {
4446 CcTest::InitializeVM(); 4498 CcTest::InitializeVM();
4447 v8::HandleScope scope(CcTest::isolate()); 4499 v8::HandleScope scope(CcTest::isolate());
4448 4500
4449 v8::Local<v8::Value> result = CompileRun("'abc'"); 4501 v8::Local<v8::Value> result = CompileRun("'abc'");
4450 Handle<Object> o = v8::Utils::OpenHandle(*result); 4502 Handle<Object> o = v8::Utils::OpenHandle(*result);
4451 CcTest::i_isolate()->heap()->TracePathToObject(*o); 4503 CcTest::i_isolate()->heap()->TracePathToObject(*o);
4452 } 4504 }
4453 #endif // DEBUG 4505 #endif // DEBUG
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698