Index: src/ia32/lithium-codegen-ia32.cc |
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc |
index 41441f5efe422c5d738459e05e487b16512f584b..7a601cf39bcfe24e96edc79bed8cde655f329b52 100644 |
--- a/src/ia32/lithium-codegen-ia32.cc |
+++ b/src/ia32/lithium-codegen-ia32.cc |
@@ -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 |
} |