Commit 4de5d180 authored by ulan@chromium.org's avatar ulan@chromium.org

Fix mozilla regress-398085-01 failure on windows.

Make sure that all stack pages are mapped before accessing them.

R=jkummerow@chromium.org

Review URL: https://chromiumcodereview.appspot.com/20607005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16007 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f62ffeef
......@@ -137,6 +137,16 @@ void LCodeGen::Comment(const char* format, ...) {
}
#ifdef _MSC_VER
void LCodeGen::MakeSureStackPagesMapped(int offset) {
const int kPageSize = 4 * KB;
for (offset -= kPageSize; offset > 0; offset -= kPageSize) {
__ mov(Operand(esp, offset), eax);
}
}
#endif
bool LCodeGen::GeneratePrologue() {
ASSERT(is_generating());
......@@ -226,6 +236,9 @@ bool LCodeGen::GeneratePrologue() {
} else {
if (FLAG_debug_code) {
__ sub(Operand(esp), Immediate(slots * kPointerSize));
#ifdef _MSC_VER
MakeSureStackPagesMapped(slots * kPointerSize);
#endif
__ push(eax);
__ mov(Operand(eax), Immediate(slots));
Label loop;
......@@ -238,15 +251,7 @@ bool LCodeGen::GeneratePrologue() {
} else {
__ sub(Operand(esp), Immediate(slots * kPointerSize));
#ifdef _MSC_VER
// On windows, you may not access the stack more than one page below
// the most recently mapped page. To make the allocated area randomly
// accessible, we write to each page in turn (the value is irrelevant).
const int kPageSize = 4 * KB;
for (int offset = slots * kPointerSize - kPageSize;
offset > 0;
offset -= kPageSize) {
__ mov(Operand(esp, offset), eax);
}
MakeSureStackPagesMapped(slots * kPointerSize);
#endif
}
......
......@@ -408,6 +408,14 @@ class LCodeGen BASE_EMBEDDED {
int X87ArrayIndex(X87Register reg);
int x87_st2idx(int pos);
#ifdef _MSC_VER
// On windows, you may not access the stack more than one page below
// the most recently mapped page. To make the allocated area randomly
// accessible, we write an arbitrary value to each page in range
// esp + offset - page_size .. esp in turn.
void MakeSureStackPagesMapped(int offset);
#endif
Zone* zone_;
LPlatformChunk* const chunk_;
MacroAssembler* const masm_;
......
......@@ -120,6 +120,16 @@ void LCodeGen::Comment(const char* format, ...) {
}
#ifdef _MSC_VER
void LCodeGen::MakeSureStackPagesMapped(int offset) {
const int kPageSize = 4 * KB;
for (offset -= kPageSize; offset > 0; offset -= kPageSize) {
__ movq(Operand(rsp, offset), rax);
}
}
#endif
bool LCodeGen::GeneratePrologue() {
ASSERT(is_generating());
......@@ -169,6 +179,9 @@ bool LCodeGen::GeneratePrologue() {
if (slots > 0) {
if (FLAG_debug_code) {
__ subq(rsp, Immediate(slots * kPointerSize));
#ifdef _MSC_VER
MakeSureStackPagesMapped(slots * kPointerSize);
#endif
__ push(rax);
__ Set(rax, slots);
__ movq(kScratchRegister, kSlotsZapValue, RelocInfo::NONE64);
......@@ -182,15 +195,7 @@ bool LCodeGen::GeneratePrologue() {
} else {
__ subq(rsp, Immediate(slots * kPointerSize));
#ifdef _MSC_VER
// On windows, you may not access the stack more than one page below
// the most recently mapped page. To make the allocated area randomly
// accessible, we write to each page in turn (the value is irrelevant).
const int kPageSize = 4 * KB;
for (int offset = slots * kPointerSize - kPageSize;
offset > 0;
offset -= kPageSize) {
__ movq(Operand(rsp, offset), rax);
}
MakeSureStackPagesMapped(slots * kPointerSize);
#endif
}
......
......@@ -345,6 +345,13 @@ class LCodeGen BASE_EMBEDDED {
void DoStoreKeyedExternalArray(LStoreKeyed* instr);
void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr);
void DoStoreKeyedFixedArray(LStoreKeyed* instr);
#ifdef _MSC_VER
// On windows, you may not access the stack more than one page below
// the most recently mapped page. To make the allocated area randomly
// accessible, we write an arbitrary value to each page in range
// rsp + offset - page_size .. rsp in turn.
void MakeSureStackPagesMapped(int offset);
#endif
Zone* zone_;
LPlatformChunk* const chunk_;
......
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