Chromium Code Reviews

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: Test fixed for x64 Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | 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...)
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 // Allocate two fixed arrays in old pointer space so, that object allocated
4459 // afterwards would end at the end of the page.
4460 SimulateFullSpace(heap->old_pointer_space());
Hannes Payer (out of office) 2014/07/28 14:34:50 I do not think you need the first fixed array. I g
4461 Handle<FixedArray> temp1 = factory->NewFixedArray(1, TENURED);
4462 CHECK(heap->InOldPointerSpace(*temp1));
4463 Page* page = Page::FromAddress(temp1->address());
4464
4465 int desired_offset = page->size() - map1->instance_size();
4466
4467 Address desired_address = page->OffsetToAddress(desired_offset);
4468 Address next_object_address =
4469 temp1->address() + FixedArray::OffsetOfElementAt(temp1->length());
4470
4471 int desired_object_size = desired_address - next_object_address;
4472 int desired_array_length =
4473 (desired_object_size - FixedArray::kHeaderSize) / kPointerSize;
4474 Handle<FixedArray> temp2 =
4475 factory->NewFixedArray(desired_array_length, TENURED);
4476 Page* page2 = Page::FromAddress(temp2->address());
4477 CHECK_EQ(page, page2);
4478 CHECK_EQ(next_object_address, temp2->address());
4479
4480 Handle<JSObject> o = factory->NewJSObjectFromMap(map1, TENURED, false);
4481 o->set_properties(*factory->empty_fixed_array());
4482
4483 CHECK_EQ(page, Page::FromAddress(o->address()));
4484 CHECK_EQ(desired_address, o->address());
4485
4486 // Now we have an object right at the end of the page.
4487
4488 // Enable incremental marking to trigger actions in Heap::AdjustLiveBytes()
4489 // that would cause crash.
4490 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
4491 marking->Abort();
4492 marking->Start();
4493 CHECK(marking->IsMarking());
4494
4495 // Now everything is set up for crashing in JSObject::MigrateFastToFast()
4496 // when it calls heap->AdjustLiveBytes(...).
4497 CHECK_EQ(desired_address, o->address());
4498 JSObject::MigrateToMap(o, map2);
4499 }
4500
4501
4444 #ifdef DEBUG 4502 #ifdef DEBUG
4445 TEST(PathTracer) { 4503 TEST(PathTracer) {
4446 CcTest::InitializeVM(); 4504 CcTest::InitializeVM();
4447 v8::HandleScope scope(CcTest::isolate()); 4505 v8::HandleScope scope(CcTest::isolate());
4448 4506
4449 v8::Local<v8::Value> result = CompileRun("'abc'"); 4507 v8::Local<v8::Value> result = CompileRun("'abc'");
4450 Handle<Object> o = v8::Utils::OpenHandle(*result); 4508 Handle<Object> o = v8::Utils::OpenHandle(*result);
4451 CcTest::i_isolate()->heap()->TracePathToObject(*o); 4509 CcTest::i_isolate()->heap()->TracePathToObject(*o);
4452 } 4510 }
4453 #endif // DEBUG 4511 #endif // DEBUG
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine