Commit 94196e4e authored by jgruber's avatar jgruber Committed by Commit Bot

Fix test-heap/Regress5831

This test started failing on arm64-debug-nosnap builds since we'd have
leftover NEVER_EVACUATE code-space pages from Isolate initialization.

Ensure that we exhaust all such pages and overflow into LO_SPACE before
continuing into the real test, and simply generate dummy code instead of
copying a fake CEntryStub.

Bug: v8:6690
Change-Id: I3889b5818e2467dcdce3485f1372f3b7383478f4
Reviewed-on: https://chromium-review.googlesource.com/608139Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47273}
parent 4dfd7503
......@@ -6107,49 +6107,58 @@ HEAP_TEST(Regress670675) {
DCHECK(marking->IsStopped());
}
namespace {
Handle<Code> GenerateDummyImmovableCode(Isolate* isolate) {
Assembler assm(isolate, NULL, 256);
const int kNumberOfNops = 1 << 10;
for (int i = 0; i < kNumberOfNops; i++) {
assm.nop(); // supported on all architectures
}
CodeDesc desc;
assm.GetCode(isolate, &desc);
const bool kImmovable = true;
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>(), kImmovable);
CHECK(code->IsCode());
return code;
}
} // namespace
HEAP_TEST(Regress5831) {
CcTest::InitializeVM();
Heap* heap = CcTest::heap();
Isolate* isolate = CcTest::i_isolate();
HandleScope handle_scope(isolate);
// Used to ensure that the first code space page remains filled.
Handle<FixedArray> array = isolate->factory()->NewFixedArray(32);
{
// Ensure that the first code space page is full.
CEntryStub stub(isolate, 1);
Handle<Code> code = stub.GetCode();
int i = 0;
array = FixedArray::SetAndGrow(array, i++, code);
while (heap->code_space()->FirstPage()->Contains(code->address())) {
code = isolate->factory()->CopyCode(code);
array = FixedArray::SetAndGrow(array, i++, code);
// Used to ensure that the generated code is not collected.
const int kInitialSize = 32;
Handle<FixedArray> array = isolate->factory()->NewFixedArray(kInitialSize);
// Ensure that all immovable code space pages are full and we overflow into
// LO_SPACE.
const int kMaxIterations = 1 << 16;
bool overflowed_into_lospace = false;
for (int i = 0; i < kMaxIterations; i++) {
Handle<Code> code = GenerateDummyImmovableCode(isolate);
array = FixedArray::SetAndGrow(array, i, code);
CHECK(heap->code_space()->Contains(code->address()) ||
heap->lo_space()->Contains(*code));
if (heap->lo_space()->Contains(*code)) {
overflowed_into_lospace = true;
break;
}
}
class ImmovableCEntryStub : public i::CEntryStub {
public:
explicit ImmovableCEntryStub(i::Isolate* isolate)
: i::CEntryStub(isolate, 3, i::kSaveFPRegs, i::kArgvOnStack, true) {}
bool NeedsImmovableCode() override { return true; }
};
ImmovableCEntryStub stub(isolate);
{
// Make sure the code object has not yet been generated.
Code* code;
CHECK(!stub.FindCodeInCache(&code));
}
CHECK(overflowed_into_lospace);
// Fake a serializer run.
isolate->serializer_enabled_ = true;
// Generate the code.
Handle<Code> code = stub.GetCode();
Handle<Code> code = GenerateDummyImmovableCode(isolate);
CHECK(code->Size() <= i::kMaxRegularHeapObjectSize);
CHECK(!heap->code_space()->FirstPage()->Contains(code->address()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment