MINGW-packages/mingw-w64-nodejs/0110-v8-heap-use-proper-sources.patch
2024-11-09 17:50:52 +01:00

109 lines
4.7 KiB
Diff

diff --git a/deps/v8/BUILD.gn b/deps/v8/BUILD.gn
index 19e0d2b5..41eee81b 100644
--- a/deps/v8/BUILD.gn
+++ b/deps/v8/BUILD.gn
@@ -23,7 +23,7 @@ target_is_simulator = (target_cpu != v8_target_cpu && !v8_multi_arch_build) ||
(current_cpu != v8_current_cpu && v8_multi_arch_build)
# For faster Windows builds. See https://crbug.com/v8/8475.
-emit_builtins_as_inline_asm = is_win && is_clang
+emit_builtins_as_inline_asm = is_msvc && is_clang
declare_args() {
# Print to stdout on Android.
@@ -6938,9 +6938,9 @@ v8_source_set("v8_heap_base") {
"src/heap/base/worklist.cc",
]
- if (is_clang || !is_win) {
+ if (is_clang || !is_msvc) {
if (current_cpu == "x64") {
- if (is_win) {
+ if (is_msvc) {
# Prefer a masm version with unwind directives.
sources += [ "src/heap/base/asm/x64/push_registers_masm.asm" ]
} else {
@@ -6965,7 +6965,7 @@ v8_source_set("v8_heap_base") {
} else if (current_cpu == "riscv64" || current_cpu == "riscv32") {
sources += [ "src/heap/base/asm/riscv/push_registers_asm.cc" ]
}
- } else if (is_win) {
+ } else if (is_msvc) {
if (current_cpu == "x64") {
sources += [ "src/heap/base/asm/x64/push_registers_masm.asm" ]
} else if (current_cpu == "x86") {
diff --git a/deps/v8/src/heap/base/asm/x64/push_registers_asm.cc b/deps/v8/src/heap/base/asm/x64/push_registers_asm.cc
index 554caddf..8bf9c4eb 100644
--- a/deps/v8/src/heap/base/asm/x64/push_registers_asm.cc
+++ b/deps/v8/src/heap/base/asm/x64/push_registers_asm.cc
@@ -21,8 +21,48 @@
// Source: https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf
#ifdef _WIN64
-#error "The masm based version must be used for Windows"
-#endif
+
+asm(".globl PushAllRegistersAndIterateStack \n"
+ "PushAllRegistersAndIterateStack: \n"
+ // rbp is callee-saved. Maintain proper frame pointer for debugging.
+ " push %rbp \n"
+ " mov %rsp, %rbp \n"
+ // Dummy for alignment.
+ " push $0xCDCDCD \n"
+ " push %rsi \n"
+ " push %rdi \n"
+ " push %rbx \n"
+ " push %r12 \n"
+ " push %r13 \n"
+ " push %r14 \n"
+ " push %r15 \n"
+ " sub $160, %rsp \n"
+ // Use aligned instrs as we are certain that the stack is properly aligned.
+ " movdqa %xmm6, 144(%rsp) \n"
+ " movdqa %xmm7, 128(%rsp) \n"
+ " movdqa %xmm8, 112(%rsp) \n"
+ " movdqa %xmm9, 96(%rsp) \n"
+ " movdqa %xmm10, 80(%rsp) \n"
+ " movdqa %xmm11, 64(%rsp) \n"
+ " movdqa %xmm12, 48(%rsp) \n"
+ " movdqa %xmm13, 32(%rsp) \n"
+ " movdqa %xmm14, 16(%rsp) \n"
+ " movdqa %xmm15, (%rsp) \n"
+ // Pass 1st parameter (rcx) unchanged (Stack*).
+ // Pass 2nd parameter (rdx) unchanged (StackVisitor*).
+ // Save 3rd parameter (r8; IterateStackCallback)
+ " mov %r8, %r9 \n"
+ // Pass 3rd parameter as rsp (stack pointer).
+ " mov %rsp, %r8 \n"
+ // Call the callback.
+ " call *%r9 \n"
+ // Pop the callee-saved registers.
+ " add $224, %rsp \n"
+ // Restore rbp as it was used as frame pointer.
+ " pop %rbp \n"
+ " ret \n");
+
+#else // !_WIN64
asm(
#ifdef __APPLE__
@@ -64,3 +104,5 @@ asm(
".Lfunc_end0-PushAllRegistersAndIterateStack \n"
#endif // !defined(__APPLE__)
);
+
+#endif // !_WIN64
diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp
index 226a3f6d..28348121 100644
--- a/tools/v8_gypfiles/v8.gyp
+++ b/tools/v8_gypfiles/v8.gyp
@@ -1895,7 +1895,7 @@
}],
# Changes in push_registers_asm.cc in V8 v12.8 requires using
# push_registers_masm on Windows even with ClangCL on x64
- ['OS=="win"', {
+ ['OS=="msvc"', {
'conditions': [
['_toolset == "host" and host_arch == "x64" or _toolset == "target" and target_arch=="x64"', {
'sources': [