added x86_32 MSVC support

This commit is contained in:
Reece Wilson 2021-09-30 17:41:42 +01:00
parent acf4597f27
commit e8e2db3e33
6 changed files with 50 additions and 38 deletions

7
.gitignore vendored
View File

@ -108,4 +108,9 @@ v8.ignition_dispatches_table.json
/builtins-generated/*
*/special-case.cc
special-case.cc
.cipd/*
.cipd/*
*.project
compile_flags.txt
snapshot.asm
snapshot_startup.cc
snapshot_embedded.asm

View File

@ -762,6 +762,7 @@ DEFINE_BOOL(optimize_for_size, false,
"speed")
DEFINE_VALUE_IMPLICATION(optimize_for_size, max_semi_space_size, 1)
#define DISABLE_UNTRUSTED_CODE_MITIGATIONS
#ifdef DISABLE_UNTRUSTED_CODE_MITIGATIONS
#define V8_DEFAULT_UNTRUSTED_CODE_MITIGATIONS false
#else

View File

@ -17,37 +17,39 @@
//
// The following assumes cdecl calling convention.
// Source: https://en.wikipedia.org/wiki/X86_calling_conventions#cdecl
asm(
#ifdef _WIN32
".globl _PushAllRegistersAndIterateStack \n"
"_PushAllRegistersAndIterateStack: \n"
#else // !_WIN32
".globl PushAllRegistersAndIterateStack \n"
".type PushAllRegistersAndIterateStack, %function \n"
".hidden PushAllRegistersAndIterateStack \n"
"PushAllRegistersAndIterateStack: \n"
#endif // !_WIN32
// [ IterateStackCallback ]
// [ StackVisitor* ]
// [ Stack* ]
// [ ret ]
// ebp is callee-saved. Maintain proper frame pointer for debugging.
" push %ebp \n"
" movl %esp, %ebp \n"
" push %ebx \n"
" push %esi \n"
" push %edi \n"
// Save 3rd parameter (IterateStackCallback).
" movl 28(%esp), %ecx \n"
// Pass 3rd parameter as esp (stack pointer).
" push %esp \n"
// Pass 2nd parameter (StackVisitor*).
" push 28(%esp) \n"
// Pass 1st parameter (Stack*).
" push 28(%esp) \n"
" call *%ecx \n"
// Pop the callee-saved registers.
" addl $24, %esp \n"
// Restore rbp as it was used as frame pointer.
" pop %ebp \n"
" ret \n");
//asm(
//#ifdef _WIN32
// ".globl _PushAllRegistersAndIterateStack \n"
// "_PushAllRegistersAndIterateStack: \n"
//#else // !_WIN32
// ".globl PushAllRegistersAndIterateStack \n"
// ".type PushAllRegistersAndIterateStack, %function \n"
// ".hidden PushAllRegistersAndIterateStack \n"
// "PushAllRegistersAndIterateStack: \n"
//#endif // !_WIN32
// // [ IterateStackCallback ]
// // [ StackVisitor* ]
// // [ Stack* ]
// // [ ret ]
// // ebp is callee-saved. Maintain proper frame pointer for debugging.
// " push %ebp \n"
// " movl %esp, %ebp \n"
// " push %ebx \n"
// " push %esi \n"
// " push %edi \n"
// // Save 3rd parameter (IterateStackCallback).
// " movl 28(%esp), %ecx \n"
// // Pass 3rd parameter as esp (stack pointer).
// " push %esp \n"
// // Pass 2nd parameter (StackVisitor*).
// " push 28(%esp) \n"
// // Pass 1st parameter (Stack*).
// " push 28(%esp) \n"
// " call *%ecx \n"
// // Pop the callee-saved registers.
// " addl $24, %esp \n"
// // Restore rbp as it was used as frame pointer.
// " pop %ebp \n"
// " ret \n");
//

View File

@ -87,7 +87,11 @@ bool TryHandleWasmTrap(EXCEPTION_POINTERS* exception) {
uintptr_t landing_pad = 0;
if (TryFindLandingPad(fault_addr, &landing_pad)) {
#if defined(_M_X64)
exception->ContextRecord->Rip = landing_pad;
#else
exception->ContextRecord->Eip = landing_pad;
#endif
// We will return to wasm code, so restore the g_thread_in_wasm_code flag.
g_thread_in_wasm_code = true;
return true;
@ -99,7 +103,7 @@ bool TryHandleWasmTrap(EXCEPTION_POINTERS* exception) {
return false;
}
LONG HandleWasmTrap(EXCEPTION_POINTERS* exception) {
LONG WINAPI HandleWasmTrap(EXCEPTION_POINTERS* exception) {
if (TryHandleWasmTrap(exception)) {
return EXCEPTION_CONTINUE_EXECUTION;
}

View File

@ -30,7 +30,7 @@ namespace v8 {
namespace internal {
namespace trap_handler {
#if V8_TRAP_HANDLER_SUPPORTED
//#if V8_TRAP_HANDLER_SUPPORTED
// This function contains the platform independent portions of fault
// classification.
@ -72,7 +72,7 @@ bool TryFindLandingPad(uintptr_t fault_addr, uintptr_t* landing_pad) {
}
return false;
}
#endif // V8_TRAP_HANDLER_SUPPORTED
//#endif // V8_TRAP_HANDLER_SUPPORTED
} // namespace trap_handler
} // namespace internal