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) { ...@@ -6107,49 +6107,58 @@ HEAP_TEST(Regress670675) {
DCHECK(marking->IsStopped()); 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) { HEAP_TEST(Regress5831) {
CcTest::InitializeVM(); CcTest::InitializeVM();
Heap* heap = CcTest::heap(); Heap* heap = CcTest::heap();
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
HandleScope handle_scope(isolate); HandleScope handle_scope(isolate);
// Used to ensure that the first code space page remains filled. // Used to ensure that the generated code is not collected.
Handle<FixedArray> array = isolate->factory()->NewFixedArray(32); const int kInitialSize = 32;
Handle<FixedArray> array = isolate->factory()->NewFixedArray(kInitialSize);
{
// Ensure that the first code space page is full. // Ensure that all immovable code space pages are full and we overflow into
CEntryStub stub(isolate, 1); // LO_SPACE.
Handle<Code> code = stub.GetCode(); const int kMaxIterations = 1 << 16;
bool overflowed_into_lospace = false;
int i = 0; for (int i = 0; i < kMaxIterations; i++) {
array = FixedArray::SetAndGrow(array, i++, code); Handle<Code> code = GenerateDummyImmovableCode(isolate);
array = FixedArray::SetAndGrow(array, i, code);
while (heap->code_space()->FirstPage()->Contains(code->address())) { CHECK(heap->code_space()->Contains(code->address()) ||
code = isolate->factory()->CopyCode(code); heap->lo_space()->Contains(*code));
array = FixedArray::SetAndGrow(array, i++, code); if (heap->lo_space()->Contains(*code)) {
overflowed_into_lospace = true;
break;
} }
} }
class ImmovableCEntryStub : public i::CEntryStub { CHECK(overflowed_into_lospace);
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));
}
// Fake a serializer run. // Fake a serializer run.
isolate->serializer_enabled_ = true; isolate->serializer_enabled_ = true;
// Generate the code. // Generate the code.
Handle<Code> code = stub.GetCode(); Handle<Code> code = GenerateDummyImmovableCode(isolate);
CHECK(code->Size() <= i::kMaxRegularHeapObjectSize); CHECK(code->Size() <= i::kMaxRegularHeapObjectSize);
CHECK(!heap->code_space()->FirstPage()->Contains(code->address())); 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