Commit 885b1ac9 authored by Victor Gomes's avatar Victor Gomes Committed by Commit Bot

[x64] Fix allocating large stack space on macOS

Similarly to Windows, on macOS we should touch the memory in a page
when allocating stack space that crosses page boundaries.

Change-Id: I8968805c4abe255123a41d0f63f89d4af509b6c8
Bug: v8:11615
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2825588
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73948}
parent f6d54b7c
......@@ -2009,6 +2009,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
}
// static
// TODO(v8:11615): Observe Code::kMaxArguments in CallOrConstructVarargs
void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
Handle<Code> code) {
// ----------- S t a t e -------------
......
......@@ -2386,6 +2386,7 @@ void Generate_PrepareForCopyingVarargs(MacroAssembler* masm, Register argc,
} // namespace
// static
// TODO(v8:11615): Observe Code::kMaxArguments in CallOrConstructVarargs
void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
Handle<Code> code) {
// ----------- S t a t e -------------
......
......@@ -2108,6 +2108,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
}
// static
// TODO(v8:11615): Observe Code::kMaxArguments in CallOrConstructVarargs
void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
Handle<Code> code) {
// ----------- S t a t e -------------
......
......@@ -2063,6 +2063,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
}
// static
// TODO(v8:11615): Observe Code::kMaxArguments in CallOrConstructVarargs
void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
Handle<Code> code) {
// ----------- S t a t e -------------
......
......@@ -118,7 +118,7 @@ class V8_EXPORT_PRIVATE TurboAssemblerBase : public Assembler {
static bool IsAddressableThroughRootRegister(
Isolate* isolate, const ExternalReference& reference);
#ifdef V8_TARGET_OS_WIN
#if defined(V8_TARGET_OS_WIN) || defined(V8_TARGET_OS_MACOSX)
// Minimum page size. We must touch memory once per page when expanding the
// stack, to avoid access violations.
static constexpr int kStackPageSize = 4 * KB;
......
......@@ -3068,11 +3068,11 @@ void TurboAssembler::LeaveFrame(StackFrame::Type type) {
popq(rbp);
}
#ifdef V8_TARGET_OS_WIN
#if defined(V8_TARGET_OS_WIN) || defined(V8_TARGET_OS_MACOSX)
void TurboAssembler::AllocateStackSpace(Register bytes_scratch) {
// In windows, we cannot increment the stack size by more than one page
// (minimum page size is 4KB) without accessing at least one byte on the
// page. Check this:
// On Windows and on macOS, we cannot increment the stack size by more than
// one page (minimum page size is 4KB) without accessing at least one byte on
// the page. Check this:
// https://msdn.microsoft.com/en-us/library/aa227153(v=vs.60).aspx.
Label check_offset;
Label touch_next_page;
......
......@@ -527,7 +527,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public SharedTurboAssembler {
// stack check, do it before calling this function because this function may
// write into the newly allocated space. It may also overwrite the given
// register's value, in the version that takes a register.
#ifdef V8_TARGET_OS_WIN
#if defined(V8_TARGET_OS_WIN) || defined(V8_TARGET_OS_MACOSX)
void AllocateStackSpace(Register bytes_scratch);
void AllocateStackSpace(int bytes);
#else
......
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